KickJava   Java API By Example, From Geeks To Geeks.

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


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
8 import org.terracotta.dso.editors.xmlbeans.XmlObjectStructureChangeEvent;
9 import org.terracotta.dso.editors.xmlbeans.XmlObjectStructureListener;
10 import com.terracottatech.config.DsoClientData;
11 import com.terracottatech.config.DsoClientDebugging;
12
13 public class DsoClientDebuggingPanel extends ConfigurationEditorPanel
14   implements XmlObjectStructureListener
15 {
16   private DsoClientData m_dsoClientData;
17   private DsoClientDebugging m_dsoClientDebugging;
18   private InstrumentationLoggingPanel m_instrumentationLoggingPanel;
19   private RuntimeLoggingPanel m_runtimeLoggingPanel;
20   private RuntimeOutputOptionsPanel m_runtimeOutputOptionsPanel;
21   
22   public DsoClientDebuggingPanel() {
23     super();
24   }
25   
26   public void load(ContainerResource containerRes) {
27     super.load(containerRes);
28
29     m_instrumentationLoggingPanel = (InstrumentationLoggingPanel)
30       findComponent("InstrumentationLogging");
31     m_runtimeLoggingPanel = (RuntimeLoggingPanel)
32       findComponent("RuntimeLogging");
33     m_runtimeOutputOptionsPanel = (RuntimeOutputOptionsPanel)
34       findComponent("RuntimeOutputOptions");
35   }
36
37   public void ensureXmlObject() {
38     super.ensureXmlObject();
39     
40     if(m_dsoClientDebugging == null) {
41       removeListeners();
42       m_dsoClientDebugging = m_dsoClientData.addNewDebugging();
43       updateChildren();
44       addListeners();
45     }
46   }
47   
48   public boolean hasAnySet() {
49     return m_dsoClientDebugging != null &&
50       (m_dsoClientDebugging.isSetInstrumentationLogging() ||
51        m_dsoClientDebugging.isSetRuntimeLogging() ||
52        m_dsoClientDebugging.isSetRuntimeOutputOptions());
53   }
54   
55   private void addListeners() {
56     m_instrumentationLoggingPanel.addXmlObjectStructureListener(this);
57     m_runtimeLoggingPanel.addXmlObjectStructureListener(this);
58     m_runtimeOutputOptionsPanel.addXmlObjectStructureListener(this);
59   }
60   
61   private void removeListeners() {
62     m_instrumentationLoggingPanel.removeXmlObjectStructureListener(this);
63     m_runtimeLoggingPanel.removeXmlObjectStructureListener(this);
64     m_runtimeOutputOptionsPanel.removeXmlObjectStructureListener(this);
65   }
66   
67   public void structureChanged(XmlObjectStructureChangeEvent e) {
68     if(!hasAnySet() && m_dsoClientData.getDebugging() != null){
69       m_dsoClientData.unsetDebugging();
70       m_dsoClientDebugging = null;
71       fireXmlObjectStructureChanged();
72       updateChildren();
73     }
74     else {
75       setDirty();
76     }
77   }
78
79   private void fireXmlObjectStructureChanged() {
80     fireXmlObjectStructureChanged(m_dsoClientData);
81   }
82     
83   private void updateChildren() {
84     m_instrumentationLoggingPanel.setup(m_dsoClientDebugging);
85     m_runtimeLoggingPanel.setup(m_dsoClientDebugging);
86     m_runtimeOutputOptionsPanel.setup(m_dsoClientDebugging);
87   }
88   
89   public void setup(DsoClientData dsoClientData) {
90     removeListeners();
91     setEnabled(true);
92     
93     m_dsoClientData = dsoClientData;
94     m_dsoClientDebugging = m_dsoClientData != null ?
95                            m_dsoClientData.getDebugging() : null;
96     
97     updateChildren();
98     addListeners();
99   }
100   
101   public void tearDown() {
102     removeListeners();
103     
104     m_dsoClientData = null;
105     m_dsoClientDebugging = null;
106
107     m_instrumentationLoggingPanel.tearDown();
108     m_runtimeLoggingPanel.tearDown();
109     m_runtimeOutputOptionsPanel.tearDown();
110
111     setEnabled(false);
112   }
113 }
114
Popular Tags