[platform-dev] Problem with Global Selection Lookup

  • From: "kosmos890" < >
  • To:
  • Subject: [platform-dev] Problem with Global Selection Lookup
  • Date: Mon, 29 Oct 2012 10:13:04 -0400

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