1 16 17 package org.mc4j.console.connection; 18 19 import org.mc4j.ems.connection.bean.EmsBean; 20 import org.mc4j.ems.connection.bean.attribute.EmsAttribute; 21 import org.openide.nodes.Node; 22 import org.openide.util.HelpCtx; 23 import org.openide.util.actions.NodeAction; 24 import org.openide.windows.IOProvider; 25 import org.openide.windows.OutputWriter; 26 27 import java.math.BigDecimal ; 28 import java.math.BigInteger ; 29 import java.util.HashSet ; 30 import java.util.Set ; 31 32 37 public class NumericIntrospectorAction extends NodeAction { 38 39 protected void performAction(Node[] nodes) { 40 ConnectionNode node = (ConnectionNode)nodes[0]; 41 42 OutputWriter w = IOProvider.getDefault().getIO("Stats Output", true).getOut(); 43 44 for (EmsBean emsBean : node.getEmsConnection().getBeans()) { 45 boolean beanOutput = false; 46 47 for (EmsAttribute attribute : emsBean.getAttributes()) { 48 49 if (!attribute.isWritable() && STATS_TYPES.contains(attribute.getType())) { 50 51 if (!beanOutput) { 52 w.println(emsBean.getBeanName().getCanonicalName()); 53 beanOutput = true; 54 } 55 56 w.println("\t" + attribute.getName() + "[" + attribute.getType() + "]"); 57 } 58 59 } 60 } 61 } 62 63 static Set STATS_TYPES = new HashSet (); 64 static { 65 STATS_TYPES.add(Short.TYPE.getName()); 66 STATS_TYPES.add(Short .class.getName()); 67 STATS_TYPES.add(Integer.TYPE.getName()); 68 STATS_TYPES.add(Integer .class.getName()); 69 STATS_TYPES.add(Long.TYPE.getName()); 70 STATS_TYPES.add(Long .class.getName()); 71 STATS_TYPES.add(Float.TYPE.getName()); 72 STATS_TYPES.add(Float .class.getName()); 73 STATS_TYPES.add(Double.TYPE.getName()); 74 STATS_TYPES.add(Double .class.getName()); 75 STATS_TYPES.add(BigInteger .class.getName()); 76 STATS_TYPES.add(BigDecimal .class.getName()); 77 } 78 79 80 protected boolean enable(Node[] nodes) { 81 return ((nodes.length == 1) && 82 (nodes[0] instanceof ConnectionNode) && 83 (((ConnectionNode)nodes[0]).isConnected())); 84 } 85 86 public String getName() { 87 return "Print numeric info"; 88 } 89 90 protected String iconResource() { 91 return null; 92 } 93 94 public HelpCtx getHelpCtx() { 95 return HelpCtx.DEFAULT_HELP; 96 } 99 100 } 101 | Popular Tags |