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 220057

Summary: Members/Hierarchy-View: Create extensionpoint to plug in own actions into the contextmenu
Product: java Reporter: markiewb
Component: NavigationAssignee: Tomas Zezula <tzezula>
Status: VERIFIED FIXED    
Severity: normal CC: markiewb
Priority: P3    
Version: 7.3   
Hardware: PC   
OS: Windows 7   
Issue Type: ENHANCEMENT Exception Reporter:
Bug Depends on: 224499    
Bug Blocks:    
Attachments: hardcoded actions in ElementNode
Patch which appends actions from a layer.xml-path to the contextmenu of ElementNode/TypeNode

Description markiewb 2012-10-14 00:34:13 UTC
[ JDK VERSION : 1.6.35 ]

From a discussion @ netdev-mailinglist:

Currently there is no way to extend the context menu of the members
+hierarchy view, because the current actions are hardcoded.

For example: 
org.netbeans.modules.java.navigation.ElementNode.getActions
(boolean):java
x.swing.Action[] (see screenshot from java.navigation)

So please create a extensionpoint to plug in own actions into the 
contextmenu of Members/Hierarchy-View.

FYI: There was a proposal to use 
<code>org.openide.util.Utilities.actionsForPath</code>

For example:<code>
 Action[] actions = org.openide.util.Utilities.actionsForPath(
                 "/de.orat.navigator.actions").toArray(new Action[]{});
        JPopupMenu menu = Utilities.actionsToPopup(actions, getLookup());
</code>
Comment 1 markiewb 2012-10-14 00:35:16 UTC
Created attachment 125926 [details]
hardcoded actions in ElementNode
Comment 2 Tomas Zezula 2012-10-15 08:25:52 UTC
What is the use case? Which actions should be added?
Defining the extension point is an API contract (both SPI the folder on system fs and API the content of Lookup) which needs to be kept compatible, the API should be created only for some use cases.
The actions from U.aFP() should be appended to the UI spec actions to prevent added actions to worse the discoverability o the UI spec actions.
Comment 3 markiewb 2012-10-15 16:50:06 UTC
Created attachment 125978 [details]
Patch which appends actions from a layer.xml-path to the contextmenu of ElementNode/TypeNode

Hello Tomas,

(In reply to comment #2)
> What is the use case? Which actions should be added?
> Defining the extension point is an API contract (both SPI the folder on system
> fs and API the content of Lookup) which needs to be kept compatible, the API
> should be created only for some use cases.

usecases are the integration of current/future actions which react on TreePathHandle like
* call hierarchy (when selected a method) (f.e. find usages is already supported)
* toggle method breakpoint (when selected a method)
* toggle class breakpoint (when selected a class)
* run/debug main method (when selected a class with a main method)
* run/debug test (when selected a class with testmethods or when selected a testmethod)
* add as profiling root (when selected a method)
* integration of the "Copy FQN" plugin http://plugins.netbeans.org/plugin/42975/ (when selected a method/class/other member)
* ...

> The actions from U.aFP() should be appended to the UI spec actions to prevent
> added actions to worse the discoverability o the UI spec actions.

yes, the actions could appended to the current actions. See the proposed patch attached to this issue.

Greetings markiewb
Comment 4 Tomas Zezula 2012-10-16 12:57:15 UTC
Fixed jet-main 8548c33070e3.
The folders are:

Navigation/Members/text/x-java/Actions
Navigation/Hierarchy/text/x-java/Actions
Comment 5 markiewb 2012-10-16 13:44:23 UTC
(In reply to comment #4)
> Fixed jet-main 8548c33070e3.
> The folders are:
> 
> Navigation/Members/text/x-java/Actions
> Navigation/Hierarchy/text/x-java/Actions

Thank you!
Comment 6 Tomas Zezula 2012-10-16 14:06:39 UTC
Not at all.
Comment 7 Quality Engineering 2012-10-17 02:02:28 UTC
Integrated into 'main-golden', will be available in build *201210170002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/8548c33070e3
User: Tomas Zezula <tzezula@netbeans.org>
Log: #220057:Members/Hierarchy-View: Create extensionpoint to plug in own actions into the contextmenu
Comment 8 markiewb 2012-12-28 08:50:13 UTC
(In reply to comment #4)
> Fixed jet-main 8548c33070e3.
> The folders are:
> 
> Navigation/Members/text/x-java/Actions
> Navigation/Hierarchy/text/x-java/Actions

Small correction: the valid extension points (taken from sourcecode) are

{{{
Navigator/Actions/Members/text/x-java
Navigator/Actions/Hierarchy/text/x-java
}}}

@Tomas: Is there any other API-spec-document to be updated?
Comment 9 Tomas Zezula 2013-01-04 17:22:10 UTC
Yes,
it should be updated in arch.xml.
I've created an issue #224499 for it.