KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > nbprefuse > AnalysisViewer


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.nbprefuse;
21
22 import java.awt.BorderLayout JavaDoc;
23 import java.awt.Dimension JavaDoc;
24 import java.beans.PropertyChangeEvent JavaDoc;
25 import java.beans.PropertyChangeListener JavaDoc;
26 import javax.swing.JComponent JavaDoc;
27 import javax.swing.JPanel JavaDoc;
28 import org.openide.util.NbBundle;
29
30 /**
31  *
32  * @author Jeri Lockhart
33  */

34 public class AnalysisViewer extends JPanel JavaDoc implements
35
36         PropertyChangeListener JavaDoc {
37     public static final String JavaDoc PROP_GRAPH_NODE_SELECTION_CHANGE =
38             "prop-graph-node-selection-changed";
39     public static final String JavaDoc PROP_GRAPH_NODE_SELECTION_CHANGED_RELAY =
40             "prop-graph-node-selection-changed-relay";
41     
42     public static final long serialVersionUID = -7710166579907141983L;
43     transient private View currentView;
44     private boolean reshowOnResize = true;
45     
46     
47     /**
48      * Creates new form AnalysisViewer
49      */

50     public AnalysisViewer() {
51         initComponents();
52         initialize();
53     }
54     
55     private void initialize() {
56         setMinimumSize(new Dimension JavaDoc(180,30));
57 // addComponentListener(new ComponentAdapter(){
58
// public void componentResized(ComponentEvent e) {
59
// if (currentView != null && reshowOnResize){
60
// currentView.usePacer(false);
61
// showCurrentView();
62
// }
63
// }
64
// });
65
}
66     
67     public void setCurrentView(final View view){
68         this.currentView = view;
69     }
70     
71     public void removeToolBar() {
72        // remove(toolbarPnl);
73
validate();
74         repaint();
75     }
76
77     private void showCurrentView(){
78         if (currentView != null){
79             showView(currentView);
80         }
81     }
82     public void addDisplayPanel(JPanel JavaDoc displayPanel) {
83         displayContainerPnl.removeAll();
84         displayContainerPnl.setLayout(new BorderLayout JavaDoc());
85         displayContainerPnl.add(displayPanel, BorderLayout.CENTER);
86     }
87     
88     
89     public boolean showView(View view) {
90         currentView = view;
91         
92         if (view.showView(this)){
93             validate();
94             repaint();
95         }
96         return true;
97     }
98     
99     /**
100      *
101      *
102      */

103     public JPanel JavaDoc getPanel() {
104         return this;
105     }
106     
107     /**
108      *
109      *
110      */

111 // public Column getColumn(){
112
// return this;
113
// }
114

115     
116     public void propertyChange(PropertyChangeEvent JavaDoc evt){
117         String JavaDoc propertyName = evt.getPropertyName();
118         if (propertyName.equals(
119                 PROP_GRAPH_NODE_SELECTION_CHANGE)){
120             // WhereUsedView's selectionFocusControl(FindUsagesFocusControl)
121
// fired this event
122
// now notify RefactoringPanel so it can select
123
// the corresponding node in the RefactoringPanel explorer
124
firePropertyChange(PROP_GRAPH_NODE_SELECTION_CHANGED_RELAY,
125                     evt.getOldValue(),evt.getNewValue());
126             
127         }
128     }
129     
130     /**
131      * @return true if this Viewer will reshow the view
132      * when the JPanel is resized
133      * false if not
134      *
135      */

136     public boolean getReshowOnResize(){
137         return this.reshowOnResize;
138     }
139     
140     /**
141      * @param reshowOnResize true if this viewer should
142      * reshow the view when the panel is resized
143      *
144      */

145     public void setReshowOnResize(boolean reshowOnResize){
146         this.reshowOnResize = reshowOnResize;
147     }
148   
149     
150     /** This method is called from within the constructor to
151      * initialize the form.
152      * WARNING: Do NOT modify this code. The content of this method is
153      * always regenerated by the Form Editor.
154      */

155     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
156
private void initComponents() {
157         displayContainerPnl = new javax.swing.JPanel JavaDoc();
158
159         setLayout(new java.awt.BorderLayout JavaDoc());
160
161         setBackground(java.awt.Color.white);
162         setPreferredSize(new java.awt.Dimension JavaDoc(200, 200));
163         displayContainerPnl.setLayout(null);
164
165         displayContainerPnl.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray));
166         add(displayContainerPnl, java.awt.BorderLayout.CENTER);
167
168     }// </editor-fold>//GEN-END:initComponents
169

170     
171     // Variables declaration - do not modify//GEN-BEGIN:variables
172
private javax.swing.JPanel JavaDoc displayContainerPnl;
173     // End of variables declaration//GEN-END:variables
174

175 }
176
Popular Tags