KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > jbuilder > properties > XMLCOptionsPanel


1 package org.enhydra.kelp.jbuilder.properties;
2
3 /**
4  * <p>Title: </p>
5  * <p>Description: New dialog for Kelp XML Compiler based on Ant tool.</p>
6  * <p>Copyright: Copyright (c) 2003</p>
7  * <p>Company: </p>
8  * @author Slobodan Vujasinovic
9  * @version 1.0
10  */

11
12 // ToolBox
13
import org.enhydra.tool.ToolBoxInfo;
14 import org.enhydra.tool.common.DataValidationException;
15 import org.enhydra.tool.common.SwingUtil;
16
17 // AddinCore
18
import org.enhydra.kelp.KelpInfo;
19 import org.enhydra.kelp.common.Constants;
20 import org.enhydra.kelp.common.event.WriteEvent;
21 import org.enhydra.kelp.common.event.WriteListener;
22 import org.enhydra.kelp.common.node.OtterProject;
23 import org.enhydra.kelp.common.node.OtterFileNode;
24 import org.enhydra.kelp.common.node.OtterNode;
25 import org.enhydra.kelp.common.swing.AddinInnerPanel;
26 import org.enhydra.kelp.ant.xmlc.AntXMLCOptionsPanel;
27 import org.enhydra.kelp.common.node.OtterDocumentNode;
28 import org.enhydra.kelp.ant.node.AntProject;
29
30 // JDK
31
import java.util.ArrayList JavaDoc;
32 import java.util.Arrays JavaDoc;
33 import java.util.ResourceBundle JavaDoc;
34 import java.awt.*;
35 import java.beans.*;
36 import javax.swing.*;
37
38 //
39
public class XMLCOptionsPanel extends AddinInnerPanel {
40
41     //
42
static ResourceBundle JavaDoc res =
43         ResourceBundle.getBundle("org.enhydra.kelp.common.Res");
44     private boolean standalone = false;
45
46     private GridBagLayout layoutMain = null;
47     private WriteListener[] writeListeners = new WriteListener[0];
48     AntXMLCOptionsPanel optionsPanel = null;
49     AntProject proj = null;
50     
51     public static XMLCOptionsPanel XMLCfindAncestor(Component comp) {
52         Component found = null;
53         XMLCOptionsPanel ancestor = null;
54
55         found = XMLCOptionsPanel.findAncestor(comp);
56         if (found == null) {}
57         else if (found instanceof XMLCOptionsPanel) {
58             ancestor = (XMLCOptionsPanel) found;
59         }
60         return ancestor;
61     }
62
63     public XMLCOptionsPanel() {
64         try {
65             jbInit();
66             pmInit();
67         } catch (Exception JavaDoc ex) {
68             ex.printStackTrace();
69         }
70     }
71
72     // overwrite org.enhydra.kelp.common.swing.InnerPanel
73
public void clearAll() {
74         super.clearAll();
75         layoutMain = null;
76         writeListeners = new WriteListener[0];
77     }
78
79     public AntXMLCOptionsPanel getOptionsPanel() {
80         return optionsPanel;
81     }
82
83     public synchronized WriteListener[] getWriteListeners() {
84         return writeListeners;
85     }
86
87     public synchronized void addWriteListener(WriteListener l) {
88         ArrayList JavaDoc list = null;
89         list = new ArrayList JavaDoc(Arrays.asList(writeListeners));
90         if (!list.contains(l)) {
91             list.add(l);
92             list.trimToSize();
93             writeListeners = new WriteListener[list.size()];
94             writeListeners = (WriteListener[]) list.toArray(writeListeners);
95         }
96         list.clear();
97     }
98
99     public synchronized void removeWriteListener(WriteListener l) {
100         ArrayList JavaDoc list = null;
101         list = new ArrayList JavaDoc(Arrays.asList(writeListeners));
102         if (list.contains(l)) {
103             list.remove(l);
104             list.trimToSize();
105             writeListeners = new WriteListener[list.size()];
106             writeListeners = (WriteListener[]) list.toArray(writeListeners);
107         }
108         list.clear();
109     }
110
111
112     // override AddinInnerPanel
113
public void read(OtterNode node) {
114         super.read(node);
115         try{
116           proj=new AntProject(getProject().getRootPath());
117           optionsPanel.setProject(proj);
118         } catch (Exception JavaDoc ex) {
119             ex.printStackTrace();
120         }
121
122     }
123
124     // override AddinInnerPanel
125
public void write(OtterNode node) throws DataValidationException {
126         super.write(node);
127         if (getProject() == null) {
128             System.err.println("AntXMLCInnerPanel.write(OtterProject p) : no project set");
129         }
130     }
131
132     //
133
// PRIVATE
134
//
135
// override AddinInnerPanel
136
public void save() {
137         super.save();
138         proj.save();
139     }
140
141     /**
142      * Add listeners and other items that are not generated by
143      * the JBuilder designer.
144      */

145     private void pmInit() {
146         this.add(optionsPanel,new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
147                                         GridBagConstraints.CENTER,
148                                         GridBagConstraints.BOTH,
149                                         new Insets(5, 5, 5, 5), 5, 5));
150     }
151
152     /**
153      * UI code generated by JBuilder.
154      * <P><I>Do not modify the signature of this method.</I></P>
155      * @throws Exception
156      */

157     private void jbInit() throws Exception JavaDoc {
158         layoutMain =
159             (GridBagLayout) Beans.instantiate(getClass().getClassLoader(),
160                                               GridBagLayout.class.getName());
161
162         optionsPanel = (AntXMLCOptionsPanel) Beans.instantiate(getClass().getClassLoader(),
163                                                 AntXMLCOptionsPanel.class.getName());
164
165         this.setLayout(layoutMain);
166     }
167
168 }
169
Popular Tags