KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > common > xmlc > XMLCOptionTab


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  * Paul Mahar
21  *
22  */

23 package org.enhydra.kelp.common.xmlc;
24
25 // Kelp imports
26
import org.enhydra.kelp.common.node.OtterNode;
27 import org.enhydra.kelp.common.node.OtterProject;
28 import org.enhydra.kelp.common.node.OtterXMLCNode;
29
30 // standard imports
31
import java.awt.*;
32 import javax.swing.*;
33 import java.beans.*;
34 import java.util.ResourceBundle JavaDoc;
35 public class XMLCOptionTab extends JPanel {
36     static ResourceBundle JavaDoc res =
37         ResourceBundle.getBundle("org.enhydra.kelp.common.Res"); // nores
38
private BorderLayout borderLayout1 = new BorderLayout();
39     private JTabbedPane tab;
40     private OtterNode node = null;
41     private XMLCOptionPanel filePanel;
42     private XMLCOptionPanel packagePanel;
43     private XMLCOptionPanel projectPanel;
44
45     public XMLCOptionTab() {
46         try {
47             jbInit();
48             pmInit();
49         } catch (Exception JavaDoc ex) {
50             ex.printStackTrace();
51         }
52     }
53
54     public void setNode(OtterNode n) {
55         node = n;
56     }
57
58     public OtterNode getNode() {
59         return node;
60     }
61
62     public void readProperties() {
63         filePanel.readProperties();
64         packagePanel.readProperties();
65         projectPanel.readProperties();
66     }
67
68     public void writeProperties() {
69         filePanel.writeProperties();
70         packagePanel.writeProperties();
71         projectPanel.writeProperties();
72     }
73
74     public void setEnabled(boolean b) {
75         super.setEnabled(b);
76         filePanel.setEnabled(b);
77         packagePanel.setEnabled(b);
78         projectPanel.setEnabled(true);
79     }
80
81     public void init() {
82         OtterNode parent = null;
83
84         if (node != null) {
85             projectPanel.setNode(node.getProject());
86             if (node instanceof OtterXMLCNode) {
87                 filePanel.setNode(node);
88                 parent = node.getParent();
89                 if (parent == null || parent instanceof OtterProject) {
90                     tab.remove(packagePanel);
91                 } else {
92                     packagePanel.setNode(node.getParent());
93                 }
94             } else {
95                 packagePanel.setNode(node);
96                 tab.remove(filePanel);
97             }
98         }
99     }
100
101     private void pmInit() {
102         setBorder(filePanel.getBorder());
103         filePanel.setBorder(null);
104         packagePanel.setBorder(null);
105         projectPanel.setBorder(null);
106     }
107
108     private void jbInit() throws Exception JavaDoc {
109         tab = (JTabbedPane) Beans.instantiate(getClass().getClassLoader(),
110                                               JTabbedPane.class.getName());
111         filePanel =
112             (XMLCOptionPanel) Beans.instantiate(getClass().getClassLoader(),
113                                                 XMLCOptionPanel.class.getName());
114         packagePanel =
115             (XMLCOptionPanel) Beans.instantiate(getClass().getClassLoader(),
116                                                 XMLCOptionPanel.class.getName());
117         projectPanel =
118             (XMLCOptionPanel) Beans.instantiate(getClass().getClassLoader(),
119                                                 XMLCOptionPanel.class.getName());
120         this.setLayout(borderLayout1);
121         this.add(tab, BorderLayout.CENTER);
122         tab.add(filePanel, res.getString("File"));
123         tab.add(packagePanel, res.getString("Package_Folder"));
124         tab.add(projectPanel, res.getString("Project"));
125     }
126
127 }
128
Popular Tags