Search in sources :

Example 6 with JBTextField

use of com.intellij.ui.components.JBTextField in project intellij-community by JetBrains.

the class JreComboboxEditor method createEditorComponent.

@Override
protected JTextField createEditorComponent() {
    JBTextField field = new JBTextField();
    field.setBorder(null);
    return field;
}
Also used : JBTextField(com.intellij.ui.components.JBTextField)

Example 7 with JBTextField

use of com.intellij.ui.components.JBTextField in project intellij-community by JetBrains.

the class ExternalDependenciesConfigurable method editPluginDependency.

@Nullable
private DependencyOnPlugin editPluginDependency(@NotNull JComponent parent, @NotNull final DependencyOnPlugin original) {
    List<String> pluginIds = new ArrayList<>(getPluginNameByIdMap().keySet());
    if (!original.getPluginId().isEmpty() && !pluginIds.contains(original.getPluginId())) {
        pluginIds.add(original.getPluginId());
    }
    Collections.sort(pluginIds, (o1, o2) -> getPluginNameById(o1).compareToIgnoreCase(getPluginNameById(o2)));
    final ComboBox pluginChooser = new ComboBox(ArrayUtilRt.toStringArray(pluginIds), 250);
    pluginChooser.setRenderer(new ListCellRendererWrapper<String>() {

        @Override
        public void customize(JList list, String value, int index, boolean selected, boolean hasFocus) {
            setText(getPluginNameById(value));
        }
    });
    new ComboboxSpeedSearch(pluginChooser) {

        @Override
        protected String getElementText(Object element) {
            return getPluginNameById((String) element);
        }
    };
    pluginChooser.setSelectedItem(original.getPluginId());
    final JBTextField minVersionField = new JBTextField(StringUtil.notNullize(original.getMinVersion()));
    final JBTextField maxVersionField = new JBTextField(StringUtil.notNullize(original.getMaxVersion()));
    final JBTextField channelField = new JBTextField(StringUtil.notNullize(original.getChannel()));
    minVersionField.getEmptyText().setText("<any>");
    minVersionField.setColumns(10);
    maxVersionField.getEmptyText().setText("<any>");
    maxVersionField.setColumns(10);
    channelField.setColumns(10);
    JPanel panel = FormBuilder.createFormBuilder().addLabeledComponent("Plugin:", pluginChooser).addLabeledComponent("Minimum version:", minVersionField).addLabeledComponent("Maximum version:", maxVersionField).addLabeledComponent("Channel:", channelField).getPanel();
    final DialogBuilder dialogBuilder = new DialogBuilder(parent).title("Required Plugin").centerPanel(panel);
    dialogBuilder.setPreferredFocusComponent(pluginChooser);
    pluginChooser.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialogBuilder.setOkActionEnabled(!StringUtil.isEmpty((String) pluginChooser.getSelectedItem()));
        }
    });
    if (dialogBuilder.show() == DialogWrapper.OK_EXIT_CODE) {
        return new DependencyOnPlugin(((String) pluginChooser.getSelectedItem()), StringUtil.nullize(minVersionField.getText().trim()), StringUtil.nullize(maxVersionField.getText().trim()), StringUtil.nullize(channelField.getText().trim()));
    }
    return null;
}
Also used : ComboBox(com.intellij.openapi.ui.ComboBox) ActionEvent(java.awt.event.ActionEvent) JBTextField(com.intellij.ui.components.JBTextField) DependencyOnPlugin(com.intellij.externalDependencies.DependencyOnPlugin) ActionListener(java.awt.event.ActionListener) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with JBTextField

use of com.intellij.ui.components.JBTextField in project intellij-community by JetBrains.

the class IdeaGradleSystemSettingsControlBuilder method fillUi.

