1 19 23 24 package org.netbeans.modules.piaget.user; 25 26 import java.awt.Image ; 27 import org.openide.loaders.DataNode; 28 import org.openide.nodes.Children; 29 import org.openide.util.Utilities; 30 import javax.swing.Action ; 31 import org.openide.util.actions.SystemAction; 32 import org.openide.actions.CopyAction; 33 import org.openide.actions.CutAction; 34 import org.openide.actions.DeleteAction; 35 import org.openide.actions.EditAction; 36 import org.openide.actions.RenameAction; 37 import org.openide.loaders.DataObject; 38 import org.openide.filesystems.FileObject; 39 import org.openide.filesystems.FileUtil; 40 import java.io.File ; 41 42 43 public class UserDataNode extends DataNode { 44 45 private String filename; 46 47 public UserDataNode(UserDataObject obj) { 48 super (obj, Children.LEAF); 49 DataObject d = this.getDataObject(); 50 FileObject fo = d.getPrimaryFile(); 51 filename = fo.getName(); 52 filename = filename + "." + UserDataLoader.EXTENSION; 53 setShortDescription("'.user' file, not parsed yet"); 54 } 55 56 public Image getIcon(int type) { 57 return Utilities.loadImage("org/netbeans/modules/piaget/resources/usernew.png"); 58 } 59 60 61 public Action [] getActions(boolean context) { 62 Action [] result = new Action [] { 63 UserNodeAction.getInstance(), 64 SystemAction.get (CutAction.class), 65 SystemAction.get (CopyAction.class), 66 SystemAction.get (RenameAction.class), 67 SystemAction.get (DeleteAction.class), 68 }; 69 return result; 70 } 71 72 public void fireDestroy(){ 73 this.firePropertyChange("myDestroy", null, null); 74 } 75 76 public Action getPreferredAction() { 77 return UserNodeAction.getInstance(); 78 } 79 80 public String getFilename(){ 81 return filename; 82 } 83 84 public String getPath(){ 85 DataObject d = this.getDataObject(); 86 FileObject fo = d.getPrimaryFile(); 87 File f = FileUtil.toFile(fo); 88 this.setHidden(true); 89 return f.getPath(); 90 } 91 } | Popular Tags |