How to open Navigator panel programmatically?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to open Navigator panel programmatically?

Peter Nabbefeld

Hello,

I wonder how to activate navigator panel programmatically. My current
code is:


/**
  *
  * @author peter
  */
public class FormDataOpenAction extends OpenAction {

     private final OpenAction action;

     public FormDataOpenAction() {
         action = SystemAction.get(OpenAction.class);
     }

     @Override
     public String getName() {
         return "Open";
     }

     @Override
     protected void performAction(final Node[] activatedNodes) {
//        Mode mode = WindowManager.getDefault().findMode("navigator");
//        TopComponent[] navComponents = mode.getTopComponents();
//        if (navComponents.length > 0) {
//            navComponents[0].requestActive();
//        }
         super.performAction(activatedNodes);
         NuclosLayoutNavigatorPanel panel =
NuclosLayoutNavigatorPanel.getInstance();
         NavigatorHandler.activateNavigator();
         NavigatorHandler.activatePanel(panel);
     }
}

If I remove the comments, the project panel is selected (obviously
because it is the first one shown in that "mode").

I'd like to find the panel and open it, eventually also creating the
TopComponent if not already done.

The code related to NavigatorHandler does not seem to work.

Kind regards
Peter

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to open Navigator panel programmatically?

arsi
Hello,

Simple way:

        ClassLoader loader = Lookup.getDefault().lookup(ClassLoader.class);
        try {
            Class<?> navigatorTC = loader.loadClass("org.netbeans.modules.navigator.NavigatorTC");
            Method m = navigatorTC.getDeclaredMethod("getInstance");
            TopComponent navPanel = (TopComponent) m.invoke(null);
            navPanel.open();
            navPanel.requestActive();
        } catch (Exception ex) {
            Exceptions.printStackTrace(ex);
        }

or:

        NavigatorTC navTC = NavigatorTC.getInstance();
        navTC.open();
        navTC.requestActive();

It's a module private package..

For nb module:

add module org-netbeans-spi-navigator, then edit and set it as implementation version..




For maven:


<plugin>    
 <artifactId>nbm-maven-plugin</artifactId>  
 <groupId>org.codehaus.mojo</groupId>    
 <extensions>true</extensions>  
 <configuration>        
  <moduleDependencies>
   <dependency>
   <!--Private Package Reference-->
   <id>org.netbeans.api:org-netbeans-spi-navigator</id>
   <type>impl</type>
   </dependency>
   </moduleDependencies>
 </configuration>
</plugin>
Arsi


From: Peter Nabbefeld
Sent: Friday, July 14, 2017 10:19PM
To: Dev
Subject: [platform-dev] How to open Navigator panel programmatically?



Hello,

I wonder how to activate navigator panel programmatically. My current code is:

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to open Navigator panel programmatically?

Peter Nabbefeld
Hi Arsi,

thank You - that works great!

Kind regards
Peter


Am 14.07.2017 um 23:43 schrieb arsi:

> Hello,
>
> Simple way:
>
> |ClassLoader loader = Lookup.getDefault().lookup(ClassLoader.class); try
> { Class<?> navigatorTC =
> loader.loadClass("org.netbeans.modules.navigator.NavigatorTC"); Method m
> = navigatorTC.getDeclaredMethod("getInstance"); TopComponent navPanel =
> (TopComponent) m.invoke(null); navPanel.open();
> navPanel.requestActive(); } catch (Exception ex) {
> Exceptions.printStackTrace(ex); } |
>
> ​
>
> or:
>
> |NavigatorTC navTC = NavigatorTC.getInstance(); navTC.open();
> navTC.requestActive(); |
>
> ​
>
> It's a module private package..
>
> For nb module:
>
> add module *org-netbeans-spi-navigator*, then edit and set it as
> implementation version..
>
>
>
>
> For maven:
>
> |<plugin> <artifactId>nbm-maven-plugin</artifactId>
> <groupId>org.codehaus.mojo</groupId> <extensions>true</extensions>
> <configuration> <moduleDependencies> <dependency> <!--Private Package
> Reference--> <id>org.netbeans.api:org-netbeans-spi-navigator</id>
> <type>impl</type> </dependency> </moduleDependencies> </configuration>
> </plugin> |
>
> ​
> Arsi
> ------------------------------------------------------------------------
>
> *From:* Peter Nabbefeld
> *Sent:* Friday, July 14, 2017 10:19PM
> *To:* Dev
> *Subject:* [platform-dev] How to open Navigator panel programmatically?
>
>
>>
>> Hello,
>>
>> I wonder how to activate navigator panel programmatically. My current
>> code is:
>


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to open Navigator panel programmatically?

Dmitry Avtonomov
Cool!
Do you know which packages are required for Properties panel?

On Fri, Jul 14, 2017 at 6:22 PM, Peter Nabbefeld <[hidden email]> wrote:
Hi Arsi,

thank You - that works great!

Kind regards
Peter


Am 14.07.2017 um 23:43 schrieb arsi:
Hello,

Simple way:

|ClassLoader loader = Lookup.getDefault().lookup(ClassLoader.class); try { Class<?> navigatorTC = loader.loadClass("org.netbeans.modules.navigator.NavigatorTC"); Method m = navigatorTC.getDeclaredMethod("getInstance"); TopComponent navPanel = (TopComponent) m.invoke(null); navPanel.open(); navPanel.requestActive(); } catch (Exception ex) { Exceptions.printStackTrace(ex); } |



or:

|NavigatorTC navTC = NavigatorTC.getInstance(); navTC.open(); navTC.requestActive(); |



It's a module private package..

For nb module:

add module *org-netbeans-spi-navigator*, then edit and set it as implementation version..




For maven:

|<plugin> <artifactId>nbm-maven-plugin</artifactId> <groupId>org.codehaus.mojo</groupId> <extensions>true</extensions> <configuration> <moduleDependencies> <dependency> <!--Private Package Reference--> <id>org.netbeans.api:org-netbeans-spi-navigator</id> <type>impl</type> </dependency> </moduleDependencies> </configuration> </plugin> |


Arsi
------------------------------------------------------------------------

*From:* Peter Nabbefeld
*Sent:* Friday, July 14, 2017 10:19PM
*To:* Dev
*Subject:* [platform-dev] How to open Navigator panel programmatically?



Hello,

I wonder how to activate navigator panel programmatically. My current code is:




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to open Navigator panel programmatically?

arsi
Hello,

        TopComponent c = NbSheet.findDefault();
        c.open ();
        c.requestActive();
Module: org-netbeans-core-windows

btw.:

Download netbeans source code and use file search:
*PropertiesAction.java and... GlobalPropertiesAction.java is the right one ;)
or *Action.java and you have all the Actions used by Netbeans

Or I use fulltext file search *.java and the Class or method I'm interested in, and I have a lot of examples..
When I do not know how to start, Bundle.properties and I'm looking for the displayed text..
And I always found what I needed ;)
To use the full potential of netbeans platform, there is no other way!!!

Arsi




From: Dmitry Avtonomov
Sent: Sunday, July 16, 2017 1:41AM
To: Dev
Subject: [platform-dev] Re: How to open Navigator panel programmatically?


Cool!
Do you know which packages are required for Properties panel?

Loading...