Java 类javax.swing.tree.DefaultTreeCellEditor 实例源码

项目:cn1    文件:BasicTreeUITest.java   
public void testStartEditing() {
    assertFalse(ui.isEditing(tree));
    ui.startEditing(new TreePath(root), null);
    assertFalse(ui.isEditing(tree));
    tree.setEditable(true);
    assertFalse(ui.isEditing(tree));
    ui.startEditing(new TreePath(root), null);
    assertTrue(ui.isEditing(tree));
    ui.cancelEditing(tree);
    assertFalse(ui.isEditing(tree));
    tree.setCellEditor(new DefaultTreeCellEditor(tree, (DefaultTreeCellRenderer) tree
            .getCellRenderer()) {
        @Override
        public boolean shouldSelectCell(final EventObject event) {
            return false;
        }
    });
    ui.startEditing(new TreePath(root), null);
    assertTrue(ui.isEditing(tree));
}
项目:freeVM    文件:BasicTreeUITest.java   
public void testStartEditing() {
    assertFalse(ui.isEditing(tree));
    ui.startEditing(new TreePath(root), null);
    assertFalse(ui.isEditing(tree));
    tree.setEditable(true);
    assertFalse(ui.isEditing(tree));
    ui.startEditing(new TreePath(root), null);
    assertTrue(ui.isEditing(tree));
    ui.cancelEditing(tree);
    assertFalse(ui.isEditing(tree));
    tree.setCellEditor(new DefaultTreeCellEditor(tree, (DefaultTreeCellRenderer) tree
            .getCellRenderer()) {
        @Override
        public boolean shouldSelectCell(final EventObject event) {
            return false;
        }
    });
    ui.startEditing(new TreePath(root), null);
    assertTrue(ui.isEditing(tree));
}
项目:freeVM    文件:BasicTreeUITest.java   
public void testStartEditing() {
    assertFalse(ui.isEditing(tree));
    ui.startEditing(new TreePath(root), null);
    assertFalse(ui.isEditing(tree));
    tree.setEditable(true);
    assertFalse(ui.isEditing(tree));
    ui.startEditing(new TreePath(root), null);
    assertTrue(ui.isEditing(tree));
    ui.cancelEditing(tree);
    assertFalse(ui.isEditing(tree));
    tree.setCellEditor(new DefaultTreeCellEditor(tree, (DefaultTreeCellRenderer) tree
            .getCellRenderer()) {
        @Override
        public boolean shouldSelectCell(final EventObject event) {
            return false;
        }
    });
    ui.startEditing(new TreePath(root), null);
    assertTrue(ui.isEditing(tree));
}
项目:OpenJSharp    文件:SynthTreeUI.java   
/**
 * {@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;
}
项目:jdk8u-jdk    文件:SynthTreeUI.java   
/**
 * {@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;
}
项目:openjdk-jdk10    文件:SynthTreeUI.java   
/**
 * {@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;
}
项目:openjdk9    文件:SynthTreeUI.java   
/**
 * {@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;
}
项目:Java8CN    文件:SynthTreeUI.java   
/**
 * {@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;
}
项目:jdk8u_jdk    文件:SynthTreeUI.java   
/**
 * {@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;
}
项目:lookaside_java-1.8.0-openjdk    文件:SynthTreeUI.java   
/**
 * {@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;
}
项目:swingx    文件:JXTreeUnitTest.java   
/**
 * focus issues with popup in editors: tweak with 
 * custom cellEditorListener.
 *
 */
@Test
public void testEditorListenerRemovedOnEditorStopped() {
    JXTree tree = createEditingTree();
    DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
    // core doesn't remove the listener ... dooh
    cellEditor.stopCellEditing();
    // but we do ... 
    assertEquals(1, cellEditor.getCellEditorListeners().length);
}
项目:swingx    文件:JXTreeUnitTest.java   
/**
 * focus issues with popup in editors: tweak with 
 * custom cellEditorListener.
 *
 */
@Test
public void testEditorListenerRemovedOnEditorCancel() {
    JXTree tree = createEditingTree();
    DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
    // core doesn't remove the listener ... dooh
    cellEditor.cancelCellEditing();
    // but we do ... 
    assertEquals(1, cellEditor.getCellEditorListeners().length);
}
项目:swingx    文件:JXTreeUnitTest.java   
/**
 * focus issues with popup in editors: tweak with 
 * custom cellEditorListener.
 *
 */
