1 23 package org.enhydra.kelp.common.xmlc; 24 25 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 import java.awt.*; 32 import javax.swing.*; 33 import java.beans.*; 34 import java.util.ResourceBundle ; 35 public class XMLCOptionTab extends JPanel { 36 static ResourceBundle res = 37 ResourceBundle.getBundle("org.enhydra.kelp.common.Res"); 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 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 { 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 |