javax.swing.tree.TreeCellEditor Java Examples

The following examples show how to use javax.swing.tree.TreeCellEditor. 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: TreeView.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Synchronize the root context from the manager of this Explorer.
*/
final void synchronizeRootContext() {
    // #151850 cancel editing before changing root node
    Mutex.EVENT.readAccess(new Runnable() {
        @Override
        public void run() {
            TreeCellEditor cellEditor = tree.getCellEditor();
            if (cellEditor instanceof TreeViewCellEditor) {
                ((TreeViewCellEditor) cellEditor).abortTimer();
            }
            tree.cancelEditing();
            final Node rc = manager.getRootContext();
            LOG.log(Level.FINE, "synchronizeRootContext {0}", rc);
            treeModel.setNode(rc, visHolder);
        }
    });
}
 
Example #2
Source File: MaterialTreeUI.java    From material-ui-swing with MIT License 6 votes vote down vote up
@Override
public void installUI (JComponent c) {
	super.installUI (c);

	DefaultTreeCellRenderer renderer = new MaterialTreeCellRenderer ();
	TreeCellEditor editor = new MaterialTreeCellEditor (tree, renderer);

	tree.setCellRenderer (renderer);
	tree.setCellEditor (editor);

	tree.setFont (UIManager.getFont ("Tree.font"));
	tree.setForeground (UIManager.getColor ("Tree.foreground"));
	tree.setBackground (UIManager.getColor ("Tree.background"));
	tree.setRowHeight (0);
	tree.setInvokesStopCellEditing (true);

	MaterialTreeUI ui = (MaterialTreeUI) tree.getUI ();
	ui.setLeftChildIndent (10);
	ui.setRightChildIndent (10);

	tree.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
 
Example #3
Source File: SynthTreeUI.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
                                         renderer);
    }
    else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
Example #4
Source File: SynthTreeUI.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
        @Override
        public String getName() {
            return "Tree.cellEditor";
        }
    };
    DefaultCellEditor editor = new DefaultCellEditor(tf);

    // One click to edit.
    editor.setClickCountToStart(1);
    return editor;
}
 
Example #5
Source File: SynthTreeUI.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
        @Override
        public String getName() {
            return "Tree.cellEditor";
        }
    };
    DefaultCellEditor editor = new DefaultCellEditor(tf);

    // One click to edit.
    editor.setClickCountToStart(1);
    return editor;
}
 
Example #6
Source File: SynthTreeUI.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
                                         renderer);
    }
    else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
Example #7
Source File: SynthTreeUI.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
        @Override
        public String getName() {
            return "Tree.cellEditor";
        }
    };
    DefaultCellEditor editor = new DefaultCellEditor(tf);

    // One click to edit.
    editor.setClickCountToStart(1);
    return editor;
}
 
Example #8
Source File: SynthTreeUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
        @Override
        public String getName() {
            return "Tree.cellEditor";
        }
    };
    DefaultCellEditor editor = new DefaultCellEditor(tf);

    // One click to edit.
    editor.setClickCountToStart(1);
    return editor;
}
 
Example #9
Source File: SynthTreeUI.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
                                         renderer);
    }
    else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
Example #10
Source File: SynthTreeUI.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
        @Override
        public String getName() {
            return "Tree.cellEditor";
        }
    };
    DefaultCellEditor editor = new DefaultCellEditor(tf);

    // One click to edit.
    editor.setClickCountToStart(1);
    return editor;
}
 
Example #11
Source File: SynthTreeUI.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
                                         renderer);
    }
    else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
Example #12
Source File: SynthTreeUI.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
        @Override
        public String getName() {
            return "Tree.cellEditor";
        }
    };
    DefaultCellEditor editor = new DefaultCellEditor(tf);

    // One click to edit.
    editor.setClickCountToStart(1);
    return editor;
}
 
Example #13
Source File: SynthTreeUI.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
                                         renderer);
    }
    else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
Example #14
Source File: SynthTreeUI.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
        @Override
        public String getName() {
            return "Tree.cellEditor";
        }
    };
    DefaultCellEditor editor = new DefaultCellEditor(tf);

    // One click to edit.
    editor.setClickCountToStart(1);
    return editor;
}
 
Example #15
Source File: NewErrorTreeEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row) {
  final ErrorTreeElement element = getElement(value);
  if (element instanceof EditableMessageElement) {
    EditableMessageElement editableMessageElement = (EditableMessageElement)element;
    final CustomizeColoredTreeCellRenderer leftSelfRenderer = editableMessageElement.getLeftSelfRenderer();
    final TreeCellEditor rightSelfEditor = editableMessageElement.getRightSelfEditor();
    myColoredTreeCellRenderer.setCurrentCallback(leftSelfRenderer);
    myRightCellRenderer.setCurrentCallback(rightSelfEditor);
    return myWrapperEditor.getTreeCellEditorComponent(tree, value, selected, expanded, leaf, row);
  }
  return myTree.getCellRenderer().getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, true);
}
 
Example #16
Source File: SynthTreeUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
                                         renderer);
    }
    else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
Example #17
Source File: SynthTreeUI.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
        @Override
        public String getName() {
            return "Tree.cellEditor";
        }
    };
    DefaultCellEditor editor = new DefaultCellEditor(tf);

    // One click to edit.
    editor.setClickCountToStart(1);
    return editor;
}
 
Example #18
Source File: SynthTreeUI.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
                                         renderer);
    }
    else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
Example #19
Source File: SynthTreeUI.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
        @Override
        public String getName() {
            return "Tree.cellEditor";
        }
    };
    DefaultCellEditor editor = new DefaultCellEditor(tf);

    // One click to edit.
    editor.setClickCountToStart(1);
    return editor;
}
 
