Java 8 TreeExpansionEvent - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 TreeExpansionEvent class.

This code example shows how to use the following methods:getSource, getPath
     * {@inheritDoc} 
     */ 
    @Override 
    public void treeExpanded ( final TreeExpansionEvent event )
    { 
        final JTree tree = ( JTree ) event.getSource ();
        final TreePath expandedPath = event.getPath ();
        final Object expandedObject = expandedPath.getLastPathComponent ();
        if ( tree.getModel ().getChildCount ( expandedObject ) == 1 )
        { 
            final Object[] parentPath = expandedPath.getPath ();
            final Object[] path = Arrays.copyOf ( parentPath, parentPath.length + 1 );
            path[ parentPath.length ] = tree.getModel ().getChild ( expandedObject, 0 );
            tree.expandPath ( new TreePath ( path ) );
        } 
    } 
 
    /** 
     * {@inheritDoc} 
     */ 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getPath
//Make sure expansion is threaded and updating the tree model 
//only occurs within the event dispatching thread. 
public class DefaultTreeExpansionListener implements TreeExpansionListener {
		 
    public void treeExpanded(TreeExpansionEvent event) {    	
        final AWorkspaceTreeNode node = (AWorkspaceTreeNode)event.getPath().getLastPathComponent();
        if(node instanceof TreeExpansionListener) {
        	((TreeExpansionListener)node).treeExpanded(event);
        } 
    } 
     
    public void treeCollapsed(TreeExpansionEvent event) {
    	final AWorkspaceTreeNode node = (AWorkspaceTreeNode)event.getPath().getLastPathComponent();
        if(node instanceof TreeExpansionListener) {
        	((TreeExpansionListener)node).treeCollapsed(event);
        } 
    }    
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getPath
//Make sure expansion is threaded and updating the tree model 
//only occurs within the event dispatching thread. 
public class DefaultTreeExpansionListener implements TreeExpansionListener {
		 
    public void treeExpanded(TreeExpansionEvent event) {    	
        final AWorkspaceTreeNode node = (AWorkspaceTreeNode)event.getPath().getLastPathComponent();
        if(node instanceof TreeExpansionListener) {
        	((TreeExpansionListener)node).treeExpanded(event);
        } 
    } 
     
    public void treeCollapsed(TreeExpansionEvent event) {
    	final AWorkspaceTreeNode node = (AWorkspaceTreeNode)event.getPath().getLastPathComponent();
        if(node instanceof TreeExpansionListener) {
        	((TreeExpansionListener)node).treeCollapsed(event);
        } 
    }    
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getPath
        this.treeModel = treeModel;
        this.actionCreator = actionCreator;
    } 
 
    public void treeWillExpand(final TreeExpansionEvent e) throws ExpandVetoException {
        final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) e.getPath().getLastPathComponent();
 
        // Remove all "old" children such as the loading/progress messages 
        treeNode.removeAllChildren();
        treeModel.nodeStructureChanged(treeNode);
 
        // Perform the loading in a background thread 
        ActionCallback callback =
                actionCreator.createContentBrowseActionCallback(
                        service, treeModel, treeNode
                ); 
        controlPoint.execute(callback);
    } 
 
    public void treeWillCollapse(TreeExpansionEvent e) throws ExpandVetoException {
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getPath
This code example shows how to use the following methods:getPath
	public ExpandedStateHandler(JTree tree) {
		this.treeView = tree;
	} 
 
	public void treeExpanded(TreeExpansionEvent event) {
		final AWorkspaceTreeNode node = (AWorkspaceTreeNode)event.getPath().getLastPathComponent();
		expandedNodeKeys.add(node.getKey());
	} 
 
	public void treeCollapsed(TreeExpansionEvent event) {
		final AWorkspaceTreeNode node = (AWorkspaceTreeNode)event.getPath().getLastPathComponent();
		expandedNodeKeys.remove(node.getKey());
		 
	} 
 
	public void treeNodesChanged(TreeModelEvent e) {
		//setExpandedState((WorkspaceModelEvent) e); 
	} 
 
	public void treeNodesInserted(TreeModelEvent e) {
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getPath
	public ExpandedStateHandler(JTree tree) {
		this.treeView = tree;
	} 
 
	public void treeExpanded(TreeExpansionEvent event) {
		final AWorkspaceTreeNode node = (AWorkspaceTreeNode)event.getPath().getLastPathComponent();
		expandedNodeKeys.add(node.getKey());
	} 
 
	public void treeCollapsed(TreeExpansionEvent event) {
		final AWorkspaceTreeNode node = (AWorkspaceTreeNode)event.getPath().getLastPathComponent();
		expandedNodeKeys.remove(node.getKey());
		 
	} 
 
	public void treeNodesChanged(TreeModelEvent e) {
		//setExpandedState((WorkspaceModelEvent) e); 
	} 
 
	public void treeNodesInserted(TreeModelEvent e) {
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getPath
	/*  
	 * Inherited 
	 */ 
	@Override 
	public void treeCollapsed(TreeExpansionEvent arg0) {
		TreePath p = arg0.getPath();
		expanded.remove(p);
	} 
 
	/*  
	 * Inherited 
	 */ 
	@Override 
	public void treeExpanded(TreeExpansionEvent arg0) {
		if (expanding) return;
		TreePath p = arg0.getPath();
		if (!expanded.contains(p)) {
			expanded.add(p);
		} 
	} 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 TreeExpansionEvent Methods: