Java Code Examples for javax.swing.event.TreeModelListener

The following examples show how to use javax.swing.event.TreeModelListener. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ghidra   Source File: GTreeModel.java    License: Apache License 2.0 6 votes vote down vote up
public void fireNodeAdded(final GTreeNode parentNode, final GTreeNode newNode) {
	if (!eventsEnabled) {
		return;
	}
	SystemUtilities.assertThisIsTheSwingThread(
		"GTreeModel.fireNodeAdded() must be " + "called from the AWT thread");

	GTreeNode parent = convertToViewNode(parentNode);
	if (parent == null) {  // it will be null if filtered out
		return;
	}

	int index = parent.getIndexOfChild(newNode);
	if (index < 0) {
		// the index will be -1 if filtered out
		return;
	}
	TreeModelEvent event = new TreeModelEvent(this, parent.getTreePath(), new int[] { index },
		new Object[] { newNode });
	for (TreeModelListener listener : listeners) {
		listener.treeNodesInserted(event);
	}
}
 
Example 2
public void fireQueryChanged( final Object query ) {
  if ( query == null ) {
    return;
  }

  final ArrayList<ReportQueryNode> nodes = new ArrayList<ReportQueryNode>();
  findAllQueryNodes( query, nodes, getDataFactoryElement() );

  final TreeModelListener[] treeModelListeners = getListeners();
  for ( int n = 0; n < nodes.size(); n++ ) {
    final ReportQueryNode queryNode = nodes.get( n );
    final TreePath path = getPathForNode( queryNode.getDataFactory() );
    final TreePath queryPath = path.pathByAddingChild( queryNode );

    final TreeModelEvent treeEvent = new TreeModelEvent( this, queryPath );
    for ( int i = treeModelListeners.length - 1; i >= 0; i -= 1 ) {
      final TreeModelListener listener = treeModelListeners[ i ];
      listener.treeStructureChanged( treeEvent );
    }
  }
}
 
Example 3
public void fireParameterRemoved( final ParameterDefinitionEntry parameter ) {
  final TreePath pathForNode = new TreePath( new Object[] { getRoot(), getReportParametersNode() } );
  final TreeModelListener[] treeModelListeners = getListeners();
  final int index = findParameterInCache( parameter );
  if ( index == -1 ) {
    return;
  }

  final TreeModelEvent treeEvent = new TreeModelEvent( this, pathForNode,
    new int[] { index }, new Object[] { parameter } );
  for ( int i = treeModelListeners.length - 1; i >= 0; i -= 1 ) {
    final TreeModelListener listener = treeModelListeners[ i ];
    listener.treeNodesRemoved( treeEvent );
  }

  refreshParameterCache();
}
 
Example 4
/**
 * Update tree if it was refreshed or an entry was changed.
 *
 * @param entry the changed entry
 * @param changed whether the entry was changed or just refreshed
 * @since 8.1.2
 */
private void updateEntry(Entry entry, boolean changed) {
	RepositoryTreeUtil treeUtil = new RepositoryTreeUtil();
	TreeModelEvent e = makeChangeEvent(entry);
	if (parentTree != null) {
		treeUtil.saveExpansionState(parentTree);
		if (!changed) {
			//Fix for UI glitches if children of a refreshed folder are selected during a refresh
			treeUtil.retainRootSelections(parentTree);
		}
	}
	for (TreeModelListener l : listeners.getListeners(TreeModelListener.class)) {
		if (changed) {
			l.treeNodesChanged(e);
		}
		l.treeStructureChanged(e);
	}
	if (parentTree != null) {
		treeUtil.restoreExpansionState(parentTree);
	}
}
 
Example 5
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)) {
			try {
				l.treeNodesChanged(e);
			} catch (Exception ex) {
				//ignore
			}
		}
	}
}
 
Example 6
Source Project: nosql4idea   Source File: RedisFragmentedKeyTreeModel.java    License: Apache License 2.0 5 votes vote down vote up
private void updateFilteredModel() {
    DefaultMutableTreeNode sourceRoot = (DefaultMutableTreeNode) super.getRoot();
    DefaultMutableTreeNode targetRoot = (DefaultMutableTreeNode) sourceRoot.clone();
    wrapNodes(sourceRoot, separator);
    fragmentedKeyModel = new DefaultTreeModel(targetRoot);
    Object[] listeners = listenerList.getListenerList();
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == TreeModelListener.class) {
            fragmentedKeyModel.addTreeModelListener((TreeModelListener) listeners[i + 1]);
        }
    }
    fireSeparatorChanged();
}
 
Example 7
Source Project: ghidra   Source File: GTreeModel.java    License: Apache License 2.0 5 votes vote down vote up
public void fireNodeStructureChanged(final GTreeNode changedNode) {
	if (!eventsEnabled || isFiringNodeStructureChanged) {
		return;
	}
	try {
		isFiringNodeStructureChanged = true;
		SystemUtilities.assertThisIsTheSwingThread(
			"GTreeModel.fireNodeStructuredChanged() must be " + "called from the AWT thread");

		GTreeNode node = convertToViewNode(changedNode);
		if (node == null) {
			return;
		}
		if (node != changedNode) {
			node.setChildren(null);
			return;	// the previous call will generate the proper event, so bail
		}

		TreeModelEvent event = new TreeModelEvent(this, node.getTreePath());
		for (TreeModelListener listener : listeners) {
			listener.treeStructureChanged(event);
		}
	}
	finally {
		isFiringNodeStructureChanged = false;
	}
}
 
