Java Code Examples for javax.swing.tree.DefaultTreeCellEditor

The following examples show how to use javax.swing.tree.DefaultTreeCellEditor. These examples are extracted from open source projects. 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 Project: ghidra   Source File: ProgramTreePlugin1Test.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateFolderDuplicate() throws Exception {
	setSelectionPath(root.getTreePath());
	final String newName = tree.getNewFolderName();

	final DockingActionIf createFolderAction = getAction("Create Folder");

	final JTextField[] newFolderTextField = new JTextField[1];
	runSwing(() -> {
		createFolderAction.actionPerformed(new ActionContext());
		program.flushEvents();
		int row = tree.getRowForPath(tree.getEditingPath());
		DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
		Container container = (Container) cellEditor.getTreeCellEditorComponent(tree,
			tree.getEditingPath().getLastPathComponent(), true, true, true, row);
		newFolderTextField[0] = (JTextField) container.getComponent(0);
		newFolderTextField[0].setText("test1");
		tree.stopEditing();
	});

	final String[] text = new String[1];
	runSwing(() -> text[0] = newFolderTextField[0].getText());

	assertEquals(newName, text[0]);
}
 
Example 2
Source Project: ghidra   Source File: ProgramTreePlugin1Test.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateFragmentDuplicate() throws Exception {

	setSelectionPath(root.getTreePath());
	final String newName = tree.getNewFragmentName();

	final DockingActionIf createFragmentAction = getAction("Create Fragment");

	final JTextField[] newFragmentTextField = new JTextField[1];
	runSwing(() -> {
		createFragmentAction.actionPerformed(new ActionContext());
		program.flushEvents();
		int row = tree.getRowForPath(tree.getEditingPath());
		DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
		Container container = (Container) cellEditor.getTreeCellEditorComponent(tree,
			tree.getEditingPath().getLastPathComponent(), true, true, true, row);
		newFragmentTextField[0] = (JTextField) container.getComponent(0);
		newFragmentTextField[0].setText("test1");
		tree.stopEditing();
	});

	final String[] text = new String[1];
	runSwing(() -> text[0] = newFragmentTextField[0].getText());
	assertEquals(newName, text[0]);
}
 
Example 3
Source Project: ghidra   Source File: SymbolTreePlugin1Test.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateNamespace() throws Exception {
	showSymbolTree();

	GTreeNode newNsNode = createNewNamespace();

	//
	// Also, check the editors contents
	//
	TreePath path = newNsNode.getTreePath();
	int row = tree.getRowForPath(path);
	DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
	JTree jTree = (JTree) AbstractGenericTest.getInstanceField("tree", tree);

	Container container = (Container) cellEditor.getTreeCellEditorComponent(jTree, newNsNode,
		true, true, true, row);
	JTextField textField = (JTextField) container.getComponent(0);
	assertEquals("NewNamespace", textField.getText());
}
 
Example 4
Source Project: ghidra   Source File: SymbolTreePlugin1Test.java    License: Apache License 2.0 6 votes vote down vote up
private void setEditorText(final TreePath path, final GTreeNode nsNode, final String newName)
		throws InterruptedException, InvocationTargetException {
	SwingUtilities.invokeAndWait(() -> {
		int row = tree.getRowForPath(path);
		DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
		JTree jTree = (JTree) AbstractGenericTest.getInstanceField("tree", tree);
		Container container = (Container) cellEditor.getTreeCellEditorComponent(jTree, nsNode,
			true, true, true, row);
		JTextField textField = (JTextField) container.getComponent(0);

		textField.setText(newName);
		tree.stopEditing();
	});

	flushAndWaitForTree();
}
 
