Example usage for com.intellij.openapi.ui TextBrowseFolderListener TextBrowseFolderListener

List of usage examples for com.intellij.openapi.ui TextBrowseFolderListener TextBrowseFolderListener

Introduction

In this page you can find the example usage for com.intellij.openapi.ui TextBrowseFolderListener TextBrowseFolderListener.

Prototype

public TextBrowseFolderListener(@NotNull FileChooserDescriptor fileChooserDescriptor) 

Source Link

Usage

From source file:com.android.tools.idea.gradle.eclipse.AdtImportLocationStep.java

License:Apache License

public AdtImportLocationStep(WizardContext context) {
    super(context);

    myDestinationLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));

    String prev = context.getProjectFileDirectory();
    mySourceProject = new File(FileUtil.toSystemDependentName(prev));

    String name = new File(prev).getName();
    //noinspection ConstantConditions
    context.setProjectFileDirectory(null);
    String defaultDir = context.getProjectFileDirectory();
    int index = 0;
    File file;//  w  ww.  j  a v  a  2s  .  c  o m
    do {
        String suffix = index == 0 ? "" : Integer.toString(index);
        index++;
        file = new File(defaultDir, name + suffix);
    } while (file.exists());
    myDestDirText.setText(file.getPath());
    context.setProjectFileDirectory(prev);

    FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    descriptor.setTitle("Choose Destination Directory");
    descriptor.setDescription("Pick a directory to import the given Eclipse Android project into");
    myDestDirText.addBrowseFolderListener(new TextBrowseFolderListener(descriptor) {
        @Override
        protected void onFileChosen(@NotNull VirtualFile chosenFile) {
            super.onFileChosen(chosenFile);
            myIsPathChangedByUser = true;
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            super.actionPerformed(e);
            myIsPathChangedByUser = true;
        }
    });
}

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  a2s .  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);
        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.npw.deprecated.ImportSourceLocationStep.java

License:Apache License

private void setupSourceLocationControls() {
    FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor();
    descriptor.setTitle("Select Source Location");
    descriptor.setDescription("Select existing ADT or Gradle project to import as a new subproject");
    mySourceLocation.addBrowseFolderListener(new TextBrowseFolderListener(descriptor));
    mySourceLocation.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
        @Override// w w w .  j  a va 2s .c  o  m
        protected void textChanged(DocumentEvent e) {
            invalidate();
        }
    });

    applyBackgroundOperationResult(checkPath(mySourceLocation.getText()));
    myErrorWarning.setIcon(null);
    myErrorWarning.setText(null);
}

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 ava2 s.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  w w w  . ja  v 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);
        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.android.tools.idea.wizard.ImportSourceLocationStep.java

License:Apache License

private void setupSourceLocationControls(@Nullable VirtualFile importSource) {
    if (importSource == null) {
        FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor();
        descriptor.setTitle("Select Source Location");
        descriptor.setDescription("Select existing ADT or Gradle project to import as a new subproject");
        mySourceLocation.addBrowseFolderListener(new TextBrowseFolderListener(descriptor));
        mySourceLocation.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
            @Override/*from  ww w. j  a va 2s  .c  o  m*/
            protected void textChanged(DocumentEvent e) {
                invalidate();
            }
        });
    } else {
        mySourceLocation.setVisible(false);
        myLocationLabel.setVisible(false);
        mySourceLocation.setText(importSource.getPath());
    }
    applyBackgroundOperationResult(checkPath(mySourceLocation.getText()));
    myErrorWarning.setIcon(null);
    myErrorWarning.setText(null);
}

From source file:com.microsoft.intellij.ui.JdkServerPanel.java

License:Open Source License

public void initForWizard() {
    jdkCheckBox.addItemListener(createJdkCheckBoxListener());
    jdkPath.addActionListener(UIUtils.createFileChooserListener(jdkPath, null,
            FileChooserDescriptorFactory.createSingleFolderDescriptor()));
    jdkPath.getTextField().getDocument().addDocumentListener(createJdkPathListener());
    uploadLocalJdk.addActionListener(createUploadLocalJdkListener());
    uploadLocalJdk.setSelected(true);/*from  w w  w . ja  v a2s .c o m*/
    jdkChkBoxUnChecked();
    serverPath.addBrowseFolderListener(
            new TextBrowseFolderListener(FileChooserDescriptorFactory.createSingleFolderDescriptor()) {
                protected void onFileChoosen(@NotNull VirtualFile chosenFile) {
                    super.onFileChosen(chosenFile);
                    serBrowseBtnListener();
                    modifySrvText(waRole, message("dlNtLblDirSrv"));
                    modified = true;
                }
            });
    serverCheckBox.addItemListener(createServerListener());
    serverCheckBox.setSelected(false);
    serverType.addItemListener(createServerTypeListener());
}

From source file:com.microsoft.intellij.ui.JdkServerPanel.java

