Java Code Examples for javax.swing.event.TreeModelListener#treeStructureChanged()

The following examples show how to use javax.swing.event.TreeModelListener#treeStructureChanged() . 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 File: Storage.java    From j-j-jvm with Apache License 2.0 6 votes vote down vote up
public void removeItem(final StorageItem item) {
  if (item instanceof ClassItem) {
    final PackageItem packageItem = ((ClassItem) item).getPackage();
    if (packageItem != null) {
      packageItem.removeClass((ClassItem) item);
      if (packageItem.getChildCount(packageItem) == 0) {
        this.items.remove(packageItem);
      }
    }
  }
  else {
    if (item instanceof PackageItem) {
      this.items.remove(item);
    }
  }

  for (final TreeModelListener l : this.treeModelListeners) {
    l.treeStructureChanged(new TreeModelEvent(this, new TreePath(this)));
  }
}
 
Example 2
Source File: CustomTreeModel.java    From Pixie with MIT License 6 votes vote down vote up
/**
 * 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;

        }
    }
}
 
Example 3
Source File: RepositoryTreeModel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 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 4
Source File: GenealogyModel.java    From marathonv5 with 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 5
Source File: LookTreeModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 6
Source File: ScoreTree.java    From libreveris with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void refreshAll ()
{
    nodeMap.clear();

    TreeModelEvent modelEvent = new TreeModelEvent(
            this,
            new Object[]{score});

    for (TreeModelListener listener : listeners) {
        listener.treeStructureChanged(modelEvent);
    }
}
 
Example 7
Source File: ConfigTreeModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Informs all listeners, that the tree's contents have changed.
 */
private void fireTreeModelChanged() {
  for ( int i = 0; i < listeners.size(); i++ ) {
    final TreeModelListener l = listeners.get( i );
    l.treeStructureChanged( new TreeModelEvent( this, new TreePath( root ) ) );
  }
}
 
Example 8
Source File: ClassesListTreeModel.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
public final void update() {
    this.list = swf.getAS3Packs();
    TreeModelEvent event = new TreeModelEvent(this, new TreePath(root));
    for (TreeModelListener listener : listeners) {
        listener.treeStructureChanged(event);
    }
}
 
Example 9
Source File: BookBrowser.java    From audiveris with GNU Affero General Public License v3.0 5 votes vote down vote up
public void refreshAll ()
{
    nodeMap.clear();

    TreeModelEvent modelEvent = new TreeModelEvent(this, new Object[]{book});

    for (TreeModelListener listener : listeners) {
        listener.treeStructureChanged(modelEvent);
    }
}
 
Example 10
Source File: BookBrowser.java    From audiveris with 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 11
Source File: AbstractReportDataTreeModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void fireTreeDataChanged() {
  final TreeModelListener[] treeModelListeners = getListeners();
  final TreeModelEvent treeEvent = new TreeModelEvent( this, new TreePath( getRoot() ) );
  //    for (int i = treeModelListeners.length - 1; i >= 0; i -= 1)
  for ( int i = 0; i < treeModelListeners.length; i++ ) {
    final TreeModelListener listener = treeModelListeners[ i ];
    listener.treeStructureChanged( treeEvent );
  }

  refreshExpressionsCache();
}
 
Example 12
Source File: SortedTreeModelWrapper.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void onMindMapStructureChanged(@Nonnull final MindMapModelEvent event) {
  clear();
  final TreeModelEvent treeEvent = new TreeModelEvent(this, event.getPath());
  for (final TreeModelListener l : this.treeListeners) {
    l.treeStructureChanged(treeEvent);
  }
}
 
Example 13
Source File: ReportStructureTreeModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void fireTreeDataChanged( final Object source ) {
  final TreeModelListener[] treeModelListeners = eventListenerList.getListeners( TreeModelListener.class );
  final TreeModelEvent treeEvent = new TreeModelEvent( this, TreeSelectionHelper.getPathForNode( this, source ) );
  for ( int i = treeModelListeners.length - 1; i >= 0; i -= 1 ) {
    final TreeModelListener listener = treeModelListeners[ i ];
    listener.treeStructureChanged( treeEvent );
  }
}
 
Example 14
Source File: ScoreTree.java    From libreveris with 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 15
Source File: Storage.java    From j-j-jvm with Apache License 2.0 4 votes vote down vote up
public void removeAll() {
  this.items.clear();
  for (TreeModelListener p_listener : this.treeModelListeners) {
    p_listener.treeStructureChanged(new TreeModelEvent(this, new TreePath(this)));
  }
}
 
Example 16
Source File: DumpTreeModel.java    From jpexs-decompiler with GNU General Public License v3.0 4 votes vote down vote up
private void fireTreeStructureChanged(TreeModelEvent e) {
    for (TreeModelListener listener : listeners) {
        listener.treeStructureChanged(e);
    }
}
 
Example 17
Source File: LibraryTreeModel.java    From Digital with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void libraryChanged(LibraryNode node) {
    final TreeModelEvent treeModelEvent = new TreeModelEvent(this, new TreePath(node.getPath()));
    for (TreeModelListener l : listeners)
        l.treeStructureChanged(treeModelEvent);
}
 
Example 18
Source File: SimulationTreeModel.java    From Logisim with GNU General Public License v3.0 4 votes vote down vote up
protected void fireStructureChanged(Object node) {
	TreeModelEvent e = new TreeModelEvent(this, findPath(node));
	for (TreeModelListener l : listeners) {
		l.treeStructureChanged(e);
	}
}
 
Example 19
Source File: FilterTreeModel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
public void fireTreeStructureChanged() {
    TreeModelEvent treeModelEvent = new TreeModelEvent(this, getPath(root));
    for (TreeModelListener listener : listeners) {
        listener.treeStructureChanged(treeModelEvent);
    }
}
 
Example 20
Source File: GTreeModel.java    From ghidra with 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);
	}
}