Example 5
Source Project: ghidra   Source File: FrontEndPluginActionsTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testRenameFile() throws Exception {
	final GTreeNode npNode = rootNode.getChild("notepad");
	setSelectionPath(npNode.getTreePath());

	DockingActionIf renameAction = getAction("Rename");
	performAction(renameAction, getDomainFileActionContext(), true);
	waitForTree();

	// select "Rename" action
	SwingUtilities.invokeAndWait(() -> {
		int row = tree.getRowForPath(npNode.getTreePath());
		DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
		JTree jTree = (JTree) getInstanceField("tree", tree);
		Container container = (Container) cellEditor.getTreeCellEditorComponent(jTree, npNode,
			true, true, false, row);
		JTextField textField = (JTextField) container.getComponent(0);

		textField.setText("My_notepad");
		tree.stopEditing();
	});
	waitForSwing();
	assertNotNull(rootNode.getChild("My_notepad"));
	assertNull(rootNode.getChild("notepad"));

}
 
Example 6
Source Project: jdk1.8-source-analysis   Source File: SynthTreeUI.java    License: 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 7
Source Project: dragonwell8_jdk   Source File: SynthTreeUI.java    License: 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 8
Source Project: ghidra   Source File: ProgramTreePlugin1Test.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testRenameDuplicateFolder() throws Exception {
	int transactionID = program.startTransaction("Test");
	createModule(root, "printf");
	createModule(root, "submodule");
	program.endTransaction(transactionID, true);
	program.flushEvents();

	expandRoot();
	buildNodeList();

	final ProgramNode[] nodes = findNodes("submodule");
	setSelectionPath(nodes[0].getTreePath());

	final DockingActionIf action = getAction(plugin, "Rename folder/fragment");
	assertTrue(action.isEnabled());

	runSwing(() -> {
		action.actionPerformed(new ActionContext());
		int row = tree.getRowForPath(nodes[0].getTreePath());
		DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
		Container container = (Container) cellEditor.getTreeCellEditorComponent(tree, nodes[0],
			true, true, false, row);
		textField = (JTextField) container.getComponent(0);

		textField.setText("printf");
		tree.stopEditing();
	});
	waitForPostedSwingRunnables();
	assertEquals("submodule", textField.getText());
}
 
Example 9
Source Project: ghidra   Source File: ProgramTreePlugin1Test.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testRenameDuplicateFragment() throws Exception {

	int transactionID = program.startTransaction("Test");
	ProgramModule m = createModule(root, "Module-1");
	ProgramFragment f = m.createFragment("strcpy");
	program.endTransaction(transactionID, true);
	program.flushEvents();

	expandRoot();

	buildNodeList();
	final ProgramNode[] nodes = findNodes("strcpy");
	setSelectionPath(nodes[0].getTreePath());
	final DockingActionIf action = getAction(plugin, "Rename folder/fragment");
	assertTrue(action.isEnabled());

	runSwing(() -> {
		action.actionPerformed(new ActionContext());
		int row = tree.getRowForPath(nodes[0].getTreePath());
		DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
		Container container = (Container) cellEditor.getTreeCellEditorComponent(tree, nodes[0],
			true, true, true, row);
		textField = (JTextField) container.getComponent(0);
		textField.setText(".data");
		tree.stopEditing();
	});
	waitForPostedSwingRunnables();
	assertEquals(f.getName(), textField.getText());
}
 
Example 10
Source Project: ghidra   Source File: ProgramTreePlugin1Test.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testRenameWithCellEditor() throws Exception {
	int transactionID = program.startTransaction("Test");
	createModule(root, "Module-1");
	createModule(root, "submodule");
	program.endTransaction(transactionID, true);
	program.flushEvents();

	expandRoot();
	buildNodeList();

	final ProgramNode[] nodes = findNodes("Module-1");
	setSelectionPath(nodes[0].getTreePath());
	final DockingActionIf action = getAction(plugin, "Rename folder/fragment");
	assertTrue(action.isEnabled());

	runSwing(() -> {
		action.actionPerformed(new ActionContext());
		int row = tree.getRowForPath(nodes[0].getTreePath());
		DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
		Container container = (Container) cellEditor.getTreeCellEditorComponent(tree, nodes[0],
			true, true, false, row);
		textField = (JTextField) container.getComponent(0);

		textField.setText("My Module-1");
		tree.stopEditing();
	});

	assertEquals("My Module-1", textField.getText());
	program.flushEvents();
	assertEquals("My Module-1", nodes[0].getModule().getName());
}
 
