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

The following examples show how to use javax.swing.event.TreeModelListener#treeNodesChanged() . 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: BugTreeModel.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void sortBranch(TreePath pathToBranch) {
    BugSet bs = bugSet.query((BugAspects) pathToBranch.getLastPathComponent());
    bs.sortList();
    Debug.println("Data in sorted branch: " + pathToBranch.getLastPathComponent());
    for (BugLeafNode b : bs) {
        Debug.println(b);
    }

    Object[] children = new Object[getChildCount(pathToBranch.getLastPathComponent())];
    int[] childIndices = new int[children.length];
    for (int x = 0; x < children.length; x++) {
        children[x] = getChild(pathToBranch.getLastPathComponent(), x);
        childIndices[x] = x;
    }
    for (TreeModelListener l : listeners) {
        TreeModelEvent event = new TreeModelEvent(this, pathToBranch, childIndices, children);
        l.treeNodesChanged(event);
    }

}
 
Example 2
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 3
Source File: ProcessTreeModel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
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 4
Source File: LookTreeModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 5
Source File: ReportStructureTreeModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void fireTreeNodeChanged( final Object element ) {
  final TreePath path = TreeSelectionHelper.getPathForNode( this, element );
  final TreeModelListener[] treeModelListeners = eventListenerList.getListeners( TreeModelListener.class );
  final TreeModelEvent treeEvent = new TreeModelEvent( this, path );
  for ( int i = treeModelListeners.length - 1; i >= 0; i -= 1 ) {
    final TreeModelListener listener = treeModelListeners[ i ];
    listener.treeNodesChanged( treeEvent );
  }
}
 
Example 6
Source File: LayerTreeModel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
protected void fireTreeNodeChanged(Layer layer) {
    TreeModelEvent event = createTreeModelEvent(layer);
    if (event == null) {
        return;
    }
    for (TreeModelListener treeModelListener : treeModelListeners.keySet()) {
        treeModelListener.treeNodesChanged(event);
    }
}
 
Example 7
Source File: ProjectTreeModel.java    From quickfix-messenger with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void fireTreeNodesChanged(Object source, Object[] path,
		int[] childIndices, Object[] children)
{
	TreeModelEvent event = new TreeModelEvent(source, path, childIndices,
			children);
	for (TreeModelListener listener : getTreeModelListeners())
	{
		listener.treeNodesChanged(event);
	}
}
 
Example 8
Source File: EditableResources.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
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 9
Source File: SortedTreeModelWrapper.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void onMindMapNodesChanged(@Nonnull final MindMapModelEvent event) {
  final TreeModelEvent treeEvent = new TreeModelEvent(this, event.getPath());
  for (final TreeModelListener l : this.treeListeners) {
    l.treeNodesChanged(treeEvent);
  }
}
 
Example 10
Source File: ProjectExplorer.java    From Logisim with GNU General Public License v3.0 5 votes vote down vote up
private void fireNodesChanged(List<TreeModelEvent> events) {
	for (TreeModelEvent e : events) {
		for (TreeModelListener l : listeners) {
			l.treeNodesChanged(e);
		}
	}
}
 
Example 11
Source File: TreeModelListenerList.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Notifies all added listeners that some nodes were changed.
 *
 * @param event the event object specifying changed nodes
 */
@Override
public void treeNodesChanged(@Nonnull TreeModelEvent event) {
  for (TreeModelListener listener : myListeners) {
    listener.treeNodesChanged(event);
  }
}
 
Example 12
Source File: ComponentsSelectionPanel.java    From netbeans with 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 13
Source File: GTreeModel.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public void fireNodeDataChanged(GTreeNode changedNode) {
	if (!eventsEnabled) {
		return;
	}
	SystemUtilities.assertThisIsTheSwingThread(
		"GTreeModel.fireNodeDataChanged() must be " + "called from the AWT thread");

	TreeModelEvent event = new TreeModelEvent(this, (TreePath) null);

	for (TreeModelListener listener : listeners) {
		listener.treeNodesChanged(event);
	}
}
 
Example 14
Source File: SimulationTreeModel.java    From Logisim with GNU General Public License v3.0 4 votes vote down vote up
protected void fireNodeChanged(Object node) {
	TreeModelEvent e = new TreeModelEvent(this, findPath(node));
	for (TreeModelListener l : listeners) {
		l.treeNodesChanged(e);
	}
}
 
