use of com.intellij.openapi.ui.TextFieldWithBrowseButton in project android by JetBrains.
the class TemplateWizardStep method refreshUiFromParameters.
public void refreshUiFromParameters() {
if (myTemplateState.myTemplate == null) {
return;
}
for (Parameter param : myTemplateState.myTemplate.getMetadata().getParameters()) {
if (param.initial != null && !myTemplateState.myModified.contains(param.id)) {
myTemplateState.myParameters.remove(param.id);
}
}
myTemplateState.setParameterDefaults();
Template.convertApisToInt(myTemplateState.getParameters());
boolean oldIgnoreUpdates = myIgnoreUpdates;
try {
myIgnoreUpdates = true;
for (String paramName : myParamFields.keySet()) {
if (myTemplateState.myHidden.contains(paramName)) {
continue;
}
JComponent component = myParamFields.get(paramName);
Object value = myTemplateState.get(paramName);
if (value == null) {
continue;
}
if (component instanceof JCheckBox) {
((JCheckBox) component).setSelected(Boolean.parseBoolean(value.toString()));
} else if (component instanceof JComboBox) {
for (int i = 0; i < ((JComboBox) component).getItemCount(); i++) {
if (((ApiComboBoxItem) ((JComboBox) component).getItemAt(i)).getData().equals(value)) {
((JComboBox) component).setSelectedIndex(i);
break;
}
}
} else if (component instanceof JTextField) {
((JTextField) component).setText(value.toString());
} else if (component instanceof TextFieldWithBrowseButton) {
((TextFieldWithBrowseButton) component).setText(value.toString());
} else if (component instanceof JSlider) {
((JSlider) component).setValue(Integer.parseInt(value.toString()));
} else if (component instanceof JSpinner) {
((JSpinner) component).setValue(Integer.parseInt(value.toString()));
} else if (component instanceof ColorPanel) {
((ColorPanel) component).setSelectedColor((Color) value);
}
}
} finally {
myIgnoreUpdates = oldIgnoreUpdates;
}
}
use of com.intellij.openapi.ui.TextFieldWithBrowseButton in project android by JetBrains.
the class IdeSdksConfigurable method createJdkLocationTextField.
private void createJdkLocationTextField() {
JTextField textField = new JTextField(10);
myJdkLocationTextField = new TextFieldWithBrowseButton(textField, e -> chooseJdkLocation());
}
use of com.intellij.openapi.ui.TextFieldWithBrowseButton in project android by JetBrains.
the class IdeSdksConfigurable method createTextFieldWithBrowseButton.
@NotNull
private TextFieldWithBrowseButton createTextFieldWithBrowseButton(@NotNull String title, @NotNull String errorMessage, @NotNull Function<File, ValidationResult> validation) {
FileChooserDescriptor descriptor = createSingleFolderDescriptor(title, file -> {
ValidationResult validationResult = validation.fun(file);
if (!validationResult.success) {
String msg = validationResult.message;
if (isEmpty(msg)) {
msg = errorMessage;
}
throw new IllegalArgumentException(msg);
}
return null;
});
JTextField textField = new JTextField(10);
return new TextFieldWithBrowseButton(textField, e -> {
VirtualFile suggestedDir = null;
File ndkLocation = getNdkLocation();
if (ndkLocation.isDirectory()) {
suggestedDir = findFileByIoFile(ndkLocation, false);
}
VirtualFile chosen = chooseFile(descriptor, null, suggestedDir);
if (chosen != null) {
File f = virtualToIoFile(chosen);
textField.setText(f.getPath());
}
});
}
use of com.intellij.openapi.ui.TextFieldWithBrowseButton in project intellij-community by JetBrains.
the class IdeaGradleProjectSettingsControlBuilder method addGradleHomeComponents.
@Override
public IdeaGradleProjectSettingsControlBuilder addGradleHomeComponents(PaintAwarePanel content, int indentLevel) {
if (dropGradleHomePathComponents)
return this;
myGradleHomeLabel = new JBLabel(GradleBundle.message("gradle.settings.text.home.path"));
myGradleHomePathField = new TextFieldWithBrowseButton();
myGradleHomePathField.addBrowseFolderListener("", GradleBundle.message("gradle.settings.text.home.path"), null, GradleUtil.getGradleHomeFileChooserDescriptor(), TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
myGradleHomePathField.getTextField().getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
myGradleHomePathField.getTextField().setForeground(LocationSettingType.EXPLICIT_CORRECT.getColor());
}
@Override
public void removeUpdate(DocumentEvent e) {
myGradleHomePathField.getTextField().setForeground(LocationSettingType.EXPLICIT_CORRECT.getColor());
}
@Override
public void changedUpdate(DocumentEvent e) {
}
});
content.add(myGradleHomeLabel, ExternalSystemUiUtil.getLabelConstraints(indentLevel));
content.add(myGradleHomePathField, ExternalSystemUiUtil.getFillLineConstraints(0));
return this;
}
use of com.intellij.openapi.ui.TextFieldWithBrowseButton in project intellij-community by JetBrains.
the class DirDiffPanel method createUIComponents.
private void createUIComponents() {
mySourceDirField = new TextFieldWithBrowseButton(null, this);
myTargetDirField = new TextFieldWithBrowseButton(null, this);
final AtomicBoolean callUpdate = new AtomicBoolean(true);
myRootPanel = new JPanel(new BorderLayout()) {
@Override
protected void paintChildren(Graphics g) {
super.paintChildren(g);
if (callUpdate.get()) {
callUpdate.set(false);
myModel.reloadModel(false);
}
}
};
}
Aggregations