Search in sources :

Example 1 with EditConfigurationsDialog

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;
        }
    };
}
Also used : EditConfigurationsDialog(com.intellij.execution.impl.EditConfigurationsDialog) Navigatable(com.intellij.pom.Navigatable) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with EditConfigurationsDialog

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()]);
}
Also used : NotNull(org.jetbrains.annotations.NotNull) DataContext(com.intellij.openapi.actionSystem.DataContext) UnknownConfigurationType(com.intellij.execution.configurations.UnknownConfigurationType) List(java.util.List) ConfigurationType(com.intellij.execution.configurations.ConfigurationType) UnknownConfigurationType(com.intellij.execution.configurations.UnknownConfigurationType) EditConfigurationsDialog(com.intellij.execution.impl.EditConfigurationsDialog) Project(com.intellij.openapi.project.Project)

Example 3 with EditConfigurationsDialog

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();
}
Also used : Project(com.intellij.openapi.project.Project) EditConfigurationsDialog(com.intellij.execution.impl.EditConfigurationsDialog)

Example 4 with EditConfigurationsDialog

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;
        }
    };
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) UnknownConfigurationType(com.intellij.execution.configurations.UnknownConfigurationType) Condition(com.intellij.openapi.util.Condition) EditConfigurationsDialog(com.intellij.execution.impl.EditConfigurationsDialog) ListPopup(com.intellij.openapi.ui.popup.ListPopup) NotNull(org.jetbrains.annotations.NotNull) Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunManagerImpl(com.intellij.execution.impl.RunManagerImpl)

Example 5 with EditConfigurationsDialog

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);
        }
    }
}
Also used : EditConfigurationsDialog(com.intellij.execution.impl.EditConfigurationsDialog) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) RunManagerImpl(com.intellij.execution.impl.RunManagerImpl)

Aggregations

EditConfigurationsDialog (com.intellij.execution.impl.EditConfigurationsDialog)8 Project (com.intellij.openapi.project.Project)5 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)3 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)2 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)2 UnknownConfigurationType (com.intellij.execution.configurations.UnknownConfigurationType)2 RunManagerImpl (com.intellij.execution.impl.RunManagerImpl)2 DataContext (com.intellij.openapi.actionSystem.DataContext)2 NotNull (org.jetbrains.annotations.NotNull)2 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)1 ExternalSystemNode (com.intellij.openapi.externalSystem.view.ExternalSystemNode)1 RunConfigurationNode (com.intellij.openapi.externalSystem.view.RunConfigurationNode)1 ListPopup (com.intellij.openapi.ui.popup.ListPopup)1 Condition (com.intellij.openapi.util.Condition)1 Navigatable (com.intellij.pom.Navigatable)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1 List (java.util.List)1 Nullable (org.jetbrains.annotations.Nullable)1