当前位置: 首页>>代码示例>>Java>>正文


Java TreeModelEvent类代码示例

本文整理汇总了Java中javax.swing.event.TreeModelEvent的典型用法代码示例。如果您正苦于以下问题:Java TreeModelEvent类的具体用法?Java TreeModelEvent怎么用?Java TreeModelEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TreeModelEvent类属于javax.swing.event包,在下文中一共展示了TreeModelEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: treeNodesRemoved

import javax.swing.event.TreeModelEvent; //导入依赖的package包/类
@Override
public void treeNodesRemoved(TreeModelEvent e) {
    // called to removed from JTree.expandedState
    super.treeNodesRemoved(e);
    
    boolean wasSelected = removedNodeWasSelected;
    removedNodeWasSelected = false;

    // part of bugfix #37279, if DnD is active then is useless select a nearby node
    if (ExplorerDnDManager.getDefault().isDnDActive()) {
        return;
    }
    if (wasSelected && tree.getSelectionCount() == 0) {
        TreePath path = findSiblingTreePath(e.getTreePath(), e.getChildIndices());

        // bugfix #39564, don't select again the same object
        if ((path == null) || e.getChildIndices().length == 0) {
            return;
        } else if (path.getPathCount() > 0) {
            tree.setSelectionPath(path);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:TreeView.java

示例2: treeStructureChanged

import javax.swing.event.TreeModelEvent; //导入依赖的package包/类
/** Process a structural change event from the user-supplied tree model.
 * This will result in a generic "something changed" 
 * TableModelEvent being fired.  */
@Override
public void treeStructureChanged(TreeModelEvent e) {
    assert SwingUtilities.isEventDispatchThread();
    
    getTreePathSupport().treeStructureChanged(e);
    fireTreeChange (translateEvent(e), STRUCTURE_CHANGED);

    if (!getLayout().isExpanded(e.getTreePath())) {
        // Do not care about structural changes in collapsed nodes.
        // But the node's leaf property could change...
        treeNodesChanged(e);
        return ;
    }
    
    getTreePathSupport().clear();
    
    //We will just fire a "Something happened. Go figure out what." event.
    fireTableChange (new TableModelEvent (getModel()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:EventBroadcaster.java

示例3: computeRowIndices

import javax.swing.event.TreeModelEvent; //导入依赖的package包/类
/**
 * Compute real table row indices of nodes that are affected by the event.
 *
 * @param e Event description.
 * @return Indices of rows in the table where the nodes (affected by the
 * event) are displayed, or null if they are not available.
 */
private int[] computeRowIndices(TreeModelEvent e) {
    int[] rowIndices;
    int parentRow = getLayout().getRowForPath(e.getTreePath());
    if (e.getChildren() != null) {
        rowIndices = new int[e.getChildren().length];
        for (int i = 0; i < e.getChildren().length; i++) {
            TreePath childPath =
                    e.getTreePath().pathByAddingChild(e.getChildren()[i]);
            int index = getLayout().getRowForPath(childPath);
            rowIndices[i] = index < 0
                    // child node is not shown yet, compute child row from
                    // parent row and index of the child
                    ? parentRow + e.getChildIndices()[i] + 1
                    : index;
        }
    } else {
        rowIndices = null;
    }
    return rowIndices;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:EventBroadcaster.java

示例4: setRootVisible

import javax.swing.event.TreeModelEvent; //导入依赖的package包/类
/** Set whether or not the root is visible */
public void setRootVisible (boolean val) {
    if (getOutlineModel() == null) {
        cachedRootVisible = val ? Boolean.TRUE : Boolean.FALSE;
    }
    if (val != isRootVisible()) {
        getLayoutCache().setRootVisible(val);
        if( getLayoutCache().getRowCount() > 0 ) {
            TreePath rootPath = getLayoutCache().getPathForRow(0);
            if( null != rootPath )
                getLayoutCache().treeStructureChanged(new TreeModelEvent(this, rootPath));
        }
        sortAndFilter();
        firePropertyChange("rootVisible", !val, val); //NOI18N
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:Outline.java

示例5: valueForPathChanged

import javax.swing.event.TreeModelEvent; //导入依赖的package包/类
public void valueForPathChanged(final TreePath path, final Object value) {
    if (path.getLastPathComponent() instanceof Product) {
        final Product product = (Product) path.getLastPathComponent();
        
        switch (product.getStatus()) {
        case NOT_INSTALLED:
            product.setStatus(Status.TO_BE_INSTALLED);
            updateRequirements(product);
            break;
        case TO_BE_INSTALLED:
            product.setStatus(Status.NOT_INSTALLED);
            break;
        case INSTALLED:
            product.setStatus(Status.TO_BE_UNINSTALLED);
            break;
        case TO_BE_UNINSTALLED:
            product.setStatus(Status.INSTALLED);
            break;
        }
    }
    
    final TreeModelListener[] clone;
    synchronized (listeners) {
        clone = listeners.toArray(new TreeModelListener[0]);
    }
    
    final TreeModelEvent event = new TreeModelEvent(this, path);
    for (TreeModelListener listener: clone) {
        listener.treeNodesChanged(event);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:ComponentsSelectionPanel.java

示例6: fire

import javax.swing.event.TreeModelEvent; //导入依赖的package包/类
private void fire () {
    TreeModelListener[] listeners = listenerList.getListeners (TreeModelListener.class);
    if (listeners.length == 0) return;
    TreeModelEvent e = new TreeModelEvent (this, new Object[] {getRoot ()});
    for (int i = 0; i < listeners.length; i++)
        listeners [i].treeStructureChanged (e);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:LanguagesNavigatorModel.java

示例7: fireRemove

import javax.swing.event.TreeModelEvent; //导入依赖的package包/类
private void fireRemove(ASTNavigatorNode node, int[] indices, ASTNavigatorNode[] children,
        LinkedList<ASTNavigatorNode> nodePath) {
    TreeModelListener[] listeners = listenerList.getListeners (TreeModelListener.class);
    if (listeners.length == 0) return;
    TreePath path = new TreePath(nodePath.toArray());
    TreeModelEvent e = new TreeModelEvent (this, path, indices, children);
    for (int i = 0; i < listeners.length; i++)
        listeners [i].treeNodesRemoved (e);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:LanguagesNavigatorModel.java

示例8: treeStructureChanged

import javax.swing.event.TreeModelEvent; //导入依赖的package包/类
@Override
public void treeStructureChanged(TreeModelEvent e) {
    // Remember selections and expansions
    TreePath[] selectionPaths = getSelectionPaths();
    java.util.Enumeration expanded = getExpandedDescendants(e.getTreePath());

    // Restructure the node
    super.treeStructureChanged(e);

    // Expand previously expanded paths
    if (expanded != null) {
        while (expanded.hasMoreElements()) {
            expandPath((TreePath) expanded.nextElement());
        }
    }

    // Select previously selected paths
    if ((selectionPaths != null) && (selectionPaths.length > 0)) {
        boolean wasSelected = isPathSelected(selectionPaths[0]);

        setSelectionPaths(selectionPaths);

        if (!wasSelected) {
            // do not scroll if the first selection path survived structure change
            scrollPathToVisible(selectionPaths[0]);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:TreeView.java

示例9: nodesWereInsertedInternal

import javax.swing.event.TreeModelEvent; //导入依赖的package包/类
void nodesWereInsertedInternal(final VisualizerEvent ev) {
    if (listenerList == null) {
        return;
    }

    TreeNode node = ev.getVisualizer();
    Object[] path = getPathToRoot(node);

    Object[] listeners = listenerList.getListenerList();
    TreeModelEvent e = null;
    // Process the listeners last to first, notifying
    // those that are interested in this event
    for (int i = listeners.length-2; i>=0; i-=2) {
        if (listeners[i]==TreeModelListener.class) {
            // Lazily create the event:
            if (e == null) {
                e = new TreeModelEventImpl(this, path, ev);
            }
            try {
                ((TreeModelListener)listeners[i+1]).treeNodesInserted(e);
            } catch (IndexOutOfBoundsException ex) {
                LOG.log(Level.WARNING, "Visualizer: {0}", node);
                Node n = Visualizer.findNode(node);
                LOG.log(Level.WARNING, "Node: {0}", n);
                if (n != null) {
                    LOG.log(Level.WARNING, "  # children: {0}", n.getChildren().getNodesCount());
                    LOG.log(Level.WARNING, "  children: {0}", n.getChildren().getClass());
                }
                LOG.log(Level.WARNING, "Path: {0}", Arrays.toString(path));
                LOG.log(Level.WARNING, "ev.getArray: {0}", Arrays.toString(ev.getArray()));
                LOG.log(Level.WARNING, "ev.getSnapshot: {0}", ev.getSnapshot());
                throw ex;
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:NodeTreeModel.java

示例10: fireTreeChange

import javax.swing.event.TreeModelEvent; //导入依赖的package包/类
/** Fire the passed TreeModelEvent of the specified type to all
 * registered TreeModelListeners.  The passed event should already have
 * its source set to be the model. */
private synchronized void fireTreeChange (TreeModelEvent e, int type) {
    //Event may be null for offscreen info, etc.
    if (e == null) {
        return;
    }
    assert (e.getSource() == getModel());
    
    TreeModelListener[] listeners;
    synchronized (this) {
        listeners = new TreeModelListener[treeListeners.size()];
        listeners = treeListeners.toArray(listeners);
    }
    
    log ("fireTreeChange-" + types[type], e);
    
    //Now refire it to any listeners
    for (int i=0; i < listeners.length; i++) {
        switch (type) {
            case NODES_CHANGED :
                listeners[i].treeNodesChanged(e);
                break;
            case NODES_INSERTED :
                listeners[i].treeNodesInserted(e);
                break;
            case NODES_REMOVED :
                listeners[i].treeNodesRemoved(e);
                break;
            case STRUCTURE_CHANGED :
                listeners[i].treeStructureChanged(e);
                break;
            default :
                assert false;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:EventBroadcaster.java

示例11: translateEvent

import javax.swing.event.TreeModelEvent; //导入依赖的package包/类
/** Creates an identical TreeModelEvent with the model we are proxying
 * as the event source */
private TreeModelEvent translateEvent (TreeModelEvent e) {
    //Create a new TreeModelEvent with us as the source
    TreeModelEvent nue = new TreeModelEvent (getModel(), e.getPath(), 
        e.getChildIndices(), e.getChildren());
    return nue;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:EventBroadcaster.java

示例12: fireDisplayChange

import javax.swing.event.TreeModelEvent; //导入依赖的package包/类
void fireDisplayChange(LookTreeNode source) {
    if (listeners.isEmpty()) {
        return;
    }
    LookTreeNode parent = source.getParent();
    TreePath path = findPath(parent != null ? parent : source);
    int[] childIndices = parent != null ? new int[] {getIndexOfChild(parent, source)} : null;
    Object[] children = parent != null ? new Object[] {source} : null;
    TreeModelEvent ev = new TreeModelEvent(this, path, childIndices, children);
    for (TreeModelListener l : listeners) {
        l.treeNodesChanged(ev);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:LookTreeModel.java

示例13: fireChildrenChange

import javax.swing.event.TreeModelEvent; //导入依赖的package包/类
void fireChildrenChange(LookTreeNode source) {
    logger.log(Level.FINER, "fireChildrenChange: {0}", source);
    if (listeners.isEmpty()) {
        return;
    }
    // XXX this is crude, could try to actually compute added/removed children...
    TreePath path = (source == root) ? null : findPath(source.getParent());
    TreeModelEvent ev = new TreeModelEvent(this, path, null, null);
    for (TreeModelListener l : listeners) {
        logger.log(Level.FINER, "firing: {0} to {1}", new Object[] {ev, l});
        l.treeStructureChanged(ev);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:LookTreeModel.java

示例14: treeStructureChanged

import javax.swing.event.TreeModelEvent; //导入依赖的package包/类
@Override
public void treeStructureChanged(TreeModelEvent e) {	
	threadTree.expandRow(0);
	threadTree.expandRow(1);
	threadTree.expandRow(2);
	threadTree.expandRow(3);
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:8,代码来源:ThreadMonitorDetailTreeTab.java

示例15: makeChangeEvent

import javax.swing.event.TreeModelEvent; //导入依赖的package包/类
private TreeModelEvent makeChangeEvent(Entry entry) {
	TreePath path = getPathTo(entry.getContainingFolder());
	int index;
	if (entry instanceof Repository) {
		index = RepositoryManager.getInstance(null).getRepositories().indexOf(entry);
	} else {
		index = getIndexOfChild(entry.getContainingFolder(), entry);
	}
	return new TreeModelEvent(RepositoryTreeModel.this, path, new int[] { index }, new Object[] { entry });
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:11,代码来源:RepositoryTreeModel.java


注:本文中的javax.swing.event.TreeModelEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。