@Override
public void fillUi(@NotNull PaintAwarePanel canvas, int indentLevel) {
    if (!dropOfflineModeBox) {
        myOfflineModeBox = new JBCheckBox(GradleBundle.message("gradle.settings.text.offline_work"));
        canvas.add(myOfflineModeBox, ExternalSystemUiUtil.getFillLineConstraints(indentLevel));
    }
    addServiceDirectoryControl(canvas, indentLevel);
    if (!dropVmOptions) {
        myGradleVmOptionsLabel = new JBLabel(GradleBundle.message("gradle.settings.text.vm.options"));
        canvas.add(myGradleVmOptionsLabel, ExternalSystemUiUtil.getLabelConstraints(indentLevel));
        myGradleVmOptionsField = new JBTextField();
        canvas.add(myGradleVmOptionsField, ExternalSystemUiUtil.getFillLineConstraints(indentLevel));
    }
}
Also used : JBLabel(com.intellij.ui.components.JBLabel) JBTextField(com.intellij.ui.components.JBTextField) JBCheckBox(com.intellij.ui.components.JBCheckBox)

Example 9 with JBTextField

use of com.intellij.ui.components.JBTextField in project android by JetBrains.

the class KeyValuePane method createComboBox.

private ComboBox createComboBox(boolean editable) {
    ComboBox comboBox = new ComboBox();
    comboBox.addItemListener(this);
    comboBox.setEditor(new FixedComboBoxEditor());
    comboBox.setEditable(true);
    // Default is only 20 chars
    comboBox.setMinLength(60);
    JBTextField editorComponent = (JBTextField) comboBox.getEditor().getEditorComponent();
    editorComponent.setEditable(editable);
    editorComponent.getDocument().addDocumentListener(this);
    return comboBox;
}
Also used : ComboBox(com.intellij.openapi.ui.ComboBox) JBTextField(com.intellij.ui.components.JBTextField) FixedComboBoxEditor(com.intellij.openapi.ui.FixedComboBoxEditor)

Example 10 with JBTextField

use of com.intellij.ui.components.JBTextField in project android by JetBrains.

the class KeyValuePane method updateCurrentObjectFromUi.

/**
   * Reads the state of the UI form objects and writes them into the currently selected object in the list, setting the dirty bit as
   * appropriate.
   */