License:Open Source License

private void initForPreference() {
    jdkPath.addFocusListener(createJdkPathPreferenceListener());
    jdkCheckBox.addItemListener(createJdkCheckBoxPreferenceListener());
    jdkPath.addBrowseFolderListener(//from  w  w  w  .j  a va  2 s  .c  o m
            new TextBrowseFolderListener(FileChooserDescriptorFactory.createSingleFolderDescriptor()) {
                protected void onFileChoosen(@NotNull VirtualFile chosenFile) {
                    String oldTxt = jdkPath.getText();
                    super.onFileChosen(chosenFile);
                    String directory = jdkPath.getText();
                    if (directory != null && !directory.equalsIgnoreCase(oldTxt)) {
                        modified = true;
                        modifyJdkText(waRole, message("dlNtLblDir"));
                    }
                }
            });
    serverPath.addFocusListener(createServerPathPreferenceListener());
    serverCheckBox.addItemListener(createServerPreferenceListener());
    serverType.addItemListener(createServerTypePreferenceListener());
    serverPath.addBrowseFolderListener(
            new TextBrowseFolderListener(FileChooserDescriptorFactory.createSingleFolderDescriptor()) {
                protected void onFileChoosen(@NotNull VirtualFile chosenFile) {
                    super.onFileChosen(chosenFile);
                    serBrowseBtnListener();
                    modifySrvText(waRole, message("dlNtLblDirSrv"));
                    enforceSameLocalCloudServer();
                    if (thrdPrtSrvBtn.isSelected()) {
                        String currentName = (String) thrdPrtSrvCmb.getSelectedItem();
                        if (!currentName.equalsIgnoreCase(srvPrevName)) {
                            srvAccepted = false;
                            srvPrevName = currentName;
                        }
                    }
                    modified = true;
                }
            });
    serverCheckBox.setSelected(false);
}

From source file:com.microsoftopentechnologies.intellij.ui.JdkServerPanel.java

License:Apache License

public void initForWizard() {
    jdkCheckBox.addItemListener(createJdkCheckBoxListener());
    jdkCheckBox.setSelected(true);/*from w  w  w  .  ja  va2s .c  o m*/
    jdkPath.addActionListener(UIUtils.createFileChooserListener(jdkPath, null,
            FileChooserDescriptorFactory.createSingleFolderDescriptor()));
    jdkPath.getTextField().getDocument().addDocumentListener(createJdkPathListener());
    serverPath.addBrowseFolderListener(
            new TextBrowseFolderListener(FileChooserDescriptorFactory.createSingleFolderDescriptor()) {
                protected void onFileChoosen(@NotNull VirtualFile chosenFile) {
                    super.onFileChoosen(chosenFile);
                    serBrowseBtnListener();
                    modifySrvText(waRole, message("dlNtLblDirSrv"));
                    modified = true;
                }
            });
    serverCheckBox.addItemListener(createServerListener());
    serverCheckBox.setSelected(false);
}

From source file:com.microsoftopentechnologies.intellij.ui.JdkServerPanel.java

License:Apache License

private void initForPreference() {
    jdkPath.addFocusListener(createJdkPathPreferenceListener());
    jdkCheckBox.addItemListener(createJdkCheckBoxPreferenceListener());
    jdkCheckBox.setSelected(true);/*from w  w  w  .j av a 2  s  . c o m*/
    jdkPath.addBrowseFolderListener(
            new TextBrowseFolderListener(FileChooserDescriptorFactory.createSingleFolderDescriptor()) {
                protected void onFileChoosen(@NotNull VirtualFile chosenFile) {
                    String oldTxt = jdkPath.getText();
                    super.onFileChoosen(chosenFile);
                    String directory = jdkPath.getText();
                    if (directory != null && !directory.equalsIgnoreCase(oldTxt)) {
                        setJDK(directory);
                        modified = true;
                        modifyJdkText(waRole, message("dlNtLblDir"));
                    }
                }
            });
    serverPath.addFocusListener(createServerPathPreferenceListener());
    serverCheckBox.addItemListener(createServerPreferenceListener());
    serverType.addItemListener(createServerTypePreferenceListener());
    serverPath.addBrowseFolderListener(
            new TextBrowseFolderListener(FileChooserDescriptorFactory.createSingleFolderDescriptor()) {
                protected void onFileChoosen(@NotNull VirtualFile chosenFile) {
                    super.onFileChoosen(chosenFile);
                    serBrowseBtnListener();
                    modifySrvText(waRole, message("dlNtLblDirSrv"));
                    modified = true;
                    /*
                    * Check server configured previously
                    * and now server name is changed.
                    */
                    if (serverPath.getText() != null) {
                        updateServer((String) serverType.getSelectedItem(), serverPath.getText(),
                                AzurePlugin.cmpntFile);
                    }
                }
            });
    serverCheckBox.setSelected(false);
}