java类javax.swing.tree.TreeCellEditor的实例源码

TreeView.java 文件源码 项目:incubator-netbeans 阅读 27 收藏 0 点赞 0 评论 0
/** 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);
        }
    });
}
BasicTreeUI.java 文件源码 项目:javify 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Uninstall all registered listeners
 */
protected void uninstallListeners()
{
  tree.removePropertyChangeListener(propertyChangeListener);
  tree.removeFocusListener(focusListener);
  tree.removeTreeSelectionListener(treeSelectionListener);
  tree.removeMouseListener(mouseListener);
  tree.removeKeyListener(keyListener);
  tree.removePropertyChangeListener(selectionModelPropertyChangeListener);
  tree.removeComponentListener(componentListener);
  tree.removeTreeExpansionListener(treeExpansionListener);

  TreeCellEditor tce = tree.getCellEditor();
  if (tce != null)
    tce.removeCellEditorListener(cellEditorListener);
  if (treeModel != null)
    treeModel.removeTreeModelListener(treeModelListener);
}
BasicTreeUI.java 文件源码 项目:jvm-stm 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Uninstall all registered listeners
 */
protected void uninstallListeners()
{
  tree.removePropertyChangeListener(propertyChangeListener);
  tree.removeFocusListener(focusListener);
  tree.removeTreeSelectionListener(treeSelectionListener);
  tree.removeMouseListener(mouseListener);
  tree.removeKeyListener(keyListener);
  tree.removePropertyChangeListener(selectionModelPropertyChangeListener);
  tree.removeComponentListener(componentListener);
  tree.removeTreeExpansionListener(treeExpansionListener);

  TreeCellEditor tce = tree.getCellEditor();
  if (tce != null)
    tce.removeCellEditorListener(cellEditorListener);
  if (treeModel != null)
    treeModel.removeTreeModelListener(treeModelListener);
}
BasicTreeUI.java 文件源码 项目:cn1 阅读 21 收藏 0 点赞 0 评论 0
public void propertyChange(final PropertyChangeEvent e) {
    String changedProperty = e.getPropertyName();
    if (JTree.CELL_RENDERER_PROPERTY.equals(changedProperty)) {
        setCellRenderer((TreeCellRenderer)e.getNewValue());
    } else if (JTree.CELL_EDITOR_PROPERTY.equals(changedProperty)) {
        setCellEditor((TreeCellEditor)e.getNewValue());
    } else if (JTree.TREE_MODEL_PROPERTY.equals(changedProperty)) {
        setModel((TreeModel)e.getNewValue());
    } else if (JTree.ROOT_VISIBLE_PROPERTY.equals(changedProperty)) {
        setRootVisible(((Boolean)e.getNewValue()).booleanValue());
    } else if (JTree.SHOWS_ROOT_HANDLES_PROPERTY.equals(changedProperty)) {
        setShowsRootHandles(((Boolean)e.getNewValue()).booleanValue());
    } else if (JTree.ROW_HEIGHT_PROPERTY.equals(changedProperty)) {
        setRowHeight(((Integer)e.getNewValue()).intValue());
    } else if (JTree.EDITABLE_PROPERTY.equals(changedProperty)) {
        setEditable(((Boolean)e.getNewValue()).booleanValue());
    } else if (JTree.LARGE_MODEL_PROPERTY.equals(changedProperty)) {
        setLargeModel(((Boolean)e.getNewValue()).booleanValue());
    } else if (JTree.SELECTION_MODEL_PROPERTY.equals(changedProperty)) {
        setSelectionModel((TreeSelectionModel)e.getNewValue());
    } else if (JTree.LEAD_SELECTION_PATH_PROPERTY.equals(changedProperty)) {
        TreePath leadPath = (TreePath)e.getNewValue();
        lastSelectedRow = leadPath != null ? tree.getRowForPath(leadPath) : -1;
    }
}
BasicTreeUI.java 文件源码 项目:JamVM-PH 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Uninstall all registered listeners
 */
