Example usage for com.intellij.openapi.fileChooser FileChooserDescriptor setShowFileSystemRoots

List of usage examples for com.intellij.openapi.fileChooser FileChooserDescriptor setShowFileSystemRoots

Introduction

In this page you can find the example usage for com.intellij.openapi.fileChooser FileChooserDescriptor setShowFileSystemRoots.

Prototype

public void setShowFileSystemRoots(boolean showFileSystemRoots) 

Source Link

Usage

From source file:bazaar4idea.action.BzrInit.java

License:Apache License

@Override
public void actionPerformed(final AnActionEvent e) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    if (project == null) {
        project = ProjectManager.getInstance().getDefaultProject();
    }//from   w  ww  . jav a2 s . c  om
    FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    fcd.setShowFileSystemRoots(true);
    fcd.setTitle(BzrBundle.getString("init.destination.directory.title"));
    fcd.setDescription(BzrBundle.getString("init.destination.directory.description"));
    fcd.setHideIgnored(false);
    VirtualFile baseDir = e.getData(CommonDataKeys.VIRTUAL_FILE);
    if (baseDir == null) {
        baseDir = project.getBaseDir();
    }
    doInit(project, fcd, baseDir, baseDir);
}

From source file:com.android.tools.idea.gradle.structure.editors.KeyValuePane.java

License:Apache License

public void init(GradleBuildFile gradleBuildFile, Collection<BuildFileKey> properties) {
    GridLayoutManager layout = new GridLayoutManager(properties.size() + 1, 2);
    setLayout(layout);/*w w  w  . j av  a  2  s. c  o  m*/
    GridConstraints constraints = new GridConstraints();
    constraints.setAnchor(GridConstraints.ANCHOR_WEST);
    constraints.setVSizePolicy(GridConstraints.SIZEPOLICY_FIXED);
    for (BuildFileKey property : properties) {
        constraints.setColumn(0);
        constraints.setFill(GridConstraints.FILL_NONE);
        constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_FIXED);
        JBLabel label = new JBLabel(property.getDisplayName());
        add(label, constraints);
        constraints.setColumn(1);
        constraints.setFill(GridConstraints.FILL_HORIZONTAL);
        constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_WANT_GROW);
        JComponent component;
        switch (property.getType()) {
        case BOOLEAN: {
            constraints.setFill(GridConstraints.FILL_NONE);
            ComboBox comboBox = createComboBox(false);
            comboBox.addItem("");
            comboBox.addItem("true");
            comboBox.addItem("false");
            comboBox.setPrototypeDisplayValue("(false) ");
            component = comboBox;
            break;
        }
        case FILE:
        case FILE_AS_STRING: {
            JBTextField textField = new JBTextField();
            TextFieldWithBrowseButton fileField = new TextFieldWithBrowseButton(textField);
            FileChooserDescriptor d = new FileChooserDescriptor(true, false, false, true, false, false);
            d.setShowFileSystemRoots(true);
            fileField.addBrowseFolderListener(new TextBrowseFolderListener(d));
            fileField.getTextField().getDocument().addDocumentListener(this);
            component = fileField;
            break;
        }
        case REFERENCE: {
            constraints.setFill(GridConstraints.FILL_NONE);
            ComboBox comboBox = createComboBox(true);
            if (hasKnownValues(property)) {
                for (String s : myKeysWithKnownValues.get(property).values()) {
                    comboBox.addItem(s);
                }
            }
            // If there are no hardcoded values, the combo box's values will get populated later when the panel for the container reference
            // type wakes up and notifies us of its current values.
            component = comboBox;
            break;
        }
        case CLOSURE:
        case STRING:
        case INTEGER:
        default: {
            if (hasKnownValues(property)) {
                constraints.setFill(GridConstraints.FILL_NONE);
                ComboBox comboBox = createComboBox(true);
                for (String s : myKeysWithKnownValues.get(property).values()) {
                    comboBox.addItem(s);
                }
                component = comboBox;
            } else {
                JBTextField textField = new JBTextField();
                textField.getDocument().addDocumentListener(this);
                component = textField;
            }
            break;
        }
        }
        add(component, constraints);
        label.setLabelFor(component);
        myProperties.put(property, component);
        constraints.setRow(constraints.getRow() + 1);
    }
    constraints.setColumn(0);
    constraints.setVSizePolicy(GridConstraints.FILL_VERTICAL);
    constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_FIXED);
    add(new JBLabel(""), constraints);
    updateUiFromCurrentObject();
}

From source file:com.android.tools.idea.structure.gradle.KeyValuePane.java

License:Apache License

