1 19 20 package org.netbeans.modules.debugger.jpda.ui.models; 21 22 import org.netbeans.spi.debugger.ContextProvider; 23 import org.netbeans.api.debugger.jpda.InvalidExpressionException; 24 import org.netbeans.api.debugger.jpda.JPDAWatch; 25 import org.netbeans.spi.viewmodel.TreeModel; 26 import org.netbeans.spi.viewmodel.ModelListener; 27 import org.netbeans.spi.viewmodel.UnknownTypeException; 28 import org.openide.util.NbBundle; 29 30 31 34 public class WatchesNodeModel extends VariablesNodeModel { 35 36 public static final String WATCH = 37 "org/netbeans/modules/debugger/resources/watchesView/Watch"; 38 39 40 public WatchesNodeModel (ContextProvider lookupProvider) { 41 super (lookupProvider); 42 } 43 44 public String getDisplayName (Object o) throws UnknownTypeException { 45 if (o == TreeModel.ROOT) 46 return NbBundle.getBundle (WatchesNodeModel.class). 47 getString ("CTL_WatchesModel_Column_Name_Name"); 48 if (o instanceof JPDAWatch) 49 return ((JPDAWatch) o).getExpression (); 50 return super.getDisplayName (o); 51 } 52 53 public String getShortDescription (Object o) throws UnknownTypeException { 54 if (o == TreeModel.ROOT) 55 return TreeModel.ROOT; 56 if (o instanceof JPDAWatch) { 57 JPDAWatch w = (JPDAWatch) o; 58 boolean evaluated; 59 evaluated = VariablesTreeModelFilter.isEvaluated(o); 60 if (!evaluated) { 61 return w.getExpression (); 62 } 63 String e = w.getExceptionDescription (); 64 if (e != null) 65 return w.getExpression () + " = >" + e + "<"; 66 String t = w.getType (); 67 if (t == null) 68 return w.getExpression () + " = " + w.getValue (); 69 else 70 try { 71 return w.getExpression () + " = (" + w.getType () + ") " + 72 w.getToStringValue (); 73 } catch (InvalidExpressionException ex) { 74 return ex.getLocalizedMessage (); 75 } 76 } 77 return super.getShortDescription (o); 78 } 79 80 public String getIconBase (Object o) throws UnknownTypeException { 81 if (o == TreeModel.ROOT) 82 return WATCH; 83 if (o instanceof JPDAWatch) 84 return WATCH; 85 return super.getIconBase (o); 86 } 87 88 } 89 | Popular Tags |