protected void uninstallListeners()
{
  tree.removePropertyChangeListener(propertyChangeListener);
  tree.removeFocusListener(focusListener);
  tree.removeTreeSelectionListener(treeSelectionListener);
  tree.removeMouseListener(mouseListener);
  tree.removeKeyListener(keyListener);
  tree.removePropertyChangeListener(selectionModelPropertyChangeListener);
  tree.removeComponentListener(componentListener);
  tree.removeTreeExpansionListener(treeExpansionListener);

  TreeCellEditor tce = tree.getCellEditor();
  if (tce != null)
    tce.removeCellEditorListener(cellEditorListener);
  if (treeModel != null)
    treeModel.removeTreeModelListener(treeModelListener);
}
BasicTreeUI.java 文件源码 项目:classpath 阅读 22 收藏 0 点赞 0 评论 0
/**
 * Uninstall all registered listeners
 */
protected void uninstallListeners()
{
  tree.removePropertyChangeListener(propertyChangeListener);
  tree.removeFocusListener(focusListener);
  tree.removeTreeSelectionListener(treeSelectionListener);
  tree.removeMouseListener(mouseListener);
  tree.removeKeyListener(keyListener);
  tree.removePropertyChangeListener(selectionModelPropertyChangeListener);
  tree.removeComponentListener(componentListener);
  tree.removeTreeExpansionListener(treeExpansionListener);

  TreeCellEditor tce = tree.getCellEditor();
  if (tce != null)
    tce.removeCellEditorListener(cellEditorListener);
  if (treeModel != null)
    treeModel.removeTreeModelListener(treeModelListener);
}
BasicTreeUI.java 文件源码 项目:freeVM 阅读 27 收藏 0 点赞 0 评论 0
public void propertyChange(final PropertyChangeEvent e) {
    String changedProperty = e.getPropertyName();
    if (JTree.CELL_RENDERER_PROPERTY.equals(changedProperty)) {
        setCellRenderer((TreeCellRenderer)e.getNewValue());
    } else if (JTree.CELL_EDITOR_PROPERTY.equals(changedProperty)) {
        setCellEditor((TreeCellEditor)e.getNewValue());
    } else if (JTree.TREE_MODEL_PROPERTY.equals(changedProperty)) {
        setModel((TreeModel)e.getNewValue());
    } else if (JTree.ROOT_VISIBLE_PROPERTY.equals(changedProperty)) {
        setRootVisible(((Boolean)e.getNewValue()).booleanValue());
    } else if (JTree.SHOWS_ROOT_HANDLES_PROPERTY.equals(changedProperty)) {
        setShowsRootHandles(((Boolean)e.getNewValue()).booleanValue());
    } else if (JTree.ROW_HEIGHT_PROPERTY.equals(changedProperty)) {
        setRowHeight(((Integer)e.getNewValue()).intValue());
    } else if (JTree.EDITABLE_PROPERTY.equals(changedProperty)) {
        setEditable(((Boolean)e.getNewValue()).booleanValue());
    } else if (JTree.LARGE_MODEL_PROPERTY.equals(changedProperty)) {
        setLargeModel(((Boolean)e.getNewValue()).booleanValue());
    } else if (JTree.SELECTION_MODEL_PROPERTY.equals(changedProperty)) {
        setSelectionModel((TreeSelectionModel)e.getNewValue());
    } else if (JTree.LEAD_SELECTION_PATH_PROPERTY.equals(changedProperty)) {
        TreePath leadPath = (TreePath)e.getNewValue();
        lastSelectedRow = leadPath != null ? tree.getRowForPath(leadPath) : -1;
    }
}
BasicTreeUI.java 文件源码 项目:freeVM 阅读 21 收藏 0 点赞 0 评论 0
public void propertyChange(final PropertyChangeEvent e) {
    String changedProperty = e.getPropertyName();
    if (JTree.CELL_RENDERER_PROPERTY.equals(changedProperty)) {
        setCellRenderer((TreeCellRenderer)e.getNewValue());
    } else if (JTree.CELL_EDITOR_PROPERTY.equals(changedProperty)) {
        setCellEditor((TreeCellEditor)e.getNewValue());
    } else if (JTree.TREE_MODEL_PROPERTY.equals(changedProperty)) {
        setModel((TreeModel)e.getNewValue());
    } else if (JTree.ROOT_VISIBLE_PROPERTY.equals(changedProperty)) {
        setRootVisible(((Boolean)e.getNewValue()).booleanValue());
    } else if (JTree.SHOWS_ROOT_HANDLES_PROPERTY.equals(changedProperty)) {
        setShowsRootHandles(((Boolean)e.getNewValue()).booleanValue());
    } else if (JTree.ROW_HEIGHT_PROPERTY.equals(changedProperty)) {
        setRowHeight(((Integer)e.getNewValue()).intValue());
    } else if (JTree.EDITABLE_PROPERTY.equals(changedProperty)) {
        setEditable(((Boolean)e.getNewValue()).booleanValue());
    } else if (JTree.LARGE_MODEL_PROPERTY.equals(changedProperty)) {
        setLargeModel(((Boolean)e.getNewValue()).booleanValue());
    } else if (JTree.SELECTION_MODEL_PROPERTY.equals(changedProperty)) {
        setSelectionModel((TreeSelectionModel)e.getNewValue());
    } else if (JTree.LEAD_SELECTION_PATH_PROPERTY.equals(changedProperty)) {
        TreePath leadPath = (TreePath)e.getNewValue();
        lastSelectedRow = leadPath != null ? tree.getRowForPath(leadPath) : -1;
    }
}
TreeViewCellEditor.java 文件源码 项目:incubator-netbeans 阅读 18 收藏 0 点赞 0 评论 0
/**
 * This is invoked if a TreeCellEditor is not supplied in the constructor.
 * It returns a TextField editor.
 */
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
            @Override
            public void addNotify() {
                stopped = cancelled = false;
                super.addNotify();
                requestFocus();
            }
        };
    //#137454 - text not visible in in-place editor
    String laf = UIManager.getLookAndFeel().getID();
    if( "GTK".equals( laf ) ) { //NOI18N
        tf.setBorder( BorderFactory.createEmptyBorder() );
    } else if( "Nimbus".equals( laf ) ) { //NOI18N
        tf.setBorder( BorderFactory.createLineBorder( new JTree().getBackground() ) );
    }
    tf.registerKeyboardAction( //TODO update to use inputMap/actionMap
        this, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, true), JComponent.WHEN_FOCUSED);

    tf.addFocusListener(this);

    Ed ed = new Ed(tf);
    ed.setClickCountToStart(1);
    ed.getComponent().getAccessibleContext().setAccessibleDescription(
        NbBundle.getMessage(TreeViewCellEditor.class, "ACSD_TreeViewCellEditor")
    ); // NOI18N
    ed.getComponent().getAccessibleContext().setAccessibleName(
        NbBundle.getMessage(TreeViewCellEditor.class, "ACSN_TreeViewCellEditor")
    ); // NOI18N

    return ed;
}
SynthTreeUI.java 文件源码 项目:OpenJSharp 阅读 26 收藏 0 点赞 0 评论 0
/**
 * {@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;
}
SynthTreeUI.java 文件源码 项目:OpenJSharp 阅读 17 收藏 0 点赞 0 评论 0
@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;
}
SynthTreeUI.java 文件源码 项目:jdk8u-jdk 阅读 25 收藏 0 点赞 0 评论 0
/**
 * {@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;
}
SynthTreeUI.java 文件源码 项目:jdk8u-jdk 阅读 29 收藏 0 点赞 0 评论 0
@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;
}
SynthTreeUI.java 文件源码 项目:openjdk-jdk10 阅读 19 收藏 0 点赞 0 评论 0
/**
 * {@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;
}
SynthTreeUI.java 文件源码 项目:openjdk-jdk10 阅读 24 收藏 0 点赞 0 评论 0
@Override
protected TreeCellEditor createTreeCellEditor() {
    @SuppressWarnings("serial") // anonymous class
    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;
}
JTreeOperator.java 文件源码 项目:openjdk-jdk10 阅读 21 收藏 0 点赞 0 评论 0
/**
 * Maps {@code JTree.getCellEditor()} through queue
 */
