Re: TopComponent/setActivatedNodes not workin with a given layer.xml file.

geertjan wielenga <[email protected]>
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Organization Oracle Corporation
Message-ID <[email protected]>

Well... if you want to synchronize with the Properties window, you must 
have properties, right? And if you're not publishing your properties, 
yes, indeed, the Properties window will not see them.

Looks like you're doing something a bit suboptimal somewhere, i.e., it's 
unlikely that you actually need setActivatedNodes at all.

You need to basically publish that Node into the global Lookup. 
'setActivatedNodes' is a really old way to do so. Doesn't look like 
you're making use of an ExplorerManager, so I suggest you use 
Utilities.actionsGlobalContext instead.

Here's a tutorial for you:

http://platform.netbeans.org/tutorials/nbm-quick-start.html

Gj

On 3-12-2015 16:28, Casqueiro Gilles wrote:
>
> Nop, just this :
>
> Node[] nodes = new Node[1];
>
> nodes[0] = lkp.lookup(DataNode.class);
>
> setActivatedNodes(nodes);
>
> Where does the manager come from in your suggestion?
>
> *From:*geertjan wielenga [mailto:[email protected]]
> *Sent:* jeudi 3 décembre 2015 16:22
> *To:* [email protected]
> *Subject:* [platform-dev] Re: TopComponent/setActivatedNodes not 
> workin with a given layer.xml file.
>
> On 3-12-2015 16:14, Casqueiro Gilles wrote:
>
>     Hi Geertjan,
>
>     Due to several reasons, I am migrating my code from a MultiView
>     approach (seen in your tutorials) to a simple TopComponent
>     approach to display the content of my files. I also use the
>     Properties window (and a DataNode returning a custom Sheet, but
>     this isn’t in the prototype I shared). Without using
>     setActivatedNodes, the Properties window isn’t updated
>
>
> Is that true?
>
> Do you have a statement like this at the end of the constructor of the 
> TopComponent:
>
> associateLookup(ExplorerUtils.createLookup(manager, getActionMap()));
>
> Gj
>
>
>
> when the focus move to another tab. Calling setActivatedNodes here 
> looks meaningful to me. If you could download the code and try to 
> reproduce the problem it would be very nice. Something is probably 
> wrong in my layer.xml file, but this is a pure assumption.
>
> https://github.com/gil-c/DemoPropertiesWindowNotWorking.git
>
> Gilles
>
> *From:*geertjan wielenga [mailto:[email protected]]
> *Sent:* mercredi 2 décembre 2015 19:06
> *To:* [email protected] <mailto:[email protected]>
> *Subject:* [platform-dev] Re: TopComponent/setActivatedNodes not 
> workin with a given layer.xml file.
>
>
> Why do you need 'setActivatedNodes' in the first place?
>
> Gj
>
> On 2-12-2015 18:48, Boris Heithecker wrote:
>
>     Hello,
>
>     if the NPE is not because Node == null, you could provide some
>     stack trace, from TopComponent.setActivatedNodes() to the NPE.
>
>     Boris
>
>     2015-12-02 13:18 GMT+01:00 Casqueiro Gilles
>     <[email protected] <mailto:[email protected]>>:
>
>     Hi Boris,
>
>     Thanks for your reply. I had to cast the DataObject “env” to
>     FileSupportDataObject, which implements  CloneableOpenSupport.Env
>     to be able to call to call the constructor of the
>     CloneableOpenSupport. Also I wonder why you made
>     FileSupportCloneableOpenSupport static?
>
>     Unfortunately, this new code didn’t solve the problem of the
>     NullPointerException. I really think that there is a
>     problem/conflict  behind the Customization module and the
>     setActivatedNodes method. This is strange…
>
>     Were you able to reproduce it?
>
>     Gilles
>
>     *From:*Boris Heithecker [mailto:[email protected]
>     <mailto:[email protected]>]
>     *Sent:* mercredi 2 décembre 2015 10:57
>     *To:* [email protected] <mailto:[email protected]>
>     *Subject:* [platform-dev] Re: TopComponent/setActivatedNodes not
>     workin with a given layer.xml file.
>
>     Try this in yourFileSupportDataObject:
>
>       
>
>       // private FileSupportDataNode node;
>
>        //  private final InstanceContent ic = new InstanceContent();
>
>        //  private final Lookup lkp;
>
>        //  private final FileSupportCloneableOpenSupport openCloneableOpenSupport;
>
>        //  private FileSupportTopComponent tc;
>
>          
>
>          
>
>          public FileSupportDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
>
>              super(pf, loader);
>
>        //      lkp = new ProxyLookup(getCookieSet().getLookup(), new AbstractLookup(ic));
>
>            FileSupportCloneableOpenSupport  openCloneableOpenSupport = new FileSupportCloneableOpenSupport(this);
>
>     getCookieSet().assign(OpenSupport.class,openCloneableOpenSupport);
>
>       
>
>         //     ic.add(openCloneableOpenSupport);
>
>              
>
>          }
>
>       
>
>          @Override
>
>          protected int associateLookup() {
>
>              return 1;
>
>          }
>
>       
>
>     //The method is create, not get...., the super class does the caching of the Node object
>
>          @Override
>
>          protected Node createNodeDelegate() {
>
>          //    if(node == null) {
>
>             return  new FileSupportDataNode(this, Children.LEAF, getLookup());
>
>           //   }
>
>            //  return node;
>
>          }
>
>          
>
>         // @Override
>
>        //  public Lookup getLookup() {
>
>          //    return lkp;
>
>        //  }
>
>        @Override
>
>          public void unmarkModified() {
>
>              setModified(false);     // not sure
>
>          }
>
>       
>
>          @Override
>
>          public CloneableOpenSupport findCloneableOpenSupport() {
>
>            //  return openCloneableOpenSupport;
>
>     return getLookup().lookup(CloneableOpenSupport.class);
>
>       
>
>          }
>
>       
>
>          @Override
>
>          public void markModified() throws IOException {
>
>              setModified(true);      // not sure
>
>          }
>
>          
>
>       
>
>       public   static class FileSupportCloneableOpenSupport extends CloneableOpenSupport implements OpenCookie, ViewCookie, CloseCookie {
>
>       
>
>              public FileSupportCloneableOpenSupport(DataObject env) {
>
>                  super(env);
>
>              }
>
>       
>
>     //See above
>
>              @Override
>
>              protected CloneableTopComponent createCloneableTopComponent() {
>
>          //        if (tc == null) {
>
>                      return new FileSupportTopComponent(((DataObject) env).getLookup());
>
>       //           }
>
>        //          return tc;
>
>              }
>
>       
>
>              @Override
>
>              protected String messageOpening() {
>
>                  return FileSupportDataObject.this.getName() + " was opened.";
>
>              }
>
>       
>
>              @Override
>
>              protected String messageOpened() {
>
>                  return FileSupportDataObject.this.getName() + " was closed.";
>
>         
>
>     Boris
>
>     2015-12-01 11:40 GMT+01:00 Casqueiro Gilles
>     <[email protected] <mailto:[email protected]>>:
>
>     Hi everybody,
>
>     I have a NullPointer exception when I use the setActivatedNodes
>     method from a TopComponent. I was able to reproduce the problem in
>     a prototype by adding one of my modules responsible for the
>     platform customization. This module basically contains only a
>     layer.xml file and some  Wstcref and Wsmode files. I cannot figure
>     out what happens with this module that prevents setActivatedNodes
>     to work properly.
>
>     Does someone could take a look at this prototype on GitHub?
>     https://github.com/gil-c/DemoPropertiesWindowNotWorking.git. The
>     steps to reproduce the problem are described in the README.md file.
>
>     Thanks in advance
>
>     Gilles
>
>
>
>     -----------------------------------------------------------------------
>
>     Le informazioni contenute in questo messaggio di posta elettronica
>     e relativi allegati sono riservate e confidenziali e ne è vietata
>     la diffusione in qualunque modo eseguita. Qualora Lei non fosse la
>     persona a cui il presente messaggio è destinato, La invitiamo ad
>     eliminarlo e a darcene gentile comunicazione.
>
>     The information contained in this e-mail and any attachments is
>     confidential and may also be privileged. If you are not the named
>     recipient please notify the sender immediately and do not disclose
>     the contents to any other person, use it for any purpose, or store
>     or copy the information in any medium.
>
>     -----------------------------------------------------------------------
>
>
>
>     -----------------------------------------------------------------------
>
>     Le informazioni contenute in questo messaggio di posta elettronica
>     e relativi allegati sono riservate e confidenziali e ne è vietata
>     la diffusione in qualunque modo eseguita. Qualora Lei non fosse la
>     persona a cui il presente messaggio è destinato, La invitiamo ad
>     eliminarlo e a darcene gentile comunicazione.
>
>     The information contained in this e-mail and any attachments is
>     confidential and may also be privileged. If you are not the named
>     recipient please notify the sender immediately and do not disclose
>     the contents to any other person, use it for any purpose, or store
>     or copy the information in any medium.
>
>     -----------------------------------------------------------------------
>
>
>
> -----------------------------------------------------------------------
>
> Le informazioni contenute in questo messaggio di posta elettronica e 
> relativi allegati sono riservate e confidenziali e ne è vietata la 
> diffusione in qualunque modo eseguita. Qualora Lei non fosse la 
> persona a cui il presente messaggio è destinato, La invitiamo ad 
> eliminarlo e a darcene gentile comunicazione.
>
> The information contained in this e-mail and any attachments is 
> confidential and may also be privileged. If you are not the named 
> recipient please notify the sender immediately and do not disclose the 
> contents to any other person, use it for any purpose, or store or copy 
> the information in any medium.
>
> -----------------------------------------------------------------------
>
>
>
> -----------------------------------------------------------------------
>
> Le informazioni contenute in questo messaggio di posta elettronica e 
> relativi allegati sono riservate e confidenziali e ne è vietata la 
> diffusione in qualunque modo eseguita. Qualora Lei non fosse la 
> persona a cui il presente messaggio è destinato, La invitiamo ad 
> eliminarlo e a darcene gentile comunicazione.
>
> The information contained in this e-mail and any attachments is 
> confidential and may also be privileged. If you are not the named 
> recipient please notify the sender immediately and do not disclose the 
> contents to any other person, use it for any purpose, or store or copy 
> the information in any medium.
>
> -----------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.