Example usage for javax.swing.event TreeExpansionEvent getSource

List of usage examples for javax.swing.event TreeExpansionEvent getSource

Introduction

In this page you can find the example usage for javax.swing.event TreeExpansionEvent getSource.

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

From source file:Main.java

public void treeExpanded(TreeExpansionEvent evt) {
    JTree tree = (JTree) evt.getSource();

    TreePath path = evt.getPath();
    System.out.println("treeExpanded");
}

From source file:Main.java

public void treeCollapsed(TreeExpansionEvent evt) {
    JTree tree = (JTree) evt.getSource();

    TreePath path = evt.getPath();
    System.out.println("treeCollapsed");
}

From source file:Main.java

public void treeWillExpand(TreeExpansionEvent evt) throws ExpandVetoException {
    JTree tree = (JTree) evt.getSource();

    TreePath path = evt.getPath();
    boolean veto = false;
    if (veto) {/*from  w ww  . j ava 2s  . c  om*/
        throw new ExpandVetoException(evt);
    }
}

From source file:Main.java

public void treeWillCollapse(TreeExpansionEvent evt) throws ExpandVetoException {
    JTree tree = (JTree) evt.getSource();

    TreePath path = evt.getPath();
    boolean veto = false;
    if (veto) {/*from  w w  w .  jav a 2 s. co  m*/
        throw new ExpandVetoException(evt);
    }
}

From source file:org.kepler.objectmanager.library.LibraryManager.java

/** Called whenever an item in the tree is expanded. */
@Override//from ww w.  jav  a2  s.  c  o m
public void treeExpanded(TreeExpansionEvent event) {
    final Object tree = event.getSource();
    final List<TreePath> expansions = _treeExpansionMap.get(tree);
    if (expansions != null) {
        //System.out.println("expanded " + event.getPath());
        expansions.add(event.getPath());
    }
}

From source file:org.kepler.objectmanager.library.LibraryManager.java

/** Called whenever an item in the tree is collapsed. */
@Override//from  w  ww  .  ja v  a 2 s. com
public void treeCollapsed(TreeExpansionEvent event) {
    final Object tree = event.getSource();
    final List<TreePath> expansions = _treeExpansionMap.get(tree);
    if (expansions != null) {
        //System.out.println("collapsed " + event.getPath());
        expansions.remove(event.getPath());
    }
}

From source file:org.openehealth.coms.cc.consent_applet.applet.ConsentApplet.java

/**
 * Listener which handles the expansion of TreeNodes
 * //from  w  w w. j a v  a  2  s .  c om
 * @return
 */
private TreeExpansionListener getMyTreeExpansionListener() {

    return new TreeExpansionListener() {

        public void treeCollapsed(TreeExpansionEvent arg0) {
        }

        public void treeExpanded(TreeExpansionEvent arg0) {

            //Normal Tree, load child Nodes from the server
            if (arg0.getPath().getLastPathComponent() instanceof LazyOIDTreeNode) {
                LazyOIDTreeNode node = (LazyOIDTreeNode) arg0.getPath().getLastPathComponent();

                if (!node.isLeaf() && !node.hasBeenExpanded()) {
                    node.setHasBeenExpanded(true);
                    requestTreeNode(node);
                }
            }
            //Search Tree, expand as usual
            else if (arg0.getPath().getLastPathComponent() instanceof DefaultMutableTreeNode) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) arg0.getPath().getLastPathComponent();

                JTree tree = (JTree) arg0.getSource();
                tree.expandPath(new TreePath(node.getPath()));

            }
        };
    };
}