public TreeCellEditor getCellEditor() {
    return (runMapping(new MapAction<TreeCellEditor>("getCellEditor") {
        @Override
        public TreeCellEditor map() {
            return ((JTree) getSource()).getCellEditor();
        }
    }));
}
JTreeOperator.java 文件源码 项目:openjdk-jdk10 阅读 21 收藏 0 点赞 0 评论 0
/**
 * Maps {@code JTree.setCellEditor(TreeCellEditor)} through queue
 */
public void setCellEditor(final TreeCellEditor treeCellEditor) {
    runMapping(new MapVoidAction("setCellEditor") {
        @Override
        public void map() {
            ((JTree) getSource()).setCellEditor(treeCellEditor);
        }
    });
}
SynthTreeUI.java 文件源码 项目:openjdk9 阅读 25 收藏 0 点赞 0 评论 0
/**
 * {@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;
}
SynthTreeUI.java 文件源码 项目:openjdk9 阅读 29 收藏 0 点赞 0 评论 0
@Override
protected TreeCellEditor createTreeCellEditor() {
    @SuppressWarnings("serial") // anonymous class
    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;
}
JTreeOperator.java 文件源码 项目:openjdk9 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Maps {@code JTree.getCellEditor()} through queue
 */
public TreeCellEditor getCellEditor() {
    return (runMapping(new MapAction<TreeCellEditor>("getCellEditor") {
        @Override
        public TreeCellEditor map() {
            return ((JTree) getSource()).getCellEditor();
        }
    }));
}
JTreeOperator.java 文件源码 项目:openjdk9 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Maps {@code JTree.setCellEditor(TreeCellEditor)} through queue
 */
