1 19 20 package org.netbeans.modules.scripting.php.dbginterface.breakpoints; 21 22 import javax.swing.Action ; 23 import org.netbeans.spi.viewmodel.NodeActionsProvider; 24 import org.netbeans.spi.viewmodel.UnknownTypeException; 25 import org.netbeans.spi.viewmodel.Models; 26 import org.netbeans.spi.viewmodel.NodeActionsProviderFilter; 27 import org.openide.filesystems.FileObject; 28 import org.openide.text.Line; 29 import org.openide.util.NbBundle; 30 31 32 35 public class BreakpointsActionsProvider implements NodeActionsProviderFilter { 36 37 private static String loc(String key) { 38 return NbBundle.getBundle(BreakpointsActionsProvider.class).getString(key); 39 } 40 41 private static final Action GO_TO_SOURCE_ACTION = Models.createAction( 42 loc("CTL_Breakpoint_GoToSource_Label"), new Models.ActionPerformer() { 44 public boolean isEnabled(Object node) { 45 return true; 46 } 47 public void perform(Object [] nodes) { 48 goToSource((PhpBreakpoint) nodes [0]); 49 } 50 }, 51 Models.MULTISELECTION_TYPE_EXACTLY_ONE 52 ); 53 66 public Action [] getActions (NodeActionsProvider original, Object node) 67 throws UnknownTypeException { 68 Action [] oas = original.getActions(node); 69 if(node instanceof PhpBreakpoint) { 70 Action [] as = new Action [oas.length + 2]; 71 as [0] = GO_TO_SOURCE_ACTION; 72 as [1] = null; 73 System.arraycopy (oas, 0, as, 2, oas.length); 74 oas = as; 75 } 76 77 return oas; 78 } 79 80 public void performDefaultAction(NodeActionsProvider original, Object node) throws UnknownTypeException { 81 if(node instanceof PhpBreakpoint) { 82 goToSource((PhpBreakpoint) node); 83 } else { 84 original.performDefaultAction(node); 85 } 86 } 87 88 private static void goToSource(PhpBreakpoint bp) { 89 Line l = bp.getLine(); 90 l.show(Line.SHOW_GOTO); 91 } 92 93 } 155 | Popular Tags |