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

Casqueiro Gilles <[email protected]>
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Message-ID <46731A37FFC5D047B3FAAD3558D349B7587E76C0@BMI-2K8-MS03.emea.bracco.priv>
Hi Boris,
Thanks, the NPE does not occur at setActivatedNodes(). When I use the debugger I see the entire constructor of FileSupportTopComponent executed without problem. The NPE occurs later, in the stack trace there is no reference to my code at all. I deduced the correlation with setActivatedNodes() and with the Customization module by trial and error. Removing one or the other avoid the NPE that’s all I can tell.

Here is the stack trace:

java.lang.NullPointerException
                at org.openide.explorer.propertysheet.PropertySheet$2.run(PropertySheet.java:613)
                at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1423)
                at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
Caused: org.openide.util.RequestProcessor$SlowItem: task failed due to
                at org.openide.util.RequestProcessor$Task.schedule(RequestProcessor.java:1464)
                at org.openide.explorer.propertysheet.PropertySheet.setNodes(PropertySheet.java:582)
                at org.netbeans.core.windows.view.ui.NbSheet.setNodes(NbSheet.java:308)
                at org.netbeans.core.windows.view.ui.NbSheet$Listener.activate(NbSheet.java:499)
                at org.netbeans.core.windows.view.ui.NbSheet$Listener.propertyChange(NbSheet.java:479)
                at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335)
                at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:327)
                at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:263)
                at org.netbeans.core.windows.RegistryImpl.tryFireChanges(RegistryImpl.java:312)
                at org.netbeans.core.windows.RegistryImpl.selectedNodesChanged(RegistryImpl.java:247)
                at org.netbeans.core.windows.RegistryImpl.topComponentActivated(RegistryImpl.java:174)
                at org.netbeans.core.windows.WindowManagerImpl.notifyRegistryTopComponentActivated(WindowManagerImpl.java:1166)
                at org.netbeans.core.windows.Central.activateModeTopComponent(Central.java:1811)
                at org.netbeans.core.windows.WindowManagerImpl.topComponentRequestActive(WindowManagerImpl.java:1334)
                at org.openide.windows.TopComponent.requestActive(TopComponent.java:861)
                at org.openide.windows.CloneableOpenSupport$1.run(CloneableOpenSupport.java:108)
                at org.openide.util.Mutex.doEvent(Mutex.java:1356)
                at org.openide.util.Mutex.writeAccess(Mutex.java:462)
                at org.openide.windows.CloneableOpenSupport.open(CloneableOpenSupport.java:104)
                at org.openide.awt.ActionDefaultPerfomer.actionPerformed(ActionDefaultPerfomer.java:70)
                at org.openide.awt.ContextAction$Performer.actionPerformed(ContextAction.java:226)
                at org.openide.awt.ContextManager.actionPerformed(ContextManager.java:260)
                at org.openide.awt.ContextAction.actionPerformed(ContextAction.java:109)
                at org.openide.util.actions.ActionInvoker$1.run(ActionInvoker.java:93)
                at org.openide.util.actions.ActionInvoker.doPerformAction(ActionInvoker.java:116)
                at org.openide.util.actions.ActionInvoker.invokeAction(ActionInvoker.java:99)
                at org.openide.awt.GeneralAction$BaseDelAction.actionPerformed(GeneralAction.java:234)
                at org.openide.explorer.view.TreeView$PopupSupport.mouseClicked(TreeView.java:1625)
                at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270)
                at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:269)
                at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:269)
                at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:269)
                at java.awt.Component.processMouseEvent(Component.java:6528)
                at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
                at java.awt.Component.processEvent(Component.java:6290)
                at java.awt.Container.processEvent(Container.java:2234)
                at java.awt.Component.dispatchEventImpl(Component.java:4881)
                at java.awt.Container.dispatchEventImpl(Container.java:2292)
                at java.awt.Component.dispatchEvent(Component.java:4703)
                at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
                at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4542)
                at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
                at java.awt.Container.dispatchEventImpl(Container.java:2278)
                at java.awt.Window.dispatchEventImpl(Window.java:2739)
                at java.awt.Component.dispatchEvent(Component.java:4703)
                at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)
                at java.awt.EventQueue.access$400(EventQueue.java:97)
                at java.awt.EventQueue$3.run(EventQueue.java:697)
                at java.awt.EventQueue$3.run(EventQueue.java:691)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
                at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
                at java.awt.EventQueue$4.run(EventQueue.java:719)
                at java.awt.EventQueue$4.run(EventQueue.java:717)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
                at java.awt.EventQueue.dispatchEvent(EventQueue.java:716)
                at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
                at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
                at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
                at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
                at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
                at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
