Search in sources :

Example 11 with RunConfiguration

use of com.intellij.execution.configurations.RunConfiguration in project intellij-community by JetBrains.

the class RunDashboardManagerImpl method getRunConfigurations.

@Override
public List<Pair<RunnerAndConfigurationSettings, RunContentDescriptor>> getRunConfigurations() {
    List<Pair<RunnerAndConfigurationSettings, RunContentDescriptor>> result = new ArrayList<>();
    List<RunnerAndConfigurationSettings> configurations = RunManager.getInstance(myProject).getAllSettings().stream().filter(runConfiguration -> RunDashboardContributor.isShowInDashboard(runConfiguration.getType())).collect(Collectors.toList());
    //noinspection ConstantConditions ???
    ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(myProject);
    configurations.forEach(configurationSettings -> {
        List<RunContentDescriptor> descriptors = executionManager.getDescriptors(settings -> Comparing.equal(settings.getConfiguration(), configurationSettings.getConfiguration()));
        if (descriptors.isEmpty()) {
            result.add(Pair.create(configurationSettings, null));
        } else {
            descriptors.forEach(descriptor -> result.add(Pair.create(configurationSettings, descriptor)));
        }
    });
    // It is possible that run configuration was deleted, but there is running content descriptor for such run configuration.
    // It should be shown in he dashboard tree.
    List<RunConfiguration> storedConfigurations = configurations.stream().map(RunnerAndConfigurationSettings::getConfiguration).collect(Collectors.toList());
    List<RunContentDescriptor> notStoredDescriptors = executionManager.getRunningDescriptors(settings -> {
        RunConfiguration configuration = settings.getConfiguration();
        return RunDashboardContributor.isShowInDashboard(settings.getType()) && !storedConfigurations.contains(configuration);
    });
    notStoredDescriptors.forEach(descriptor -> {
        Set<RunnerAndConfigurationSettings> settings = executionManager.getConfigurations(descriptor);
        settings.forEach(setting -> result.add(Pair.create(setting, descriptor)));
    });
    return result;
}
Also used : Storage(com.intellij.openapi.components.Storage) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) Arrays(java.util.Arrays) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) AllIcons(com.intellij.icons.AllIcons) PersistentStateComponent(com.intellij.openapi.components.PersistentStateComponent) ArrayList(java.util.ArrayList) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) Comparing(com.intellij.openapi.util.Comparing) DashboardGrouper(com.intellij.execution.dashboard.tree.DashboardGrouper) ToolWindowId(com.intellij.openapi.wm.ToolWindowId) State(com.intellij.openapi.components.State) Disposer(com.intellij.openapi.util.Disposer) Project(com.intellij.openapi.project.Project) ContentUI(com.intellij.ui.content.ContentUI) ToolWindowAnchor(com.intellij.openapi.wm.ToolWindowAnchor) DumbService(com.intellij.openapi.project.DumbService) ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) Set(java.util.Set) Collectors(java.util.stream.Collectors) ProcessHandler(com.intellij.execution.process.ProcessHandler) com.intellij.execution(com.intellij.execution) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) ContentFactory(com.intellij.ui.content.ContentFactory) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) StoragePathMacros(com.intellij.openapi.components.StoragePathMacros) Pair(com.intellij.openapi.util.Pair) ExecutionManagerImpl(com.intellij.execution.impl.ExecutionManagerImpl) ContentManager(com.intellij.ui.content.ContentManager) Registry(com.intellij.openapi.util.registry.Registry) NotNull(org.jetbrains.annotations.NotNull) javax.swing(javax.swing) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ArrayList(java.util.ArrayList) Pair(com.intellij.openapi.util.Pair) ExecutionManagerImpl(com.intellij.execution.impl.ExecutionManagerImpl)

Example 12 with RunConfiguration

use of com.intellij.execution.configurations.RunConfiguration in project intellij-community by JetBrains.

the class CompoundRunConfigurationSettingsEditor method createEditor.

