Search in sources :

Example 1 with NewFolderAction

use of com.intellij.openapi.fileChooser.actions.NewFolderAction in project intellij-community by JetBrains.

the class ContentEntryTreeEditor method setContentEntryEditor.

/**
   * @param contentEntryEditor : null means to clear the editor
   */
public void setContentEntryEditor(final ContentEntryEditor contentEntryEditor) {
    if (myContentEntryEditor != null && myContentEntryEditor.equals(contentEntryEditor)) {
        return;
    }
    if (myFileSystemTree != null) {
        Disposer.dispose(myFileSystemTree);
        myFileSystemTree = null;
    }
    if (myContentEntryEditor != null) {
        myContentEntryEditor.removeContentEntryEditorListener(myContentEntryEditorListener);
        myContentEntryEditor = null;
    }
    if (contentEntryEditor == null) {
        ((DefaultTreeModel) myTree.getModel()).setRoot(EMPTY_TREE_ROOT);
        myTreePanel.setVisible(false);
        if (myFileSystemTree != null) {
            Disposer.dispose(myFileSystemTree);
        }
        return;
    }
    myTreePanel.setVisible(true);
    myContentEntryEditor = contentEntryEditor;
    myContentEntryEditor.addContentEntryEditorListener(myContentEntryEditorListener);
    final ContentEntry entry = contentEntryEditor.getContentEntry();
    assert entry != null : contentEntryEditor;
    final VirtualFile file = entry.getFile();
    if (file != null) {
        myDescriptor.setRoots(file);
    } else {
        String path = VfsUtilCore.urlToPath(entry.getUrl());
        myDescriptor.setTitle(FileUtil.toSystemDependentName(path));
    }
    final Runnable init = () -> {
        //noinspection ConstantConditions
        myFileSystemTree.updateTree();
        myFileSystemTree.select(file, null);
    };
    myFileSystemTree = new FileSystemTreeImpl(myProject, myDescriptor, myTree, getContentEntryCellRenderer(), init, null) {

        @Override
        protected AbstractTreeBuilder createTreeBuilder(JTree tree, DefaultTreeModel treeModel, AbstractTreeStructure treeStructure, Comparator<NodeDescriptor> comparator, FileChooserDescriptor descriptor, final Runnable onInitialized) {
            return new MyFileTreeBuilder(tree, treeModel, treeStructure, comparator, descriptor, onInitialized);
        }
    };
    myFileSystemTree.showHiddens(true);
    Disposer.register(myProject, myFileSystemTree);
    final NewFolderAction newFolderAction = new MyNewFolderAction();
    final DefaultActionGroup mousePopupGroup = new DefaultActionGroup();
    mousePopupGroup.add(myEditingActionsGroup);
    mousePopupGroup.addSeparator();
    mousePopupGroup.add(newFolderAction);
    myFileSystemTree.registerMouseListener(mousePopupGroup);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) AbstractTreeBuilder(com.intellij.ide.util.treeView.AbstractTreeBuilder) NodeDescriptor(com.intellij.ide.util.treeView.NodeDescriptor) FileSystemTreeImpl(com.intellij.openapi.fileChooser.ex.FileSystemTreeImpl) NewFolderAction(com.intellij.openapi.fileChooser.actions.NewFolderAction) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) ContentEntry(com.intellij.openapi.roots.ContentEntry) AbstractTreeStructure(com.intellij.ide.util.treeView.AbstractTreeStructure)

Aggregations

AbstractTreeBuilder (com.intellij.ide.util.treeView.AbstractTreeBuilder)1 AbstractTreeStructure (com.intellij.ide.util.treeView.AbstractTreeStructure)1 NodeDescriptor (com.intellij.ide.util.treeView.NodeDescriptor)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 NewFolderAction (com.intellij.openapi.fileChooser.actions.NewFolderAction)1 FileSystemTreeImpl (com.intellij.openapi.fileChooser.ex.FileSystemTreeImpl)1 ContentEntry (com.intellij.openapi.roots.ContentEntry)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1