Example 8
Source Project: ghidra   Source File: GTreeModel.java    License: Apache License 2.0 5 votes vote down vote up
public void fireNodeRemoved(GTreeNode parentNode, GTreeNode removedNode, int index) {

		SystemUtilities.assertThisIsTheSwingThread(
			"GTreeModel.fireNodeRemoved() must be " + "called from the AWT thread");

		GTreeNode parent = convertToViewNode(parentNode);
		if (parent == null) {  // will be null if filtered out
			return;
		}

		// if filtered, remove filtered node
		if (parent != parentNode) {
			index = removeFromFiltered(parent, removedNode);
			return;  // the above call will generate the event for the filtered node
		}

		if (index < 0) {  // will be -1 if filtered out
			return;
		}

		TreeModelEvent event = new TreeModelEvent(this, parent.getTreePath(), new int[] { index },
			new Object[] { removedNode });

		for (TreeModelListener listener : listeners) {
			listener.treeNodesRemoved(event);
		}
	}
 
Example 9
Source Project: marathonv5   Source File: GenealogyModel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 10
Source Project: DroidUIBuilder   Source File: WidgetTreeModel.java    License: Apache License 2.0 5 votes vote down vote up
protected void fireStructureChangedEvent(TreeModelEvent event)
{
	for (TreeModelListener listener : listeners)
	{
		listener.treeStructureChanged(event);
	}
}
 
Example 11
Source Project: netbeans   Source File: ComponentsSelectionPanel.java    License: Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 12
Source Project: audiveris   Source File: BookBrowser.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public void refreshPath (TreePath path)
{
    TreeModelEvent modelEvent = new TreeModelEvent(this, path);

    for (TreeModelListener listener : listeners) {
        listener.treeStructureChanged(modelEvent);
    }
}
 
Example 13
private void fireTreeStructureChanged(ExecutionUnit unit) {
	TreePath path = getPathTo(unit).getParentPath();
	TreeModelEvent e = new TreeModelEvent(this, path);
	for (TreeModelListener l : listenerList.getListeners(TreeModelListener.class)) {
		try {
			l.treeStructureChanged(e);
		} catch (Exception ex) {
			//ignore
		}
	}
}
 
Example 14
public void valueForPathChanged(TreePath path, Object newValue) {
    Object oldValue = path.getLastPathComponent();
    renameEntry((String)oldValue, (String)newValue);
    TreeModelEvent ev = new TreeModelEvent(this, path.getParentPath().pathByAddingChild(newValue));
    for(TreeModelListener l : listeners) {
        l.treeNodesChanged(ev);
    }
}
 
Example 15
Source Project: libreveris   Source File: ScoreTree.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
public void refreshPath (TreePath path)
{
    TreeModelEvent modelEvent = new TreeModelEvent(this, path);

    for (TreeModelListener listener : listeners) {
        listener.treeStructureChanged(modelEvent);
    }
}
 
Example 16
Source Project: codebuff   Source File: JTreeASTModel.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void addTreeModelListener(TreeModelListener treeModelListener) {
}
 
Example 17
Source Project: DroidUIBuilder   Source File: WidgetTreeModel.java    License: Apache License 2.0 4 votes vote down vote up
public void removeTreeModelListener(TreeModelListener listener)
{
	listeners.remove(listener);
}
 
Example 18
public void removeTreeModelListener(TreeModelListener listener) {
}
 
Example 19
Source Project: codebuff   Source File: JTreeSTModel.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void removeTreeModelListener(TreeModelListener treeModelListener) {
}
 
Example 20
Source Project: megamek   Source File: ForceGeneratorViewUi.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public void removeTreeModelListener(TreeModelListener listener) {
	if (null != listener) {
		listeners.remove(listener);
	}
}
 
Example 21
Source Project: ghidra   Source File: GTreeModel.java    License: Apache License 2.0 4 votes vote down vote up
private void swingFireRootChanged() {
	TreeModelEvent event = new TreeModelEvent(this, (TreePath) null);
	for (TreeModelListener listener : listeners) {
		listener.treeStructureChanged(event);
	}
}
 
Example 22
public void addTreeModelListener(TreeModelListener listener) {
}
 
Example 23
public void addTreeModelListener( final TreeModelListener l ) {
  eventListenerList.add( TreeModelListener.class, l );
}
 
Example 24
Source Project: Logisim   Source File: SimulationTreeModel.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public void removeTreeModelListener(TreeModelListener l) {
	listeners.remove(l);
}
 
Example 25
Source Project: snap-desktop   Source File: FilterTreeModel.java    License: GNU General Public License v3.0 4 votes vote down vote up
private void fireTreeNodesRemoved(TreeModelEvent treeModelEvent) {
    for (TreeModelListener listener : listeners) {
        listener.treeNodesRemoved(treeModelEvent);
    }
}
 
Example 26
public void fireTreeNodeChanged(final String nodeName, int index) {
    TreeModelEvent ev = createEventForNode(nodeName, getResourceType(nodeName), index);
    for(TreeModelListener l : listeners) {
        l.treeNodesChanged(ev);
    }
}
 
Example 27
@Override
public void addTreeModelListener(TreeModelListener l) {
	listenerList.add(TreeModelListener.class, l);
}
 
Example 28
Source Project: marathonv5   Source File: FilterableTreeModel.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void addTreeModelListener(TreeModelListener l) {
    treeModel.addTreeModelListener(l);
}
 
Example 29
Source Project: marathonv5   Source File: FilterableTreeModel.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void removeTreeModelListener(TreeModelListener l) {
    treeModel.removeTreeModelListener(l);
}
 
Example 30
Source Project: codebuff   Source File: JTreeSTModel.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void removeTreeModelListener(TreeModelListener treeModelListener) {
}