Java Code Examples for javax.swing.tree.DefaultTreeModel#nodeChanged()

The following examples show how to use javax.swing.tree.DefaultTreeModel#nodeChanged() . 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: XSheet.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Update the label of the supplied MBean tree node.
 */
// Call on EDT
private void updateNotificationsNodeLabel(
        DefaultMutableTreeNode node, String label) {
    synchronized (mbeansTab.getTree()) {
        invalidate();
        XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject();
        XNodeInfo newUserObject = new XNodeInfo(
                oldUserObject.getType(), oldUserObject.getData(),
                label, oldUserObject.getToolTipText());
        node.setUserObject(newUserObject);
        DefaultTreeModel model =
                (DefaultTreeModel) mbeansTab.getTree().getModel();
        model.nodeChanged(node);
        validate();
        repaint();
    }
}
 
Example 2
Source File: XSheet.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Update the label of the supplied MBean tree node.
 */
// Call on EDT
private void updateNotificationsNodeLabel(
        DefaultMutableTreeNode node, String label) {
    synchronized (mbeansTab.getTree()) {
        invalidate();
        XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject();
        XNodeInfo newUserObject = new XNodeInfo(
                oldUserObject.getType(), oldUserObject.getData(),
                label, oldUserObject.getToolTipText());
        node.setUserObject(newUserObject);
        DefaultTreeModel model =
                (DefaultTreeModel) mbeansTab.getTree().getModel();
        model.nodeChanged(node);
        validate();
        repaint();
    }
}
 
Example 3
Source File: XSheet.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Update the label of the supplied MBean tree node.
 */
// Call on EDT
private void updateNotificationsNodeLabel(
        DefaultMutableTreeNode node, String label) {
    synchronized (mbeansTab.getTree()) {
        invalidate();
        XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject();
        XNodeInfo newUserObject = new XNodeInfo(
                oldUserObject.getType(), oldUserObject.getData(),
                label, oldUserObject.getToolTipText());
        node.setUserObject(newUserObject);
        DefaultTreeModel model =
                (DefaultTreeModel) mbeansTab.getTree().getModel();
        model.nodeChanged(node);
        validate();
        repaint();
    }
}
 
Example 4
Source File: XSheet.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Update the label of the supplied MBean tree node.
 */
// Call on EDT
private void updateNotificationsNodeLabel(
        DefaultMutableTreeNode node, String label) {
    synchronized (mbeansTab.getTree()) {
        invalidate();
        XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject();
        XNodeInfo newUserObject = new XNodeInfo(
                oldUserObject.getType(), oldUserObject.getData(),
                label, oldUserObject.getToolTipText());
        node.setUserObject(newUserObject);
        DefaultTreeModel model =
                (DefaultTreeModel) mbeansTab.getTree().getModel();
        model.nodeChanged(node);
        validate();
        repaint();
    }
}
 
Example 5
Source File: XSheet.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Update the label of the supplied MBean tree node.
 */
// Call on EDT
private void updateNotificationsNodeLabel(
        DefaultMutableTreeNode node, String label) {
    synchronized (mbeansTab.getTree()) {
        invalidate();
        XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject();
        XNodeInfo newUserObject = new XNodeInfo(
                oldUserObject.getType(), oldUserObject.getData(),
                label, oldUserObject.getToolTipText());
        node.setUserObject(newUserObject);
        DefaultTreeModel model =
                (DefaultTreeModel) mbeansTab.getTree().getModel();
        model.nodeChanged(node);
        validate();
        repaint();
    }
}
 
Example 6
Source File: XSheet.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Update the label of the supplied MBean tree node.
 */
// Call on EDT
private void updateNotificationsNodeLabel(
        DefaultMutableTreeNode node, String label) {
    synchronized (mbeansTab.getTree()) {
        invalidate();
        XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject();
        XNodeInfo newUserObject = new XNodeInfo(
                oldUserObject.getType(), oldUserObject.getData(),
                label, oldUserObject.getToolTipText());
        node.setUserObject(newUserObject);
        DefaultTreeModel model =
                (DefaultTreeModel) mbeansTab.getTree().getModel();
        model.nodeChanged(node);
        validate();
        repaint();
    }
}
 
