001: /*
002: * Enhydra Java Application Server Project
003: *
004: * The contents of this file are subject to the Enhydra Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License on
007: * the Enhydra web site ( http://www.enhydra.org/ ).
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011: * the License for the specific terms governing rights and limitations
012: * under the License.
013: *
014: * The Initial Developer of the Enhydra Application Server is Lutris
015: * Technologies, Inc. The Enhydra Application Server and portions created
016: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017: * All Rights Reserved.
018: *
019: * Contributor(s):
020: * Paul Mahar
021: *
022: */
023: package org.enhydra.kelp.common.xmlc;
024:
025: // Kelp imports
026: import org.enhydra.kelp.common.node.OtterNode;
027: import org.enhydra.kelp.common.node.OtterProject;
028: import org.enhydra.kelp.common.node.OtterXMLCNode;
029:
030: // standard imports
031: import java.awt.*;
032: import javax.swing.*;
033: import java.beans.*;
034: import java.util.ResourceBundle;
035:
036: public class XMLCOptionTab extends JPanel {
037: static ResourceBundle res = ResourceBundle
038: .getBundle("org.enhydra.kelp.common.Res"); // nores
039: private BorderLayout borderLayout1 = new BorderLayout();
040: private JTabbedPane tab;
041: private OtterNode node = null;
042: private XMLCOptionPanel filePanel;
043: private XMLCOptionPanel packagePanel;
044: private XMLCOptionPanel projectPanel;
045:
046: public XMLCOptionTab() {
047: try {
048: jbInit();
049: pmInit();
050: } catch (Exception ex) {
051: ex.printStackTrace();
052: }
053: }
054:
055: public void setNode(OtterNode n) {
056: node = n;
057: }
058:
059: public OtterNode getNode() {
060: return node;
061: }
062:
063: public void readProperties() {
064: filePanel.readProperties();
065: packagePanel.readProperties();
066: projectPanel.readProperties();
067: }
068:
069: public void writeProperties() {
070: filePanel.writeProperties();
071: packagePanel.writeProperties();
072: projectPanel.writeProperties();
073: }
074:
075: public void setEnabled(boolean b) {
076: super .setEnabled(b);
077: filePanel.setEnabled(b);
078: packagePanel.setEnabled(b);
079: projectPanel.setEnabled(true);
080: }
081:
082: public void init() {
083: OtterNode parent = null;
084:
085: if (node != null) {
086: projectPanel.setNode(node.getProject());
087: if (node instanceof OtterXMLCNode) {
088: filePanel.setNode(node);
089: parent = node.getParent();
090: if (parent == null || parent instanceof OtterProject) {
091: tab.remove(packagePanel);
092: } else {
093: packagePanel.setNode(node.getParent());
094: }
095: } else {
096: packagePanel.setNode(node);
097: tab.remove(filePanel);
098: }
099: }
100: }
101:
102: private void pmInit() {
103: setBorder(filePanel.getBorder());
104: filePanel.setBorder(null);
105: packagePanel.setBorder(null);
106: projectPanel.setBorder(null);
107: }
108:
109: private void jbInit() throws Exception {
110: tab = (JTabbedPane) Beans.instantiate(getClass()
111: .getClassLoader(), JTabbedPane.class.getName());
112: filePanel = (XMLCOptionPanel) Beans.instantiate(getClass()
113: .getClassLoader(), XMLCOptionPanel.class.getName());
114: packagePanel = (XMLCOptionPanel) Beans.instantiate(getClass()
115: .getClassLoader(), XMLCOptionPanel.class.getName());
116: projectPanel = (XMLCOptionPanel) Beans.instantiate(getClass()
117: .getClassLoader(), XMLCOptionPanel.class.getName());
118: this .setLayout(borderLayout1);
119: this .add(tab, BorderLayout.CENTER);
120: tab.add(filePanel, res.getString("File"));
121: tab.add(packagePanel, res.getString("Package_Folder"));
122: tab.add(projectPanel, res.getString("Project"));
123: }
124:
125: }
|