Search in sources :

Example 1 with ComponentWithBrowseButton

use of com.intellij.openapi.ui.ComponentWithBrowseButton in project intellij-plugins by JetBrains.

the class CompilerOptionsConfigurable method createValueRenderer.

private TableCellRenderer createValueRenderer() {
    return new TableCellRenderer() {

        private final JLabel myLabel = new JLabel();

        private final JCheckBox myCheckBox = new JCheckBox();

        private final ComponentWithBrowseButton<JLabel> myLabelWithBrowse = new ComponentWithBrowseButton<>(new JLabel(), null);

        public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
            if (!(value instanceof CompilerOptionInfo)) {
                // invisible root node or group node
                myLabel.setText("");
                return myLabel;
            }
            final CompilerOptionInfo info = (CompilerOptionInfo) value;
            final Pair<String, ValueSource> valueAndSource = getValueAndSource(info);
            switch(info.TYPE) {
                case Boolean:
                    myCheckBox.setBackground(table.getBackground());
                    //myCheckBox.setForeground(UIUtil.getTableForeground());
                    //myCheckBox.setEnabled(moduleDefault || fromConfigFile || custom);
                    myCheckBox.setSelected("true".equalsIgnoreCase(valueAndSource.first));
                    return myCheckBox;
                case String:
                case Int:
                case List:
                case IncludeClasses:
                case IncludeFiles:
                    myLabel.setBackground(table.getBackground());
                    myLabel.setText(getPresentableSummary(valueAndSource.first, info));
                    renderAccordingToSource(myLabel, valueAndSource.second, false);
                    return myLabel;
                case File:
                    final JLabel label = myLabelWithBrowse.getChildComponent();
                    myLabelWithBrowse.setBackground(table.getBackground());
                    label.setText(FileUtil.toSystemDependentName(valueAndSource.first));
                    renderAccordingToSource(label, valueAndSource.second, false);
                    return myLabelWithBrowse;
                case Group:
                default:
                    assert false;
                    return null;
            }
        }
    };
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) CompilerOptionInfo(com.intellij.flex.model.bc.CompilerOptionInfo) ValueSource(com.intellij.flex.model.bc.ValueSource) ComponentWithBrowseButton(com.intellij.openapi.ui.ComponentWithBrowseButton)

Example 2 with ComponentWithBrowseButton

use of com.intellij.openapi.ui.ComponentWithBrowseButton in project ballerina by ballerina-lang.

the class BallerinaRunUtil method installFileChooser.

private static void installFileChooser(@NotNull Project project, @NotNull ComponentWithBrowseButton field, @Nullable Condition<VirtualFile> fileFilter) {
    FileChooserDescriptor chooseDirectoryDescriptor = FileChooserDescriptorFactory.createSingleFileDescriptor(BallerinaFileType.INSTANCE);
    chooseDirectoryDescriptor.setRoots(project.getBaseDir());
    chooseDirectoryDescriptor.setShowFileSystemRoots(false);
    chooseDirectoryDescriptor.withShowHiddenFiles(false);
    chooseDirectoryDescriptor.withFileFilter(fileFilter);
    if (field instanceof TextFieldWithBrowseButton) {
        ((TextFieldWithBrowseButton) field).addBrowseFolderListener(new TextBrowseFolderListener(chooseDirectoryDescriptor, project));
    } else {
        // noinspection unchecked
        field.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener(null, null, field, project, chooseDirectoryDescriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT));
    }
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ComponentWithBrowseButton(com.intellij.openapi.ui.ComponentWithBrowseButton) TextBrowseFolderListener(com.intellij.openapi.ui.TextBrowseFolderListener)

Example 3 with ComponentWithBrowseButton

use of com.intellij.openapi.ui.ComponentWithBrowseButton in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoRunUtil method installFileChooser.

public static void installFileChooser(@NotNull Project project, @NotNull 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 {
        // noinspection unchecked
        field.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener(null, null, field, project, chooseDirectoryDescriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT));
    }
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ComponentWithBrowseButton(com.intellij.openapi.ui.ComponentWithBrowseButton) TextBrowseFolderListener(com.intellij.openapi.ui.TextBrowseFolderListener)

Example 4 with ComponentWithBrowseButton

use of com.intellij.openapi.ui.ComponentWithBrowseButton in project intellij-community by JetBrains.

the class MavenEnvironmentForm method createUIComponents.