Example 7
Source File: XSheet.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Update the label of the supplied MBean tree node.
 */
// Call on EDT
private void updateNotificationsNodeLabel(
        DefaultMutableTreeNode node, String label) {
    synchronized (mbeansTab.getTree()) {
        invalidate();
        XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject();
        XNodeInfo newUserObject = new XNodeInfo(
                oldUserObject.getType(), oldUserObject.getData(),
                label, oldUserObject.getToolTipText());
        node.setUserObject(newUserObject);
        DefaultTreeModel model =
                (DefaultTreeModel) mbeansTab.getTree().getModel();
        model.nodeChanged(node);
        validate();
        repaint();
    }
}
 
Example 8
Source File: XSheet.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Update the label of the supplied MBean tree node.
 */
// Call on EDT
private void updateNotificationsNodeLabel(
        DefaultMutableTreeNode node, String label) {
    synchronized (mbeansTab.getTree()) {
        invalidate();
        XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject();
        XNodeInfo newUserObject = new XNodeInfo(
                oldUserObject.getType(), oldUserObject.getData(),
                label, oldUserObject.getToolTipText());
        node.setUserObject(newUserObject);
        DefaultTreeModel model =
                (DefaultTreeModel) mbeansTab.getTree().getModel();
        model.nodeChanged(node);
        validate();
        repaint();
    }
}
 
Example 9
Source File: XSheet.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Update the label of the supplied MBean tree node.
 */
// Call on EDT
private void updateNotificationsNodeLabel(
        DefaultMutableTreeNode node, String label) {
    synchronized (mbeansTab.getTree()) {
        invalidate();
        XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject();
        XNodeInfo newUserObject = new XNodeInfo(
                oldUserObject.getType(), oldUserObject.getData(),
                label, oldUserObject.getToolTipText());
        node.setUserObject(newUserObject);
        DefaultTreeModel model =
                (DefaultTreeModel) mbeansTab.getTree().getModel();
        model.nodeChanged(node);
        validate();
        repaint();
    }
}
 
Example 10
Source File: FmtSpaces.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private boolean toggle(TreePath treePath) {

        if (treePath == null) {
            return false;
        }

        Object o = ((DefaultMutableTreeNode) treePath.getLastPathComponent()).getUserObject();

        DefaultTreeModel dtm = (DefaultTreeModel) cfgTree.getModel();
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent();

        if (o instanceof Item) {
            Item item = (Item) o;

            if (node.getAllowsChildren()) {
                return false;
            }

            item.value = !item.value;
            dtm.nodeChanged(node);
            dtm.nodeChanged(node.getParent());
            scs.notifyChanged();
        }

        return false;
    }
 
Example 11
Source File: FmtSpaces.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private boolean toggle(TreePath treePath) {

        if( treePath == null ) {
            return false;
        }

        Object o = ((DefaultMutableTreeNode)treePath.getLastPathComponent()).getUserObject();

        DefaultTreeModel dtm = (DefaultTreeModel)cfgTree.getModel();
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent();

        if ( o instanceof Item ) {
            Item item = (Item)o;

            if ( node.getAllowsChildren() ) {
                return false;
            }

            item.value = !item.value;
            dtm.nodeChanged(node);
            dtm.nodeChanged(node.getParent());
            scs.notifyChanged();
        }

        return false;
    }
 
Example 12
Source File: FmtSpaces.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private boolean toggle(TreePath treePath) {

        if( treePath == null ) {
            return false;
        }

        Object o = ((DefaultMutableTreeNode)treePath.getLastPathComponent()).getUserObject();

        DefaultTreeModel dtm = (DefaultTreeModel)cfgTree.getModel();
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent();

        if ( o instanceof Item ) {
            Item item = (Item)o;

            if ( node.getAllowsChildren() ) {
                return false;
            }

            item.value = !item.value;
            dtm.nodeChanged(node);
            dtm.nodeChanged(node.getParent());
            scs.notifyChanged();
        }

        return false;
    }
 