@Test
public void testEditorListenerRemovedOnTreeCancel() {
    JXTree tree = createEditingTree();
    DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
    // core doesn't remove the listener ... dooh
    tree.cancelEditing();
    // but we do ... 
    assertEquals(1, cellEditor.getCellEditorListeners().length);
}
项目:swingx    文件:JXTreeUnitTest.java   
/**
 * focus issues with popup in editors: tweak with 
 * custom cellEditorListener.
 *
 */
@Test
public void testEditorListenerRemovedOnTreeStop() {
    JXTree tree = createEditingTree();
    DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
    // core doesn't remove the listener ... dooh
    tree.stopEditing();
    // but we do ... 
    assertEquals(1, cellEditor.getCellEditorListeners().length);
}
项目:swingx    文件:JXTreeUnitTest.java   
/**
 * focus issues with popup in editors: tweak with 
 * custom cellEditorListener.
 *
 */
@Test
public void testEditorListenerOnXTree() {
    JTree core = new JTree();
    int coreCount = getListenerCountAfterStartEditing(core);
    JXTree tree = createEditingTree();
    DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
    assertEquals("need one more listener than core", 
            coreCount + 1, cellEditor.getCellEditorListeners().length);
}
项目:swingx    文件:JXTreeUnitTest.java   
/**
 * characterization: listeners in core tree.
 *
 */
@Test
public void testEditorListenerOnCoreTree() {
    JTree tree = new JTree();
    int listenerCount = getListenerCountAfterStartEditing(tree);
    assertEquals(1, listenerCount);
    tree.stopEditing();
    // doesn't remove the listener ... dooh
    assertEquals(1, ((DefaultTreeCellEditor) tree.getCellEditor()).getCellEditorListeners().length);

}
项目:swingx    文件:JXTreeUnitTest.java   
/**
 * Starts editing on row 2 and returns the cell editor listener count after.
 * 
 * @param tree
 * @return
 */
private int getListenerCountAfterStartEditing(JTree tree) {
    tree.setEditable(true);
    // sanity
    assertTrue(tree.getRowCount() > 2);
    TreePath path = tree.getPathForRow(2);
    tree.startEditingAtPath(path);
    DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
    int listenerCount = cellEditor.getCellEditorListeners().length;
    return listenerCount;
}
项目:swingx    文件:JXTreeVisualCheck.java   
/**
 * visually check if invokesStopCellEditing jumps in on focusLost.
 *
 */
public void interactiveToggleEditProperties() {
    final JXTree table = new JXTree();
    table.setEditable(true);
    DefaultTreeCellEditor editor = new DefaultTreeCellEditor(null, null) {

        @Override
        public boolean stopCellEditing() {
            String value = String.valueOf(getCellEditorValue());
            if (value.startsWith("s")) {
                return false;
            }
            return super.stopCellEditing();
        }

    };
    table.setCellEditor(editor);
    JXFrame frame = wrapWithScrollingInFrame(table, new JButton("something to focus"), 
            "JXTree: toggle invokesStopEditing ");
    Action toggleTerminate = new AbstractAction("toggleInvokesStop") {

        public void actionPerformed(ActionEvent e) {
            table.setInvokesStopCellEditing(!table.getInvokesStopCellEditing());

        }

    };
    addAction(frame, toggleTerminate);
    frame.setVisible(true);

}
项目:swingx    文件:DatePickerCellEditorVisualCheck.java   
/**
 * visualize datepicker editing of the hierarchical column, both
 * in a tree and a xTree switching CO.
 *
 * standard editor
 */
