1 10 11 package org.netbeans.modules.piagetproject.treestructure; 12 13 import java.awt.Image ; 14 import javax.swing.AbstractAction ; 15 import javax.swing.Action ; 16 import org.netbeans.modules.piagetproject.layout.LayoutBuilder; 17 import org.openide.util.Utilities; 18 import org.openide.nodes.AbstractNode; 19 import org.openide.nodes.Children; 20 21 22 26 public class LayoutNode extends AbstractNode implements PiagetTreeNode{ 27 28 Info info; 29 private AbstractAction actionInstance; 30 31 32 public LayoutNode(String filepath, String username, String level) { 33 super(Children.LEAF); 34 info = new Info(filepath, username, level); 35 setShortDescription("window layout"); 36 super.setName("layout"); 37 } 38 39 public Action [] getActions(boolean context) { 40 Action [] result = new Action [] { 41 getLayoutAction(), 42 new DeleteAction((AbstractNode)this, info.path) 43 }; 44 return result; 45 } 46 47 public synchronized AbstractAction getLayoutAction(){ 48 if(actionInstance==null) actionInstance = new LayoutAction(info.path); 49 return actionInstance; 50 } 51 52 public Image getIcon(int type) { 53 return Utilities.loadImage("org/netbeans/modules/piagetproject/resources/layout.png"); 54 } 55 56 public Image getOpenedIcon(int type) { 57 return getIcon(type); 58 } 59 60 public Action getPreferredAction() { 61 return getLayoutAction(); 62 } 63 64 public Info [] getInfos() { 65 return new Info [] {info}; 66 } 67 68 private class LayoutAction extends AbstractAction { 69 70 String filepath; 71 72 public LayoutAction(String filepath){ 73 putValue(Action.NAME, "layout"); 74 this.filepath = filepath; 75 } 76 77 public void actionPerformed(java.awt.event.ActionEvent e) { 78 LayoutBuilder.doLayout(filepath); 79 } 80 81 protected Object clone() throws CloneNotSupportedException { 82 throw new CloneNotSupportedException (); 83 } 84 } 85 } 86 | Popular Tags |