public void init(GradleBuildFile gradleBuildFile, Collection<BuildFileKey> properties) {
    GridLayoutManager layout = new GridLayoutManager(properties.size() + 1, 2);
    setLayout(layout);/*w  w  w  .j  a  va 2s.  c om*/
    GridConstraints constraints = new GridConstraints();
    constraints.setAnchor(GridConstraints.ANCHOR_WEST);
    constraints.setVSizePolicy(GridConstraints.SIZEPOLICY_FIXED);
    for (BuildFileKey property : properties) {
        constraints.setColumn(0);
        constraints.setFill(GridConstraints.FILL_NONE);
        constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_FIXED);
        JBLabel label = new JBLabel(property.getDisplayName());
        add(label, constraints);
        constraints.setColumn(1);
        constraints.setFill(GridConstraints.FILL_HORIZONTAL);
        constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_WANT_GROW);
        JComponent component;
        switch (property.getType()) {
        case BOOLEAN: {
            constraints.setFill(GridConstraints.FILL_NONE);
            ComboBox comboBox = getComboBox(false);
            comboBox.addItem("");
            comboBox.addItem("true");
            comboBox.addItem("false");
            comboBox.setPrototypeDisplayValue("(false) ");
            component = comboBox;
            break;
        }
        case FILE:
        case FILE_AS_STRING: {
            JBTextField textField = new JBTextField();
            TextFieldWithBrowseButton fileField = new TextFieldWithBrowseButton(textField);
            FileChooserDescriptor d = new FileChooserDescriptor(true, false, false, true, false, false);
            d.setShowFileSystemRoots(true);
            fileField.addBrowseFolderListener(new TextBrowseFolderListener(d));
            fileField.getTextField().getDocument().addDocumentListener(this);
            component = fileField;
            break;
        }
        case REFERENCE: {
            constraints.setFill(GridConstraints.FILL_NONE);
            ComboBox comboBox = getComboBox(true);
            if (hasKnownValues(property)) {
                for (String s : myKeysWithKnownValues.get(property).values()) {
                    comboBox.addItem(s);
                }
            }
            // If there are no hardcoded values, the combo box's values will get populated later when the panel for the container reference
            // type wakes up and notifies us of its current values.
            component = comboBox;
            break;
        }
        case CLOSURE:
        case STRING:
        case INTEGER:
        default: {
            if (hasKnownValues(property)) {
                constraints.setFill(GridConstraints.FILL_NONE);
                ComboBox comboBox = getComboBox(true);
                for (String s : myKeysWithKnownValues.get(property).values()) {
                    comboBox.addItem(s);
                }
                component = comboBox;
            } else {
                JBTextField textField = new JBTextField();
                textField.getDocument().addDocumentListener(this);
                component = textField;
            }
            break;
        }
        }
        add(component, constraints);
        label.setLabelFor(component);
        myProperties.put(property, component);
        constraints.setRow(constraints.getRow() + 1);
    }
    constraints.setColumn(0);
    constraints.setVSizePolicy(GridConstraints.FILL_VERTICAL);
    constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_FIXED);
    add(new JBLabel(""), constraints);
    updateUiFromCurrentObject();
}

From source file:com.android.tools.idea.structure.KeyValuePane.java

License:Apache License

public void init(GradleBuildFile gradleBuildFile, Collection<BuildFileKey> properties) {
    GridLayoutManager layout = new GridLayoutManager(properties.size() + 1, 2);
    setLayout(layout);//from  www.  j a v  a 2  s .co m
    GridConstraints constraints = new GridConstraints();
    constraints.setAnchor(GridConstraints.ANCHOR_WEST);
    constraints.setVSizePolicy(GridConstraints.SIZEPOLICY_FIXED);
    for (BuildFileKey property : properties) {
        constraints.setColumn(0);
        constraints.setFill(GridConstraints.FILL_NONE);
        constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_FIXED);
        add(new JBLabel(property.getDisplayName()), constraints);
        constraints.setColumn(1);
        constraints.setFill(GridConstraints.FILL_HORIZONTAL);
        constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_WANT_GROW);
        JComponent component;
        switch (property.getType()) {
        case BOOLEAN: {
            constraints.setFill(GridConstraints.FILL_NONE);
            ComboBox comboBox = getComboBox(false);
            comboBox.addItem("");
            comboBox.addItem("true");
            comboBox.addItem("false");
            comboBox.setPrototypeDisplayValue("(false) ");
            component = comboBox;
            break;
        }
        case FILE:
        case FILE_AS_STRING: {
            JBTextField textField = new JBTextField();
            TextFieldWithBrowseButton fileField = new TextFieldWithBrowseButton(textField);
            FileChooserDescriptor d = new FileChooserDescriptor(true, false, false, true, false, false);
            d.setShowFileSystemRoots(true);
            fileField.addBrowseFolderListener(new TextBrowseFolderListener(d));
            fileField.getTextField().getDocument().addDocumentListener(this);
            component = fileField;
            break;
        }
        case REFERENCE: {
            constraints.setFill(GridConstraints.FILL_NONE);
            ComboBox comboBox = getComboBox(true);
            if (hasKnownValues(property)) {
                for (String s : myKeysWithKnownValues.get(property).values()) {
                    comboBox.addItem(s);
                }
            }
            // If there are no hardcoded values, the combo box's values will get populated later when the panel for the container reference
            // type wakes up and notifies us of its current values.
            component = comboBox;
            break;
        }
        case CLOSURE:
        case STRING:
        case INTEGER:
        default: {
            if (hasKnownValues(property)) {
                constraints.setFill(GridConstraints.FILL_NONE);
                ComboBox comboBox = getComboBox(true);
                for (String s : myKeysWithKnownValues.get(property).values()) {
                    comboBox.addItem(s);
                }
                component = comboBox;
            } else {
                JBTextField textField = new JBTextField();
                textField.getDocument().addDocumentListener(this);
                component = textField;
            }
            break;
        }
        }
        add(component, constraints);
        myProperties.put(property, component);
        constraints.setRow(constraints.getRow() + 1);
    }
    constraints.setColumn(0);
    constraints.setVSizePolicy(GridConstraints.FILL_VERTICAL);
    constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_FIXED);
    add(new JBLabel(""), constraints);
    updateUiFromCurrentObject();
}