public void interactiveTreeEditingRToLDatePicker() {
    TreeModel model = createTreeModelWithDates();
    JTree tree =  new JTree(model); 
    tree.setEditable(true);
    tree.setCellEditor(new DefaultTreeCellEditor(tree, null, new DatePickerCellEditor()));
    JXTree xTree = new JXTree(model);
    xTree.setEditable(true);
    xTree.setCellEditor(new DefaultTreeCellEditor(tree, null, new DatePickerCellEditor()));
    final JXFrame frame = wrapWithScrollingInFrame(tree, xTree, "standard Editing (DatePicker): compare tree and xtree");
    addComponentOrientationToggle(frame);
    show(frame);
}
项目:mzmine2    文件:ProjectTree.java   
/**
    * 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);

   }
项目:seaglass    文件:SeaGlassTreeUI.java   
/**
 * @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;
}
项目:infobip-open-jdk-8    文件:SynthTreeUI.java   
/**
 * {@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;
}
项目:jdk8u-dev-jdk    文件:SynthTreeUI.java   
/**
 * {@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;
}
项目:jdk7-jdk    文件:SynthTreeUI.java   
/**
 * @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;
}
项目:openjdk-source-code-learn    文件:SynthTreeUI.java   
/**
 * @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;
}
项目:OLD-OpenJDK8    文件:SynthTreeUI.java   
/**
 * {@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;
}
项目:cn1    文件:BasicTreeUI.java   
protected TreeCellEditor createDefaultCellEditor() {
    DefaultTreeCellRenderer renderer = currentCellRenderer instanceof DefaultTreeCellRenderer
        ? (DefaultTreeCellRenderer)currentCellRenderer
        : null;

    return new DefaultTreeCellEditor(tree, renderer);
}
项目:cn1    文件:JTreeTest.java   
public void testSetCellEditor() {
    PropertyChangeController listener = new PropertyChangeController();
    DefaultTreeCellEditor editor1 = new DefaultTreeCellEditor(tree,
            (DefaultTreeCellRenderer) tree.getCellRenderer());
    DefaultTreeCellEditor editor2 = new DefaultTreeCellEditor(tree,
            (DefaultTreeCellRenderer) tree.getCellRenderer());
    tree.addPropertyChangeListener(listener);
    TreeCellEditor oldEditor = tree.getCellEditor();
    tree.setCellEditor(editor1);
    listener.checkPropertyFired(tree, "cellEditor", oldEditor, editor1);
    assertEquals("cellEditor", editor1, tree.getCellEditor());
    tree.setEditable(true);
    listener.reset();
    tree.setCellEditor(editor2);
    listener.checkPropertyFired(tree, "cellEditor", editor1, editor2);
    assertEquals("cellEditor", editor2, tree.getCellEditor());
    assertTrue(tree.isEditable());
    listener.reset();
    tree.setCellEditor(editor2);
    assertFalse("event's not been fired ", listener.isChanged());
    listener.reset();
    tree.setCellEditor(null);
    listener.checkPropertyFired(tree, "cellEditor", editor2, null);
    // it's being controlled by UI via listener
    assertNotNull("cellEditor", tree.getCellEditor());
    assertNotSame("cellEditor", oldEditor, tree.getCellEditor());
    assertNotSame("cellEditor", editor2, tree.getCellEditor());
    assertTrue(tree.isEditable());
    listener.reset();
}
项目:cn1    文件:BasicTreeUITest.java   
public void testSetGetCellEditor() {
    assertNull(ui.getCellEditor());
    DefaultTreeCellEditor editor = new DefaultTreeCellEditor(tree,
            new DefaultTreeCellRenderer());
    tree.setCellEditor(editor);
    assertEquals(editor, ui.getCellEditor());
    ui.setCellEditor(new DefaultTreeCellEditor(tree, new DefaultTreeCellRenderer()));
    assertEquals(editor, ui.getCellEditor());
}
项目:cn1    文件:BasicTreeUITest.java   
public void testUpdateCellEditor() {
    DefaultTreeCellEditor e1 = new DefaultTreeCellEditor(tree,
            new DefaultTreeCellRenderer());
    tree.setCellEditor(e1);
    assertSame(e1, tree.getCellEditor());
    assertNull(ui.cellEditor);
    assertSame(e1, ui.getCellEditor());
    tree.setEditable(true);
    assertSame(e1, ui.cellEditor);
    assertSame(e1, ui.getCellEditor());
    DefaultTreeCellEditor e2 = new DefaultTreeCellEditor(tree,
            new DefaultTreeCellRenderer());
    ui.cellEditor = e2;
    assertSame(e1, ui.getCellEditor());
    assertSame(e2, ui.cellEditor);
    ui.updateCellEditor();
    assertSame(e1, ui.cellEditor);
    assertSame(e1, tree.getCellEditor());
    ui.cellEditor = null;
    assertFalse(ui.createdCellEditor);
    ui.createdCellEditor = true;
    assertTrue(ui.createdCellEditor);
    ui.updateCellEditor();
    assertFalse(ui.createdCellEditor);
    assertSame(e1, ui.cellEditor);
    assertSame(e1, tree.getCellEditor());
    tree.setCellRenderer(new DefaultTreeCellRenderer());
    assertFalse(ui.createdCellEditor);
    assertSame(e1, ui.cellEditor);
    assertSame(e1, tree.getCellEditor());
    ui.createdCellEditor = true;
    tree.setCellRenderer(new DefaultTreeCellRenderer());
    assertTrue(ui.createdCellEditor);
    assertNotSame(e1, ui.cellEditor);
    assertNotSame(e1, tree.getCellEditor());
}
项目:openjdk-jdk7u-jdk    文件:SynthTreeUI.java   
/**
 * @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;
}
项目:freeVM    文件:BasicTreeUI.java   
protected TreeCellEditor createDefaultCellEditor() {
    DefaultTreeCellRenderer renderer = currentCellRenderer instanceof DefaultTreeCellRenderer
        ? (DefaultTreeCellRenderer)currentCellRenderer
        : null;

    return new DefaultTreeCellEditor(tree, renderer);
}
项目:freeVM    文件:JTreeTest.java   
public void testSetCellEditor() {
    PropertyChangeController listener = new PropertyChangeController();
    DefaultTreeCellEditor editor1 = new DefaultTreeCellEditor(tree,
            (DefaultTreeCellRenderer) tree.getCellRenderer());
    DefaultTreeCellEditor editor2 = new DefaultTreeCellEditor(tree,
            (DefaultTreeCellRenderer) tree.getCellRenderer());
    tree.addPropertyChangeListener(listener);
    TreeCellEditor oldEditor = tree.getCellEditor();
    tree.setCellEditor(editor1);
    listener.checkPropertyFired(tree, "cellEditor", oldEditor, editor1);
    assertEquals("cellEditor", editor1, tree.getCellEditor());
    tree.setEditable(true);
    listener.reset();
    tree.setCellEditor(editor2);
    listener.checkPropertyFired(tree, "cellEditor", editor1, editor2);
    assertEquals("cellEditor", editor2, tree.getCellEditor());
    assertTrue(tree.isEditable());
    listener.reset();
    tree.setCellEditor(editor2);
    assertFalse("event's not been fired ", listener.isChanged());
    listener.reset();
    tree.setCellEditor(null);
    listener.checkPropertyFired(tree, "cellEditor", editor2, null);
    // it's being controlled by UI via listener
    assertNotNull("cellEditor", tree.getCellEditor());
    assertNotSame("cellEditor", oldEditor, tree.getCellEditor());
    assertNotSame("cellEditor", editor2, tree.getCellEditor());
    assertTrue(tree.isEditable());
    listener.reset();
}
项目:freeVM    文件:BasicTreeUITest.java   
public void testSetGetCellEditor() {
    assertNull(ui.getCellEditor());
    DefaultTreeCellEditor editor = new DefaultTreeCellEditor(tree,
            new DefaultTreeCellRenderer());
    tree.setCellEditor(editor);
    assertEquals(editor, ui.getCellEditor());
    ui.setCellEditor(new DefaultTreeCellEditor(tree, new DefaultTreeCellRenderer()));
    assertEquals(editor, ui.getCellEditor());
}
项目:freeVM    文件:BasicTreeUITest.java   
public void testUpdateCellEditor() {
    DefaultTreeCellEditor e1 = new DefaultTreeCellEditor(tree,
            new DefaultTreeCellRenderer());
    tree.setCellEditor(e1);
    assertSame(e1, tree.getCellEditor());
    assertNull(ui.cellEditor);
    assertSame(e1, ui.getCellEditor());
    tree.setEditable(true);
    assertSame(e1, ui.cellEditor);
    assertSame(e1, ui.getCellEditor());
    DefaultTreeCellEditor e2 = new DefaultTreeCellEditor(tree,
            new DefaultTreeCellRenderer());
    ui.cellEditor = e2;
    assertSame(e1, ui.getCellEditor());
    assertSame(e2, ui.cellEditor);
    ui.updateCellEditor();
    assertSame(e1, ui.cellEditor);
    assertSame(e1, tree.getCellEditor());
    ui.cellEditor = null;
    assertFalse(ui.createdCellEditor);
    ui.createdCellEditor = true;
    assertTrue(ui.createdCellEditor);
    ui.updateCellEditor();
    assertFalse(ui.createdCellEditor);
    assertSame(e1, ui.cellEditor);
    assertSame(e1, tree.getCellEditor());
    tree.setCellRenderer(new DefaultTreeCellRenderer());
    assertFalse(ui.createdCellEditor);
    assertSame(e1, ui.cellEditor);
    assertSame(e1, tree.getCellEditor());
    ui.createdCellEditor = true;
    tree.setCellRenderer(new DefaultTreeCellRenderer());
    assertTrue(ui.createdCellEditor);
    assertNotSame(e1, ui.cellEditor);
    assertNotSame(e1, tree.getCellEditor());
}
项目:freeVM    文件:BasicTreeUI.java   
protected TreeCellEditor createDefaultCellEditor() {
    DefaultTreeCellRenderer renderer = currentCellRenderer instanceof DefaultTreeCellRenderer
        ? (DefaultTreeCellRenderer)currentCellRenderer
        : null;

    return new DefaultTreeCellEditor(tree, renderer);
}
项目:freeVM    文件:JTreeTest.java   
public void testSetCellEditor() {
    PropertyChangeController listener = new PropertyChangeController();
    DefaultTreeCellEditor editor1 = new DefaultTreeCellEditor(tree,
            (DefaultTreeCellRenderer) tree.getCellRenderer());
    DefaultTreeCellEditor editor2 = new DefaultTreeCellEditor(tree,
            (DefaultTreeCellRenderer) tree.getCellRenderer());
    tree.addPropertyChangeListener(listener);
    TreeCellEditor oldEditor = tree.getCellEditor();
    tree.setCellEditor(editor1);
    listener.checkPropertyFired(tree, "cellEditor", oldEditor, editor1);
    assertEquals("cellEditor", editor1, tree.getCellEditor());
    tree.setEditable(true);
    listener.reset();
    tree.setCellEditor(editor2);
    listener.checkPropertyFired(tree, "cellEditor", editor1, editor2);
    assertEquals("cellEditor", editor2, tree.getCellEditor());
    assertTrue(tree.isEditable());
    listener.reset();
    tree.setCellEditor(editor2);
    assertFalse("event's not been fired ", listener.isChanged());
    listener.reset();
    tree.setCellEditor(null);
    listener.checkPropertyFired(tree, "cellEditor", editor2, null);
    // it's being controlled by UI via listener
    assertNotNull("cellEditor", tree.getCellEditor());
    assertNotSame("cellEditor", oldEditor, tree.getCellEditor());
    assertNotSame("cellEditor", editor2, tree.getCellEditor());
    assertTrue(tree.isEditable());
    listener.reset();
}
项目:freeVM    文件:BasicTreeUITest.java   
public void testSetGetCellEditor() {
    assertNull(ui.getCellEditor());
    DefaultTreeCellEditor editor = new DefaultTreeCellEditor(tree,
            new DefaultTreeCellRenderer());
    tree.setCellEditor(editor);
    assertEquals(editor, ui.getCellEditor());
    ui.setCellEditor(new DefaultTreeCellEditor(tree, new DefaultTreeCellRenderer()));
    assertEquals(editor, ui.getCellEditor());
}
项目:freeVM    文件:BasicTreeUITest.java   
public void testUpdateCellEditor() {
    DefaultTreeCellEditor e1 = new DefaultTreeCellEditor(tree,
            new DefaultTreeCellRenderer());
    tree.setCellEditor(e1);
    assertSame(e1, tree.getCellEditor());
    assertNull(ui.cellEditor);
    assertSame(e1, ui.getCellEditor());
    tree.setEditable(true);
    assertSame(e1, ui.cellEditor);
    assertSame(e1, ui.getCellEditor());
    DefaultTreeCellEditor e2 = new DefaultTreeCellEditor(tree,
            new DefaultTreeCellRenderer());
    ui.cellEditor = e2;
    assertSame(e1, ui.getCellEditor());
    assertSame(e2, ui.cellEditor);
    ui.updateCellEditor();
    assertSame(e1, ui.cellEditor);
    assertSame(e1, tree.getCellEditor());
    ui.cellEditor = null;
    assertFalse(ui.createdCellEditor);
    ui.createdCellEditor = true;
    assertTrue(ui.createdCellEditor);
    ui.updateCellEditor();
    assertFalse(ui.createdCellEditor);
    assertSame(e1, ui.cellEditor);
    assertSame(e1, tree.getCellEditor());
    tree.setCellRenderer(new DefaultTreeCellRenderer());
    assertFalse(ui.createdCellEditor);
    assertSame(e1, ui.cellEditor);
    assertSame(e1, tree.getCellEditor());
    ui.createdCellEditor = true;
    tree.setCellRenderer(new DefaultTreeCellRenderer());
    assertTrue(ui.createdCellEditor);
    assertNotSame(e1, ui.cellEditor);
    assertNotSame(e1, tree.getCellEditor());
}
项目:openjdk-icedtea7    文件:SynthTreeUI.java   
/**
 * @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;
}