KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > multiview > ui > TreePanelDesignEditor


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
20 package org.netbeans.modules.xml.multiview.ui;
21
22 import java.awt.*;
23 import javax.swing.*;
24
25 import org.openide.explorer.view.BeanTreeView;
26 import org.openide.windows.*;
27
28 /**
29  * The TreePanelDesignEditor two pane editor. This is basically a container that implements the ExplorerManager
30  * interface. It coordinates the selection of a node in the structure pane and the display of a panel by the a PanelView
31  * in the content pane. It will populate the tree view in the structure pane
32  * from the root node of the supplied PanelView.
33  *
34  **/

35
36 public class TreePanelDesignEditor extends AbstractDesignEditor {
37     
38     public static final int CONTENT_RIGHT = 0;
39     public static final int CONTENT_LEFT = 1;
40     
41     /** The default width of the ComponentInspector */
42     public static final int DEFAULT_STRUCTURE_WIDTH = 170;
43     /** The default height of the ComponentInspector */
44     public static final int DEFAULT_STRUCTURE_HEIGHT = 300;
45     
46     /** Default icon base for control panel. */
47     private static final String JavaDoc EMPTY_INSPECTOR_ICON_BASE =
48     "/org/netbeans/modules/form/resources/emptyInspector"; // NOI18N
49

50     protected JSplitPane split;
51     protected int panelOrientation;
52     
53     /**
54      * Creates a new instance of ComponentPanel
55      * @param panel The PanelView which will provide the node tree for the structure view
56      * and the set of panels the nodes map to.
57      */

58     public TreePanelDesignEditor(PanelView panel) {
59         super(panel);
60         initComponents();
61         panelOrientation=CONTENT_RIGHT;
62     }
63     
64     /**
65      * Creates a new instance of ComponentPanel
66      * @param panel The PanelView which will provide the node tree for the structure view
67      * and the set of panels the nodes map to.
68      * @param orientation Determines if the content pane is on the left or the right.
69      */

70     public TreePanelDesignEditor(PanelView panel, int orientation){
71         this(panel);
72         panelOrientation = orientation;
73     }
74     
75     protected void initComponents() {
76         add(BorderLayout.CENTER,createDesignPanel());
77     };
78    
79     protected JComponent createDesignPanel() {
80         if (panelOrientation == CONTENT_LEFT) {
81             split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,getContentView(), getStructureView());
82         } else {
83             split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,getStructureView(), getContentView());
84         }
85         split.setOneTouchExpandable(true);
86     return split;
87         
88     }
89     
90     /**
91      * Used to get the JComponent used for the structure pane. Usually a container for the structure component or the structure component itself.
92      * @return the JComponent
93      */

94     public JComponent getStructureView(){
95         if (structureView ==null){
96             structureView = createStructureComponent();
97             structureView.getAccessibleContext().setAccessibleName("ACS_StructureView");
98             structureView.getAccessibleContext().setAccessibleDescription("ACSD_StructureView");
99         }
100         return structureView;
101     }
102     /**
103      * Used to create an instance of the JComponent used for the structure component. Usually a subclass of BeanTreeView.
104      * @return the JComponent
105      */

106     public JComponent createStructureComponent() {
107         return new BeanTreeView();
108     }
109     
110      /**
111      * Used to create an instance of the JComponent used for the properties component. Usually a subclass of PropertySheetView.
112      * @return JComponent
113      */

114     public JComponent createPropertiesComponent(){
115         return null;
116     }
117
118     public ErrorPanel getErrorPanel() {
119         return getContentView().getErrorPanel();
120     }
121     
122 }
123
Popular Tags