Example 13
Source File: FmtSpaces.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private boolean toggle(TreePath treePath) {
    
    if( treePath == null ) {
        return false;
    }

    Object o = ((DefaultMutableTreeNode)treePath.getLastPathComponent()).getUserObject();

    DefaultTreeModel dtm = (DefaultTreeModel)cfgTree.getModel();
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent();

    if ( o instanceof Item ) {
        Item item = (Item)o;
        
        if ( node.getAllowsChildren() ) {
            return false;
        }
        
        item.value = !item.value;            
        dtm.nodeChanged(node);
        dtm.nodeChanged(node.getParent());
        scs.notifyChanged();
    }
    
    return false;
}
 
Example 14
Source File: XSheet.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Update the label of the supplied MBean tree node.
 */
// Call on EDT
private void updateNotificationsNodeLabel(
        DefaultMutableTreeNode node, String label) {
    synchronized (mbeansTab.getTree()) {
        invalidate();
        XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject();
        XNodeInfo newUserObject = new XNodeInfo(
                oldUserObject.getType(), oldUserObject.getData(),
                label, oldUserObject.getToolTipText());
        node.setUserObject(newUserObject);
        DefaultTreeModel model =
                (DefaultTreeModel) mbeansTab.getTree().getModel();
        model.nodeChanged(node);
        validate();
        repaint();
    }
}
 
Example 15
Source File: XSheet.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Update the label of the supplied MBean tree node.
 */
// Call on EDT
private void updateNotificationsNodeLabel(
        DefaultMutableTreeNode node, String label) {
    synchronized (mbeansTab.getTree()) {
        invalidate();
        XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject();
        XNodeInfo newUserObject = new XNodeInfo(
                oldUserObject.getType(), oldUserObject.getData(),
                label, oldUserObject.getToolTipText());
        node.setUserObject(newUserObject);
        DefaultTreeModel model =
                (DefaultTreeModel) mbeansTab.getTree().getModel();
        model.nodeChanged(node);
        validate();
        repaint();
    }
}
 
Example 16
Source File: XSheet.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Update the label of the supplied MBean tree node.
 */
// Call on EDT
private void updateNotificationsNodeLabel(
        DefaultMutableTreeNode node, String label) {
    synchronized (mbeansTab.getTree()) {
        invalidate();
        XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject();
        XNodeInfo newUserObject = new XNodeInfo(
                oldUserObject.getType(), oldUserObject.getData(),
                label, oldUserObject.getToolTipText());
        node.setUserObject(newUserObject);
        DefaultTreeModel model =
                (DefaultTreeModel) mbeansTab.getTree().getModel();
        model.nodeChanged(node);
        validate();
        repaint();
    }
}
 
Example 17
Source File: GroupNode.java    From consulo with Apache License 2.0 5 votes vote down vote up
int removeUsagesBulk(@Nonnull Set<UsageNode> usages, @Nonnull DefaultTreeModel treeModel) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  int removed = 0;
  synchronized (this) {
    List<MutableTreeNode> removedNodes = new SmartList<>();
    for (UsageNode usage : usages) {
      if (myChildren.remove(usage)) {
        removedNodes.add(usage);
        removed++;
      }
    }

    if (removed == 0) {
      for (GroupNode groupNode : getSubGroups()) {
        int delta = groupNode.removeUsagesBulk(usages, treeModel);
        if (delta > 0) {
          if (groupNode.getRecursiveUsageCount() == 0) {
            myChildren.remove(groupNode);
            removedNodes.add(groupNode);
          }
          removed += delta;
          if (removed == usages.size()) break;
        }
      }
    }
    if (!myChildren.isEmpty()) {
      removeNodesFromParent(treeModel, this, removedNodes);
    }
  }

  if (removed > 0) {
    myRecursiveUsageCount -= removed;
    if (myRecursiveUsageCount != 0) {
      treeModel.nodeChanged(this);
    }
  }

  return removed;
}
 
