[platform-dev] Global Selection not triggered by TopComponent

  • From: Mario Spindizzy < >
  • To:
  • Subject: [platform-dev] Global Selection not triggered by TopComponent
  • Date: Thu, 1 Nov 2012 13:23:12 +0100

Hi,

I'm having a use case where the selection is triggered by a
DataObject. But the change is never registered in another module which
shall display something in a TopComponent.

My DataObject extends from XmlMultiViewDataObject to display section
of the document similar to the editor for web.xml. There is no need to
write a TopComponent for the DataObject.

In the constructor of the DataObject I added AbstractLookup &
InstanceContent, then I changed the getLookup() method:

...
content = new InstanceContent();
lookup = new AbstractLookup(content);
...

@Override
public Lookup getLookup() {
    return new ProxyLookup(super.getLookup(), lookup);
}

I also added a getter for the InstanceContent.

The code which fires the selection looks like this:

dataObject.getContent().set(trackPoints, null);

The code for listening with selection changes in the TopComponent
looks like this:

Lookup lookup = Utilities.actionsGlobalContext();
result = lookup.lookupResult(Position.class);
result.allItems();
result.addLookupListener(this);

But the listener is never called. I came up with a workaround that
uses a singleton which contains the above Lookup and InstanceContent.
However this is not the solution I want to have, since it uses a self
written selection API. I want to use the Lookup provided by Utilities.

What am I missing? Any hints are appreciated.


[platform-dev] Global Selection not triggered by TopComponent

Mario Spindizzy 11/01/2012

Project Features

Project Links

About this Project

Platform was started in November 2009, is owned by Antonin Nebuzelsky, and has 144 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20150226.965aeb8). © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close