Search in sources :

Example 1 with ExecutionManagerImpl

use of com.intellij.execution.impl.ExecutionManagerImpl 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 2 with ExecutionManagerImpl

use of com.intellij.execution.impl.ExecutionManagerImpl in project intellij-community by JetBrains.

the class CompoundRunConfiguration method hasRunningSingletones.

protected boolean hasRunningSingletones() {
    Project project = getProject();
    if (project.isDisposed())
        return false;
    final ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(project);
    return executionManager.getRunningDescriptors(s -> {
        RunManagerImpl manager = RunManagerImpl.getInstanceImpl(project);
        for (RunConfiguration runConfiguration : mySetToRun) {
            if (runConfiguration instanceof CompoundRunConfiguration && ((CompoundRunConfiguration) runConfiguration).hasRunningSingletones()) {
                return true;
            }
            RunnerAndConfigurationSettings settings = manager.findConfigurationByTypeAndName(runConfiguration.getType().getId(), runConfiguration.getName());
            if (settings != null && settings.isSingleton() && runConfiguration.equals(s.getConfiguration())) {
                return true;
            }
        }
        return false;
    }).size() > 0;
}
Also used : Project(com.intellij.openapi.project.Project) ExecutionManagerImpl(com.intellij.execution.impl.ExecutionManagerImpl) RunManagerImpl(com.intellij.execution.impl.RunManagerImpl)

Example 3 with ExecutionManagerImpl

use of com.intellij.execution.impl.ExecutionManagerImpl in project intellij-community by JetBrains.

the class RunConfigurationsComboBoxAction method setConfigurationIcon.

private static void setConfigurationIcon(final Presentation presentation, final RunnerAndConfigurationSettings settings, final Project project) {
    try {
        Icon icon = RunManagerEx.getInstanceEx(project).getConfigurationIcon(settings);
        ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(project);
        List<RunContentDescriptor> runningDescriptors = executionManager.getRunningDescriptors(s -> s == settings);
        if (runningDescriptors.size() == 1) {
            icon = ExecutionUtil.getLiveIndicator(icon);
        }
        if (runningDescriptors.size() > 1) {
            icon = IconUtil.addText(icon, String.valueOf(runningDescriptors.size()));
        }
        presentation.setIcon(icon);
    } catch (IndexNotReadyException ignored) {
    }
}
Also used : RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) SizedIcon(com.intellij.ui.SizedIcon) EmptyIcon(com.intellij.util.ui.EmptyIcon) ExecutionManagerImpl(com.intellij.execution.impl.ExecutionManagerImpl)

Example 4 with ExecutionManagerImpl

use of com.intellij.execution.impl.ExecutionManagerImpl in project intellij-community by JetBrains.

the class ShowRunningListAction method getCurrentState.

private static Pair<? extends JComponent, String> getCurrentState(@NotNull List<Project> projects) {
    NonOpaquePanel panel = new NonOpaquePanel(new GridLayout(0, 1, 10, 10));
    StringBuilder state = new StringBuilder();
    for (int i = 0; i < projects.size(); i++) {
        Project project = projects.get(i);
        final ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(project);
        List<RunContentDescriptor> runningDescriptors = executionManager.getRunningDescriptors(Condition.TRUE);
        if (!runningDescriptors.isEmpty() && projects.size() > 1) {
            state.append(project.getName());
            panel.add(new JLabel("<html><body><b>Project '" + project.getName() + "'</b></body></html>"));
        }
        for (RunContentDescriptor descriptor : runningDescriptors) {
            Set<Executor> executors = executionManager.getExecutors(descriptor);
            for (Executor executor : executors) {
                state.append(System.identityHashCode(descriptor.getAttachedContent())).append("@").append(System.identityHashCode(executor.getIcon())).append(";");
                ProcessHandler processHandler = descriptor.getProcessHandler();
                Icon icon = (processHandler instanceof KillableProcess && processHandler.isProcessTerminating()) ? AllIcons.Debugger.KillProcess : executor.getIcon();
                JLabel label = new JLabel("<html><body><a href=\"\">" + descriptor.getDisplayName() + "</a></body></html>", icon, SwingConstants.LEADING);
                label.setIconTextGap(JBUI.scale(2));
                label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                label.putClientProperty(KEY, Trinity.create(project, executor, descriptor));
                panel.add(label);
            }
        }
    }
    if (panel.getComponentCount() == 0) {
        panel.setBorder(JBUI.Borders.empty(10));
        panel.add(new JLabel(ExecutionBundle.message("show.running.list.balloon.nothing"), SwingConstants.CENTER));
    } else {
        panel.setBorder(JBUI.Borders.empty(10, 10, 0, 10));
        JLabel label = new JLabel(ExecutionBundle.message("show.running.list.balloon.hint"));
        label.setFont(JBUI.Fonts.miniFont());
        panel.add(label);
    }
    return Pair.create(panel, state.toString());
}
Also used : RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) RelativePoint(com.intellij.ui.awt.RelativePoint) KillableProcess(com.intellij.execution.KillableProcess) NonOpaquePanel(com.intellij.ui.components.panels.NonOpaquePanel) Project(com.intellij.openapi.project.Project) Executor(com.intellij.execution.Executor) ProcessHandler(com.intellij.execution.process.ProcessHandler) LayeredIcon(com.intellij.ui.LayeredIcon) ExecutionManagerImpl(com.intellij.execution.impl.ExecutionManagerImpl)

Aggregations

ExecutionManagerImpl (com.intellij.execution.impl.ExecutionManagerImpl)4 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)3 Project (com.intellij.openapi.project.Project)3 ProcessHandler (com.intellij.execution.process.ProcessHandler)2 com.intellij.execution (com.intellij.execution)1 Executor (com.intellij.execution.Executor)1 KillableProcess (com.intellij.execution.KillableProcess)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1 DashboardGrouper (com.intellij.execution.dashboard.tree.DashboardGrouper)1 RunManagerImpl (com.intellij.execution.impl.RunManagerImpl)1 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)1 AllIcons (com.intellij.icons.AllIcons)1 PersistentStateComponent (com.intellij.openapi.components.PersistentStateComponent)1 State (com.intellij.openapi.components.State)1 Storage (com.intellij.openapi.components.Storage)1 StoragePathMacros (com.intellij.openapi.components.StoragePathMacros)1 DumbService (com.intellij.openapi.project.DumbService)1 IndexNotReadyException (com.intellij.openapi.project.IndexNotReadyException)1 Comparing (com.intellij.openapi.util.Comparing)1 Disposer (com.intellij.openapi.util.Disposer)1