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.

Bug 180558 - Make new watch action session specific
Summary: Make new watch action session specific
Alias: None
Product: debugger
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P3 normal (vote)
Assignee: Martin Entlicher
Depends on:
Blocks: 180100
  Show dependency tree
Reported: 2010-02-10 08:32 UTC by Egor Ushakov
Modified: 2010-03-01 09:20 UTC (History)
2 users (show)

See Also:
Exception Reporter:

The Add Watch action taken from a provider (2.24 KB, patch)
2010-02-12 09:16 UTC, Martin Entlicher
Details | Diff
The testing Add Watch action demonstrating the usage. (3.21 KB, patch)
2010-02-12 09:17 UTC, Martin Entlicher
Details | Diff
Add Watch action now tracks created watches and opens watches window when a new watch is created. (6.55 KB, patch)
2010-02-16 06:27 UTC, Martin Entlicher
Details | Diff
Tested also with a lazy action provider. (3.63 KB, text/x-java)
2010-02-16 06:29 UTC, Martin Entlicher
I've renamed the action from ADD_WATCH to NEW_WATCH, added apichanges, it's hopefully ready for the review now... (8.20 KB, patch)
2010-02-16 07:11 UTC, Martin Entlicher
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Egor Ushakov 2010-02-10 08:32:34 UTC
We would like to have debugger session specific feedback in "new watch window" - e.g. debugger can check entered watch expression and provide value or other information as you type.
To do that we can substitute addWatchAction in main menu, file contex menu and other places but that would affect all debuggers not only ours...
That would be great if core AddWatchAction used session specifics (if there is an active session). The same way all views models do. So that we could register some kind of AddWatchActionProvider in META-INF/debugger/C-session and have owr own session specific implementation.
Comment 1 Egor Ushakov 2010-02-11 05:36:16 UTC
I'd be happy with simple solution like this:
in the very beginning of AddWatchAction.performAction add a lookup check in the current session and call provider (if any) method like:
AddWatchSessionProvider sp = DebuggerManager.getDebuggerManager().getCurrentEngine().lookup(null, AddWatchSessionProvider.class);
if (sp != null) {
} else {
//open watches view
Comment 2 Martin Entlicher 2010-02-11 06:53:33 UTC
O.K. If I got it right, the intent is to provide your own UI for submission of watches? Do you expect that AddWatchActionProvider should provide a UI component that would be placed into the New Watch dialog instead of the current single field?
What is the proposed AddWatchSessionProvider.perform() method supposed to do?

Do you need this only when a debugger session is active, or you would make some use of a MIME type-sensitive provider (e.g. use your provider if a C/C++ file is active)?
Comment 3 Martin Entlicher 2010-02-11 06:58:34 UTC
Oh, I've read it too fast... perform() would replace all dialog construction that AddWatchAction.performAction() does. Fine, that's simple enough to implement.
Do you need also to override getName()? And probably asynchronous() as well...
Comment 4 Egor Ushakov 2010-02-11 07:51:53 UTC
It is only required if there native session is active.
I think it would be easier if we provide whole UI component.
It does not look like we would need to override getName() and asynchronous(). At least for now.
Comment 5 Martin Entlicher 2010-02-12 09:16:15 UTC
Created attachment 94127 [details]
The Add Watch action taken from a provider

I've made the change really minimalistic. If we use existing ActionsProvider for this purpose it's enough to just add ACTION_ADD_WATCH constant into the API.

Please let me know if you're fine with this solution and I'd post it to apireviews.
Comment 6 Martin Entlicher 2010-02-12 09:17:29 UTC
Created attachment 94128 [details]
The testing Add Watch action demonstrating the usage.
Comment 7 Egor Ushakov 2010-02-15 05:57:31 UTC
I'm fine with one small request:
default performAction does "open watches view" stuff at the end, I'd prefer not to do that by myself if possible. Can you make it:
if (!performEngineAddWatchAction()) {
... default code ...
// open watches view

Comment 8 Martin Entlicher 2010-02-15 07:45:14 UTC
Well, for that we would really need some specialized provider :-(
We should not open watches view if you cancel the Add Watch action. But when I simply run
I'm not able to find out if the action was canceled later or not.

Or, we can implement a "detector": listen for watch add while the action is running. And when a watch is added, open the watches view automatically.

I'll write such a detector and will attach it here for review...
Comment 9 Martin Entlicher 2010-02-16 06:27:29 UTC
Created attachment 94197 [details]
Add Watch action now tracks created watches and opens watches window when a new watch is created.
Comment 10 Martin Entlicher 2010-02-16 06:29:04 UTC
Created attachment 94198 [details]
Tested also with a lazy action provider.
Comment 11 Martin Entlicher 2010-02-16 07:11:23 UTC
Created attachment 94201 [details]
I've renamed the action from ADD_WATCH to NEW_WATCH, added apichanges, it's hopefully ready for the review now...
Comment 12 Martin Entlicher 2010-02-16 07:12:30 UTC
Please review addition of ACTION_NEW_WATCH constant. Thanks.
Comment 13 Egor Ushakov 2010-02-16 08:00:26 UTC
look fine for me
Comment 14 Martin Entlicher 2010-02-22 01:03:41 UTC
Thanks for the review, I'll push the change tomorrow.
Comment 15 Martin Entlicher 2010-02-23 01:14:01 UTC
Implemented in changeset:   160994:92a2e5078f66
Comment 16 Quality Engineering 2010-02-26 11:19:24 UTC
Integrated into 'main-golden', will be available in build *201002261426* on (upload may still be in progress)
Log: #180558 - Debuggers can provide session-specific New Watch dialog.
Comment 17 Egor Ushakov 2010-02-27 07:53:02 UTC
Thanks a lot! It works good.
Question is how to add new watch action to watch nodes popup menu?
NodeActionsProvider.getActions have to contain an instance of global newWatch action, how can I obtain it?
Comment 18 Martin Entlicher 2010-03-01 09:02:41 UTC
Well, debugger core adds the new watch action into the Watches window. It's the first one, therefore if you implement NodeActionsProviderFilter, you can get it.
Other approach can be to retrieve it from the actions registry:
NewWatchAction action = (Action) DataObject.find (FileUtil.getConfigFile ("Actions/Debug/org-netbeans-modules-debugger-ui-actions-AddWatchAction.instance")).getLookup().lookup(InstanceCookie.class).instanceCreate();
Comment 19 Egor Ushakov 2010-03-01 09:20:49 UTC