1 10 11 package org.netbeans.modules.piagetproject.treestructure; 12 13 import java.awt.Image ; 14 import java.util.ArrayList ; 15 import javax.swing.Action ; 16 import org.netbeans.modules.piagetproject.PiagetProjectFactory; 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 LevelNode extends AbstractNode implements PiagetTreeNode{ 27 28 private int level; 29 30 31 public LevelNode(int level) { 32 super(NodeRetriever.getUsers(level)); 33 this.level = level; 34 String myLevel = PiagetProjectFactory.getLevelName(level); 35 this.setName(myLevel); 36 setShortDescription("Level node: "+myLevel); 37 } 38 39 public Action [] getActions(boolean context) { 40 41 Action [] result = new Action [] { 42 StatsAction.getInstance() 43 }; 44 return result; 45 } 46 47 public Image getIcon(int type) { 48 switch (level){ 49 case 1: 50 return Utilities.loadImage("org/netbeans/modules/piagetproject/resources/level1.png"); 51 case 2: 52 return Utilities.loadImage("org/netbeans/modules/piagetproject/resources/level2.png"); 53 case 3: 54 return Utilities.loadImage("org/netbeans/modules/piagetproject/resources/level3.png"); 55 default: 56 return Utilities.loadImage("org/netbeans/modules/piagetproject/resources/level1.png"); 57 } 58 } 59 60 public Image getOpenedIcon(int type) { 61 return getIcon(type); 62 } 63 64 65 71 public Info [] getInfos() { 72 Children c = this.getChildren(); 73 Node n [] = c.getNodes(); 74 ArrayList infos = new ArrayList (); 75 76 for(int i=0; i<c.getNodesCount(); i++){ 77 Info nodeInfos [] = ((PiagetTreeNode)n[i]).getInfos(); 78 for(int j=0; j<nodeInfos.length; j++) infos.add(nodeInfos[j]); 79 } 80 81 Info [] out = new Info [infos.size()]; 82 for(int i=0; i<out.length; i++) out [i] = (Info)infos.get(i); 83 84 return out; 85 } 86 87 } 88 89 | Popular Tags |