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