mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[service-view] accept service object as a parent in added event
GitOrigin-RevId: b1d4ca94f5c209b3153a3960b503806e110fef34
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a012c9f7bb
commit
8db2418c25
@@ -18,30 +18,19 @@ public interface ServiceEventListener {
|
||||
public final Object target;
|
||||
public final Class<?> contributorClass;
|
||||
|
||||
public final ServiceViewContributor parent;
|
||||
public final Object parent;
|
||||
public final int index;
|
||||
|
||||
public ServiceEvent(@NotNull Class<?> rootContributorClass) {
|
||||
this(EventType.RESET, rootContributorClass, rootContributorClass);
|
||||
}
|
||||
|
||||
public ServiceEvent(@NotNull EventType type,
|
||||
@NotNull Object target,
|
||||
@NotNull Class<?> contributorClass) {
|
||||
private ServiceEvent(@NotNull EventType type,
|
||||
@NotNull Object target,
|
||||
@NotNull Class<?> contributorClass) {
|
||||
this(type, target, contributorClass, null, -1);
|
||||
}
|
||||
|
||||
public ServiceEvent(@NotNull Object target,
|
||||
@NotNull Class<?> contributorClass,
|
||||
@Nullable ServiceViewContributor parent,
|
||||
int index) {
|
||||
this(EventType.SERVICE_ADDED, target, contributorClass, parent, index);
|
||||
}
|
||||
|
||||
private ServiceEvent(@NotNull EventType type,
|
||||
@NotNull Object target,
|
||||
@NotNull Class<?> contributorClass,
|
||||
@Nullable ServiceViewContributor parent,
|
||||
@Nullable Object parent,
|
||||
int index) {
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
@@ -49,6 +38,23 @@ public interface ServiceEventListener {
|
||||
this.parent = parent;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public static ServiceEvent createEvent(@NotNull EventType type,
|
||||
@NotNull Object target,
|
||||
@NotNull Class<?> rootContributorClass) {
|
||||
return new ServiceEvent(type, target, rootContributorClass);
|
||||
}
|
||||
|
||||
public static ServiceEvent createResetEvent(@NotNull Class<?> rootContributorClass) {
|
||||
return new ServiceEvent(EventType.RESET, rootContributorClass, rootContributorClass);
|
||||
}
|
||||
|
||||
public static ServiceEvent createServiceAddedEvent(@NotNull Object target,
|
||||
@NotNull Class<?> contributorClass,
|
||||
@Nullable Object parent,
|
||||
int index) {
|
||||
return new ServiceEvent(EventType.SERVICE_ADDED, target, contributorClass, parent, index);
|
||||
}
|
||||
}
|
||||
|
||||
enum EventType {
|
||||
|
||||
+1
-3
@@ -384,9 +384,7 @@ public class RunDashboardManagerImpl implements RunDashboardManager, PersistentS
|
||||
@Override
|
||||
public void updateDashboard(boolean withStructure) {
|
||||
myProject.getMessageBus().syncPublisher(ServiceEventListener.TOPIC).handle(
|
||||
new ServiceEventListener.ServiceEvent(
|
||||
RunConfigurationsServiceViewContributor.class
|
||||
));
|
||||
ServiceEventListener.ServiceEvent.createResetEvent(RunConfigurationsServiceViewContributor.class));
|
||||
|
||||
if (Registry.is("ide.service.view")) return;
|
||||
|
||||
|
||||
@@ -196,9 +196,10 @@ class ServiceModel implements Disposable, InvokerSupplier {
|
||||
|
||||
if (e.parent != null) {
|
||||
ServiceViewItem parent = findItem(e.parent, e.contributorClass);
|
||||
if (parent == null) return;
|
||||
ServiceViewContributor<?> parentContributor = parent instanceof ServiceNode ? ((ServiceNode)parent).getProvidingContributor() : null;
|
||||
if (parentContributor == null) return;
|
||||
|
||||
addService(e.target, parent.getChildren(), myProject, parent, (ServiceViewContributor<?>)e.parent, e.index);
|
||||
addService(e.target, parent.getChildren(), myProject, parent, parentContributor, e.index);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -296,7 +297,7 @@ class ServiceModel implements Disposable, InvokerSupplier {
|
||||
parent.getChildren().remove(item);
|
||||
}
|
||||
|
||||
addService(e.target, parent.getChildren(), myProject, parent, (ServiceViewContributor<?>)parent.getContributor(), index);
|
||||
addService(e.target, parent.getChildren(), myProject, parent, (ServiceViewContributor<?>)item.getContributor(), index);
|
||||
if (group != null && group.getChildren().isEmpty()) {
|
||||
parent.getChildren().remove(group);
|
||||
}
|
||||
@@ -543,6 +544,11 @@ class ServiceModel implements Disposable, InvokerSupplier {
|
||||
protected List<ServiceViewItem> doGetChildren() {
|
||||
return myProvidingContributor == null ? Collections.emptyList() : getContributorChildren(myProject, this, myProvidingContributor);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ServiceViewContributor<?> getProvidingContributor() {
|
||||
return myProvidingContributor;
|
||||
}
|
||||
}
|
||||
|
||||
static class ServiceGroupNode extends ServiceViewItem {
|
||||
|
||||
Reference in New Issue
Block a user