This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 180558
Collapse All | Expand All

(-)a/api.debugger/apichanges.xml (+19 lines)
Lines 384-389 Link Here
384
        <issue number="177561"/>
384
        <issue number="177561"/>
385
    </change>
385
    </change>
386
386
387
    <change id="AddWatchActionProvider">
388
        <api name="DebuggerCoreAPI"/>
389
        <summary>It's possible to override New Watch action with a session-specific provider.</summary>
390
        <version major="1" minor="24"/>
391
        <date day="23" month="2" year="2010"/>
392
        <author login="mentlicher"/>
393
        <compatibility binary="compatible" source="compatible" addition="yes"/>
394
        <description>
395
             <p>
396
             ActionsManager.ACTION_NEW_WATCH constant was added for use by session-specific
397
             provider of New Watch action. That action invokes an implementation
398
             of ActionsProvider that is registered for the active debugger session
399
             and contains ActionsManager.ACTION_NEW_WATCH action.
400
             </p>
401
        </description>
402
        <class package="org.netbeans.api.debugger" name="ActionsManager" />
403
        <issue number="180558"/>
404
    </change>
405
387
</changes>
406
</changes>
388
407
389
  <!-- Now the surrounding HTML text and document structure: -->
408
  <!-- Now the surrounding HTML text and document structure: -->
(-)a/api.debugger/manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.api.debugger/1
2
OpenIDE-Module: org.netbeans.api.debugger/1
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/api/debugger/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/api/debugger/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.23
4
OpenIDE-Module-Specification-Version: 1.24
5
OpenIDE-Module-Layer: org/netbeans/api/debugger/layer.xml
5
OpenIDE-Module-Layer: org/netbeans/api/debugger/layer.xml
(-)a/api.debugger/src/org/netbeans/api/debugger/ActionsManager.java (+4 lines)
Lines 106-111 Link Here
106
    /** Action constant for Toggle Breakpoint Action. */
106
    /** Action constant for Toggle Breakpoint Action. */
107
    public static final Object              ACTION_TOGGLE_BREAKPOINT = "toggleBreakpoint";
107
    public static final Object              ACTION_TOGGLE_BREAKPOINT = "toggleBreakpoint";
108
    
108
    
109
    /** Action constant for New Watch Action.
110
     * @since 1.24 */
111
    public static final Object              ACTION_NEW_WATCH = "newWatch";
112
109
    
113
    
110
    // variables ...............................................................
114
    // variables ...............................................................
111
    
115
    
(-)a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/AddWatchAction.java (-21 / +94 lines)
Lines 45-51 Link Here
45
import java.util.ResourceBundle;
45
import java.util.ResourceBundle;
46
import java.util.prefs.Preferences;
46
import java.util.prefs.Preferences;
47
import javax.swing.*;
47
import javax.swing.*;
48
import org.netbeans.api.debugger.ActionsManager;
49
import org.netbeans.api.debugger.DebuggerEngine;
48
import org.netbeans.api.debugger.DebuggerManager;
50
import org.netbeans.api.debugger.DebuggerManager;
51
import org.netbeans.api.debugger.DebuggerManagerAdapter;
52
import org.netbeans.api.debugger.Watch;
49
import org.netbeans.modules.debugger.ui.WatchPanel;
53
import org.netbeans.modules.debugger.ui.WatchPanel;
50
54
51
import org.netbeans.modules.debugger.ui.views.VariablesViewButtons;
55
import org.netbeans.modules.debugger.ui.views.VariablesViewButtons;
Lines 55-60 Link Here
55
import org.openide.util.HelpCtx;
59
import org.openide.util.HelpCtx;
56
import org.openide.util.NbBundle;
60
import org.openide.util.NbBundle;
57
import org.openide.util.NbPreferences;
61
import org.openide.util.NbPreferences;
62
import org.openide.util.RequestProcessor;
63
import org.openide.util.Task;
58
import org.openide.util.actions.CallableSystemAction;
64
import org.openide.util.actions.CallableSystemAction;
59
import org.openide.windows.Mode;
65
import org.openide.windows.Mode;
60
import org.openide.windows.TopComponent;
66
import org.openide.windows.TopComponent;
Lines 101-107 Link Here
101
    }
107
    }
102
    
108
    
