1 19 20 package org.netbeans.modules.xml.wsdl.ui.netbeans.module; 21 22 import java.io.IOException ; 23 24 import org.netbeans.spi.xml.cookies.CheckXMLSupport; 25 import org.netbeans.spi.xml.cookies.DataObjectAdapters; 26 import org.openide.cookies.SaveCookie; 27 import org.openide.filesystems.FileObject; 28 import org.openide.loaders.DataFolder; 29 import org.openide.loaders.DataObjectExistsException; 30 import org.openide.loaders.MultiDataObject; 31 import org.openide.loaders.MultiFileLoader; 32 import org.openide.nodes.CookieSet; 33 import org.openide.nodes.Node; 34 import org.openide.util.HelpCtx; 35 import org.xml.sax.InputSource ; 36 37 42 public class WSDLDataObject extends MultiDataObject { 43 44 public WSDLDataObject(FileObject fObj, MultiFileLoader loader) throws 45 DataObjectExistsException { 46 super(fObj, loader); 47 CookieSet set = getCookieSet(); 48 49 editorSupport = new WSDLEditorSupport(this); 50 set.add(editorSupport); 52 53 InputSource is = DataObjectAdapters.inputSource(this); 55 set.add(new CheckXMLSupport(is)); 56 58 set.add(new WSDLMultiViewSupport(this)); 59 set.add(new WSDLValidateXMLCookie(this)); 61 } 62 63 @Override 64 protected Node createNodeDelegate() { 65 return new WSDLNode(this); 66 } 67 68 @Override 69 public HelpCtx getHelpCtx() { 70 return HelpCtx.DEFAULT_HELP; 71 } 72 73 @Override 74 protected void handleDelete() throws IOException { 75 if (isModified()) { 76 setModified(false); 77 } 78 getWSDLEditorSupport().getEnv().unmarkModified(); 79 super.handleDelete(); 80 } 81 82 protected FileObject handleMove(DataFolder df) throws IOException { 83 if(isModified()) { 87 SaveCookie sCookie = (SaveCookie) this.getCookie(SaveCookie.class); 88 if(sCookie != null) { 89 sCookie.save(); 90 } 91 } 92 93 return super.handleMove(df); 94 } 95 96 97 @Override 98 public void setModified(boolean modified) { 99 super.setModified(modified); 100 if (modified) { 101 getCookieSet().add(getSaveCookie()); 102 } else { 103 getCookieSet().remove(getSaveCookie()); 104 } 105 } 106 107 private SaveCookie getSaveCookie() { 108 return new SaveCookie() { 109 public void save() throws IOException { 110 getWSDLEditorSupport().saveDocument(); 111 } 112 113 @Override 114 public int hashCode() { 115 return getClass().hashCode(); 116 } 117 118 @Override 119 public boolean equals(Object other) { 120 return other != null && getClass().equals(other.getClass()); 121 } 122 }; 123 } 124 125 public WSDLEditorSupport getWSDLEditorSupport() { 126 return editorSupport; 127 } 128 129 private static final long serialVersionUID = 6338889116068357651L; 130 private transient WSDLEditorSupport editorSupport; 131 132 public static final String WSDL_ICON_BASE_WITH_EXT = "org/netbeans/modules/xml/wsdl/ui/netbeans/module/resources/wsdl16.png"; 133 } 134 | Popular Tags |