[catch] at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
SEVERE [global]
java.lang.NullPointerException
                at org.netbeans.core.windows.view.ui.NbSheet$SheetNodesListener.attach(NbSheet.java:565)
                at org.netbeans.core.windows.view.ui.NbSheet.setNodes(NbSheet.java:318)
                at org.netbeans.core.windows.view.ui.NbSheet$Listener.activate(NbSheet.java:499)
                at org.netbeans.core.windows.view.ui.NbSheet$Listener.propertyChange(NbSheet.java:479)
                at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335)
                at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:327)
                at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:263)
                at org.netbeans.core.windows.RegistryImpl.tryFireChanges(RegistryImpl.java:312)
                at org.netbeans.core.windows.RegistryImpl.selectedNodesChanged(RegistryImpl.java:247)
                at org.netbeans.core.windows.RegistryImpl.topComponentActivated(RegistryImpl.java:174)
                at org.netbeans.core.windows.WindowManagerImpl.notifyRegistryTopComponentActivated(WindowManagerImpl.java:1166)
                at org.netbeans.core.windows.Central.activateModeTopComponent(Central.java:1811)
                at org.netbeans.core.windows.WindowManagerImpl.topComponentRequestActive(WindowManagerImpl.java:1334)
                at org.openide.windows.TopComponent.requestActive(TopComponent.java:861)
                at org.openide.windows.CloneableOpenSupport$1.run(CloneableOpenSupport.java:108)
                at org.openide.util.Mutex.doEvent(Mutex.java:1356)
                at org.openide.util.Mutex.writeAccess(Mutex.java:462)
                at org.openide.windows.CloneableOpenSupport.open(CloneableOpenSupport.java:104)
                at org.openide.awt.ActionDefaultPerfomer.actionPerformed(ActionDefaultPerfomer.java:70)
                at org.openide.awt.ContextAction$Performer.actionPerformed(ContextAction.java:226)
                at org.openide.awt.ContextManager.actionPerformed(ContextManager.java:260)
                at org.openide.awt.ContextAction.actionPerformed(ContextAction.java:109)
                at org.openide.util.actions.ActionInvoker$1.run(ActionInvoker.java:93)
                at org.openide.util.actions.ActionInvoker.doPerformAction(ActionInvoker.java:116)
                at org.openide.util.actions.ActionInvoker.invokeAction(ActionInvoker.java:99)
                at org.openide.awt.GeneralAction$BaseDelAction.actionPerformed(GeneralAction.java:234)
                at org.openide.explorer.view.TreeView$PopupSupport.mouseClicked(TreeView.java:1625)
                at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270)
                at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:269)
                at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:269)
                at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:269)
                at java.awt.Component.processMouseEvent(Component.java:6528)
                at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
                at java.awt.Component.processEvent(Component.java:6290)
                at java.awt.Container.processEvent(Container.java:2234)
                at java.awt.Component.dispatchEventImpl(Component.java:4881)
                at java.awt.Container.dispatchEventImpl(Container.java:2292)
                at java.awt.Component.dispatchEvent(Component.java:4703)
                at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
                at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4542)
                at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
                at java.awt.Container.dispatchEventImpl(Container.java:2278)
                at java.awt.Window.dispatchEventImpl(Window.java:2739)
                at java.awt.Component.dispatchEvent(Component.java:4703)
                at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)
                at java.awt.EventQueue.access$400(EventQueue.java:97)
                at java.awt.EventQueue$3.run(EventQueue.java:697)
                at java.awt.EventQueue$3.run(EventQueue.java:691)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
                at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
                at java.awt.EventQueue$4.run(EventQueue.java:719)
                at java.awt.EventQueue$4.run(EventQueue.java:717)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
                at java.awt.EventQueue.dispatchEvent(EventQueue.java:716)
                at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
[catch] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
                at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
                at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
                at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
                at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
                at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

From: Boris Heithecker [mailto:[email protected]]
Sent: mercredi 2 décembre 2015 18:49
To: [email protected]
Subject: [platform-dev] Re: TopComponent/setActivatedNodes not workin with a given layer.xml file.

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 your FileSupportDataObject:



 // 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.

-----------------------------------------------------------------------
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.