KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > browser > plugins > fractal > panel > DefaultFractalViewPanel


1 /*====================================================================
2  
3  Objectweb Browser Framework
4  Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5  Contact: openccm@objectweb.org
6  
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or any later version.
11  
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16  
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20  USA
21  
22  Initial developer(s): Jerome Moroy.
23  Contributor(s): ______________________________________.
24  
25  ---------------------------------------------------------------------
26  $Id: DefaultFractalViewPanel.java,v 1.1 2004/04/20 16:37:27 moroy Exp $
27  ====================================================================*/

28
29 package org.objectweb.util.browser.plugins.fractal.panel;
30
31 import javax.swing.JPanel JavaDoc;
32
33 import org.objectweb.fractal.api.NoSuchInterfaceException;
34 import org.objectweb.fractal.api.control.LifeCycleController;
35 import org.objectweb.util.browser.api.Panel;
36 import org.objectweb.util.browser.api.TreeView;
37 import org.objectweb.util.browser.core.panel.WhitePanel;
38 import org.objectweb.util.browser.plugins.fractal.FcBrowser;
39 import org.objectweb.util.browser.plugins.fractal.api.FractalViewPanel;
40
41 /**
42  * Specialization of the view panel for entities having life cycle properties.
43  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
44  * @version 0.1
45  */

46 public abstract class DefaultFractalViewPanel
47            implements Panel JavaDoc,
48                       FractalViewPanel
49 {
50     //==================================================================
51
//
52
// Internal state.
53
//
54
//==================================================================
55

56     /** A white panel. */
57     protected final Panel JavaDoc whitePanel_ = new WhitePanel();
58     
59     /** Boolean which indicates if the component is strated or not. */
60     protected boolean isStarted_ = true;
61     
62     //==================================================================
63
//
64
// No constructor.
65
//
66
//==================================================================
67

68     //==================================================================
69
//
70
// Internal methods.
71
//
72
//==================================================================
73

74     //==================================================================
75
//
76
// Public methods for TreeView interface.
77
//
78
//==================================================================
79

80     /**
81      * @see org.objectweb.util.browser.api.ViewPanel#preInitialize(org.objectweb.util.browser.api.TreeView)
82      */

83     public void selected(TreeView treeView) {
84         LifeCycleController lcc = null;
85         try{
86             lcc = FcBrowser.getLifeCycleController(FcBrowser.getComponent(treeView.getSelectedObject()));
87         } catch(NoSuchInterfaceException e) {
88             try {
89                 selectedStarted(treeView);
90             } catch (Exception JavaDoc e1) {
91                 isStarted_ = false;
92                 selectedStopped(treeView);
93             }
94         }
95         if(lcc.getFcState().equals(LifeCycleController.STARTED)){
96             isStarted_ = true;
97             selectedStarted(treeView);
98         } else {
99             isStarted_ = false;
100             selectedStopped(treeView);
101         }
102     }
103     
104     /**
105      * @see org.objectweb.util.browser.api.ViewPanel#getPanel()
106      */

107     public JPanel JavaDoc getPanel(){
108         if(isStarted_){
109             try{
110                 return getStartedPanel();
111             } catch (Exception JavaDoc e) {
112                 return getStoppedPanel();
113             }
114         } else {
115             return getStoppedPanel();
116         }
117     }
118     
119     /**
120      * @see org.objectweb.util.browser.api.ViewPanel#postInitialize(org.objectweb.util.browser.api.TreeView)
121      */

122     public void unselected(TreeView treeView) {
123         LifeCycleController lcc = null;
124         try{
125             lcc = FcBrowser.getLifeCycleController(FcBrowser.getComponent(treeView.getSelectedObject()));
126         } catch(NoSuchInterfaceException e) {
127             try {
128                 unselectedStarted(treeView);
129             } catch (Exception JavaDoc e1) {
130                 unselectedStopped(treeView);
131             }
132         }
133         if(lcc.getFcState().equals(LifeCycleController.STARTED))
134             unselectedStarted(treeView);
135         else
136             unselectedStopped(treeView);
137     }
138     
139     //==================================================================
140
//
141
// Public methods for FractalTreeView interface.
142
//
143
//==================================================================
144

145     public abstract void selectedStarted(TreeView treeView);
146     
147     public void selectedStopped(TreeView treeView) {
148     }
149     
150     public abstract JPanel JavaDoc getStartedPanel();
151     
152     public JPanel JavaDoc getStoppedPanel() {
153         return whitePanel_.getPanel();
154     }
155     
156     public abstract void unselectedStarted(TreeView treeView);
157     
158     public void unselectedStopped(TreeView treeView){
159     }
160     
161 }
Popular Tags