1 10 11 package org.netbeans.modules.piagetproject.treestructure; 12 13 import java.awt.Image ; 14 import java.util.ArrayList ; 15 import javax.swing.AbstractAction ; 16 import javax.swing.Action ; 17 import org.openide.nodes.AbstractNode; 18 import org.openide.nodes.Children; 19 import org.openide.nodes.Node; 20 import org.openide.util.Utilities; 21 22 26 public class UserNode extends AbstractNode implements PiagetTreeNode{ 27 28 private String filepath; 29 private AbstractAction layoutAction; 30 31 private String username; 32 private String level; 33 34 35 public UserNode(String filepath, String username, String level) { 36 super(NodeRetriever.getSessions(filepath, username, level)); 37 this.filepath = filepath; 38 this.level = level; 39 this.username = username; 40 super.setName(username); 41 setShortDescription("User node: "+username); 42 Children c = this.getChildren(); 43 try{ 44 LayoutNode layout = (LayoutNode)c.findChild("layout"); 45 layoutAction = layout.getLayoutAction(); 46 }catch(Exception e){ 47 layoutAction = null; 48 } 49 } 50 51 public Action [] getActions(boolean context) { 52 53 if(layoutAction != null) 54 return new Action [] { 55 StatsAction.getInstance(), 56 layoutAction, 57 new DeleteAction((AbstractNode)this, filepath) 58 }; 59 else 60 return new Action [] { 61 StatsAction.getInstance(), 62 new DeleteAction((AbstractNode)this, filepath) 63 }; 64 } 65 66 public Image getIcon(int type) { 67 return Utilities.loadImage("org/netbeans/modules/piagetproject/resources/user.png"); 68 } 69 70 public Image getOpenedIcon(int type) { 71 return getIcon(type); 72 } 73 74 public Info [] getInfos() { 75 Children c = this.getChildren(); 76 Node n [] = c.getNodes(); 77 ArrayList infos = new ArrayList (); 78 79 for(int i=0; i<c.getNodesCount(); i++){ 80 Info infoNode [] = ((PiagetTreeNode)n[i]).getInfos(); 81 for(int j=0; j<infoNode.length; j++){ 82 infos.add(infoNode[j]); 83 } 84 } 85 86 Info [] out = new Info [infos.size()]; 87 for(int i=0; i<out.length; i++){ 88 out [i] = (Info)infos.get(i); 89 } 90 91 return out; 92 } 93 } 94 | Popular Tags |