From source file:com.github.rholder.gradle.intellij.DependencyViewer.java

License:Apache License

private void promptForGradleBaseDir() {
    FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    fcd.setShowFileSystemRoots(true);
    fcd.setTitle("Choose a Gradle folder...");
    fcd.setDescription(//from w  w w . ja v  a  2s .c  om
            "Pick the top level directory to use when viewing dependencies (in case you have a multi-module project)");
    fcd.setHideIgnored(false);

    FileChooser.chooseFiles(fcd, project, project.getBaseDir(), new Consumer<List<VirtualFile>>() {
        @Override
        public void consume(List<VirtualFile> files) {
            gradleBaseDir = files.get(0).getPath();
        }
    });
}

From source file:com.goide.runconfig.GoRunUtil.java

License:Apache License

public static void installFileChooser(@Nonnull Project project, @Nonnull ComponentWithBrowseButton field,
        boolean directory, boolean showFileSystemRoots, @Nullable Condition<VirtualFile> fileFilter) {
    FileChooserDescriptor chooseDirectoryDescriptor = directory
            ? FileChooserDescriptorFactory.createSingleFolderDescriptor()
            : FileChooserDescriptorFactory.createSingleLocalFileDescriptor();
    chooseDirectoryDescriptor.setRoots(project.getBaseDir());
    chooseDirectoryDescriptor.setShowFileSystemRoots(showFileSystemRoots);
    chooseDirectoryDescriptor.withFileFilter(fileFilter);
    if (field instanceof TextFieldWithBrowseButton) {
        ((TextFieldWithBrowseButton) field)
                .addBrowseFolderListener(new TextBrowseFolderListener(chooseDirectoryDescriptor, project));
    } else {//from w  w w .ja  v  a 2  s  .  c om
        //noinspection unchecked
        field.addBrowseFolderListener(project,
                new ComponentWithBrowseButton.BrowseFolderActionListener(null, null, field, project,
                        chooseDirectoryDescriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT));
    }
}

From source file:com.google.cloud.tools.intellij.vcs.CloneCloudRepositoryDialog.java

License:Apache License