103
    public void performAction () {
109
    public void performAction () {
104
        ResourceBundle bundle = NbBundle.getBundle (AddWatchAction.class);
110
        final AddWatchListener addWatchListener = performEngineAddWatchAction();
111
        if (addWatchListener != null) {
112
            if (addWatchListener.getTask().isFinished()) {
113
                if (addWatchListener.isWatchAdded()) {
114
                    openWatchesView();
115
                }
116
                DebuggerManager.getDebuggerManager().removeDebuggerListener(addWatchListener);
117
            } else {
118
                RequestProcessor.getDefault().post(new Runnable() {
119
                    public @Override void run() {
120
                        addWatchListener.getTask().waitFinished();
121
                        if (addWatchListener.isWatchAdded()) {
122
                            SwingUtilities.invokeLater(new Runnable() {
123
                                public @Override void run() {
124
                                    openWatchesView();
125
                                }
126
                            });
127
                        }
128
                        DebuggerManager.getDebuggerManager().removeDebuggerListener(addWatchListener);
129
                    }
130
                });
131
            }
132
        } else {
133
            ResourceBundle bundle = NbBundle.getBundle (AddWatchAction.class);
105
134
106
        WatchPanel wp = new WatchPanel (watchHistory);
135
        WatchPanel wp = new WatchPanel (watchHistory);
107
        JComponent panel = wp.getPanel ();
136
        JComponent panel = wp.getPanel ();
Lines 128-154 Link Here
128
        dialog.setVisible (true);
157
        dialog.setVisible (true);
129
        dialog.dispose ();
158
        dialog.dispose ();
130
159
131
        if (dd.getValue() != org.openide.DialogDescriptor.OK_OPTION) return;
160
            if (dd.getValue() != org.openide.DialogDescriptor.OK_OPTION) return;
132
        String watch = wp.getExpression ();
161
            String watch = wp.getExpression ();
133
        if ( (watch == null) || 
162
            if ( (watch == null) ||
134
             (watch.trim ().length () == 0)
163
                 (watch.trim ().length () == 0)
135
        )   return;
164
            )   return;
136
        
165
137
        String s = watch;
166
            String s = watch;
138
        int i = s.indexOf (';');
167
            int i = s.indexOf (';');
139
        while (i > 0) {
168
            while (i > 0) {
140
            String ss = s.substring (0, i).trim ();
169
                String ss = s.substring (0, i).trim ();
141
            if (ss.length () > 0)
170
                if (ss.length () > 0)
142
                DebuggerManager.getDebuggerManager ().createWatch (ss);
171
                    DebuggerManager.getDebuggerManager ().createWatch (ss);
143
            s = s.substring (i + 1);
172
                s = s.substring (i + 1);
144
            i = s.indexOf (';');
173
                i = s.indexOf (';');
174
            }
175
            s = s.trim ();
176
            if (s.length () > 0)
177
                DebuggerManager.getDebuggerManager ().createWatch (s);
178
179
            watchHistory = watch;
180
181
            openWatchesView();
145
        }
182
        }
146
        s = s.trim ();
183
    }
147
        if (s.length () > 0)
184
148
            DebuggerManager.getDebuggerManager ().createWatch (s);
185
    private static void openWatchesView() {
149
        
150
        watchHistory = watch;
151
        
152
        // open watches view
186
        // open watches view
153
        TopComponent watchesView = WindowManager.getDefault().findTopComponent("watchesView"); // NOI18N
187
        TopComponent watchesView = WindowManager.getDefault().findTopComponent("watchesView"); // NOI18N
154
        if (watchesView != null && watchesView.isOpened()) {
188
        if (watchesView != null && watchesView.isOpened()) {
Lines 160-163 Link Here
160
        String viewName = VariablesViewButtons.isWatchesViewNested() ? "localsView" : "watchesView";
194
        String viewName = VariablesViewButtons.isWatchesViewNested() ? "localsView" : "watchesView";
161
        ViewActions.openComponent (viewName, false).requestVisible();
195
        ViewActions.openComponent (viewName, false).requestVisible();
162
    }
196
    }
197
198
    private static AddWatchListener performEngineAddWatchAction() {
199
        DebuggerEngine engine = DebuggerManager.getDebuggerManager().getCurrentEngine();
200
        if (engine != null) {
201
            ActionsManager manager = engine.getActionsManager();
202
            if (manager.isEnabled(ActionsManager.ACTION_NEW_WATCH)) {
203
                AddWatchListener addWatchListener = new AddWatchListener();
204
                DebuggerManager.getDebuggerManager().addDebuggerListener(addWatchListener);
205
                Task addWatchTask = manager.postAction(ActionsManager.ACTION_NEW_WATCH);
206
                addWatchListener.setTask(addWatchTask);
207
                return addWatchListener;
208
            }
209
        }
210
        return null;
211
    }
212
213
    private static final class AddWatchListener extends DebuggerManagerAdapter {
214
215
        private boolean watchAdded;
216
        private Task addWatchTask;
217
218
        @Override
219
        public void watchAdded(Watch watch) {
220
            watchAdded = true;
221
        }
222
223
        public boolean isWatchAdded() {
224
            return watchAdded;
225
        }
226
227
        public void setTask(Task addWatchTask) {
228
            this.addWatchTask = addWatchTask;
229
        }
230
231
        public Task getTask() {
232
            return addWatchTask;
233
        }
234
        
235
    }
163
}
236
}

Return to bug 180558