Example 11
Source Project: ghidra   Source File: DataTypeManagerPluginTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testRenameCategoryDuplicate() throws Exception {
	expandNode(programNode);
	String miscNodeName = "MISC";
	final CategoryNode miscNode = (CategoryNode) programNode.getChild(miscNodeName);
	assertNotNull(miscNode);
	expandNode(miscNode);
	selectNode(miscNode);

	final DockingActionIf action = getAction(plugin, "Rename");
	assertTrue(action.isEnabledForContext(treeContext));
	DataTypeTestUtils.performAction(action, tree);
	waitForTree();
	SwingUtilities.invokeLater(() -> {
		TreePath editingPath = jTree.getEditingPath();
		GTreeNode editingNode = (GTreeNode) editingPath.getLastPathComponent();
		int rowForPath = jTree.getRowForPath(editingPath);

		DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
		Container container = (Container) cellEditor.getTreeCellEditorComponent(jTree,
			editingNode, true, true, true, rowForPath);
		JTextField textField = (JTextField) container.getComponent(0);

		textField.setText("Category1");
		jTree.stopEditing();
	});

	final OptionDialog d = waitForDialogComponent(OptionDialog.class);
	runSwing(() -> d.close());
	waitForSwing();

	assertTrue(!jTree.isEditing());
}
 
Example 12
Source Project: ghidra   Source File: SymbolTreePlugin1Test.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateClass() throws Exception {
	showSymbolTree();

	util.selectNode(rootNode.getChild("Classes"));
	performAction(createClassAction, util.getSymbolTreeContext(), true);

	GTreeNode cnode = rootNode.getChild(4);
	util.expandNode(cnode);

	// wait until NewClass gets added		
	GTreeNode newNode = waitForValue(() -> cnode.getChild(0));

	assertNotNull(newNode);
	Symbol s = ((SymbolNode) newNode).getSymbol();
	assertEquals("NewClass", s.getName());

	TreePath path = newNode.getTreePath();
	int row = tree.getRowForPath(path);
	JTree jTree = (JTree) AbstractGenericTest.getInstanceField("tree", tree);

	JTextField tf = runSwing(() -> {
		DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
		Container container = (Container) cellEditor.getTreeCellEditorComponent(jTree, newNode,
			true, true, true, row);
		JTextField textField = (JTextField) container.getComponent(0);
		return textField;
	});

	assertEquals("NewClass", tf.getText());
}
 
Example 13
Source Project: ghidra   Source File: SymbolTreeTestUtils.java    License: Apache License 2.0 5 votes vote down vote up
void rename(GTreeNode node, final String newName) throws Exception {
	selectNode(node);

	final TreePath path = node.getTreePath();
	assertTrue(tree.isPathSelected(path));

	final GTreeNode nsNode = node;
	assertTrue(renameAction.isEnabledForContext(getSymbolTreeContext()));
	runSwing(() -> renameAction.actionPerformed(getSymbolTreeContext()));

	waitForTree();

	runSwing(() -> {
		int row = tree.getRowForPath(path);
		JTree jTree = (JTree) getInstanceField("tree", tree);
		DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
		Container container = (Container) cellEditor.getTreeCellEditorComponent(jTree, nsNode,
			true, true, true, row);
		JTextField textField = (JTextField) container.getComponent(0);

		textField.setText(newName);
		tree.stopEditing();
	});
	program.flushEvents();
	waitForSwing();
	waitForTree();
}
 
