1 19 20 package org.netbeans.modules.scripting.php.dbginterface.breakpoints; 21 22 import org.netbeans.modules.scripting.php.dbginterface.ModelSupport; 23 import org.netbeans.modules.scripting.php.dbginterface.Utils; 24 import org.netbeans.spi.viewmodel.NodeModel; 25 import org.netbeans.spi.viewmodel.TableModel; 26 import org.netbeans.spi.viewmodel.UnknownTypeException; 27 import org.netbeans.spi.debugger.ui.Constants; 28 import org.openide.filesystems.FileObject; 29 import org.openide.text.Line; 30 31 36 public class BreakpointModel extends ModelSupport 37 implements NodeModel, TableModel { 39 public static final String LINE_BREAKPOINT = 40 "org/netbeans/modules/debugger/resources/editor/Breakpoint"; public static final String LINE_BREAKPOINT_PC = 42 "org/netbeans/modules/debugger/resources/editor/Breakpoint+PC"; public static final String DISABLED_LINE_BREAKPOINT = 44 "org/netbeans/modules/debugger/resources/editor/DisabledBreakpoint"; 46 public String getDisplayName(Object node) throws UnknownTypeException { 50 if (node instanceof PhpBreakpoint) { 51 PhpBreakpoint breakpoint = (PhpBreakpoint)node; 52 FileObject fileObject = (FileObject)breakpoint.getLine().getLookup().lookup(FileObject.class); 53 return fileObject.getNameExt() + ":" + (breakpoint.getLine().getLineNumber() + 1); 54 } 55 throw new UnknownTypeException(node); 56 } 57 58 public String getIconBase(Object node) throws UnknownTypeException { 59 if (node instanceof PhpBreakpoint) { 60 PhpBreakpoint breakpoint = (PhpBreakpoint)node; 61 if(!breakpoint.isEnabled()) { 62 return DISABLED_LINE_BREAKPOINT; 63 } 64 Line line = Utils.getCurrentLine(); 65 if(line != null && line.getLineNumber() == breakpoint.getLine().getLineNumber()) { 66 return LINE_BREAKPOINT_PC; 67 } 68 return LINE_BREAKPOINT; 69 } 70 71 throw new UnknownTypeException(node); 72 } 73 74 public String getShortDescription(Object node) throws UnknownTypeException { 75 if (node instanceof PhpBreakpoint) { 76 return ((PhpBreakpoint)node).getLine().getDisplayName(); 77 } 78 79 throw new UnknownTypeException(node); 80 } 81 82 public Object getValueAt(Object node, String columnID) throws UnknownTypeException { 86 if (node instanceof PhpBreakpoint) { 87 if (columnID.equals(Constants.BREAKPOINT_ENABLED_COLUMN_ID)) { 88 return Boolean.valueOf(((PhpBreakpoint)node).isEnabled()); 89 } else { 90 System.out.println("BreakpointModel.getValueAt(node=" + node + ", columnId=" + columnID + ")"); 91 } 92 } 93 94 throw new UnknownTypeException(node); 95 } 96 97 public boolean isReadOnly(Object node, String columnID) throws UnknownTypeException { 98 if (node instanceof PhpBreakpoint) { 99 if (columnID.equals(Constants.BREAKPOINT_ENABLED_COLUMN_ID)) { 100 return false; 101 } else { 102 System.out.println("BreakpointModel.getValueAt(node=" + node + ", columnId=" + columnID + ")"); 103 } 104 } 105 106 throw new UnknownTypeException(node); 107 } 108 109 public void setValueAt(Object node, String columnID, Object value) throws UnknownTypeException { 110 if(node instanceof PhpBreakpoint) { 111 if(columnID.equals(Constants.BREAKPOINT_ENABLED_COLUMN_ID)) { 112 if(((Boolean )value).equals(Boolean.TRUE)) { 113 ((PhpBreakpoint)node).enable(); 114 } else { 115 ((PhpBreakpoint)node).disable(); 116 } 117 } 118 } else { 119 throw new UnknownTypeException(node); 120 } 121 } 122 123 } 138 | Popular Tags |