本文整理匯總了Java中javax.swing.event.TreeModelListener類的典型用法代碼示例。如果您正苦於以下問題:Java TreeModelListener類的具體用法?Java TreeModelListener怎麽用?Java TreeModelListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TreeModelListener類屬於javax.swing.event包,在下文中一共展示了TreeModelListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fireTreeStructureChanged
import javax.swing.event.TreeModelListener; //導入依賴的package包/類
/**
* Generate events specific to the user actions and trigger the internal
* management of the tree.
*
* @param parent the parent node of the changed nodes (rename, add, remove)
* @param indices the indexes of the changed nodes
* @param nodes the affected nodes; the nodes which are changed
* @param action the action related to the node: rename, add, remove
*/
public void fireTreeStructureChanged(CustomTreeNode parent, int[] indices, Object[] nodes, TreeActions action) {
TreeModelEvent eventInsRem = new TreeModelEvent(this, parent.getPath(), indices, nodes);
TreeModelEvent eventStructChange = new TreeModelEvent(this, new Object[]{parent});
for (TreeModelListener lis : treeModelListeners) {
switch (action) {
case NODE_RENAMED:
lis.treeNodesChanged(eventInsRem);
break;
case NODE_INSERTED:
lis.treeNodesInserted(eventInsRem);
break;
case NODE_REMOVED:
lis.treeNodesRemoved(eventInsRem);
break;
case TREE_STRUCTURE_CHANGED:
lis.treeStructureChanged(eventStructChange);
break;
}
}
}
示例2: filter
import javax.swing.event.TreeModelListener; //導入依賴的package包/類
void filter() {
final String[] term = new String[1];
filter.render(new Runnable() {
public void run() {
try {
term[0] = filter.getText(0, filter.getLength());
} catch (BadLocationException ex) {
throw new IllegalStateException(ex);
}
}
});
category2Nodes.clear();
filterNodes(delegate.getRoot(), term[0]);
for (TreeModelListener l : getListeners()) {
l.treeStructureChanged(new TreeModelEvent(this, new Object[] {getRoot()}));
}
}
示例3: fireTreeNode
import javax.swing.event.TreeModelListener; //導入依賴的package包/類
private void fireTreeNode(int changeType, Object source, Object[] path, int[] childIndices, Object[] children) {
Object[] listeners = listenerList.getListenerList();
TreeModelEvent e = new TreeModelEvent(source, path, childIndices, children);
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == TreeModelListener.class) {
switch (changeType) {
case CHANGED:
((TreeModelListener) listeners[i + 1]).treeNodesChanged(e);
break;
case INSERTED:
((TreeModelListener) listeners[i + 1]).treeNodesInserted(e);
break;
case REMOVED:
((TreeModelListener) listeners[i + 1]).treeNodesRemoved(e);
break;
case STRUCTURE_CHANGED:
((TreeModelListener) listeners[i + 1]).treeStructureChanged(e);
break;
default:
break;
}
}
}
}
示例4: fire
import javax.swing.event.TreeModelListener; //導入依賴的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);
}
示例5: fireRemove
import javax.swing.event.TreeModelListener; //導入依賴的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);
}
示例6: fireInsert
import javax.swing.event.TreeModelListener; //導入依賴的package包/類
private void fireInsert(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].treeNodesInserted (e);
}
示例7: nodesWereInsertedInternal
import javax.swing.event.TreeModelListener; //導入依賴的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;
}
}
}
}
示例8: removeTreeModelListener
import javax.swing.event.TreeModelListener; //導入依賴的package包/類
@Override
public synchronized void removeTreeModelListener(TreeModelListener l) {
listeners.remove(l);
if (delegatingTreeModelListener) {
delegate.removeTreeModelListener(l);
}
}
示例9: entryAdded
import javax.swing.event.TreeModelListener; //導入依賴的package包/類
@Override
public void entryAdded(final Entry newEntry, Folder parent) {
SwingTools.invokeAndWait(new Runnable() {
@Override
public void run() {
final TreeModelEvent e = makeChangeEvent(newEntry);
for (TreeModelListener l : listeners.getListeners(TreeModelListener.class)) {
l.treeNodesInserted(e);
}
}
});
}
示例10: folderRefreshed
import javax.swing.event.TreeModelListener; //導入依賴的package包/類
@Override
public void folderRefreshed(final Folder folder) {
final TreeModelEvent e = makeChangeEvent(folder);
final RepositoryTreeUtil treeUtil = new RepositoryTreeUtil();
SwingTools.invokeAndWait(new Runnable() {
@Override
public void run() {
if (parentTree != null) {
treeUtil.saveExpansionState(parentTree);
}
for (TreeModelListener l : listeners.getListeners(TreeModelListener.class)) {
l.treeStructureChanged(e);
}
treeUtil.locateExpandedEntries();
}
});
if (parentTree != null) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
treeUtil.restoreExpansionState(parentTree);
}
});
}
}
示例11: refresh
import javax.swing.event.TreeModelListener; //導入依賴的package包/類
private void refresh() {
for (Repository repo : root.getRepositories()) {
final TreeModelEvent e = makeChangeEvent(repo);
SwingTools.invokeAndWait(new Runnable() {
@Override
public void run() {
for (TreeModelListener l : listeners.getListeners(TreeModelListener.class)) {
l.treeStructureChanged(e);
}
}
});
}
}
示例12: fireTreeNodesChanged
import javax.swing.event.TreeModelListener; //導入依賴的package包/類
private void fireTreeNodesChanged(Operator operator) {
TreeModelEvent e = makeChangeEvent(operator);
if (e.getChildIndices() != null && e.getChildIndices()[0] != -1) { // otherwise the
// operator is in
// the state of
// being removed and
// has
// triggered an
// update while
// dying.
for (TreeModelListener l : listenerList.getListeners(TreeModelListener.class)) {
l.treeNodesChanged(e);
}
}
}
示例13: fireTreeNodesRemoved
import javax.swing.event.TreeModelListener; //導入依賴的package包/類
private void fireTreeNodesRemoved(Operator operator, int oldIndex) {
TreePath path = getPathTo(operator).getParentPath();
TreeModelEvent e = new TreeModelEvent(this, path, new int[] { oldIndex }, new Object[] { operator });
for (TreeModelListener l : listenerList.getListeners(TreeModelListener.class)) {
l.treeNodesRemoved(e);
}
}
示例14: fireTreeStructureChanged
import javax.swing.event.TreeModelListener; //導入依賴的package包/類
private void fireTreeStructureChanged(ExecutionUnit unit) {
TreePath path = getPathTo(unit).getParentPath();
TreeModelEvent e = new TreeModelEvent(this, path);
for (TreeModelListener l : listenerList.getListeners(TreeModelListener.class)) {
l.treeStructureChanged(e);
}
}
示例15: fireTreeStructureChanged
import javax.swing.event.TreeModelListener; //導入依賴的package包/類
/**
* The only event raised by this model is TreeStructureChanged with the root
* as path, i.e. the whole tree has changed.
*/
protected void fireTreeStructureChanged(Person oldRoot) {
int len = treeModelListeners.size();
TreeModelEvent e = new TreeModelEvent(this, new Object[] { oldRoot });
for (TreeModelListener tml : treeModelListeners) {
tml.treeStructureChanged(e);
}
}