Example 14
Source Project: ghidra   Source File: FrontEndPluginActionsTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testNewFolderBlankName() throws Exception {
	// try entering a blank name
	final DockingActionIf newFolderAction = getAction("New Folder");
	setSelectionPaths(new TreePath[] { rootNode.getTreePath() });
	performAction(newFolderAction, getDomainFileActionContext(), true);
	waitForTree();
	SwingUtilities.invokeLater(() -> {
		GTreeNode node = rootNode.getChild("NewFolder");
		int row = tree.getRowForPath(node.getTreePath());
		DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
		JTree jTree = (JTree) getInstanceField("tree", tree);
		Container container = (Container) cellEditor.getTreeCellEditorComponent(jTree, node,
			true, true, false, row);
		JTextField textField = (JTextField) container.getComponent(0);

		textField.setText("");

		tree.stopEditing();
	});
	waitForSwing();

	OptionDialog d = waitForDialogComponent(OptionDialog.class);
	assertNotNull(d);
	assertEquals("Rename Failed", d.getTitle());
	pressButtonByText(d.getComponent(), "OK");
}
 
Example 15
Source Project: ghidra   Source File: FrontEndPluginActionsTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testRenameFolder() throws Exception {
	rootFolder.createFolder("myFolder");
	waitForSwing();

	final GTreeNode myNode = rootNode.getChild("myFolder");
	setSelectionPath(myNode.getTreePath());

	DockingActionIf renameAction = getAction("Rename");
	performAction(renameAction, getDomainFileActionContext(), true);
	waitForTree();

	// select "Rename" action
	SwingUtilities.invokeAndWait(() -> {
		int row = tree.getRowForPath(myNode.getTreePath());
		JTree jTree = (JTree) getInstanceField("tree", tree);
		DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
		Container container = (Container) cellEditor.getTreeCellEditorComponent(jTree, myNode,
			true, true, false, row);
		JTextField textField = (JTextField) container.getComponent(0);

		textField.setText("MyNewFolder");
		tree.stopEditing();
	});
	waitForSwing();
	assertNotNull(rootNode.getChild("MyNewFolder"));
	assertNull(rootNode.getChild("myFolder"));
}
 
Example 16
Source Project: TencentKona-8   Source File: SynthTreeUI.java    License: 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 Project: jdk8u60   Source File: SynthTreeUI.java    License: 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 18
Source Project: JDKSourceCode1.8   Source File: SynthTreeUI.java    License: 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 19
Source Project: openjdk-jdk8u   Source File: SynthTreeUI.java    License: 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 20
/**
 * {@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 Project: Bytecoder   Source File: SynthTreeUI.java    License: 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 22
Source Project: openjdk-jdk9   Source File: SynthTreeUI.java    License: 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 23
Source Project: jdk8u-jdk   Source File: SynthTreeUI.java    License: 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 24
Source Project: Java8CN   Source File: SynthTreeUI.java    License: 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 25
Source Project: hottub   Source File: SynthTreeUI.java    License: 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 26
Source Project: openjdk-8-source   Source File: SynthTreeUI.java    License: 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 27
Source Project: openjdk-8   Source File: SynthTreeUI.java    License: 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 28
Source Project: jdk8u_jdk   Source File: SynthTreeUI.java    License: 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 29
Source Project: mzmine2   Source File: ProjectTree.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 */
public ProjectTree() {

  ProjectTreeRenderer renderer = new ProjectTreeRenderer();
  setCellRenderer(renderer);

  DefaultTreeCellEditor editor =
      new DefaultTreeCellEditor(this, renderer, new ProjectTreeEditor(this));
  setCellEditor(editor);
  setEditable(true);
  setInvokesStopCellEditing(true);

  setRootVisible(true);
  setShowsRootHandles(false);

  setToggleClickCount(-1);

  // Activate drag&drop
  ProjectTreeDnDHandler dndHandler = new ProjectTreeDnDHandler();
  setTransferHandler(dndHandler);
  setDropMode(DropMode.INSERT);
  setDragEnabled(true);

  // Attach a handler for handling popup menus and double clicks
  ProjectTreeMouseHandler popupHandler = new ProjectTreeMouseHandler(this);
  addMouseListener(popupHandler);

}
 
Example 30
Source Project: jdk8u-jdk   Source File: SynthTreeUI.java    License: 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;
}