mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[service-view] simplify view descriptor by using ColoredItem
GitOrigin-RevId: 5147027e6526044f44835466af13f29808ad0963
This commit is contained in:
committed by
intellij-monorepo-bot
parent
188571e759
commit
197f9f47c2
@@ -10,7 +10,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
@ApiStatus.Experimental
|
||||
@@ -73,11 +72,6 @@ public interface ServiceViewDescriptor {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default Color getItemBackgroundColor() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default Runnable getRemover() {
|
||||
return null;
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.intellij.ide.util.treeView.NodeDescriptor;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.ColoredItem;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.AppUIUtil;
|
||||
import com.intellij.util.Function;
|
||||
@@ -18,7 +19,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.concurrency.CancellablePromise;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -425,7 +428,7 @@ class ServiceModel implements Disposable, InvokerSupplier {
|
||||
groupChildren.add(child);
|
||||
}
|
||||
|
||||
abstract static class ServiceViewItem {
|
||||
abstract static class ServiceViewItem implements ColoredItem {
|
||||
private final Object myValue;
|
||||
private final ServiceViewItem myParent;
|
||||
private final ServiceViewContributor myContributor;
|
||||
@@ -490,6 +493,13 @@ class ServiceModel implements Disposable, InvokerSupplier {
|
||||
@NotNull
|
||||
protected abstract List<ServiceViewItem> doGetChildren();
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Color getColor() {
|
||||
ServiceViewDescriptor descriptor = getViewDescriptor();
|
||||
return descriptor instanceof ColoredItem ? ((ColoredItem)descriptor).getColor() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
||||
@@ -16,7 +16,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.TreeModel;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import static com.intellij.ui.AnimatedIcon.ANIMATION_IN_RENDERER_ALLOWED;
|
||||
@@ -60,20 +59,6 @@ class ServiceViewTree extends Tree {
|
||||
setDragEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileColorsEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Color getFileColorForPath(@NotNull TreePath path) {
|
||||
Object node = path.getLastPathComponent();
|
||||
if (!(node instanceof ServiceViewItem)) return null;
|
||||
|
||||
return ((ServiceViewItem)node).getViewDescriptor().getItemBackgroundColor();
|
||||
}
|
||||
|
||||
private static class ServiceViewTreeCellRenderer extends ServiceViewTreeCellRendererBase {
|
||||
private ServiceViewDescriptor myDescriptor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user