use of com.intellij.execution.configuration.EnvironmentVariablesTextFieldWithBrowseButton in project intellij-plugins by JetBrains.
the class PhoneGapRunConfigurationEditor method createEditor.
@NotNull
@Override
protected JComponent createEditor() {
myExecutablePathField = PhoneGapUtil.createPhoneGapExecutableTextField(myProject);
myWorkDirField = PhoneGapUtil.createPhoneGapWorkingDirectoryField(myProject);
myPlatformField = new ComboBoxWithMoreOption(getDefaultPlatforms(), getNonDefaultPlatforms());
myCommand = new ComboBox();
myEnvComponent = new EnvironmentVariablesTextFieldWithBrowseButton();
myEnvComponent.setPassParentEnvs(true);
myHasTarget = new JBCheckBox("Specify target");
myTarget = new PhoneGapTargetsPanel();
myExtraArgsTextField = new JBTextField(15);
myCommand.setMinimumAndPreferredWidth(200);
myPlatformField.setMinimumAndPreferredWidth(200);
myTarget.getTargetsField().setMinimumAndPreferredWidth(myPlatformField.getPreferredSize().width);
myTarget.setDataProvider(new ReloadableComboBoxPanel.DataProvider<String>() {
@NotNull
@Override
public Set<String> getCachedValues() {
return ContainerUtil.newHashOrEmptySet(null);
}
@Override
public void updateValuesAsynchronously() {
if (!myTarget.isEnabled()) {
processEmpty();
return;
}
final String platform = getPlatformAsCodeFromField();
final String command = (String) myCommand.getSelectedItem();
final PhoneGapTargets targetsProvider = PhoneGapTargets.createTargetsList(myProject, platform);
if (targetsProvider == null) {
processEmpty();
return;
}
ApplicationManager.getApplication().executeOnPooledThread(() -> {
final String currentText = myTarget.getTargetsField().getText();
final Set<String> targets = ContainerUtil.newLinkedHashSet(PhoneGapTargets.listTargets(targetsProvider, command));
if (!StringUtil.isEmpty(currentText) && !targets.contains(currentText)) {
targets.add(currentText);
}
UIUtil.invokeLaterIfNeeded(() -> myTarget.onUpdateValues(targets));
});
}
private void processEmpty() {
myTarget.onUpdateValues(ContainerUtil.newHashOrEmptySet(null));
}
});
setListenerForPlatforms();
setListenerForCommand();
setListenerForHasTarget();
setListenerForExecutablePath();
setCommandList();
return FormBuilder.createFormBuilder().addLabeledComponent(PhoneGapBundle.message("phonegap.conf.executable.name"), myExecutablePathField).addLabeledComponent(PhoneGapBundle.message("phonegap.conf.work.dir.name"), myWorkDirField).addLabeledComponent(ExecutionBundle.message("environment.variables.component.title"), myEnvComponent).addLabeledComponent("Command:", myCommand).addLabeledComponent("Platform:", myPlatformField).addLabeledComponent(PhoneGapBundle.message("phonegap.conf.extra.args.name"), myExtraArgsTextField).addLabeledComponent(myHasTarget, myTarget.getMainPanel()).getPanel();
}
Aggregations