KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mc4j > console > swing > ExtendedExplorerPanel


1 /*
2  * Copyright 2002-2004 Greg Hinkle
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.mc4j.console.swing;
18
19 import java.awt.BorderLayout JavaDoc;
20 import java.io.ObjectStreamException JavaDoc;
21
22 import org.openide.explorer.ExplorerPanel;
23 import org.openide.explorer.view.BeanTreeView;
24 import org.openide.explorer.view.TreeView;
25 import org.openide.nodes.Node;
26 import org.openide.windows.WindowManager;
27 import org.openide.windows.Workspace;
28
29
30
31 /**
32  *
33  * @author Greg Hinkle (ghinkle@users.sourceforge.net), September 2002
34  * @version $Revision: 480 $($Author: ghinkl $ / $Date: 2004-10-05 01:17:41 -0400 (Tue, 05 Oct 2004) $)
35  */

36 public class ExtendedExplorerPanel extends ExplorerPanel {
37
38     /** composited view */
39     protected TreeView view;
40     
41     /** mini status bar */
42     private MiniStatusBar miniStatusBar;
43
44     public ExtendedExplorerPanel () {
45         super();
46         putClientProperty("PersistenceType","Never");
47     }
48     
49     public TreeView getTreeView() {
50         return view;
51     }
52
53     /** Initialize visual content of component */
54     protected void componentShowing () {
55         super.componentShowing ();
56
57         if (view == null) {
58             view = initGui ();
59         }
60     }
61
62     /** Performs superclass addNotify code, then delegates to
63      * componentShowing if component is used outside window system.
64      * Needed for proper initialization.
65      */

66     public void addNotify () {
67         super.addNotify();
68         /*
69         Workspace curWs = WindowManager.getDefault().getCurrentWorkspace();
70         if ((curWs != null) && curWs.findMode(this) != null) {
71             return;
72         }
73         */

74         componentShowing();
75     }
76
77     /** Initializes gui of this component. Subclasses can override
78     * this method to install their own gui.
79     * @return Tree view that will serve as main view for this explorer.
80     */

81     protected TreeView initGui () {
82         TreeView view = new BeanTreeView();
83         //TreeView view = new TreeTableView();
84
setLayout(new BorderLayout JavaDoc());
85
86         add(view);
87
88         // add mini status bar at the bottom of this explorer panel
89
add(getMiniStatusBar(), BorderLayout.SOUTH);
90         getMiniStatusBar().setVisible(true);
91
92         return view;
93     }
94
95
96
97     private MiniStatusBar getMiniStatusBar () {
98         if (miniStatusBar==null) {
99             miniStatusBar = new MiniStatusBar (getExplorerManager ());
100         }
101         return miniStatusBar;
102     }
103
104     void adjustComponentPersistence() {
105         // Don't need to persist these panes (their reinstalled)
106
putClientProperty("PersistenceType", "Never"); // NOI18N
107
}
108
109
110     void focusView() {
111         if (view != null) {
112             view.requestFocus();
113         }
114     }
115         
116
117
118     public Node getRootContext () {
119         return getExplorerManager().getRootContext();
120     }
121
122
123     /* Updated accessible name of the tree view */
124     public void setName(String JavaDoc name) {
125         super.setName(name);
126         if (view != null) {
127             view.getAccessibleContext().setAccessibleName(name);
128         }
129     }
130
131
132     /**
133      * Sets the title to the name of the root context only
134      */

135     protected void updateTitle () {
136         // set name by the root context
137
setName(getExplorerManager ().getRootContext().getDisplayName());
138     }
139
140
141
142
143
144
145     /* Updated accessible description of the tree view */
146     public void setToolTipText(String JavaDoc text) {
147         super.setToolTipText(text);
148         if (view != null) {
149             view.getAccessibleContext().setAccessibleDescription(text);
150         }
151     }
152
153
154     /**
155      * Does not resolve in order to disable persistence.
156      * @return null always
157      * @throws ObjectStreamException
158      */

159     private Object JavaDoc readResolve() throws ObjectStreamException JavaDoc {
160         return null;
161     }
162
163 }
Popular Tags