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

The following are Jave code examples for showing how to use canRename() of the org.openide.nodes.Node class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: incubator-netbeans   File: TreeViewCellEditor.java   Source Code and License Vote up 6 votes
/** 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
Project: incubator-netbeans   File: TreeViewCellEditor.java   Source Code and License Vote up 6 votes
/** 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
Project: incubator-netbeans   File: TreeTable.java   Source Code and License Vote up 5 votes
/** 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
Project: incubator-netbeans   File: TreeViewCellEditor.java   Source Code and License Vote up 5 votes
@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
Project: incubator-netbeans   File: OutlineView.java   Source Code and License Vote up 5 votes
@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
Project: incubator-netbeans   File: AsynchronousTest.java   Source Code and License Vote up 5 votes
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);
}