mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RunDashboard: grouping rules may provide comparator for groups ordering
This commit is contained in:
@@ -35,6 +35,8 @@ public interface RunDashboardGroupingRule extends TreeAction {
|
||||
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.
|
||||
@@ -60,6 +62,10 @@ public interface RunDashboardGroupingRule extends TreeAction {
|
||||
@Nullable
|
||||
RunDashboardGroup getGroup(AbstractTreeNode<?> node);
|
||||
|
||||
default Comparator<RunDashboardGroup> getGroupComparator() {
|
||||
return GROUP_NAME_COMPARATOR;
|
||||
}
|
||||
|
||||
interface Priorities {
|
||||
int BY_RUN_CONFIG = 200;
|
||||
int BY_FOLDER = 400;
|
||||
|
||||
+11
-5
@@ -27,20 +27,22 @@ import javax.swing.*;
|
||||
*/
|
||||
public class RunDashboardRunConfigurationStatus {
|
||||
public static final RunDashboardRunConfigurationStatus STARTED = new RunDashboardRunConfigurationStatus(
|
||||
ExecutionBundle.message("run.dashboard.started.group.name"), AllIcons.Actions.Execute);
|
||||
ExecutionBundle.message("run.dashboard.started.group.name"), AllIcons.Actions.Execute, 10);
|
||||
public static final RunDashboardRunConfigurationStatus FAILED = new RunDashboardRunConfigurationStatus(
|
||||
ExecutionBundle.message("run.dashboard.failed.group.name"), AllIcons.General.Error);
|
||||
ExecutionBundle.message("run.dashboard.failed.group.name"), AllIcons.General.Error, 20);
|
||||
public static final RunDashboardRunConfigurationStatus STOPPED = new RunDashboardRunConfigurationStatus(
|
||||
ExecutionBundle.message("run.dashboard.stopped.group.name"), AllIcons.Actions.Restart);
|
||||
ExecutionBundle.message("run.dashboard.stopped.group.name"), AllIcons.Actions.Restart, 30);
|
||||
public static final RunDashboardRunConfigurationStatus CONFIGURED = new RunDashboardRunConfigurationStatus(
|
||||
ExecutionBundle.message("run.dashboard.configured.group.name"), AllIcons.General.Settings);
|
||||
ExecutionBundle.message("run.dashboard.configured.group.name"), AllIcons.General.Settings, 40);
|
||||
|
||||
private final String myName;
|
||||
private final Icon myIcon;
|
||||
private final int myPriority;
|
||||
|
||||
public RunDashboardRunConfigurationStatus(String name, Icon icon) {
|
||||
public RunDashboardRunConfigurationStatus(String name, Icon icon, int priority) {
|
||||
myName = name;
|
||||
myIcon = icon;
|
||||
myPriority = priority;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -51,6 +53,10 @@ public class RunDashboardRunConfigurationStatus {
|
||||
return myIcon;
|
||||
}
|
||||
|
||||
public int getPriority() {
|
||||
return myPriority;
|
||||
}
|
||||
|
||||
public static RunDashboardRunConfigurationStatus getStatus(RunDashboardRunConfigurationNode node) {
|
||||
RunContentDescriptor descriptor = node.getDescriptor();
|
||||
if (descriptor == null) {
|
||||
|
||||
+7
@@ -33,6 +33,10 @@ public class RunDashboardGroupImpl<T> implements RunDashboardGroup {
|
||||
myIcon = icon;
|
||||
}
|
||||
|
||||
public T getValue() {
|
||||
return myValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
@@ -50,6 +54,9 @@ public class RunDashboardGroupImpl<T> implements RunDashboardGroup {
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof RunDashboardGroupImpl) {
|
||||
return myValue.equals(((RunDashboardGroupImpl)obj).myValue);
|
||||
}
|
||||
|
||||
+1
-1
@@ -138,7 +138,7 @@ public class RunDashboardTreeStructure extends AbstractTreeStructureBase {
|
||||
});
|
||||
}
|
||||
else {
|
||||
Collections.sort(result, Comparator.comparing(node -> ((GroupingNode)node).getGroup().getName()));
|
||||
Collections.sort(result, Comparator.comparing(node -> ((GroupingNode)node).getGroup(), rule.getGroupComparator()));
|
||||
result.addAll(ungroupedNodes);
|
||||
}
|
||||
return result;
|
||||
|
||||
+8
@@ -25,6 +25,8 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* @author konstantin.aleev
|
||||
*/
|
||||
@@ -72,4 +74,10 @@ public class StatusDashboardGroupingRule implements RunDashboardGroupingRule {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Comparator<RunDashboardGroup> getGroupComparator() {
|
||||
//noinspection unchecked
|
||||
return Comparator.comparing(group -> ((RunDashboardGroupImpl<RunDashboardRunConfigurationStatus>)group).getValue().getPriority());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user