1 19 20 package org.netbeans.modules.j2ee.ddloaders.client; 21 22 import java.beans.PropertyChangeEvent ; 23 import java.beans.PropertyChangeListener ; 24 import org.openide.util.NbBundle; 25 import org.netbeans.modules.xml.multiview.XmlMultiViewDataObject; 26 import org.openide.loaders.DataNode; 27 import org.openide.nodes.Children; 28 import org.openide.nodes.Node; 29 import org.openide.nodes.PropertySupport; 30 import org.openide.nodes.Sheet; 31 import org.openide.util.HelpCtx; 32 33 38 public class ClientDataNode extends DataNode { 39 40 private static final String DEPLOYMENT = "deployment"; private static final java.awt.Image ERROR_BADGE = 42 org.openide.util.Utilities.loadImage( "org/netbeans/modules/j2ee/ddloaders/client/error-badge.gif" ); private static final java.awt.Image CLIETN_XML = 44 org.openide.util.Utilities.loadImage( "org/netbeans/modules/j2ee/ddloaders/client/DDDataIcon.gif" ); 46 private ClientDataObject dataObject; 47 48 49 public static final String PROPERTY_DOCUMENT_TYPE = "documentType"; 51 52 private PropertyChangeListener ddListener; 53 54 public ClientDataNode (ClientDataObject obj) { 55 this (obj, Children.LEAF); 56 } 57 58 public ClientDataNode (ClientDataObject obj, Children ch) { 59 super (obj, ch); 60 dataObject=obj; 61 initListeners(); 62 } 63 64 67 private void initListeners(){ 68 ddListener = new PropertyChangeListener () { 69 70 public void propertyChange (PropertyChangeEvent evt) { 71 String propertyName = evt.getPropertyName (); 72 Object newValue = evt.getNewValue (); 73 Object oldValue = evt.getOldValue (); 74 if (ClientDataObject.PROP_DOCUMENT_DTD.equals (propertyName)) { 75 firePropertyChange (PROPERTY_DOCUMENT_TYPE, oldValue, newValue); 76 } 77 if (ClientDataObject.PROP_VALID.equals (propertyName) 78 && Boolean.TRUE.equals (newValue)) { 79 removePropertyChangeListener (ClientDataNode.this.ddListener); 80 } 81 if (Node.PROP_PROPERTY_SETS.equals (propertyName)) { 82 firePropertySetsChange(null,null); 83 } 84 if (XmlMultiViewDataObject.PROP_SAX_ERROR.equals(propertyName)) { 85 fireShortDescriptionChange((String ) oldValue, (String ) newValue); 86 } 87 } 88 89 }; 90 getDataObject ().addPropertyChangeListener (ddListener); 91 } 92 93 private ClientDataObject getDDDataObject () { 94 return (ClientDataObject) getDataObject (); 95 } 96 97 protected Sheet createSheet () { 98 Sheet s = super.createSheet(); 99 Sheet.Set ss = s.get(Sheet.PROPERTIES); 100 101 Node.Property p = new PropertySupport.ReadOnly ( 102 PROPERTY_DOCUMENT_TYPE, 103 String .class, 104 NbBundle.getBundle(ClientDataNode.class).getString("PROP_documentDTD"), 105 NbBundle.getBundle(ClientDataNode.class).getString("HINT_documentDTD") 106 ) { 107 public Object getValue () { 108 return dataObject.getAppClient().getVersion(); 109 } 110 }; 111 ss.put (p); 112 s.put (ss); 113 114 return s; 115 } 116 117 public HelpCtx getHelpCtx() { 118 return new HelpCtx("TBD application-client.xml file"); } 120 121 void iconChanged() { 122 fireIconChange(); 123 } 124 125 public java.awt.Image getIcon(int type) { 126 if (dataObject.getSaxError()==null) 127 return CLIETN_XML; 128 else 129 return org.openide.util.Utilities.mergeImages(CLIETN_XML, ERROR_BADGE, 6, 6); 130 } 131 132 public String getShortDescription() { 133 org.xml.sax.SAXException saxError = dataObject.getSaxError(); 134 if (saxError==null) { 135 return NbBundle.getBundle(ClientDataNode.class).getString("HINT_web_dd"); 136 } else { 137 return saxError.getMessage(); 138 } 139 } 140 141 } 142 | Popular Tags |