1 package org.enhydra.kelp.jbuilder.properties; 2 3 11 12 import org.enhydra.tool.ToolBoxInfo; 14 import org.enhydra.tool.common.DataValidationException; 15 import org.enhydra.tool.common.SwingUtil; 16 17 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 import java.util.ArrayList ; 32 import java.util.Arrays ; 33 import java.util.ResourceBundle ; 34 import java.awt.*; 35 import java.beans.*; 36 import javax.swing.*; 37 38 public class XMLCOptionsPanel extends AddinInnerPanel { 40 41 static ResourceBundle 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 ex) { 68 ex.printStackTrace(); 69 } 70 } 71 72 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 list = null; 89 list = new ArrayList (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 list = null; 101 list = new ArrayList (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 public void read(OtterNode node) { 114 super.read(node); 115 try{ 116 proj=new AntProject(getProject().getRootPath()); 117 optionsPanel.setProject(proj); 118 } catch (Exception ex) { 119 ex.printStackTrace(); 120 } 121 122 } 123 124 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 public void save() { 137 super.save(); 138 proj.save(); 139 } 140 141 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 157 private void jbInit() throws Exception { 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 |