mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[service-view] remove master component key
This commit is contained in:
@@ -3,15 +3,12 @@ package com.intellij.execution.services;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.concurrency.Promise;
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public interface ServiceViewManager {
|
||||
Key<Boolean> SERVICE_VIEW_MASTER_COMPONENT = Key.create("SERVICE_VIEW_MASTER_COMPONENT");
|
||||
|
||||
static ServiceViewManager getInstance(Project project) {
|
||||
return ServiceManager.getService(project, ServiceViewManager.class);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ import com.intellij.ui.content.*;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.TreeModelAdapter;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -60,7 +59,6 @@ import java.util.*;
|
||||
|
||||
import static com.intellij.execution.dashboard.RunDashboardManagerImpl.getRunnerLayoutUi;
|
||||
import static com.intellij.execution.dashboard.RunDashboardRunConfigurationStatus.*;
|
||||
import static com.intellij.execution.services.ServiceViewManager.SERVICE_VIEW_MASTER_COMPONENT;
|
||||
|
||||
/**
|
||||
* @author konstantin.aleev
|
||||
@@ -215,7 +213,6 @@ public class RunDashboardContent extends JPanel implements TreeContent, Disposab
|
||||
}
|
||||
return null;
|
||||
});
|
||||
UIUtil.putClientProperty(myTree, SERVICE_VIEW_MASTER_COMPONENT, Boolean.TRUE);
|
||||
new DoubleClickListener() {
|
||||
@Override
|
||||
protected boolean onDoubleClick(MouseEvent event) {
|
||||
|
||||
+15
-8
@@ -19,20 +19,21 @@ import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.RunManager;
|
||||
import com.intellij.execution.dashboard.RunDashboardManager;
|
||||
import com.intellij.execution.dashboard.RunDashboardRunConfigurationNode;
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.util.containers.JBIterable;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import static com.intellij.execution.dashboard.actions.RunDashboardActionUtils.getTargets;
|
||||
import static com.intellij.execution.services.ServiceViewManager.SERVICE_VIEW_MASTER_COMPONENT;
|
||||
|
||||
/**
|
||||
* @author konstantin.aleev
|
||||
@@ -46,15 +47,21 @@ public class RemoveConfigurationAction extends AnAction {
|
||||
return;
|
||||
}
|
||||
|
||||
Component contextComponent = e.getData(PlatformDataKeys.CONTEXT_COMPONENT);
|
||||
if (!Boolean.TRUE.equals(UIUtil.getClientProperty(contextComponent, SERVICE_VIEW_MASTER_COMPONENT))) {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
JBIterable<RunDashboardRunConfigurationNode> targets = getTargets(e);
|
||||
RunManager runManager = RunManager.getInstance(project);
|
||||
boolean enabled = targets.isNotEmpty() && targets.filter(node -> !runManager.hasSettings(node.getConfigurationSettings())).isEmpty();
|
||||
|
||||
if (enabled) {
|
||||
RunDashboardRunConfigurationNode node = targets.single();
|
||||
Content content = node == null ? null : node.getContent();
|
||||
JComponent contentComponent = content == null ? null : content.getComponent();
|
||||
if (contentComponent != null && ActionPlaces.MAIN_MENU.equals(e.getPlace()) &&
|
||||
UIUtil.isAncestor(content.getComponent(), e.getData(PlatformDataKeys.CONTEXT_COMPONENT))) {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
e.getPresentation().setEnabled(enabled);
|
||||
e.getPresentation().setVisible(targets.isNotEmpty());
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import static com.intellij.execution.dashboard.RunDashboardRunConfigurationStatus.*;
|
||||
import static com.intellij.execution.services.ServiceViewManager.SERVICE_VIEW_MASTER_COMPONENT;
|
||||
import static com.intellij.ui.AnimatedIcon.ANIMATION_IN_RENDERER_ALLOWED;
|
||||
|
||||
class ServiceView extends JPanel implements Disposable {
|
||||
@@ -155,7 +154,6 @@ class ServiceView extends JPanel implements Disposable {
|
||||
myTree.setLineStyleAngled();
|
||||
myTree.setCellRenderer(new MyTreeCellRenderer());
|
||||
UIUtil.putClientProperty(myTree, ANIMATION_IN_RENDERER_ALLOWED, true);
|
||||
UIUtil.putClientProperty(myTree, SERVICE_VIEW_MASTER_COMPONENT, Boolean.TRUE);
|
||||
|
||||
// listeners
|
||||
myTree.addTreeSelectionListener(e -> onSelectionChanged());
|
||||
|
||||
Reference in New Issue
Block a user