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;
}
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++;
}
}
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;
}
Aggregations