Search in sources :

Example 16 with JBTextField

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

the class KeyValuePane method updateUiFromCurrentObject.

/**
   * Updates the form UI objects to reflect the currently selected object. Clears the objects and disables them if there is no selected
   * object.
   */
public void updateUiFromCurrentObject() {
    myIsUpdating = true;
    for (Map.Entry<BuildFileKey, JComponent> entry : myProperties.entrySet()) {
        BuildFileKey key = entry.getKey();
        JComponent component = entry.getValue();
        Object value = myCurrentBuildFileObject != null ? myCurrentBuildFileObject.get(key) : null;
        final Object modelValue = myCurrentModelObject != null ? myCurrentModelObject.get(key) : null;
        switch(key.getType()) {
            case BOOLEAN:
                {
                    ComboBox comboBox = (ComboBox) component;
                    String text = formatDefaultValue(modelValue);
                    comboBox.removeItemAt(0);
                    comboBox.insertItemAt(text, 0);
                    JBTextField editorComponent = (JBTextField) comboBox.getEditor().getEditorComponent();
                    if (Boolean.FALSE.equals(value)) {
                        comboBox.setSelectedIndex(2);
                        editorComponent.setForeground(JBColor.BLACK);
                    } else if (Boolean.TRUE.equals(value)) {
                        comboBox.setSelectedIndex(1);
                        editorComponent.setForeground(JBColor.BLACK);
                    } else {
                        comboBox.setSelectedIndex(0);
                        editorComponent.setForeground(JBColor.GRAY);
                    }
                    break;
                }
            case FILE:
            case FILE_AS_STRING:
                {
                    TextFieldWithBrowseButton fieldWithButton = (TextFieldWithBrowseButton) component;
                    fieldWithButton.setText(value != null ? value.toString() : "");
                    JBTextField textField = (JBTextField) fieldWithButton.getTextField();
                    textField.getEmptyText().setText(formatDefaultValue(modelValue));
                    break;
                }
            case REFERENCE:
                {
                    String stringValue = (String) value;
                    if (hasKnownValues(key) && stringValue != null) {
                        stringValue = getMappedValue(myKeysWithKnownValues.get(key), stringValue);
                    }
                    String prefix = getReferencePrefix(key);
                    if (stringValue == null) {
                        stringValue = "";
                    } else if (stringValue.startsWith(prefix)) {
                        stringValue = stringValue.substring(prefix.length());
                    }
                    ComboBox comboBox = (ComboBox) component;
                    JBTextField textField = (JBTextField) comboBox.getEditor().getEditorComponent();
                    textField.getEmptyText().setText(formatDefaultValue(modelValue));
                    comboBox.setSelectedItem(stringValue);
                    break;
                }
            case CLOSURE:
                if (value instanceof List) {
                    value = Joiner.on(", ").join((List) value);
                }
            // Fall through to INTEGER/STRING/default case
            case INTEGER:
            case STRING:
            default:
                {
                    if (hasKnownValues(key)) {
                        if (value != null) {
                            value = getMappedValue(myKeysWithKnownValues.get(key), value.toString());
                        }
                        ComboBox comboBox = (ComboBox) component;
                        comboBox.setSelectedItem(value != null ? value.toString() : "");
                        JBTextField textField = (JBTextField) comboBox.getEditor().getEditorComponent();
                        textField.getEmptyText().setText(formatDefaultValue(modelValue));
                    } else {
                        JBTextField textField = (JBTextField) component;
                        textField.setText(value != null ? value.toString() : "");
                        textField.getEmptyText().setText(formatDefaultValue(modelValue));
                    }
                    break;
                }
        }
        component.setEnabled(myCurrentBuildFileObject != null);
    }
    myIsUpdating = false;
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) ComboBox(com.intellij.openapi.ui.ComboBox) JBTextField(com.intellij.ui.components.JBTextField) AndroidTargetHash.getAddonHashString(com.android.sdklib.AndroidTargetHash.getAddonHashString) BuildFileKey(com.android.tools.idea.gradle.parser.BuildFileKey)

Example 17 with JBTextField

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

the class ConfigureActivityStep method onEntering.

@Override
protected void onEntering() {
    // Verified by shouldSkip
    assert getModel().getTargetTemplate() != null;
    myRootPanel.removeAll();
    int row = 0;
    for (String param : getModel().getTargetTemplate().getParameters()) {
        myRootPanel.add(new JBLabel(param + ": "), new TabularLayout.Constraint(row, 0));
        JBTextField valueTextField = new JBTextField("Value" + (row + 1));
        valueTextField.putClientProperty("param", param);
        myRootPanel.add(valueTextField, new TabularLayout.Constraint(row, 1));
        if (row == 0) {
            myPreferredFocus = valueTextField;
        }
        row++;
    }
}
Also used : JBLabel(com.intellij.ui.components.JBLabel) TabularLayout(com.android.tools.adtui.TabularLayout) JBTextField(com.intellij.ui.components.JBTextField)

Example 18 with JBTextField

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

the class KarmaRunConfigurationEditor method createBrowsersTextField.

@NotNull
private static JTextField createBrowsersTextField() {
    JBTextField browsers = new JBTextField();
    StatusText emptyStatusText = browsers.getEmptyText();
    emptyStatusText.setText("comma-separated list of browsers (e.g. Chrome,ChromeCanary,Firefox)");
    return browsers;
}
Also used : JBTextField(com.intellij.ui.components.JBTextField) NotNull(org.jetbrains.annotations.NotNull)

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