1 19 20 package org.apache.tools.ant.module.loader; 21 22 import java.beans.PropertyChangeEvent ; 23 import java.beans.PropertyChangeListener ; 24 import java.io.IOException ; 25 import org.apache.tools.ant.module.api.AntProjectCookie; 26 import org.apache.tools.ant.module.nodes.AntProjectNode; 27 import org.apache.tools.ant.module.xml.AntProjectSupport; 28 import org.netbeans.spi.xml.cookies.CheckXMLSupport; 29 import org.netbeans.spi.xml.cookies.DataObjectAdapters; 30 import org.openide.cookies.SaveCookie; 31 import org.openide.filesystems.FileObject; 32 import org.openide.loaders.DataObject; 33 import org.openide.loaders.DataObjectExistsException; 34 import org.openide.loaders.MultiDataObject; 35 import org.openide.nodes.CookieSet; 36 import org.openide.nodes.Node; 37 38 public class AntProjectDataObject extends MultiDataObject implements PropertyChangeListener { 39 40 public AntProjectDataObject(FileObject pf, AntProjectDataLoader loader) throws DataObjectExistsException, IOException { 41 super(pf, loader); 42 CookieSet cookies = getCookieSet(); 43 cookies.add (new AntProjectDataEditor (this)); 44 FileObject prim = getPrimaryFile (); 45 AntProjectCookie proj = new AntProjectSupport (prim); 46 cookies.add (proj); 47 if (proj.getFile () != null) { 48 cookies.add (new AntActionInstance (proj)); 49 } 50 cookies.add(new CheckXMLSupport(DataObjectAdapters.inputSource(this))); 51 addPropertyChangeListener (this); 52 } 53 54 @Override 55 protected Node createNodeDelegate () { 56 return new AntProjectNode (this); 57 } 58 59 void addSaveCookie (final SaveCookie save) { 60 if (getCookie (SaveCookie.class) == null) { 61 getCookieSet ().add (save); 62 setModified (true); 63 } 64 } 65 66 void removeSaveCookie (final SaveCookie save) { 67 if (getCookie (SaveCookie.class) == save) { 68 getCookieSet ().remove (save); 69 setModified (false); 70 } 71 } 72 73 public void propertyChange (PropertyChangeEvent ev) { 74 String prop = ev.getPropertyName (); 75 if (prop == null || prop.equals (DataObject.PROP_PRIMARY_FILE)) { ((AntProjectSupport) getCookie (AntProjectSupport.class)).setFileObject (getPrimaryFile ()); 78 } 79 } 80 81 } 82 | Popular Tags |