private void createUIComponents() {
    mavenHomeField = new TextFieldWithHistory();
    mavenHomeField.setHistorySize(-1);
    final ArrayList<String> foundMavenHomes = new ArrayList<>();
    foundMavenHomes.add(MavenServerManager.BUNDLED_MAVEN_2);
    foundMavenHomes.add(MavenServerManager.BUNDLED_MAVEN_3);
    final File mavenHomeDirectory = MavenUtil.resolveMavenHomeDirectory(null);
    if (mavenHomeDirectory != null) {
        foundMavenHomes.add(FileUtil.toSystemIndependentName(mavenHomeDirectory.getPath()));
    }
    mavenHomeField.setHistory(foundMavenHomes);
    mavenHomeComponent = LabeledComponent.create(new ComponentWithBrowseButton<>(mavenHomeField, null), "Maven &amp;home directory");
    final JBLabel versionLabel = new JBLabel();
    versionLabel.setOpaque(true);
    versionLabel.setVerticalAlignment(SwingConstants.TOP);
    versionLabel.setVerticalTextPosition(SwingConstants.TOP);
    mavenVersionLabelComponent = LabeledComponent.create(versionLabel, "");
}
Also used : JBLabel(com.intellij.ui.components.JBLabel) TextFieldWithHistory(com.intellij.ui.TextFieldWithHistory) ComponentWithBrowseButton(com.intellij.openapi.ui.ComponentWithBrowseButton) ArrayList(java.util.ArrayList) File(java.io.File)

Example 5 with ComponentWithBrowseButton

use of com.intellij.openapi.ui.ComponentWithBrowseButton in project intellij-community by JetBrains.

the class GenerateGetterSetterHandlerBase method getHeaderPanel.

protected static JComponent getHeaderPanel(final Project project, final TemplatesManager templatesManager, final String templatesTitle) {
    final JPanel panel = new JPanel(new BorderLayout());
    final JLabel templateChooserLabel = new JLabel(templatesTitle);
    panel.add(templateChooserLabel, BorderLayout.WEST);
    final ComboBox comboBox = new ComboBox();
    templateChooserLabel.setLabelFor(comboBox);
    comboBox.setRenderer(new ListCellRendererWrapper<TemplateResource>() {

        @Override
        public void customize(JList list, TemplateResource value, int index, boolean selected, boolean hasFocus) {
            setText(value.getName());
        }
    });
    final ComponentWithBrowseButton<ComboBox> comboBoxWithBrowseButton = new ComponentWithBrowseButton<>(comboBox, new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final TemplatesPanel ui = new TemplatesPanel(project, templatesManager) {

                @Override
                protected boolean onMultipleFields() {
                    return false;
                }

                @Nls
                @Override
                public String getDisplayName() {
                    return StringUtil.capitalizeWords(UIUtil.removeMnemonic(StringUtil.trimEnd(templatesTitle, ":")), true);
                }
            };
            ui.setHint("Visibility is applied according to File | Settings | Editor | Code Style | Java | Code Generation");
            ui.selectNodeInTree(templatesManager.getDefaultTemplate());
            if (ShowSettingsUtil.getInstance().editConfigurable(panel, ui)) {
                setComboboxModel(templatesManager, comboBox);
            }
        }
    });
    setComboboxModel(templatesManager, comboBox);
    comboBox.addActionListener(new ActionListener() {

        public void actionPerformed(@NotNull final ActionEvent M) {
            templatesManager.setDefaultTemplate((TemplateResource) comboBox.getSelectedItem());
        }
    });
    panel.add(comboBoxWithBrowseButton, BorderLayout.CENTER);
    return panel;
}
Also used : ComboBox(com.intellij.openapi.ui.ComboBox) ActionEvent(java.awt.event.ActionEvent) TemplatesPanel(org.jetbrains.java.generate.view.TemplatesPanel) ActionListener(java.awt.event.ActionListener) Nls(org.jetbrains.annotations.Nls) ComponentWithBrowseButton(com.intellij.openapi.ui.ComponentWithBrowseButton) TemplateResource(org.jetbrains.java.generate.template.TemplateResource)

Aggregations

ComponentWithBrowseButton (com.intellij.openapi.ui.ComponentWithBrowseButton)6 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)3 TextBrowseFolderListener (com.intellij.openapi.ui.TextBrowseFolderListener)3 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)3 CompilerOptionInfo (com.intellij.flex.model.bc.CompilerOptionInfo)1 ValueSource (com.intellij.flex.model.bc.ValueSource)1 ComboBox (com.intellij.openapi.ui.ComboBox)1 TextFieldWithHistory (com.intellij.ui.TextFieldWithHistory)1 JBLabel (com.intellij.ui.components.JBLabel)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 TableCellRenderer (javax.swing.table.TableCellRenderer)1 Nls (org.jetbrains.annotations.Nls)1 TemplateResource (org.jetbrains.java.generate.template.TemplateResource)1 TemplatesPanel (org.jetbrains.java.generate.view.TemplatesPanel)1