Example #20
Source File: SynthTreeUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
                                         renderer);
    }
    else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
Example #21
Source File: SynthTreeUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
        @Override
        public String getName() {
            return "Tree.cellEditor";
        }
    };
    DefaultCellEditor editor = new DefaultCellEditor(tf);

    // One click to edit.
    editor.setClickCountToStart(1);
    return editor;
}
 
Example #22
Source File: SeaGlassTreeUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * @inheritDoc
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if (renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer) renderer);
    } else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
Example #23
Source File: SeaGlassTreeUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
        @Override
        public String getName() {
            return "Tree.cellEditor";
        }
    };
    DefaultCellEditor editor = new DefaultCellEditor(tf);

    // One click to edit.
    editor.setClickCountToStart(1);
    return editor;
}
 
Example #24
Source File: SynthTreeUI.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
                                         renderer);
    }
    else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
Example #25
Source File: SynthTreeUI.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
        @Override
        public String getName() {
            return "Tree.cellEditor";
        }
    };
    DefaultCellEditor editor = new DefaultCellEditor(tf);

    // One click to edit.
    editor.setClickCountToStart(1);
    return editor;
}
 
Example #26
Source File: MainPanel.java    From java-swing-tips with MIT License 5 votes vote down vote up
private static TreeCellEditor makeLeafTreeCellEditor(JTree tree) {
  return new DefaultTreeCellEditor(tree, (DefaultTreeCellRenderer) tree.getCellRenderer()) {
    @Override public boolean isCellEditable(EventObject e) {
      Object o = tree.getLastSelectedPathComponent();
      return super.isCellEditable(e) && o instanceof TreeNode && ((TreeNode) o).isLeaf();
    }
  };
}
 
Example #27
Source File: AbstractTreeDescriptor.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void updateUI ( @NotNull final C component )
{
    // Updating component UI
    super.updateUI ( component );

    // Updating renderer UI
    final TreeCellRenderer renderer = component.getCellRenderer ();
    if ( renderer instanceof Component )
    {
        SwingUtilities.updateComponentTreeUI ( ( Component ) renderer );
    }

    // Updating editor UI
    final TreeCellEditor editor = component.getCellEditor ();
    if ( editor instanceof Component )
    {
        SwingUtilities.updateComponentTreeUI ( ( Component ) editor );
    }
    else if ( editor instanceof DefaultCellEditor )
    {
        final Component editorComponent = ( ( DefaultCellEditor ) editor ).getComponent ();
        if ( editorComponent != null )
        {
            SwingUtilities.updateComponentTreeUI ( editorComponent );
        }
    }
}
 
Example #28
Source File: WebExTree.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Costructs new {@link WebExTree} with the specified {@link ExTreeDataProvider} as data source.
 *
 * @param id           {@link StyleId}
 * @param dataProvider {@link ExTreeDataProvider} implementation
 * @param renderer     {@link TreeCellRenderer} implementation, default implementation is used if {@code null} is provided
 * @param editor       {@link TreeCellEditor} implementation, default implementation is used if {@code null} is provided
 */
public WebExTree ( @NotNull final StyleId id, @Nullable final ExTreeDataProvider dataProvider,
                   @Nullable final TreeCellRenderer renderer, @Nullable final TreeCellEditor editor )
{
    super ( id, dataProvider != null ? new ExTreeModel<N> ( dataProvider ) : null );
    if ( renderer != null )
    {
        setCellRenderer ( renderer );
    }
    if ( editor != null )
    {
        setEditable ( true );
        setCellEditor ( editor );
    }
}
 
Example #29
Source File: WebExCheckBoxTree.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Costructs new {@link WebExCheckBoxTree} with the specified {@link ExTreeDataProvider} as data source.
 *
 * @param id           {@link StyleId}
 * @param dataProvider {@link ExTreeDataProvider} implementation
 * @param renderer     {@link TreeCellRenderer} implementation, default implementation is used if {@code null} is provided
 * @param editor       {@link TreeCellEditor} implementation, default implementation is used if {@code null} is provided
 */
public WebExCheckBoxTree ( @NotNull final StyleId id, @Nullable final ExTreeDataProvider dataProvider,
                           @Nullable final TreeCellRenderer renderer, @Nullable final TreeCellEditor editor )
{
    super ( id, dataProvider != null ? new ExTreeModel<N> ( dataProvider ) : null );
    if ( renderer != null )
    {
        setCellRenderer ( renderer );
    }
    if ( editor != null )
    {
        setEditable ( true );
        setCellEditor ( editor );
    }
}
 
Example #30
Source File: WebAsyncTree.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Costructs new {@link WebAsyncTree} with the specified {@link AsyncTreeDataProvider} as data source.
 *
 * @param id           {@link StyleId}
 * @param dataProvider {@link AsyncTreeDataProvider} implementation
 * @param renderer     {@link TreeCellRenderer} implementation, default implementation is used if {@code null} is provided
 * @param editor       {@link TreeCellEditor} implementation, default implementation is used if {@code null} is provided
 */
public WebAsyncTree ( @NotNull final StyleId id, @Nullable final AsyncTreeDataProvider dataProvider,
                      @Nullable final TreeCellRenderer renderer, @Nullable final TreeCellEditor editor )
{
    super ( id, dataProvider != null ? new AsyncTreeModel<N> ( dataProvider ) : null );
    if ( renderer != null )
    {
        setCellRenderer ( renderer );
    }
    if ( editor != null )
    {
        setEditable ( true );
        setCellEditor ( editor );
    }
}