private void updateCurrentObjectFromUi() {
    if (myIsUpdating || myCurrentBuildFileObject == null) {
        return;
    }
    for (Map.Entry<BuildFileKey, JComponent> entry : myProperties.entrySet()) {
        BuildFileKey key = entry.getKey();
        JComponent component = entry.getValue();
        Object currentValue = myCurrentBuildFileObject.get(key);
        Object newValue;
        BuildFileKeyType type = key.getType();
        switch(type) {
            case BOOLEAN:
                {
                    ComboBox comboBox = (ComboBox) component;
                    JBTextField editorComponent = (JBTextField) comboBox.getEditor().getEditorComponent();
                    int index = comboBox.getSelectedIndex();
                    if (index == 2) {
                        newValue = Boolean.FALSE;
                        editorComponent.setForeground(JBColor.BLACK);
                    } else if (index == 1) {
                        newValue = Boolean.TRUE;
                        editorComponent.setForeground(JBColor.BLACK);
                    } else {
                        newValue = null;
                        editorComponent.setForeground(JBColor.GRAY);
                    }
                    break;
                }
            case FILE:
            case FILE_AS_STRING:
                {
                    newValue = ((TextFieldWithBrowseButton) component).getText();
                    if ("".equals(newValue)) {
                        newValue = null;
                    }
                    if (newValue != null) {
                        newValue = new File(newValue.toString());
                    }
                    break;
                }
            case INTEGER:
                {
                    try {
                        if (hasKnownValues(key)) {
                            String newStringValue = ((ComboBox) component).getEditor().getItem().toString();
                            newStringValue = getMappedValue(myKeysWithKnownValues.get(key).inverse(), newStringValue);
                            newValue = Integer.valueOf(newStringValue);
                        } else {
                            newValue = Integer.valueOf(((JBTextField) component).getText());
                        }
                    } catch (Exception e) {
                        newValue = null;
                    }
                    break;
                }
            case REFERENCE:
                {
                    newValue = ((ComboBox) component).getEditor().getItem();
                    String newStringValue = (String) newValue;
                    if (hasKnownValues(key)) {
                        newStringValue = getMappedValue(myKeysWithKnownValues.get(key).inverse(), newStringValue);
                    }
                    if (newStringValue != null && newStringValue.isEmpty()) {
                        newStringValue = null;
                    }
                    String prefix = getReferencePrefix(key);
                    if (newStringValue != null && !newStringValue.startsWith(prefix)) {
                        newStringValue = prefix + newStringValue;
                    }
                    newValue = newStringValue;
                    break;
                }
            case CLOSURE:
            case STRING:
            default:
                {
                    if (hasKnownValues(key)) {
                        String newStringValue = ((ComboBox) component).getEditor().getItem().toString();
                        newStringValue = getMappedValue(myKeysWithKnownValues.get(key).inverse(), newStringValue);
                        if (newStringValue.isEmpty()) {
                            newStringValue = null;
                        }
                        newValue = newStringValue;
                    } else {
                        newValue = ((JBTextField) component).getText();
                        if ("".equals(newValue)) {
                            newValue = null;
                        }
                    }
                    if (type == BuildFileKeyType.CLOSURE && newValue != null) {
                        List newListValue = new ArrayList();
                        for (String s : Splitter.on(',').omitEmptyStrings().trimResults().split((String) newValue)) {
                            newListValue.add(key.getValueFactory().parse(s, myProject));
                        }
                        newValue = newListValue;
                    }
                    break;
                }
        }
        if (!Objects.equal(currentValue, newValue)) {
            if (newValue == null) {
                myCurrentBuildFileObject.remove(key);
            } else {
                myCurrentBuildFileObject.put(key, newValue);
            }
            if (GradleBuildFile.shouldWriteValue(currentValue, newValue)) {
                myListener.modified(key);
            }
        }
    }
}
Also used : ComboBox(com.intellij.openapi.ui.ComboBox) JBTextField(com.intellij.ui.components.JBTextField) AndroidTargetHash.getAddonHashString(com.android.sdklib.AndroidTargetHash.getAddonHashString) BuildFileKeyType(com.android.tools.idea.gradle.parser.BuildFileKeyType) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) BuildFileKey(com.android.tools.idea.gradle.parser.BuildFileKey) GradleBuildFile(com.android.tools.idea.gradle.parser.GradleBuildFile) File(java.io.File)

Aggregations

JBTextField (com.intellij.ui.components.JBTextField)18 ComboBox (com.intellij.openapi.ui.ComboBox)6 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)5 JBLabel (com.intellij.ui.components.JBLabel)4 NotNull (org.jetbrains.annotations.NotNull)4 AndroidTargetHash.getAddonHashString (com.android.sdklib.AndroidTargetHash.getAddonHashString)3 BuildFileKey (com.android.tools.idea.gradle.parser.BuildFileKey)3 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)3 DocumentAdapter (com.intellij.ui.DocumentAdapter)3 JBCheckBox (com.intellij.ui.components.JBCheckBox)3 DocumentEvent (javax.swing.event.DocumentEvent)3 DialogBuilder (com.intellij.openapi.ui.DialogBuilder)2 GridConstraints (com.intellij.uiDesigner.core.GridConstraints)2 GridLayoutManager (com.intellij.uiDesigner.core.GridLayoutManager)2 TabularLayout (com.android.tools.adtui.TabularLayout)1 BuildFileKeyType (com.android.tools.idea.gradle.parser.BuildFileKeyType)1 GradleBuildFile (com.android.tools.idea.gradle.parser.GradleBuildFile)1 PhoneGapTargets (com.github.masahirosuzuka.PhoneGapIntelliJPlugin.commandLine.PhoneGapTargets)1 EnvironmentVariablesTextFieldWithBrowseButton (com.intellij.execution.configuration.EnvironmentVariablesTextFieldWithBrowseButton)1 DependencyOnPlugin (com.intellij.externalDependencies.DependencyOnPlugin)1