KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > config > ui > PaneledDesignEditor


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.j2ee.sun.share.config.ui;
20
21 import java.io.*;
22 import java.util.*;
23 import java.awt.*;
24 import java.beans.*;
25 import java.text.MessageFormat JavaDoc;
26 import javax.swing.border.LineBorder JavaDoc;
27 import javax.swing.event.ChangeListener JavaDoc;
28 import javax.swing.event.ListSelectionEvent JavaDoc;
29 import javax.swing.event.ListSelectionListener JavaDoc;
30 import javax.swing.*;
31 import javax.swing.table.TableColumn JavaDoc;
32 import javax.swing.undo.CannotRedoException JavaDoc;
33 import javax.swing.undo.CannotUndoException JavaDoc;
34
35 import org.openide.*;
36 import org.openide.nodes.*;
37 import org.openide.explorer.*;
38 import org.openide.explorer.propertysheet.*;
39 import org.openide.explorer.view.BeanTreeView;
40 import org.openide.windows.*;
41 import org.openide.util.HelpCtx;
42 import org.openide.util.SharedClassObject;
43 import org.openide.util.Utilities;
44
45
46 /**
47  * The ComponentPanel three pane editor. This is basically a container that implements the ExplorerManager
48  * interface. It coordinates the selection of a node in the structure pane and the display of a panel by the a PanelView
49  * in the content pane and the nodes properties in the properties pane. It will populate the tree view in the structure pane
50  * from the root node of the supplied PanelView.
51  *
52  **/

53
54 public class PaneledDesignEditor extends AbstractDesignEditor {
55     
56     public static final int CONTENT_RIGHT = 0;
57     public static final int CONTENT_LEFT = 1;
58     
59     /** The default width of the ComponentInspector */
60     public static final int DEFAULT_STRUCTURE_WIDTH = 170;
61     /** The default height of the ComponentInspector */
62     public static final int DEFAULT_STRUCTURE_HEIGHT = 300;
63     /** The default percents of the splitting of the ComponentInspector */
64     public static final int DEFAULT_STRUCTURE_SPLIT = 500;
65     public static final int DEFAULT_CONTENT_SPLIT = 150;
66     
67     protected static EmptyInspectorNode emptyInspectorNode;
68     
69     /** Default icon base for control panel. */
70     private static final String JavaDoc EMPTY_INSPECTOR_ICON_BASE =
71     "/org/netbeans/modules/form/resources/emptyInspector"; // NOI18N
72

73     
74     
75     protected JSplitPane split1;
76     protected JSplitPane split2;
77     protected int panelOrientation;
78     
79     /** The icon for ComponentInspector */
80     protected static String JavaDoc iconURL = "/org/netbeans/modules/form/resources/inspector.gif"; // NOI18N
81

82     protected static final long serialVersionUID =1L;
83     
84     
85     protected PaneledDesignEditor(){
86     }
87     /**
88      * Creates a new instance of ComponentPanel
89      * @param panel The PanelView which will provide the node tree for the structure view
90      * and the set of panels the nodes map to.
91      */

92     public PaneledDesignEditor(PanelView panel){
93         contentView = panel;
94         contentView.setPreferredSize(new Dimension(DEFAULT_WIDTH,DEFAULT_HEIGHT));
95         initComponents();
96         setRootContext(panel.getRoot());
97     }
98     
99     /**
100      * Creates a new instance of ComponentPanel
101      * @param panel The PanelView which will provide the node tree for the structure view
102      * and the set of panels the nodes map to.
103      * @param orientation Determines if the content pane is on the left or the right.
104      */

105     public PaneledDesignEditor(PanelView panel, int orientation){
106         contentView = panel;
107         contentView.setPreferredSize(new Dimension(DEFAULT_WIDTH,DEFAULT_HEIGHT));
108         panelOrientation = orientation;
109         initComponents();
110         setRootContext(panel.getRoot());
111     }
112     /**
113      * Creates a new instance of ComponentPanel
114      * @param panel The PanelView which will provide the node tree for the structure view
115      * and the set of panels the nodes map to.
116      * @param structure The JComponent that will be used in the structure pane. Should follow the
117      * ExplorerManager protocol. Will usually be some subclass of BeanTreeView.
118      */

119     
120     public PaneledDesignEditor(PanelView panel, JComponent structure){
121         contentView = panel;
122         contentView.setPreferredSize(new Dimension(DEFAULT_WIDTH,DEFAULT_HEIGHT));
123         structureView = structure;
124         initComponents();
125         setRootContext(panel.getRoot());
126     }
127     /**
128      * Creates a new instance of ComponentPanel
129      * @param panel The PanelView which will provide the node tree for the structure view
130      * and the set of panels the nodes map to.
131      * @param structure The JComponent that will be used in the structure pane. Should follow the
132      * ExplorerManager protocol. Will usually be some subclass of BeanTreeView.
133      * @param orientation Determines if the content pane is on the left or the right.
134      */

135     
136     public PaneledDesignEditor(PanelView panel, JComponent structure, int orientation){
137         contentView = panel;
138         contentView.setPreferredSize(new Dimension(DEFAULT_WIDTH,DEFAULT_HEIGHT));
139         panelOrientation = orientation;
140         structureView = structure;
141         initComponents();
142         setRootContext(panel.getRoot());
143     }
144     
145     
146     protected void initComponents() {
147         super.initComponents();
148         createVerticalSplit();
149         createHorizontalSplit();
150         add(BorderLayout.CENTER, split1);
151         
152
153     }
154     
155     protected void createHorizontalSplit() {
156         if (panelOrientation == 1)
157             split1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,getContentView(), split2);
158         else
159             split1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,split2, getContentView());
160         //split1.setDividerLocation(DEFAULT_CONTENT_SPLIT);
161
split1.setOneTouchExpandable(true);
162         
163     }
164     
165     protected void createVerticalSplit() {
166         split2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT,getStructureView(),getPropertiesView());
167         split2.setPreferredSize(new Dimension(200,400));
168         split2.setMinimumSize(new Dimension(100,100));
169         split2.setOneTouchExpandable(true);
170         split2.setDividerLocation(DEFAULT_STRUCTURE_SPLIT);
171     }
172     
173
174     
175     /**
176      * Used to get the JComponent used for the structure pane. Usually a container for the structure component or the structure component itself.
177      * @return the JComponent
178      */

