mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RunDashboard: use extension order for grouping rules
This commit is contained in:
+1
-20
@@ -24,27 +24,15 @@ import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Action for grouping items in a run dashboard tree.
|
||||
* Grouping rules are applied to dashboard nodes according to their order defined in plug-in configuration.
|
||||
*
|
||||
* @author konstantin.aleev
|
||||
*/
|
||||
public interface RunDashboardGroupingRule extends TreeAction {
|
||||
ExtensionPointName<RunDashboardGroupingRule> EP_NAME = ExtensionPointName.create("com.intellij.runDashboardGroupingRule");
|
||||
|
||||
Comparator<RunDashboardGroupingRule> PRIORITY_COMPARATOR = (o1, o2) -> {
|
||||
final int res = o2.getPriority() - o1.getPriority();
|
||||
return res != 0 ? res : (o1.getName().compareTo(o2.getName()));
|
||||
};
|
||||
|
||||
Comparator<RunDashboardGroup> GROUP_NAME_COMPARATOR = Comparator.comparing(RunDashboardGroup::getName);
|
||||
|
||||
/**
|
||||
* Grouping rules are ordered and applied to dashboard nodes according to their priority.
|
||||
* The higher the priority, the higher groups produced by this rule are presented in the dashboard tree.
|
||||
*
|
||||
* @return rule's priority.
|
||||
*/
|
||||
int getPriority();
|
||||
|
||||
/**
|
||||
* @return {@code true} if grouping rule should always be applied to dashboard nodes.
|
||||
*/
|
||||
@@ -65,11 +53,4 @@ public interface RunDashboardGroupingRule extends TreeAction {
|
||||
default Comparator<RunDashboardGroup> getGroupComparator() {
|
||||
return GROUP_NAME_COMPARATOR;
|
||||
}
|
||||
|
||||
interface Priorities {
|
||||
int BY_RUN_CONFIG = 200;
|
||||
int BY_FOLDER = 400;
|
||||
int BY_STATUS = 800;
|
||||
int BY_TYPE = 1000;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,6 @@ public class RunDashboardManagerImpl implements RunDashboardManager, PersistentS
|
||||
myReuseCondition = this::canReuseContent;
|
||||
|
||||
myGroupers = Arrays.stream(RunDashboardGroupingRule.EP_NAME.getExtensions())
|
||||
.sorted(RunDashboardGroupingRule.PRIORITY_COMPARATOR)
|
||||
.map(RunDashboardGrouper::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
-5
@@ -49,11 +49,6 @@ public class ConfigurationTypeDashboardGroupingRule implements RunDashboardGroup
|
||||
AllIcons.Actions.GroupByFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return Priorities.BY_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysEnabled() {
|
||||
return false;
|
||||
|
||||
-5
@@ -50,11 +50,6 @@ public class FolderDashboardGroupingRule implements RunDashboardGroupingRule {
|
||||
AllIcons.Actions.GroupByPackage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return Priorities.BY_FOLDER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysEnabled() {
|
||||
return true;
|
||||
|
||||
-5
@@ -41,11 +41,6 @@ public class RunConfigurationDashboardGroupingRule implements RunDashboardGroupi
|
||||
return "RunConfigurationDashboardGroupingRule";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return Priorities.BY_RUN_CONFIG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysEnabled() {
|
||||
return true;
|
||||
|
||||
-5
@@ -47,11 +47,6 @@ public class StatusDashboardGroupingRule implements RunDashboardGroupingRule {
|
||||
AllIcons.Actions.GroupByPrefix); // TODO [konstantin.aleev] provide new icon
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return Priorities.BY_STATUS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysEnabled() {
|
||||
return false;
|
||||
|
||||
@@ -1025,10 +1025,14 @@
|
||||
<projectService serviceInterface="com.intellij.execution.ExecutionTargetManager" serviceImplementation="com.intellij.execution.ExecutionTargetManagerImpl"/>
|
||||
|
||||
<projectService serviceInterface="com.intellij.execution.dashboard.RunDashboardManager" serviceImplementation="com.intellij.execution.dashboard.RunDashboardManagerImpl"/>
|
||||
<runDashboardGroupingRule implementation="com.intellij.execution.dashboard.tree.ConfigurationTypeDashboardGroupingRule"/>
|
||||
<runDashboardGroupingRule implementation="com.intellij.execution.dashboard.tree.StatusDashboardGroupingRule"/>
|
||||
<runDashboardGroupingRule implementation="com.intellij.execution.dashboard.tree.FolderDashboardGroupingRule"/>
|
||||
<runDashboardGroupingRule implementation="com.intellij.execution.dashboard.tree.RunConfigurationDashboardGroupingRule"/>
|
||||
<runDashboardGroupingRule implementation="com.intellij.execution.dashboard.tree.ConfigurationTypeDashboardGroupingRule"
|
||||
id="type" order="first"/>
|
||||
<runDashboardGroupingRule implementation="com.intellij.execution.dashboard.tree.StatusDashboardGroupingRule"
|
||||
id="status" order="after type"/>
|
||||
<runDashboardGroupingRule implementation="com.intellij.execution.dashboard.tree.FolderDashboardGroupingRule"
|
||||
id="folder" order="after status"/>
|
||||
<runDashboardGroupingRule implementation="com.intellij.execution.dashboard.tree.RunConfigurationDashboardGroupingRule"
|
||||
id="runConfiguration" order="after folder"/>
|
||||
<projectService serviceInterface="com.intellij.execution.ui.RunContentManager"
|
||||
serviceImplementation="com.intellij.execution.ui.RunContentManagerImpl"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user