[platform-dev] Re: Problem with Global Selection Lookup

  • From: Benno Markiewicz < >
  • To:
  • Subject: [platform-dev] Re: Problem with Global Selection Lookup
  • Date: Mon, 29 Oct 2012 20:48:41 +0100

Did you miss to publish the content of the node/tree-lookup (within the topComponent of module1) to the global lookup?

For example:
associateLookup(ExplorerUtils.createLookup ( explorermanager, this.getActionMap() ) );

See http://netbeans.dzone.com/articles/netbeans-lookups-explained

Greetings markiewb

Am 29.10.2012 15:13, schrieb kosmos890:
I want to create the DOM tree of an html file. I use jsoup to parse html: 
http://jsoup.org/
I used  this tutorial about Nodes API: 
http://platform.netbeans.org/tutorials/nbm-selection-2.html
I created two modules.
Module1 (explorer mode) A view of DOM tree.

I created this class

Code:

//....
import org.jsoup.nodes.Element;
//..
public class ElementChildFactory extends ChildFactory<Element>{
    private Element element;

    public ElementChildFactory(Element element) {
       this.element=element;
    }

    @Override
    protected boolean createKeys(List<Element>  toPopulate) {
       toPopulate.addAll(element.children());
       return true;
    }

    @Override
        protected Node createNodeForKey(Element key) {
     Node result = new AbstractNode(Children.create(new 
ElementChildFactory(key), true), Lookups.singleton(key));
     result.setDisplayName(key.toString());
     return result;
        }
}




Module2 (editor mode) This TopComponent shows the content of an html node in 
a JTextArea.

I cant listen to the selection (the selected Node of DOM Tree) from Module2


Code:

public final class Module2 extends TopComponent implements LookupListener{





Code:

//....
     private Lookup.Result<Element>  result = null;
     @Override
     public void componentOpened() {
         result = 
Utilities.actionsGlobalContext().lookupResult(Element.class);
         result.addLookupListener (this);
     }
     @Override
     public void componentClosed() {
         result.removeLookupListener (this);
         result = null;
     }
     @Override
     public void resultChanged(LookupEvent lookupEvent) {
       System.out.println(" A new Element is selected !!!!");
     }
//....




But I can listen to global selection lookup from Module1


Code:

//..
public final class Module1 extends TopComponent implements 
ExplorerManager.Provider, LookupListener
//..










[platform-dev] Problem with Global Selection Lookup

kosmos890 10/29/2012

[platform-dev] Re: Problem with Global Selection Lookup

Benno Markiewicz 10/29/2012

[platform-dev] Problem with Global Selection Lookup

kosmos890 10/29/2012

[platform-dev] Re: Problem with Global Selection Lookup

Frédéric Deniger 10/30/2012

[platform-dev] Problem with Global Selection Lookup

kosmos890 10/30/2012

[platform-dev] Re: Problem with Global Selection Lookup

Frédéric Deniger 10/31/2012

[platform-dev] Problem with Global Selection Lookup

kosmos890 10/31/2012

Project Features

Project Links

About this Project

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