1 19 20 package org.netbeans.modules.web.monitor.client; 21 22 import org.openide.nodes.Children; 23 import org.openide.util.actions.*; 24 import org.openide.util.Utilities; 25 import org.openide.nodes.AbstractNode; 26 import org.openide.util.actions.SystemAction; 27 import java.awt.Image ; 28 import java.util.StringTokenizer ; 29 import org.netbeans.modules.web.monitor.data.Constants; 30 31 public class NestedNode extends AbstractNode { 32 33 private String resource = null; 34 private String method = null; 35 private int statusCode; 36 private int[] index; 37 38 public NestedNode(String resource, String method, int[] index, int statusCode) { 39 40 super(Children.LEAF); 41 this.resource = resource; 42 this.method = method; 43 this.index = index; 44 this.statusCode = statusCode; 45 setProperties(); 46 } 47 48 49 public NestedNode(String resource, 50 String method, 51 Children ch, 52 int[] index, 53 int statusCode) { 54 super(ch); 55 this.resource = resource; 56 this.method = method; 57 this.index = index; 58 this.statusCode = statusCode; 59 setProperties(); 60 } 61 62 public String getLongName() { 63 return getName(); 64 } 65 66 public Image getIcon(int type) { 67 Image base; 68 if(method.equals(Constants.Http.GET)) { 70 base = Utilities.loadImage("org/netbeans/modules/web/monitor/client/icons/get.gif"); 71 } else if(method.equals(Constants.Http.POST)) { 73 base = Utilities.loadImage("org/netbeans/modules/web/monitor/client/icons/post.gif"); } else { 76 base = Utilities.loadImage("org/netbeans/modules/web/monitor/client/icons/other.gif"); } 78 79 Image badge; 80 if (statusCode >= 400 || statusCode < 0) { 81 badge = Utilities.loadImage("org/netbeans/modules/web/monitor/client/icons/infoBadge.gif"); } else if (statusCode >= 300) { 83 badge = Utilities.loadImage("org/netbeans/modules/web/monitor/client/icons/warningBadge.gif"); } else if (statusCode >= 200) { 85 return base; 86 } else { 87 badge = Utilities.loadImage("org/netbeans/modules/web/monitor/client/icons/errorBadge.gif"); } 89 return Utilities.mergeImages(base, badge, 0, 0); 90 } 91 92 public Image getOpenedIcon(int type) { 93 return getIcon(type); 94 } 95 96 public String getResource() { 97 return resource; 98 } 99 100 public int[] getIndex() { 101 return index; 102 } 103 104 111 112 protected SystemAction[] createActions () { 113 114 return new SystemAction[] { 115 }; 116 } 117 118 121 public boolean canCopy () { 122 return false; 123 } 124 125 128 public boolean canCut () { 129 return false; 130 } 131 132 private void setProperties() { 133 setNameString(); 134 } 135 136 public void setNameString() { 137 138 String name = null; 139 if(resource.equals("/")) name = resource; else { 141 StringTokenizer st = new StringTokenizer (resource,"/"); while(st.hasMoreTokens()) name = st.nextToken(); 143 } 144 setName(name); 145 } 146 147 public String toString() { 148 StringBuilder buf = new StringBuilder ("NestedNode: "); buf.append(this.getName()); 150 buf.append(", resource="); buf.append(resource); 152 buf.append(", index="); for(int i=0; i<index.length; ++i) { 154 buf.append(index[i]); 155 buf.append(','); } 157 return buf.toString(); 158 } 159 } | Popular Tags |