public void setCellEditor(final TreeCellEditor treeCellEditor) {
    runMapping(new MapVoidAction("setCellEditor") {
        @Override
        public void map() {
            ((JTree) getSource()).setCellEditor(treeCellEditor);
        }
    });
}
SynthTreeUI.java 文件源码 项目:Java8CN 阅读 23 收藏 0 点赞 0 评论 0
/**
 * {@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;
}
SynthTreeUI.java 文件源码 项目:Java8CN 阅读 20 收藏 0 点赞 0 评论 0
@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;
}
SynthTreeUI.java 文件源码 项目:jdk8u_jdk 阅读 25 收藏 0 点赞 0 评论 0
/**
 * {@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;
}
SynthTreeUI.java 文件源码 项目:jdk8u_jdk 阅读 18 收藏 0 点赞 0 评论 0
@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;
}
SynthTreeUI.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 17 收藏 0 点赞 0 评论 0
/**
 * {@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;
}
SynthTreeUI.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 22 收藏 0 点赞 0 评论 0
@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;
}
JTree.java 文件源码 项目:javify 阅读 25 收藏 0 点赞 0 评论 0
public void setCellEditor(TreeCellEditor editor)
{
  if (cellEditor == editor)
    return;

  TreeCellEditor oldValue = cellEditor;
  cellEditor = editor;
  firePropertyChange(CELL_EDITOR_PROPERTY, oldValue, editor);
}
BasicTreeUI.java 文件源码 项目:javify 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Updates the cellEditor based on editability of the JTree that we're
 * contained in. If the tree is editable but doesn't have a cellEditor, a
 * basic one will be used.
 */
protected void updateCellEditor()
{
  completeEditing();
  TreeCellEditor newEd = null;
  if (tree != null && tree.isEditable())
    {
      newEd = tree.getCellEditor();
      if (newEd == null)
        {
          newEd = createDefaultCellEditor();
          if (newEd != null)
            {
              tree.setCellEditor(newEd);
              createdCellEditor = true;
            }
        }
    }
  // Update listeners.
  if (newEd != cellEditor)
    {
      if (cellEditor != null && cellEditorListener != null)
        cellEditor.removeCellEditorListener(cellEditorListener);
      cellEditor = newEd;
      if (cellEditorListener == null)
        cellEditorListener = createCellEditorListener();
      if (cellEditor != null && cellEditorListener != null)
        cellEditor.addCellEditorListener(cellEditorListener);
      createdCellEditor = false;
    }
}
NewErrorTreeEditor.java 文件源码 项目:intellij-ce-playground 阅读 24 收藏 0 点赞 0 评论 0
@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);
}


问题


面经


文章

微信
公众号

扫码关注公众号