1 19 20 package org.netbeans.modules.web.debug.breakpoints; 21 22 import java.awt.Dialog ; 23 import java.awt.event.ActionEvent ; 24 import java.util.List ; 25 import javax.swing.Action ; 26 import javax.swing.JButton ; 27 import javax.swing.JComponent ; 28 29 import org.netbeans.api.debugger.*; 30 import org.netbeans.api.debugger.jpda.*; 31 import org.netbeans.spi.debugger.ui.*; 32 import org.netbeans.spi.viewmodel.*; 33 34 import org.netbeans.modules.web.debug.*; 35 36 import org.openide.*; 37 import org.openide.util.*; 38 39 40 43 public class JspBreakpointActionsProvider implements NodeActionsProviderFilter { 44 45 private static final Action GO_TO_SOURCE_ACTION = Models.createAction ( 46 "Go to Source", 47 new Models.ActionPerformer () { 48 public boolean isEnabled (Object node) { 49 return true; 50 } 51 public void perform (Object [] nodes) { 52 goToSource ((JspLineBreakpoint) nodes [0]); 53 } 54 }, 55 Models.MULTISELECTION_TYPE_EXACTLY_ONE 56 ); 57 private static final Action CUSTOMIZE_ACTION = Models.createAction ( 58 "Customize", 59 new Models.ActionPerformer () { 60 public boolean isEnabled (Object node) { 61 return true; 62 } 63 public void perform (Object [] nodes) { 64 customize ((Breakpoint) nodes [0]); 65 } 66 }, 67 Models.MULTISELECTION_TYPE_EXACTLY_ONE 68 ); 69 70 71 public Action [] getActions (NodeActionsProvider original, Object node) throws UnknownTypeException { 72 if (!(node instanceof JspLineBreakpoint)) 73 return original.getActions (node); 74 75 Action [] oas = original.getActions (node); 76 if (node instanceof JspLineBreakpoint) { 77 Action [] as = new Action [oas.length + 3]; 78 as [0] = GO_TO_SOURCE_ACTION; 79 as [1] = null; 80 System.arraycopy (oas, 0, as, 2, oas.length); 81 as [as.length - 1] = CUSTOMIZE_ACTION; 82 return as; 83 } 84 Action [] as = new Action [oas.length + 1]; 85 System.arraycopy (oas, 0, as, 0, oas.length); 86 as [as.length - 1] = CUSTOMIZE_ACTION; 87 return as; 88 } 89 90 public void performDefaultAction (NodeActionsProvider original, Object node) throws UnknownTypeException { 91 if (node instanceof JspLineBreakpoint) 92 goToSource ((JspLineBreakpoint) node); 93 else 94 original.performDefaultAction (node); 95 } 96 97 public void addModelListener (ModelListener l) { 98 } 99 100 public void removeModelListener (ModelListener l) { 101 } 102 103 private static void customize (Breakpoint b) { 104 JComponent c = null; 105 if (b instanceof JspLineBreakpoint) { 106 c = new JspBreakpointPanel((JspLineBreakpoint) b); 107 } 108 109 DialogDescriptor descriptor = new DialogDescriptor ( 110 c, 111 NbBundle.getMessage ( 112 JspBreakpointActionsProvider.class, 113 "CTL_Breakpoint_Customizer_Title" ) 115 ); 116 117 JButton bOk = null; 118 JButton bClose = null; 119 descriptor.setOptions (new JButton [] { 120 bOk = new JButton (NbBundle.getMessage ( 121 JspBreakpointActionsProvider.class, 122 "CTL_Ok" )), 124 bClose = new JButton (NbBundle.getMessage ( 125 JspBreakpointActionsProvider.class, 126 "CTL_Close" )) 128 }); 129 HelpCtx helpCtx = HelpCtx.findHelp (c); 130 if (helpCtx == null) 131 helpCtx = new HelpCtx ("debug.add.breakpoint");; 132 descriptor.setHelpCtx (helpCtx); 133 bOk.getAccessibleContext ().setAccessibleDescription ( 134 NbBundle.getMessage ( 135 JspBreakpointActionsProvider.class, 136 "ACSD_CTL_Ok" ) 138 ); 139 bOk.setMnemonic(NbBundle.getMessage(JspBreakpointActionsProvider.class, "CTL_Ok_MNEM").charAt(0)); bClose.getAccessibleContext ().setAccessibleDescription ( 141 NbBundle.getMessage ( 142 JspBreakpointActionsProvider.class, 143 "ACSD_CTL_Close" ) 145 ); 146 bClose.setMnemonic(NbBundle.getMessage(JspBreakpointActionsProvider.class, "CTL_Close_MNEM").charAt(0)); descriptor.setClosingOptions (null); 148 Dialog d = DialogDisplayer.getDefault ().createDialog (descriptor); 149 d.pack (); 150 d.setVisible (true); 151 if (descriptor.getValue () == bOk) { 152 ((Controller) c).ok (); 153 } 154 } 155 156 private static void goToSource (JspLineBreakpoint b) { 157 Context.showSource (b); 158 } 159 } 160 | Popular Tags |