Example 18
Source File: ComponentSelector.java    From Logisim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void circuitChanged(CircuitEvent event) {
	int action = event.getAction();
	DefaultTreeModel model = (DefaultTreeModel) getModel();
	if (action == CircuitEvent.ACTION_SET_NAME) {
		model.nodeChanged(this);
	} else {
		if (computeChildren()) {
			model.nodeStructureChanged(this);
		} else if (action == CircuitEvent.ACTION_INVALIDATE) {
			Object o = event.getData();
			for (int i = children.size() - 1; i >= 0; i--) {
				Object o2 = children.get(i);
				if (o2 instanceof ComponentNode) {
					ComponentNode n = (ComponentNode) o2;
					if (n.comp == o) {
						int[] changed = { i };
						children.remove(i);
						model.nodesWereRemoved(this, changed, new Object[] { n });
						children.add(i, new ComponentNode(this, n.comp));
						model.nodesWereInserted(this, changed);
					}
				}
			}
		}
	}
}
 
Example 19
Source File: Editor.java    From jclic with GNU General Public License v2.0 5 votes vote down vote up
public void fireEditorDataChanged(EditorListener agent) {
  setModified(true);
  DefaultTreeModel tm = getTreeModel();
  if (tm != null)
    tm.nodeChanged(this);

  Iterator it = listeners.iterator();
  while (it.hasNext()) {
    EditorListener ls = (EditorListener) it.next();
    if (ls != agent)
      ls.editorDataChanged(this);
  }
}
 
Example 20
Source File: ElistTablePanel.java    From ramus with GNU General Public License v3.0 4 votes vote down vote up
public ElistTablePanel(GUIFramework framework, Qualifier qualifier) {
    leafIcon = new ImageIcon(getClass().getResource(
            "/com/ramussoft/gui/table/sheet.png"));
    folderIcon = new ImageIcon(getClass().getResource(
            "/com/ramussoft/gui/table/folder.png"));
    folderSheetIcon = new ImageIcon(getClass().getResource(
            "/com/ramussoft/gui/table/folder-sheet.png"));
    setRootVisible(false);
    List<Attribute> list = qualifier.getAttributes();
    if (list.size() > 0)
        attribute = list.get(0);
    for (Attribute attr : list) {
        if (attr.getId() == qualifier.getAttributeForName()) {
            attribute = attr;
            break;
        }
    }
    Attribute[] attributes;
    if (attribute != null)
        attributes = new Attribute[]{attribute};
    else
        attributes = new Attribute[]{};
    rowSet = new RowSet(framework.getEngine(), qualifier, attributes) {

        @Override
        protected void removedFromChildren(Row parentRow, Row row, int i) {
            try {
                model.nodesWereRemoved(parentRow, new int[]{i},
                        new Object[]{row});
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        @Override
        protected void added(Row parent, final Row row, int index) {
            super.added(parent, row, index);
            if (parent == null)
                parent = getRoot();
            try {
                model.nodesWereInserted(parent, new int[]{index});
                expandPath(new TreePath(model.getPathToRoot(parent)));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        @Override
        protected void attributeChanged(Row row, Attribute attr,
                                        Object newValue, Object oldValue, boolean journaled) {
            if (attribute.getId() == attr.getId()) {
                try {
                    model.nodeChanged(row);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    };

    model = new DefaultTreeModel(rowSet.getRoot());
    setModel(model);
    for (int i = 0; i < getRowCount(); i++)
        expandRow(i);
    setRowHeight(ElistTableTabView.CELL_BORDER);
    this.addMouseMotionListener(new MouseMotionAdapter() {
        @Override
        public void mouseMoved(MouseEvent e) {
            setToolTipText(getToolTipText(e));
        }
    });

    setCellRenderer(renderer);
}