use of com.intellij.execution.impl.EditConfigurationsDialog in project intellij-community by JetBrains.
the class RunConfigurationNode method getNavigatable.
@Nullable
@Override
public Navigatable getNavigatable() {
return new Navigatable() {
@Override
public void navigate(boolean requestFocus) {
RunManager.getInstance(myProject).setSelectedConfiguration(mySettings);
EditConfigurationsDialog dialog = new EditConfigurationsDialog(myProject);
dialog.show();
}
@Override
public boolean canNavigate() {
return true;
}
@Override
public boolean canNavigateToSource() {
return false;
}
};
}
use of com.intellij.execution.impl.EditConfigurationsDialog in project intellij-community by JetBrains.
the class ChooseRunConfigurationPopup method createSettingsList.
public static ItemWrapper[] createSettingsList(@NotNull Project project, @NotNull ExecutorProvider executorProvider, boolean createEditAction) {
List<ItemWrapper> result = new ArrayList<>();
if (createEditAction) {
ItemWrapper<Void> edit = new ItemWrapper<Void>(null) {
@Override
public Icon getIcon() {
return AllIcons.Actions.EditSource;
}
@Override
public String getText() {
return UIUtil.removeMnemonic(ActionsBundle.message("action.editRunConfigurations.text"));
}
@Override
public void perform(@NotNull final Project project, @NotNull final Executor executor, @NotNull DataContext context) {
if (new EditConfigurationsDialog(project) {
@Override
protected void init() {
setOKButtonText(executor.getStartActionText());
setOKButtonIcon(executor.getIcon());
myExecutor = executor;
super.init();
}
}.showAndGet()) {
ApplicationManager.getApplication().invokeLater(() -> {
RunnerAndConfigurationSettings configuration = RunManager.getInstance(project).getSelectedConfiguration();
if (configuration != null) {
ExecutionUtil.runConfiguration(configuration, executor);
}
}, project.getDisposed());
}
}
@Override
public boolean available(Executor executor) {
return true;
}
};
edit.setMnemonic(0);
result.add(edit);
}
RunManagerEx manager = RunManagerEx.getInstanceEx(project);
final RunnerAndConfigurationSettings selectedConfiguration = manager.getSelectedConfiguration();
if (selectedConfiguration != null) {
boolean isFirst = true;
final ExecutionTarget activeTarget = ExecutionTargetManager.getActiveTarget(project);
for (ExecutionTarget eachTarget : ExecutionTargetManager.getTargetsToChooseFor(project, selectedConfiguration)) {
result.add(new ItemWrapper<ExecutionTarget>(eachTarget, isFirst) {
{
setChecked(getValue().equals(activeTarget));
}
@Override
public Icon getIcon() {
return getValue().getIcon();
}
@Override
public String getText() {
return getValue().getDisplayName();
}
@Override
public void perform(@NotNull final Project project, @NotNull final Executor executor, @NotNull DataContext context) {
ExecutionTargetManager.setActiveTarget(project, getValue());
ExecutionUtil.runConfiguration(selectedConfiguration, executor);
}
@Override
public boolean available(Executor executor) {
return true;
}
});
isFirst = false;
}
}
Map<RunnerAndConfigurationSettings, ItemWrapper> wrappedExisting = new LinkedHashMap<>();
for (ConfigurationType type : manager.getConfigurationFactories()) {
if (!(type instanceof UnknownConfigurationType)) {
Map<String, List<RunnerAndConfigurationSettings>> structure = manager.getStructure(type);
for (Map.Entry<String, List<RunnerAndConfigurationSettings>> entry : structure.entrySet()) {
if (entry.getValue().isEmpty()) {
continue;
}
final String key = entry.getKey();
if (key != null) {
boolean isSelected = entry.getValue().contains(selectedConfiguration);
if (isSelected) {
assert selectedConfiguration != null;
}
FolderWrapper folderWrapper = new FolderWrapper(project, executorProvider, key + (isSelected ? " (mnemonic is to \"" + selectedConfiguration.getName() + "\")" : ""), entry.getValue());
if (isSelected) {
folderWrapper.setMnemonic(1);
}
result.add(folderWrapper);
} else {
for (RunnerAndConfigurationSettings configuration : entry.getValue()) {
final ItemWrapper wrapped = ItemWrapper.wrap(project, configuration);
if (configuration == selectedConfiguration) {
wrapped.setMnemonic(1);
}
wrappedExisting.put(configuration, wrapped);
}
}
}
}
}
if (!DumbService.isDumb(project)) {
populateWithDynamicRunners(result, wrappedExisting, project, manager, selectedConfiguration);
}
result.addAll(wrappedExisting.values());
return result.toArray(new ItemWrapper[result.size()]);
}
use of com.intellij.execution.impl.EditConfigurationsDialog in project intellij-community by JetBrains.
the class EditRunConfigurationsAction method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
if (project != null && project.isDisposed()) {
return;
}
if (project == null) {
//setup template project configurations
project = ProjectManager.getInstance().getDefaultProject();
}
final EditConfigurationsDialog dialog = new EditConfigurationsDialog(project);
dialog.show();
}
use of com.intellij.execution.impl.EditConfigurationsDialog in project intellij-community by JetBrains.
the class ProjectStartupConfigurable method createNewWrapper.
private ChooseRunConfigurationPopup.ItemWrapper<Void> createNewWrapper(final AnActionButton button) {
return new ChooseRunConfigurationPopup.ItemWrapper<Void>(null) {
@Override
public Icon getIcon() {
return IconUtil.getAddIcon();
}
@Override
public String getText() {
return UIUtil.removeMnemonic(ExecutionBundle.message("add.new.run.configuration.acrtion.name"));
}
@Override
public void perform(@NotNull final Project project, @NotNull final Executor executor, @NotNull DataContext context) {
final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project);
final ConfigurationType[] factories = runManager.getConfigurationFactories();
final Condition<ConfigurationType> filter = new Condition<ConfigurationType>() {
private final RunnerRegistry myRegistry = RunnerRegistry.getInstance();
@Override
public boolean value(ConfigurationType configurationType) {
ConfigurationFactory factory;
return !UnknownConfigurationType.INSTANCE.equals(configurationType) && ((factory = runManager.getFactory(configurationType.getId(), null)) != null) && myRegistry.getRunner(executor.getId(), runManager.getConfigurationTemplate(factory).getConfiguration()) != null;
}
};
final List<ConfigurationType> factoriesList = ContainerUtil.filter(Arrays.asList(factories), filter);
final ListPopup popup = NewRunConfigurationPopup.createAddPopup(factoriesList, "", factory -> ApplicationManager.getApplication().invokeLater(() -> {
final EditConfigurationsDialog dialog = new EditConfigurationsDialog(project, factory);
if (dialog.showAndGet()) {
ApplicationManager.getApplication().invokeLater(() -> {
RunnerAndConfigurationSettings configuration = RunManager.getInstance(project).getSelectedConfiguration();
if (configuration != null) {
addConfiguration(configuration);
}
}, ModalityState.any(), project.getDisposed());
}
}, ModalityState.any(), project.getDisposed()), null, EmptyRunnable.getInstance(), false);
showPopup(button, popup);
}
@Override
public boolean available(Executor executor) {
return true;
}
};
}
use of com.intellij.execution.impl.EditConfigurationsDialog in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudToolsRunConfigurationAction method createNewConfiguration.
private void createNewConfiguration(Project project) {
final RunManagerImpl manager = RunManagerImpl.getInstanceImpl(project);
final ConfigurationFactory factory = configType != null ? configType.getConfigurationFactories()[0] : null;
EditConfigurationsDialog dialog = new EditConfigurationsDialog(project, factory);
if (dialog.showAndGet()) {
RunnerAndConfigurationSettings settings = manager.getSelectedConfiguration();
if (settings != null) {
manager.addConfiguration(settings, false);
}
}
}
Aggregations