1 19 20 package org.netbeans.modules.j2ee.ddloaders.app; 21 22 import java.beans.PropertyChangeEvent ; 23 import java.beans.PropertyChangeListener ; 24 import java.util.ArrayList ; 25 import java.util.List ; 26 import javax.swing.Action ; 27 import org.openide.actions.OpenAction; 28 import org.openide.loaders.DataNode; 29 import org.openide.loaders.DataObject; 30 import org.openide.nodes.Children; 31 import org.openide.nodes.Node; 32 import org.openide.nodes.PropertySupport; 33 import org.openide.nodes.Sheet; 34 import org.openide.util.HelpCtx; 35 import org.openide.util.NbBundle; 36 37 43 public final class EarDataNode extends DataNode { 44 45 private static final String DEPLOYMENT="deployment"; 47 private EarDataObject dataObject; 48 49 50 public static final String PROPERTY_DOCUMENT_TYPE = "documentType"; 52 53 private PropertyChangeListener ddListener; 54 55 private Action [] filteredActions; 56 57 public EarDataNode (EarDataObject obj) { 58 this (obj, Children.LEAF); 59 } 60 61 public EarDataNode (EarDataObject obj, Children ch) { 62 super (obj, ch); 63 dataObject=obj; 64 setIconBaseWithExtension(dataObject.getIconBaseForValidDocument()); 65 initListeners(); 66 } 67 68 72 public Action [] getActions(boolean context) { 73 if (filteredActions == null) { 74 Action [] origActions = super.getActions(context); 75 List actions = new ArrayList (); 76 for (int i = 0; i < origActions.length; i++) { 77 if (!(origActions[i] instanceof OpenAction)) { 78 actions.add(origActions[i]); 79 } 80 } 81 filteredActions = (Action []) actions.toArray(new Action [actions.size()]); 82 } 83 return filteredActions; 84 } 85 86 89 private void initListeners(){ 90 ddListener = new PropertyChangeListener () { 91 92 public void propertyChange (PropertyChangeEvent evt) { 93 if (EarDataObject.PROP_DOCUMENT_DTD.equals (evt.getPropertyName ())) { 94 firePropertyChange (PROPERTY_DOCUMENT_TYPE, evt.getOldValue (), evt.getNewValue ()); 95 } 96 if (DataObject.PROP_VALID.equals (evt.getPropertyName ()) 97 && Boolean.TRUE.equals (evt.getNewValue ())) { 98 removePropertyChangeListener (EarDataNode.this.ddListener); 99 } 100 if (EarDataObject.PROP_DOC_VALID.equals (evt.getPropertyName ())) { 101 if (Boolean.TRUE.equals (evt.getNewValue ())) 102 setIconBaseWithExtension(dataObject.getIconBaseForValidDocument()); 103 else 104 setIconBaseWithExtension(dataObject.getIconBaseForInvalidDocument()); 105 } 106 if (Node.PROP_PROPERTY_SETS.equals (evt.getPropertyName ())) { 107 firePropertySetsChange(null,null); 108 } 109 } 110 111 }; 112 getDataObject ().addPropertyChangeListener (ddListener); 113 } 114 115 protected Sheet createSheet () { 116 Sheet s = new Sheet (); 117 Sheet.Set ss = new Sheet.Set (); 118 ss.setName (DEPLOYMENT); 119 ss.setDisplayName (NbBundle.getMessage (EarDataNode.class, "PROP_deploymentSet")); 120 ss.setShortDescription (NbBundle.getMessage (EarDataNode.class, "HINT_deploymentSet")); 121 ss.setValue ("helpID", "TBD---Ludo ejbjar node"); 123 Node.Property p = new PropertySupport.ReadOnly ( 124 PROPERTY_DOCUMENT_TYPE, 125 String .class, 126 NbBundle.getBundle(EarDataNode.class).getString("PROP_documentDTD"), 127 NbBundle.getBundle(EarDataNode.class).getString("HINT_documentDTD") 128 ) { 129 public Object getValue () { 130 return dataObject.getApplication().getVersion(); 131 } 132 }; 133 ss.put (p); 134 s.put (ss); 135 136 return s; 137 } 138 139 public HelpCtx getHelpCtx() { 140 return new HelpCtx("TBD ejbjar file"); } 142 143 } 144 | Popular Tags |