Example 15
Source File: NodeProjectGroup.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public void valueForPathChanged(@Nonnull final TreePath path, @Nonnull final Object newValue) {
  String newFileName = String.valueOf(newValue);

  if (FILE_NAME.matcher(newFileName).matches()) {
    final Object last = path.getLastPathComponent();
    if (last instanceof NodeFileOrFolder) {
      final NodeFileOrFolder editedNode = (NodeFileOrFolder) last;

      final String oldName = editedNode.toString();

      if (!oldName.equals(newFileName)) {
        final File origFile = ((NodeFileOrFolder) last).makeFileForNode();
        final String oldExtension = FilenameUtils.getExtension(oldName);
        final String newExtension = FilenameUtils.getExtension(newFileName);

        if (!oldExtension.equals(newExtension)) {
          if (DialogProviderManager.getInstance().getDialogProvider().msgConfirmYesNo(Main.getApplicationFrame(), "Changed extension", String.format("You have changed extension! Restore old extension '%s'?", oldExtension))) {
            newFileName = FilenameUtils.getBaseName(newFileName) + (oldExtension.isEmpty() ? "" : '.' + oldExtension); //NOI18N
          }
        }

        if (origFile != null) {
          final File newFile = new File(origFile.getParentFile(), newFileName);

          if (!editedNode.isLeaf() && !context.safeCloseEditorsForFile(origFile)) {
            return;
          }

          try {

            boolean doIt = true;

            List<File> affectedFiles = null;

            final NodeProject project = editedNode.findProject();
            if (project != null) {
              affectedFiles = project.findAffectedFiles(origFile);
              if (!affectedFiles.isEmpty()) {
                affectedFiles = UiUtils.showSelectAffectedFiles(affectedFiles);
                if (affectedFiles == null) {
                  doIt = false;
                } else {
                  affectedFiles = project.replaceAllLinksToFile(affectedFiles, origFile, newFile);
                }
              }
            }

            if (doIt) {
              Files.move(origFile.toPath(), newFile.toPath());
              editedNode.setName(newFile.getName());

              final TreeModelEvent renamedEvent = new TreeModelEvent(this, editedNode.makeTreePath());
              for (final TreeModelListener l : listeners) {
                l.treeNodesChanged(renamedEvent);
              }

              editedNode.fireNotifySubtreeChanged(this, listeners);

              this.context.notifyFileRenamed(affectedFiles, origFile, newFile);
            }
          } catch (IOException ex) {
            LOGGER.error("Can't rename file", ex); //NOI18N
            DialogProviderManager.getInstance().getDialogProvider().msgError(Main.getApplicationFrame(), "Can't rename file to '" + newValue + "\'");
          }
        }
      }
    }
  } else {
    DialogProviderManager.getInstance().getDialogProvider().msgError(Main.getApplicationFrame(), "Inapropriate file name '" + newFileName + "'!");
  }
}
 
Example 16
Source File: EditableResources.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public void fireTreeNodeChanged(final String nodeName, int index) {
    TreeModelEvent ev = createEventForNode(nodeName, getResourceType(nodeName), index);
    for(TreeModelListener l : listeners) {
        l.treeNodesChanged(ev);
    }
}
 
Example 17
Source File: ProductLayerAssistantPage.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
protected void fireTreeNodeChanged(TreePath treePath) {
    TreeModelEvent event = new TreeModelEvent(this, treePath);
    for (TreeModelListener treeModelListener : treeModelListeners.keySet()) {
        treeModelListener.treeNodesChanged(event);
    }
}
 
Example 18
Source File: WmsAssistantPage2.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
protected void fireTreeNodeChanged(TreePath treePath) {
    TreeModelEvent event = new TreeModelEvent(this, treePath);
    for (TreeModelListener treeModelListener : treeModelListeners.keySet()) {
        treeModelListener.treeNodesChanged(event);
    }
}
 
Example 19
Source File: FilterTreeModel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private void fireTreeNodesChanged(TreeModelEvent treeModelEvent) {
    for (TreeModelListener listener : listeners) {
        listener.treeNodesChanged(treeModelEvent);
    }
}
 
Example 20
Source File: CustomTopicPanelConfiguration.java    From wandora with GNU General Public License v3.0 4 votes vote down vote up
public void fireNodesChanged(TreeModelEvent e){
    for(TreeModelListener l : listeners) l.treeNodesChanged(e);
}