private void initComponents() {
    FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    fcd.setShowFileSystemRoots(true);
    fcd.setTitle(GctBundle.message("clonefromgcp.destination.directory.title"));
    fcd.setDescription(GctBundle.message("clonefromgcp.destination.directory.description"));
    fcd.setHideIgnored(false);/*www .  j ava2s. c  o m*/
    parentDirectory.addActionListener(new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(
            fcd.getTitle(), fcd.getDescription(), parentDirectory, project, fcd,
            TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {
        @Override
        protected VirtualFile getInitialFile() {
            String text = getComponentText();
            if (text.length() == 0) {
                VirtualFile file = project.getBaseDir();
                if (file != null) {
                    return file;
                }
            }
            return super.getInitialFile();
        }
    });

    final DocumentListener updateOkButtonListener = new DocumentAdapter() {
        @Override
        protected void textChanged(DocumentEvent event) {
            updateButtons();
        }
    };
    parentDirectory.getChildComponent().getDocument().addDocumentListener(updateOkButtonListener);
    parentDirectory.setText(ProjectUtil.getBaseDir());
    directoryName.getDocument().addDocumentListener(updateOkButtonListener);

    setOKActionEnabled(false);
}

From source file:com.google.gct.idea.git.CloneGcpDialog.java

License:Apache License

private void initComponents() {
    FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    fcd.setShowFileSystemRoots(true);
    fcd.setTitle(GctBundle.message("clonefromgcp.destination.directory.title"));
    fcd.setDescription(GctBundle.message("clonefromgcp.destination.directory.description"));
    fcd.setHideIgnored(false);//from  w ww.j ava2 s  . c  o m
    myParentDirectory.addActionListener(new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(
            fcd.getTitle(), fcd.getDescription(), myParentDirectory, myProject, fcd,
            TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {
        @Override
        protected VirtualFile getInitialFile() {
            String text = getComponentText();
            if (text.length() == 0) {
                VirtualFile file = myProject.getBaseDir();
                if (file != null) {
                    return file;
                }
            }
            return super.getInitialFile();
        }
    });

    final DocumentListener updateOkButtonListener = new DocumentAdapter() {
        @Override
        protected void textChanged(DocumentEvent e) {
            updateButtons();
        }
    };
    myParentDirectory.getChildComponent().getDocument().addDocumentListener(updateOkButtonListener);
    myParentDirectory.setText(ProjectUtil.getBaseDir());
    myDirectoryName.getDocument().addDocumentListener(updateOkButtonListener);

    setOKActionEnabled(false);
}

From source file:com.intellij.dvcs.ui.CloneDvcsDialog.java

License:Apache License

/**
 * Init components/* w ww.j a va 2 s .  c  o  m*/
 */
private void initListeners() {
    FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    fcd.setShowFileSystemRoots(true);
    fcd.setTitle(DvcsBundle.message("clone.destination.directory.title"));
    fcd.setDescription(DvcsBundle.message("clone.destination.directory.description"));
    fcd.setHideIgnored(false);
    myParentDirectory.addActionListener(new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(
            fcd.getTitle(), fcd.getDescription(), myParentDirectory, myProject, fcd,
            TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {
        @Override
        protected VirtualFile getInitialFile() {
            // suggest project base directory only if nothing is typed in the component.
            String text = getComponentText();
            if (text.length() == 0) {
                VirtualFile file = myProject.getBaseDir();
                if (file != null) {
                    return file;
                }
            }
            return super.getInitialFile();
        }
    });

    final DocumentListener updateOkButtonListener = new DocumentAdapter() {
        @Override
        protected void textChanged(DocumentEvent e) {
            updateButtons();
        }
    };
    myParentDirectory.getChildComponent().getDocument().addDocumentListener(updateOkButtonListener);
    String parentDir = getRememberedInputs().getCloneParentDir();
    if (StringUtil.isEmptyOrSpaces(parentDir)) {
        parentDir = ProjectUtil.getBaseDir();
    }
    myParentDirectory.setText(parentDir);

    myDirectoryName.getDocument().addDocumentListener(updateOkButtonListener);

    myTestButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            test();
        }
    });

    setOKActionEnabled(false);
    myTestButton.setEnabled(false);
}

From source file:com.intellij.ui.PathsChooserComponent.java

License:Apache License

public PathsChooserComponent(@NotNull final List<String> collection, @NotNull final PathProcessor processor,
        @Nullable final Project project) {
    myList = new JBList();
    myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    myInitialCollection = collection;/*from   ww w.  ja va  2 s .  com*/
    myProject = project;
    myWorkingCollection = new ArrayList<String>(myInitialCollection);
    myListModel = new DefaultListModel();
    myList.setModel(myListModel);

    myContentPane = ToolbarDecorator.createDecorator(myList).disableUpDownActions()
            .setAddAction(new AnActionButtonRunnable() {
                @Override
                public void run(AnActionButton button) {
                    final FileChooserDescriptor dirChooser = FileChooserDescriptorFactory
                            .createSingleFolderDescriptor();
                    dirChooser.setShowFileSystemRoots(true);
                    dirChooser.setHideIgnored(true);
                    dirChooser.setTitle(UIBundle.message("file.chooser.default.title"));
                    FileChooser.chooseFiles(dirChooser, myProject, null, new Consumer<List<VirtualFile>>() {
                        @Override
                        public void consume(List<VirtualFile> files) {
                            for (VirtualFile file : files) {
                                // adding to the end
                                final String path = file.getPath();
                                if (processor.addPath(myWorkingCollection, path)) {
                                    myListModel.addElement(path);
                                }
                            }
                        }
                    });
                }
            }).setRemoveAction(new AnActionButtonRunnable() {
                @Override
                public void run(AnActionButton button) {
                    int selected = myList.getSelectedIndex();
                    if (selected != -1) {
                        // removing index
                        final String path = (String) myListModel.get(selected);
                        if (processor.removePath(myWorkingCollection, path)) {
                            myListModel.remove(selected);
                        }
                    }
                }
            }).createPanel();

    // fill list
    reset();
}