logo of the SSW institute
Institut für Systemsoftware
Johannes Kepler Universität Linz
Fachbereich Informatik
logo of the Cristian Doppler Research Association
Christian Doppler Labor
Automated Software Engineering

Home

General
Staff
Contact
Partners
Alumni

Research
Areas
Projects
Papers
Books
Reports

Teaching
Lectures
Exams
B.Projects
M.Theses
PhD Theses
Go Abroad

Misc
Library
Seminars
Gallery
Links
Search

Webmaster


logo of the Johannes Kepler University (JKU)
back

WordApp Example - Part 4

  • Create a new module named "Numbers" with code name base "at.ssw.numbers" and add a window component with prefix "Numbers" in package "at.ssw.numbers".

  • Add a tree table view to the component by adding the following code. You have to add a module dependency to the "Explorer and Property Sheet API".
    private NumbersTopComponent() {
        ...
    
    
        this.setLayout(new BorderLayout());
        this.add(new TreeTableView(), BorderLayout.CENTER);
    }
    

  • Make the window component an explorer manager provider.
    final class NumbersTopComponent extends TopComponent implements ExplorerManager.Provider {
    
        private ExplorerManager manager;
        
        public ExplorerManager getExplorerManager() {
            return manager;
        }
    
        ...
    
    }
    

  • Add a module dependency to the "Nodes API" and create an inner class called MyChildren that is responsible for lazily creating the children of a node. For this example every node gets {1, 2, 3, 4, 5} as its children.
    private class MyChildren extends Children.Keys {
    
        @Override
        protected Node[] createNodes(Integer i) {
            Node[] result = new Node[1];
            result[0] = new AbstractNode(new MyChildren());
            result[0].setDisplayName(i.toString());
            return result;
        }
    
        @Override
        protected void addNotify() {
            this.setKeys(new Integer[]{1, 2, 3, 4, 5});
        }
    }
    

  • Create the explorer manager and register a root context in the constructor of the window component.
    private NumbersTopComponent() {
        ...
    
        manager = new ExplorerManager();
        manager.setRootContext(new AbstractNode(new MyChildren()));
    }
    

  • Make the lookup of the window component refer to the lookup of the current selected nodes.
    private NumbersTopComponent() {
        ...
    
        associateLookup(ExplorerUtils.createLookup(manager, getActionMap()));
    }
    

  • Now you are ready to run the application again! The result should look similar to the screenshot below. Note that the NetBeans property window automatically knows which nodes are selected, because it listens to the lookup of the current activated window, which was delegated to the lookup of the current selected nodes in the tree view.
    screen14
feedback
back