diff --git a/platform/execution.dashboard/src/RunDashboardServiceViewContributor.java b/platform/execution.dashboard/src/RunDashboardServiceViewContributor.java index e2418b2dfb1e..cfd159b9feb3 100644 --- a/platform/execution.dashboard/src/RunDashboardServiceViewContributor.java +++ b/platform/execution.dashboard/src/RunDashboardServiceViewContributor.java @@ -166,14 +166,13 @@ public final class RunDashboardServiceViewContributor @Nullable private static RunDashboardRunConfigurationNode getRunConfigurationNode(@NotNull DnDEvent event, @NotNull Project project) { Object object = event.getAttachedObject(); - if (!(object instanceof DataProvider)) return null; + if (!(object instanceof ServiceViewDragBeanBase dragBean)) return null; - Object data = ((DataProvider)object).getData(PlatformCoreDataKeys.SELECTED_ITEMS.getName()); - if (!(data instanceof Object[] items)) return null; + List items = dragBean.getSelectedItems(); + Object item = ContainerUtil.getOnlyItem(items); + if (item == null) return null; - if (items.length != 1) return null; - - RunDashboardRunConfigurationNode node = ObjectUtils.tryCast(items[0], RunDashboardRunConfigurationNode.class); + RunDashboardRunConfigurationNode node = ObjectUtils.tryCast(item, RunDashboardRunConfigurationNode.class); if (node != null && !node.getConfigurationSettings().getConfiguration().getProject().equals(project)) return null; return node; diff --git a/platform/execution.serviceView/src/ServiceViewDragHelper.java b/platform/execution.serviceView/src/ServiceViewDragHelper.java index 88223f86be58..d317533b3e07 100644 --- a/platform/execution.serviceView/src/ServiceViewDragHelper.java +++ b/platform/execution.serviceView/src/ServiceViewDragHelper.java @@ -2,17 +2,12 @@ package com.intellij.platform.execution.serviceView; import com.intellij.execution.ExecutionBundle; -import com.intellij.execution.services.ServiceViewContributor; -import com.intellij.execution.services.ServiceViewDescriptor; -import com.intellij.execution.services.ServiceViewDnDDescriptor; +import com.intellij.execution.services.*; import com.intellij.execution.services.ServiceViewDnDDescriptor.Position; -import com.intellij.execution.services.ServiceViewManager; import com.intellij.ide.dnd.*; import com.intellij.ide.projectView.PresentationData; import com.intellij.ide.util.treeView.PresentableNodeDescriptor; import com.intellij.navigation.ItemPresentation; -import com.intellij.openapi.actionSystem.DataProvider; -import com.intellij.openapi.actionSystem.PlatformCoreDataKeys; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.NlsContexts; import com.intellij.openapi.util.NlsSafe; @@ -147,7 +142,7 @@ final class ServiceViewDragHelper { return content; } - static final class ServiceViewDragBean implements DataProvider { + static final class ServiceViewDragBean implements ServiceViewDragBeanBase { private final ServiceView myServiceView; private final List myItems; private final ServiceViewContributor myContributor; @@ -182,17 +177,10 @@ final class ServiceViewDragHelper { return myContributor; } - @Nullable @Override - public Object getData(@NotNull String dataId) { - if (PlatformCoreDataKeys.SELECTED_ITEMS.is(dataId)) { - return ContainerUtil.map2Array(myItems, ServiceViewItem::getValue); - } - if (PlatformCoreDataKeys.SELECTED_ITEM.is(dataId)) { - ServiceViewItem item = ContainerUtil.getOnlyItem(myItems); - return item != null ? item.getValue() : null; - } - return null; + @NotNull + public List getSelectedItems() { + return ContainerUtil.map(myItems, ServiceViewItem::getValue); } } diff --git a/platform/lang-api/api-dump-unreviewed.txt b/platform/lang-api/api-dump-unreviewed.txt index f76932e3b0dc..ebbff7b1559b 100644 --- a/platform/lang-api/api-dump-unreviewed.txt +++ b/platform/lang-api/api-dump-unreviewed.txt @@ -2209,6 +2209,8 @@ e:com.intellij.execution.services.ServiceViewDnDDescriptor$Position - sf:INTO:com.intellij.execution.services.ServiceViewDnDDescriptor$Position - s:valueOf(java.lang.String):com.intellij.execution.services.ServiceViewDnDDescriptor$Position - s:values():com.intellij.execution.services.ServiceViewDnDDescriptor$Position[] +com.intellij.execution.services.ServiceViewDragBeanBase +- a:getSelectedItems():java.util.List com.intellij.execution.services.ServiceViewGroupingContributor - com.intellij.execution.services.ServiceViewContributor - a:getGroupDescriptor(java.lang.Object):com.intellij.execution.services.ServiceViewDescriptor diff --git a/platform/lang-api/src/com/intellij/execution/services/ServiceViewDragBeanBase.java b/platform/lang-api/src/com/intellij/execution/services/ServiceViewDragBeanBase.java new file mode 100644 index 000000000000..01e584cff9ee --- /dev/null +++ b/platform/lang-api/src/com/intellij/execution/services/ServiceViewDragBeanBase.java @@ -0,0 +1,11 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.execution.services; + +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public interface ServiceViewDragBeanBase { + @NotNull + List getSelectedItems(); +}