Java Code Examples for org.openide.nodes.Node#canRename()

The following examples show how to use org.openide.nodes.Node#canRename() . 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: TreeViewCellEditor.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Implements <code>CellEditorListener</code> interface method. */
public void editingStopped(ChangeEvent e) {
    //CellEditor sometimes(probably after stopCellEditing() call) gains one focus but loses two
    if (stopped) {
        return;
    }

    stopped = true;

    TreePath lastP = lastPath;

    if (lastP != null) {
        Node n = Visualizer.findNode(lastP.getLastPathComponent());

        if ((n != null) && n.canRename()) {
            String newStr = (String) getCellEditorValue();
            ViewUtil.nodeRename(n, newStr);
        }
    }
}
 
Example 2
Source File: TreeViewCellEditor.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Main method of the editor.
* @return component of editor
*/
@Override
public Component getTreeCellEditorComponent(
    JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row
) {
    Node ren = Visualizer.findNode(value);

    if ((ren != null) && (ren.canRename())) {
        delegate.setValue(ren.getName());
    } else {
        delegate.setValue(""); // NOI18N
    }

    editingIcon = ((VisualizerNode) value).getIcon(expanded, false);

    ((JTextField) editorComponent).selectAll();

    return editorComponent;
}
 
Example 3
Source File: TreeTable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Implements <code>CellEditorListener</code> interface method. */
public void editingStopped(ChangeEvent e) {
    TreePath lastP = tree.getPathForRow(lastRow);

    if (lastP != null) {
        Node n = Visualizer.findNode(lastP.getLastPathComponent());

        if ((n != null) && n.canRename()) {
            String newStr = (String) getCellEditorValue();
            ViewUtil.nodeRename(n, newStr);
        }
    }
}
 
Example 4
Source File: TreeViewCellEditor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isCellEditable(EventObject event) {
    if ((event != null) && (event instanceof MouseEvent)) {
        if (!SwingUtilities.isLeftMouseButton((MouseEvent) event) || ((MouseEvent) event).isPopupTrigger()) {
            abortTimer();
            return false;
        }
        if (!wasFocusOwner) {
            wasFocusOwner = true;
            return false;
        }
    }

    if (lastPath != null) {
        Node n = Visualizer.findNode(lastPath.getLastPathComponent());

        if ((n == null) || !n.canRename()) {
            return false;
        }
    } else {
        // Disallow rename when multiple nodes are selected
        return false;
    }

    // disallow editing if we are in DnD operation
    if (dndActive) {
        return false;
    }

    return super.isCellEditable(event);
}
 
Example 5
Source File: OutlineView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
    if (columnIndex == 0) {
        Node treeNode = getNodeAt(rowIndex);
        return null != treeNode && treeNode.canRename();
    }
    return super.isCellEditable(rowIndex, columnIndex);
}
 
Example 6
Source File: AsynchronousTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void inspectNode(Node n) {
    n.getDisplayName();
    n.getHtmlDisplayName();
    n.getShortDescription();
    n.getIcon(BeanInfo.ICON_COLOR_16x16);
    n.canCopy();
    n.canCut();
    n.canRename();
    n.getNewTypes();
    n.getActions(true);
    n.getPreferredAction();
    inspectProperties(n);
}