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