KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > terracotta > dso > editors > DsoApplicationPanel


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package org.terracotta.dso.editors;
5
6 import org.dijon.ContainerResource;
7 import org.dijon.DictionaryResource;
8 import org.eclipse.core.resources.IProject;
9 import org.terracotta.dso.TcPlugin;
10 import org.terracotta.dso.editors.xmlbeans.XmlObjectStructureChangeEvent;
11 import org.terracotta.dso.editors.xmlbeans.XmlObjectStructureListener;
12
13 import com.terracottatech.config.Application;
14 import com.terracottatech.config.DsoApplication;
15 import com.terracottatech.config.TcConfigDocument.TcConfig;
16
17 public class DsoApplicationPanel extends ConfigurationEditorPanel
18   implements ConfigurationEditorRoot,
19              XmlObjectStructureListener
20 {
21   private static ContainerResource m_res;
22   private IProject m_project;
23   private TcConfig m_config;
24   private Application m_application;
25   private DsoApplication m_dsoApp;
26   private InstrumentedClassesPanel m_instrumentedClassesPanel;
27   private TransientFieldsPanel m_transientFieldsPanel;
28   private LocksPanel m_locksPanel;
29   private RootsPanel m_rootsPanel;
30   private DistributedMethodsPanel m_distributedMethodsPanel;
31   private BootClassesPanel m_bootClassesPanel;
32   
33   static {
34     TcPlugin plugin = TcPlugin.getDefault();
35     DictionaryResource topRes = plugin.getResources();
36
37     m_res = (ContainerResource)topRes.find("DsoApplicationPanel");
38   }
39   
40   public DsoApplicationPanel() {
41     super();
42     if(m_res != null) {
43       load(m_res);
44     }
45   }
46   
47   public void load(ContainerResource containerRes) {
48     super.load(containerRes);
49
50     m_instrumentedClassesPanel = (InstrumentedClassesPanel)findComponent("InstrumentedClassesPanel");
51     m_transientFieldsPanel = (TransientFieldsPanel)findComponent("TransientFieldsPanel");
52     m_locksPanel = (LocksPanel)findComponent("LocksPanel");
53     m_rootsPanel = (RootsPanel)findComponent("RootsPanel");
54     m_distributedMethodsPanel = (DistributedMethodsPanel)findComponent("DistributedMethodsPanel");
55     m_bootClassesPanel = (BootClassesPanel)findComponent("BootClassesPanel");
56   }
57  
58   public void structureChanged(XmlObjectStructureChangeEvent e) {/**/}
59
60   private void addListeners() {
61     m_instrumentedClassesPanel.addXmlObjectStructureListener(this);
62     m_transientFieldsPanel.addXmlObjectStructureListener(this);
63     m_locksPanel.addXmlObjectStructureListener(this);
64     m_rootsPanel.addXmlObjectStructureListener(this);
65     m_distributedMethodsPanel.addXmlObjectStructureListener(this);
66     m_bootClassesPanel.addXmlObjectStructureListener(this);
67   }
68   
69   private void removeListeners() {
70     m_instrumentedClassesPanel.removeXmlObjectStructureListener(this);
71     m_transientFieldsPanel.removeXmlObjectStructureListener(this);
72     m_locksPanel.removeXmlObjectStructureListener(this);
73     m_rootsPanel.removeXmlObjectStructureListener(this);
74     m_distributedMethodsPanel.removeXmlObjectStructureListener(this);
75     m_bootClassesPanel.removeXmlObjectStructureListener(this);
76   }
77   
78   public void ensureXmlObject() {
79     if(m_dsoApp == null) {
80       removeListeners();
81       if(m_application == null) {
82         m_application = m_config.addNewApplication();
83       }
84       m_dsoApp = m_application.addNewDso();
85       initPanels();
86       addListeners();
87     }
88   }
89   
90   public void setupInternal() {
91     TcPlugin plugin = TcPlugin.getDefault();
92     
93     m_config = plugin.getConfiguration(m_project);
94     m_application = m_config != null ? m_config.getApplication() : null;
95     m_dsoApp = m_application != null ? m_application.getDso() : null;
96     
97     initPanels();
98   }
99
100   private void initPanels() {
101     m_instrumentedClassesPanel.setup(m_project, m_dsoApp);
102     m_transientFieldsPanel.setup(m_project, m_dsoApp);
103     m_locksPanel.setup(m_project, m_dsoApp);
104     m_rootsPanel.setup(m_project, m_dsoApp);
105     m_distributedMethodsPanel.setup(m_project, m_dsoApp);
106     m_bootClassesPanel.setup(m_project, m_dsoApp);
107   }
108
109   public void updateInstrumentedClassesPanel() {
110     m_instrumentedClassesPanel.updateModel();
111   }
112
113   public void updateTransientsPanel() {
114     m_transientFieldsPanel.updateModel();
115   }
116   
117   public void updateLocksPanel() {
118     m_locksPanel.updateModel();
119   }
120
121   public void updateRootsPanel() {
122     m_rootsPanel.updateModel();
123   }
124
125   public void updateDistributedMethodsPanel() {
126     m_distributedMethodsPanel.updateModel();
127   }
128
129   public void updateBootClassesPanel() {
130     m_bootClassesPanel.updateModel();
131   }
132
133   public void setup(IProject project) {
134     m_project = project;
135     
136     setEnabled(true);
137     removeListeners();
138     setupInternal();
139     addListeners();
140   }
141   
142   public IProject getProject() {
143     return m_project;
144   }
145   
146   public void tearDown() {
147     removeListeners();
148     
149     m_instrumentedClassesPanel.tearDown();
150     m_transientFieldsPanel.tearDown();
151     m_locksPanel.tearDown();
152     m_rootsPanel.tearDown();
153     m_distributedMethodsPanel.tearDown();
154     m_bootClassesPanel.tearDown();
155
156     setEnabled(false);
157   }
158 }
159
Popular Tags