KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > scripting > php > dbginterface > breakpoints > BreakpointsActionsProvider


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.scripting.php.dbginterface.breakpoints;
21
22 import javax.swing.Action JavaDoc;
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 /**
33  * @author Peter Williams
34  */

35 public class BreakpointsActionsProvider implements NodeActionsProviderFilter {
36
37     private static String JavaDoc loc(String JavaDoc key) {
38         return NbBundle.getBundle(BreakpointsActionsProvider.class).getString(key);
39     }
40
41     private static final Action JavaDoc GO_TO_SOURCE_ACTION = Models.createAction(
42         loc("CTL_Breakpoint_GoToSource_Label"), // NOI18N
43
new Models.ActionPerformer() {
44             public boolean isEnabled(Object JavaDoc node) {
45                 return true;
46             }
47             public void perform(Object JavaDoc[] nodes) {
48                 goToSource((PhpBreakpoint) nodes [0]);
49             }
50         },
51         Models.MULTISELECTION_TYPE_EXACTLY_ONE
52     );
53 // private static final Action CUSTOMIZE_ACTION = Models.createAction (
54
// loc("CTL_Breakpoint_Customize_Label"), // NOI18N
55
// new Models.ActionPerformer () {
56
// public boolean isEnabled (Object node) {
57
// return true;
58
// }
59
// public void perform (Object[] nodes) {
60
// customize ((Breakpoint) nodes [0]);
61
// }
62
// },
63
// Models.MULTISELECTION_TYPE_EXACTLY_ONE
64
// );
65

66     public Action JavaDoc[] getActions (NodeActionsProvider original, Object JavaDoc node)
67             throws UnknownTypeException {
68         Action JavaDoc[] oas = original.getActions(node);
69         if(node instanceof PhpBreakpoint) {
70             Action JavaDoc[] as = new Action JavaDoc [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 JavaDoc 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 // public static void customize (Breakpoint b) {
94
// JComponent c = null;
95
// if (b instanceof LineBreakpoint)
96
// c = new LineBreakpointPanel ((LineBreakpoint) b);
97
// else
98
// if (b instanceof FieldBreakpoint)
99
// c = new FieldBreakpointPanel ((FieldBreakpoint) b);
100
// else
101
// if (b instanceof ClassLoadUnloadBreakpoint)
102
// c = new ClassBreakpointPanel ((ClassLoadUnloadBreakpoint) b);
103
// else
104
// if (b instanceof MethodBreakpoint)
105
// c = new MethodBreakpointPanel ((MethodBreakpoint) b);
106
// else
107
// if (b instanceof ThreadBreakpoint)
108
// c = new ThreadBreakpointPanel ((ThreadBreakpoint) b);
109
// else
110
// if (b instanceof ExceptionBreakpoint)
111
// c = new ExceptionBreakpointPanel ((ExceptionBreakpoint) b);
112
//
113
// c.getAccessibleContext().setAccessibleDescription(
114
// NbBundle.getMessage(BreakpointsActionsProvider.class, "ACSD_Breakpoint_Customizer_Dialog")); // NOI18N
115
// HelpCtx helpCtx = HelpCtx.findHelp (c);
116
// if (helpCtx == null) {
117
// helpCtx = new HelpCtx ("debug.add.breakpoint"); // NOI18N
118
// }
119
// final Controller[] cPtr = new Controller[] { (Controller) c };
120
// final DialogDescriptor[] descriptorPtr = new DialogDescriptor[1];
121
// final Dialog[] dialogPtr = new Dialog[1];
122
// ActionListener buttonsActionListener = new ActionListener() {
123
// public void actionPerformed(ActionEvent ev) {
124
// if (descriptorPtr[0].getValue() == DialogDescriptor.OK_OPTION) {
125
// boolean ok = cPtr[0].ok();
126
// if (ok) {
127
// dialogPtr[0].setVisible(false);
128
// }
129
// } else {
130
// dialogPtr[0].setVisible(false);
131
// }
132
// }
133
// };
134
// DialogDescriptor descriptor = new DialogDescriptor (
135
// c,
136
// NbBundle.getMessage (
137
// BreakpointsActionsProvider.class,
138
// "CTL_Breakpoint_Customizer_Title" // NOI18N
139
// ),
140
// true,
141
// DialogDescriptor.OK_CANCEL_OPTION,
142
// DialogDescriptor.OK_OPTION,
143
// DialogDescriptor.DEFAULT_ALIGN,
144
// helpCtx,
145
// buttonsActionListener
146
// );
147
// descriptor.setClosingOptions(new Object[] {});
148
// Dialog d = DialogDisplayer.getDefault ().createDialog (descriptor);
149
// d.pack ();
150
// descriptorPtr[0] = descriptor;
151
// dialogPtr[0] = d;
152
// d.setVisible (true);
153
// }
154
}
155
Popular Tags