179     public JComponent getStructureView(){
180         if (structureView ==null){
181             structureView = createStructureComponent();
182             structureView.getAccessibleContext().setAccessibleName("ACS_StructureView");
183             structureView.getAccessibleContext().setAccessibleDescription("ACSD_StructureView");
184             structureView.setMinimumSize(new Dimension(100,100));
185             structureView.setPreferredSize(new Dimension(DEFAULT_STRUCTURE_WIDTH ,DEFAULT_STRUCTURE_HEIGHT ));
186         }
187         return structureView;
188     }
189     /**
190      * Used to create an instance of the JComponent used for the structure component. Usually a subclass of BeanTreeView.
191      * @return the JComponent
192      */

193     public JComponent createStructureComponent() {
194         return new BeanTreeView();
195     }
196     
197     /**
198      * Used to get the JComponent used for the properties pane. Usually a subclass of PropertySheetView.
199      * @return the JComponent
200      */

201     
202     public JComponent getPropertiesView(){
203         if (propertiesView == null){
204             propertiesView = createPropertiesComponent();
205             propertiesView.addPropertyChangeListener(new PropertiesDisplayListener());
206             propertiesView.setMinimumSize(new Dimension(100,100));
207             propertiesView.setPreferredSize(new Dimension(100,100));
208         }
209         return propertiesView;
210     }
211     
212     /**
213      * Used to create an instance of the JComponent used for the properties component. Usually a subclass of PropertySheetView.
214      * @return JComponent
215      */

216     public JComponent createPropertiesComponent() {
217         return new PropertySheetView();
218     }
219 }
220
Popular Tags