1 23 24 package org.enhydra.kelp.forte.node; 25 26 import org.openide.actions.*; 27 import org.openide.cookies.*; 28 import org.openide.loaders.*; 29 import org.openide.nodes.*; 30 import org.openide.util.HelpCtx; 31 import org.openide.filesystems.FileObject; 32 import org.openide.filesystems.FileSystem; 33 import org.openide.filesystems.FileStateInvalidException; 34 import org.enhydra.kelp.forte.node.DodsDataLoader; 35 36 import org.enhydra.kelp.forte.DodsSettings; 37 38 import org.enhydra.kelp.common.PathUtil; 39 40 import java.io.File ; 41 42 46 public class DodsDataObject extends MultiDataObject { 47 48 static final long serialVersionUID = -1461825550268566994L; 49 50 protected DodsSettings settings = null; 51 52 public DodsDataObject (FileObject pf, DodsDataLoader loader) throws DataObjectExistsException 53 { 54 super (pf, loader); 55 init (); 56 } 57 58 private void init () { 59 settings = DodsSettings.getDefault(); 60 CookieSet cookies = getCookieSet (); 61 74 cookies.add(new XMLCEditorSupport(this)); 75 } 76 77 public HelpCtx getHelpCtx () { 78 return HelpCtx.DEFAULT_HELP; 79 } 82 83 protected Node createNodeDelegate () { 84 return new DodsDataNode (this); 85 } 86 87 public String getPath() 88 { 89 FileObject file = getPrimaryFile(); 90 StringBuffer res = new StringBuffer (); 91 FileSystem fs = null; 92 try 93 { 94 fs = file.getFileSystem(); 95 } catch (FileStateInvalidException e) 96 { 97 System.err.println(e); 98 return "invalid"; 99 } 100 101 res.append(fs.getSystemName()); 102 String pack = file.getPackageNameExt(File.separatorChar, '.'); 103 res.append(File.separatorChar); 104 res.append(pack); 105 106 return res.toString(); 107 } 108 109 public String getProperty(String key) 110 { 111 String path = PathUtil.compressPathRelativeToProject(new ForteProject(), getPath()); 112 return (String )settings.getNodeProperty(path + key); 113 } 114 115 public void setProperty(String key, String value) 116 { 117 String path = PathUtil.compressPathRelativeToProject(new ForteProject(), getPath()); 118 settings.setNodeProperty(path + key, value); 119 } 120 } 121 | Popular Tags |