@NotNull
@Override
protected JComponent createEditor() {
    final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myList);
    return decorator.disableUpDownActions().setAddAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            final List<RunConfiguration> all = new ArrayList<>();
            for (ConfigurationType type : myRunManager.getConfigurationFactories()) {
                if (!(type instanceof UnknownConfigurationType)) {
                    for (RunnerAndConfigurationSettings settings : myRunManager.getConfigurationSettingsList(type)) {
                        all.add(settings.getConfiguration());
                    }
                }
            }
            final List<RunConfiguration> configurations = ContainerUtil.filter(all, configuration -> !mySnapshot.getSetToRun().contains(configuration) && canBeAdded(configuration, mySnapshot));
            JBPopupFactory.getInstance().createListPopup(new MultiSelectionListPopupStep<RunConfiguration>(null, configurations) {

                @Nullable
                @Override
                public ListSeparator getSeparatorAbove(RunConfiguration value) {
                    int i = configurations.indexOf(value);
                    if (i < 1)
                        return null;
                    RunConfiguration previous = configurations.get(i - 1);
                    return value.getType() != previous.getType() ? new ListSeparator() : null;
                }

                @Override
                public Icon getIconFor(RunConfiguration value) {
                    return value.getType().getIcon();
                }

                @Override
                public boolean isSpeedSearchEnabled() {
                    return true;
                }

                @NotNull
                @Override
                public String getTextFor(RunConfiguration value) {
                    return value.getName();
                }

                @Override
                public PopupStep<?> onChosen(List<RunConfiguration> selectedValues, boolean finalChoice) {
                    myList.clearSelection();
                    myModel.addAll(selectedValues);
                    return FINAL_CHOICE;
                }
            }).showUnderneathOf(decorator.getActionsPanel());
        }
    }).setEditAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            int index = myList.getSelectedIndex();
            if (index == -1)
                return;
            RunConfiguration configuration = myModel.get(index);
            RunConfigurationSelector selector = RunConfigurationSelector.KEY.getData(DataManager.getInstance().getDataContext(button.getContextComponent()));
            if (selector != null) {
                selector.select(configuration);
            }
        }
    }).setToolbarPosition(ActionToolbarPosition.TOP).createPanel();
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) UnknownConfigurationType(com.intellij.execution.configurations.UnknownConfigurationType) ListSeparator(com.intellij.openapi.ui.popup.ListSeparator) ArrayList(java.util.ArrayList) RunConfigurationSelector(com.intellij.execution.impl.RunConfigurationSelector) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) UnknownConfigurationType(com.intellij.execution.configurations.UnknownConfigurationType) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ArrayList(java.util.ArrayList) JBList(com.intellij.ui.components.JBList) List(java.util.List) MultiSelectionListPopupStep(com.intellij.openapi.ui.popup.MultiSelectionListPopupStep) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with RunConfiguration

use of com.intellij.execution.configurations.RunConfiguration in project intellij-community by JetBrains.

the class CompoundRunConfigurationSettingsEditor method applyEditorTo.

@Override
protected void applyEditorTo(@NotNull CompoundRunConfiguration s) throws ConfigurationException {
    Set<RunConfiguration> checked = new HashSet<>();
    for (int i = 0; i < myModel.getSize(); i++) {
        RunConfiguration configuration = myModel.get(i);
        String message = LangBundle.message("compound.run.configuration.cycle", configuration.getType().getDisplayName(), configuration.getName());
        if (!canBeAdded(configuration, s))
            throw new ConfigurationException(message);
        checked.add(configuration);
    }
    Set<RunConfiguration> toRun = s.getSetToRun();
    toRun.clear();
    toRun.addAll(checked);
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ConfigurationException(com.intellij.openapi.options.ConfigurationException) HashSet(java.util.HashSet)

Example 14 with RunConfiguration

use of com.intellij.execution.configurations.RunConfiguration in project intellij-community by JetBrains.

the class RunConfigurationProducer method createLightConfiguration.

@Nullable
public RunConfiguration createLightConfiguration(@NotNull final ConfigurationContext context) {
    RunConfiguration configuration = myConfigurationFactory.createTemplateConfiguration(context.getProject());
    final Ref<PsiElement> ref = new Ref<>(context.getPsiLocation());
    try {
        if (!setupConfigurationFromContext((T) configuration, context, ref)) {
            return null;
        }
    } catch (ClassCastException e) {
        LOG.error(myConfigurationFactory + " produced wrong type", e);
        return null;
    }
    return configuration;
}
Also used : Ref(com.intellij.openapi.util.Ref) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Example 15 with RunConfiguration

use of com.intellij.execution.configurations.RunConfiguration in project intellij-community by JetBrains.

the class EditConfigurationsDialog method addRunConfiguration.

public void addRunConfiguration(@NotNull final ConfigurationFactory factory) {
    final RunConfigurable configurable = (RunConfigurable) getConfigurable();
    final SingleConfigurationConfigurable<RunConfiguration> configuration = configurable.createNewConfiguration(factory);
    if (!isVisible()) {
        getContentPanel().addComponentListener(new ComponentAdapter() {

            @Override
            public void componentShown(ComponentEvent e) {
                if (configuration != null) {
                    configurable.updateRightPanel(configuration);
                    getContentPanel().removeComponentListener(this);
                }
            }
        });
    }
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Aggregations

RunConfiguration (com.intellij.execution.configurations.RunConfiguration)59 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)16 Module (com.intellij.openapi.module.Module)13 Nullable (org.jetbrains.annotations.Nullable)12 Project (com.intellij.openapi.project.Project)10 PsiElement (com.intellij.psi.PsiElement)7 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)6 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)6 Pair (com.intellij.openapi.util.Pair)6 NotNull (org.jetbrains.annotations.NotNull)6 AndroidTestRunConfiguration (com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration)5 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)5 BeforeRunTask (com.intellij.execution.BeforeRunTask)4 FlashRunConfiguration (com.intellij.lang.javascript.flex.run.FlashRunConfiguration)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 ArrayList (java.util.ArrayList)4 AndroidJUnitConfiguration (com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration)3 BeforeRunTaskProvider (com.intellij.execution.BeforeRunTaskProvider)3 Location (com.intellij.execution.Location)3 RunManager (com.intellij.execution.RunManager)3