migrate getData to uiDataSnapshot: java

GitOrigin-RevId: 6917901f5fe425ee883779c2fc1775960c2af540
This commit is contained in:
Gregory.Shrago
2024-07-01 17:55:51 +00:00
committed by intellij-monorepo-bot
parent ffb2afa1b3
commit 92047f763d
15 changed files with 108 additions and 188 deletions
@@ -2,7 +2,8 @@
package com.intellij.compiler.backwardRefs.view;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.actionSystem.DataSink;
import com.intellij.openapi.actionSystem.UiDataProvider;
import com.intellij.openapi.compiler.JavaCompilerBundle;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.project.Project;
@@ -22,8 +23,8 @@ import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.components.JBScrollPane;
import com.intellij.ui.content.impl.ContentImpl;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.ui.tree.TreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
@@ -31,7 +32,7 @@ import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.*;
public class InternalCompilerRefServiceView extends JPanel implements DataProvider {
public class InternalCompilerRefServiceView extends JPanel implements UiDataProvider {
private static final String TOOL_WINDOW_ID = "Compiler Reference View";
private final Tree myTree;
private final Project myProject;
@@ -73,22 +74,14 @@ public class InternalCompilerRefServiceView extends JPanel implements DataProvid
add(new JBScrollPane(myTree));
}
@Nullable
@Override
public Object getData(@NotNull String dataId) {
if (CommonDataKeys.NAVIGATABLE.is(dataId)) {
final TreePath path = myTree.getSelectionPath();
if (path != null) {
final Object usrObject = ((DefaultMutableTreeNode)path.getLastPathComponent()).getUserObject();
if (usrObject instanceof VirtualFile) {
return new OpenFileDescriptor(myProject, (VirtualFile)usrObject);
}
else if (usrObject instanceof NavigatablePsiElement) {
return usrObject;
}
}
}
return null;
public void uiDataSnapshot(@NotNull DataSink sink) {
TreePath path = myTree.getSelectionPath();
Object usrObject = TreeUtil.getLastUserObject(path);
sink.lazy(CommonDataKeys.NAVIGATABLE, () -> {
return usrObject instanceof VirtualFile o ? new OpenFileDescriptor(myProject, o) :
usrObject instanceof NavigatablePsiElement o ? o : null;
});
}
public static void showFindUsages(CompilerReferenceFindUsagesTestInfo info, PsiElement element) {
@@ -12,7 +12,8 @@ import com.intellij.debugger.ui.impl.watch.DebuggerTree;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.ActionPopupMenu;
import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.actionSystem.DataSink;
import com.intellij.openapi.actionSystem.UiDataProvider;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.wm.IdeFocusManager;
@@ -27,7 +28,7 @@ import org.jetbrains.annotations.Nullable;
import java.awt.*;
public abstract class DebuggerTreePanel extends UpdatableDebuggerView implements DataProvider, Disposable {
public abstract class DebuggerTreePanel extends UpdatableDebuggerView implements UiDataProvider, Disposable {
public static final DataKey<DebuggerTreePanel> DATA_KEY = DataKey.create("DebuggerPanel");
private final SingleAlarm myRebuildAlarm = new SingleAlarm(() -> {
@@ -124,11 +125,8 @@ public abstract class DebuggerTreePanel extends UpdatableDebuggerView implements
}
@Override
public Object getData(@NotNull String dataId) {
if (DATA_KEY.is(dataId)) {
return this;
}
return null;
public void uiDataSnapshot(@NotNull DataSink sink) {
sink.set(DATA_KEY, this);
}
@Override
@@ -13,10 +13,7 @@ import com.intellij.debugger.ui.impl.watch.DebuggerTree;
import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
import com.intellij.ide.DataManager;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.ActionPopupMenu;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
@@ -158,11 +155,9 @@ public class ThreadsPanel extends DebuggerTreePanel {
}
@Override
public Object getData(@NotNull String dataId) {
if (PlatformCoreDataKeys.HELP_ID.is(dataId)) {
return HELP_ID;
}
return super.getData(dataId);
public void uiDataSnapshot(@NotNull DataSink sink) {
super.uiDataSnapshot(sink);
sink.set(PlatformCoreDataKeys.HELP_ID, HELP_ID);
}
public ThreadsDebuggerTree getThreadsTree() {
@@ -25,7 +25,8 @@ import com.intellij.debugger.ui.impl.tree.TreeBuilderNode;
import com.intellij.ide.dnd.aware.DnDAwareTree;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.actionSystem.DataSink;
import com.intellij.openapi.actionSystem.UiDataProvider;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
@@ -45,7 +46,7 @@ import java.util.Enumeration;
import java.util.LinkedList;
import java.util.List;
public abstract class DebuggerTree extends DnDAwareTree implements DataProvider, Disposable {
public abstract class DebuggerTree extends DnDAwareTree implements UiDataProvider, Disposable {
private static final Logger LOG = Logger.getInstance(DebuggerTree.class);
protected static final Key<Rectangle> VISIBLE_RECT = Key.create("VISIBLE_RECT");
@@ -114,14 +115,10 @@ public abstract class DebuggerTree extends DnDAwareTree implements DataProvider,
}
@Override
public Object getData(@NotNull String dataId) {
if (DATA_KEY.is(dataId)) {
return this;
}
return null;
public void uiDataSnapshot(@NotNull DataSink sink) {
sink.set(DATA_KEY, this);
}
private void buildNode(final DebuggerTreeNodeImpl node) {
if (node == null || node.getDescriptor() == null) {
return;
@@ -23,7 +23,6 @@ import com.intellij.util.ui.update.Update;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import one.util.streamex.StreamEx;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -39,7 +38,7 @@ import java.util.function.Function;
import static com.intellij.util.containers.ContainerUtil.getFirstItem;
import static com.intellij.util.containers.ContainerUtil.mapNotNull;
public class OverheadView extends BorderLayoutPanel implements Disposable, DataProvider {
public class OverheadView extends BorderLayoutPanel implements Disposable, UiDataProvider {
@NotNull private final DebugProcessImpl myProcess;
static final EnabledColumnInfo ENABLED_COLUMN = new EnabledColumnInfo();
@@ -143,25 +142,13 @@ public class OverheadView extends BorderLayoutPanel implements Disposable, DataP
return myTable;
}
@Nullable
@Override
public Object getData(@NotNull String dataId) {
if (PlatformCoreDataKeys.BGT_DATA_PROVIDER.is(dataId)) {
var selectedBreakpoints = getSelectedBreakpoints(); // gather in EDT
return (DataProvider)realDataId -> getSlowData(selectedBreakpoints, realDataId);
}
return null;
}
@Nullable
private static Object getSlowData(@NotNull List<XBreakpoint> selected, @NonNls String dataId) {
if (CommonDataKeys.NAVIGATABLE_ARRAY.is(dataId)) {
List<Navigatable> navigatables = mapNotNull(selected, XBreakpoint::getNavigatable);
if (!navigatables.isEmpty()) {
return navigatables.toArray(Navigatable.EMPTY_NAVIGATABLE_ARRAY);
}
}
return null;
public void uiDataSnapshot(@NotNull DataSink sink) {
var selection = getSelectedBreakpoints();
sink.lazy(CommonDataKeys.NAVIGATABLE_ARRAY, () -> {
List<Navigatable> navigatables = mapNotNull(selection, XBreakpoint::getNavigatable);
return navigatables.isEmpty() ? null : navigatables.toArray(Navigatable.EMPTY_NAVIGATABLE_ARRAY);
});
}
private static class EnabledColumnInfo extends ColumnInfo<OverheadProducer, Boolean> {
@@ -5,10 +5,7 @@ import com.intellij.execution.ExecutionBundle;
import com.intellij.ide.CommonActionsManager;
import com.intellij.ide.DefaultTreeExpander;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.compiler.JavaCompilerBundle;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
@@ -42,7 +39,7 @@ import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
class DiscoveredTestsTree extends Tree implements DataProvider, Disposable {
class DiscoveredTestsTree extends Tree implements UiDataProvider, Disposable {
private final DiscoveredTestsTreeModel myModel;
DiscoveredTestsTree(String title) {
@@ -155,25 +152,16 @@ class DiscoveredTestsTree extends Tree implements DataProvider, Disposable {
return myModel.getTestClassesCount();
}
@Nullable
@Override
public Object getData(@NotNull String dataId) {
if (PlatformCoreDataKeys.BGT_DATA_PROVIDER.is(dataId)) {
TreePath[] paths = getSelectionPaths();
return (DataProvider)slowId -> getSlowData(slowId, paths);
}
else if (LangDataKeys.POSITION_ADJUSTER_POPUP.is(dataId)) {
return PopupUtil.getPopupContainerFor(this);
}
return null;
}
public void uiDataSnapshot(@NotNull DataSink sink) {
TreePath[] paths = getSelectionPaths();
sink.set(LangDataKeys.POSITION_ADJUSTER_POPUP, PopupUtil.getPopupContainerFor(this));
private @Nullable Object getSlowData(@NotNull String dataId, TreePath @Nullable [] paths) {
if (paths == null || paths.length == 0) return null;
if (CommonDataKeys.PSI_ELEMENT.is(dataId)) {
if (paths == null || paths.length == 0) return;
sink.lazy(CommonDataKeys.PSI_ELEMENT, () -> {
return obj2psi(paths[0].getLastPathComponent());
}
else if (PlatformCoreDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
});
sink.lazy(PlatformCoreDataKeys.PSI_ELEMENT_ARRAY, () -> {
List<PsiElement> result = new SmartList<>();
TreeModel model = getModel();
for (TreePath p : paths) {
@@ -195,7 +183,6 @@ class DiscoveredTestsTree extends Tree implements DataProvider, Disposable {
}
}
return result.toArray(PsiElement.EMPTY_ARRAY);
}
return null;
});
}
}
@@ -4,8 +4,9 @@ package com.intellij.openapi.roots.ui.configuration;
import com.intellij.facet.impl.ProjectFacetsConfigurator;
import com.intellij.ide.JavaUiBundle;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.actionSystem.DataSink;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.UiDataProvider;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.module.Module;
@@ -547,17 +548,14 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
updateImportedModelWarning();
}
private class ModuleEditorPanel extends JPanel implements DataProvider{
private class ModuleEditorPanel extends JPanel implements UiDataProvider {
ModuleEditorPanel() {
super(new BorderLayout());
}
@Override
public Object getData(@NotNull String dataId) {
if (LangDataKeys.MODULE_CONTEXT.is(dataId)) {
return getModule();
}
return null;
public void uiDataSnapshot(@NotNull DataSink sink) {
sink.set(LangDataKeys.MODULE_CONTEXT, getModule());
}
}
}
@@ -615,21 +615,15 @@ public class ProjectStructureConfigurable implements SearchableConfigurable, Pla
return myContext;
}
private class MyPanel extends JPanel implements DataProvider {
private class MyPanel extends JPanel implements UiDataProvider {
MyPanel() {
super(new BorderLayout());
}
@Override
@Nullable
public Object getData(@NotNull @NonNls final String dataId) {
if (KEY.is(dataId)) {
return ProjectStructureConfigurable.this;
} else if (History.KEY.is(dataId)) {
return getHistory();
} else {
return null;
}
public void uiDataSnapshot(@NotNull DataSink sink) {
sink.set(KEY, ProjectStructureConfigurable.this);
sink.set(History.KEY, getHistory());
}
@Override
@@ -58,7 +58,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Objects;
public class ArtifactEditorImpl implements ArtifactEditorEx, DataProvider {
public class ArtifactEditorImpl implements ArtifactEditorEx, UiDataProvider {
private JPanel myMainPanel;
private JCheckBox myBuildOnMakeCheckBox;
private TextFieldWithBrowseButton myOutputDirectoryField;
@@ -189,7 +189,7 @@ public class ArtifactEditorImpl implements ArtifactEditorEx, DataProvider {
public JComponent createMainComponent() {
myLayoutTreeComponent.initTree();
DataManager.registerDataProvider(myMainPanel, this);
DataManager.registerDataProvider(myMainPanel, (EdtNoGetDataProvider)this::uiDataSnapshot);
myErrorPanelPlace.add(myValidationManager.getMainErrorPanel(), BorderLayout.CENTER);
@@ -549,13 +549,9 @@ public class ArtifactEditorImpl implements ArtifactEditorEx, DataProvider {
return helpId != null ? helpId : "reference.settingsdialog.project.structure.artifacts";
}
@Nullable
@Override
public Object getData(@NotNull String dataId) {
if (ARTIFACTS_EDITOR_KEY.is(dataId)) {
return this;
}
return null;
public void uiDataSnapshot(@NotNull DataSink sink) {
sink.set(ARTIFACTS_EDITOR_KEY, this);
}
}
@@ -38,7 +38,10 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProj
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureDaemonAnalyzer;
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement;
import com.intellij.openapi.ui.*;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.NullableComputable;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.NioFiles;
import com.intellij.openapi.util.text.StringUtil;
@@ -803,24 +806,21 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
}
}
private class MyDataProviderWrapper extends JPanel implements DataProvider {
private class MyDataProviderWrapper extends JPanel implements UiDataProvider {
MyDataProviderWrapper(final JComponent component) {
super(new BorderLayout());
add(component, BorderLayout.CENTER);
}
@Override
@Nullable
public Object getData(@NotNull @NonNls String dataId) {
return ValueKey.match(dataId)
.ifEq(LangDataKeys.MODULE_CONTEXT_ARRAY).thenGet(this::getModuleContexts)
.ifEq(LangDataKeys.MODULE_CONTEXT).thenGet(() -> getSelectedModule())
.ifEq(LangDataKeys.MODIFIABLE_MODULE_MODEL).thenGet(() -> myContext.myModulesConfigurator.getModuleModel())
.ifEq(PlatformCoreDataKeys.SELECTED_ITEM).thenGet(() -> getSelectedObject())
.orNull();
public void uiDataSnapshot(@NotNull DataSink sink) {
sink.set(LangDataKeys.MODULE_CONTEXT_ARRAY, getModuleContexts());
sink.set(LangDataKeys.MODULE_CONTEXT, getSelectedModule());
sink.set(LangDataKeys.MODIFIABLE_MODULE_MODEL, myContext.myModulesConfigurator.getModuleModel());
sink.set(PlatformCoreDataKeys.SELECTED_ITEM, getSelectedObject());
}
private Module[] getModuleContexts() {
private Module @Nullable [] getModuleContexts() {
final TreePath[] paths = myTree.getSelectionPaths();
Set<Module> modules = new LinkedHashSet<>();
if (paths != null) {
@@ -6,7 +6,8 @@ import com.intellij.ide.actions.exclusion.ExclusionHandler;
import com.intellij.java.refactoring.JavaRefactoringBundle;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.actionSystem.DataSink;
import com.intellij.openapi.actionSystem.UiDataProvider;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
@@ -26,7 +27,6 @@ import com.intellij.util.ui.DialogUtil;
import com.intellij.util.ui.components.BorderLayoutPanel;
import one.util.streamex.StreamEx;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
@@ -34,7 +34,7 @@ import java.awt.*;
import java.util.List;
import java.util.Optional;
class PreviewPanel extends BorderLayoutPanel implements Disposable, DataProvider {
class PreviewPanel extends BorderLayoutPanel implements Disposable, UiDataProvider {
private final Project myProject;
private final PreviewTree myTree;
private final ExclusionHandler<DefaultMutableTreeNode> myExclusionHandler;
@@ -74,31 +74,23 @@ class PreviewPanel extends BorderLayoutPanel implements Disposable, DataProvider
Disposer.register(this, myDiffPanel);
}
@Nullable
@Override
public Object getData(@NotNull String dataId) {
if (ExclusionHandler.EXCLUSION_HANDLER.is(dataId)) {
return myExclusionHandler;
}
if (CommonDataKeys.NAVIGATABLE.is(dataId)) {
List<FragmentNode> selectedNodes = myTree.getSelectedNodes();
if (selectedNodes.size() == 1) {
return Optional.ofNullable(selectedNodes.get(0))
.map(FragmentNode::getNavigatable)
.map(n -> new Navigatable[]{n})
.orElse(null);
}
}
if (CommonDataKeys.NAVIGATABLE_ARRAY.is(dataId)) {
List<FragmentNode> selectedNodes = myTree.getSelectedNodes();
if (!selectedNodes.isEmpty()) {
return StreamEx.of(selectedNodes)
.map(FragmentNode::getNavigatable)
.nonNull()
.toArray(Navigatable[]::new);
}
}
return null;
public void uiDataSnapshot(@NotNull DataSink sink) {
List<FragmentNode> selectedNodes = myTree.getSelectedNodes();
sink.set(ExclusionHandler.EXCLUSION_HANDLER, myExclusionHandler);
sink.lazy(CommonDataKeys.NAVIGATABLE, () -> {
if (selectedNodes.size() != 1) return null;
return Optional.ofNullable(selectedNodes.get(0))
.map(FragmentNode::getNavigatable)
.orElse(null);
});
sink.lazy(CommonDataKeys.NAVIGATABLE_ARRAY, () -> {
if (selectedNodes.isEmpty()) return null;
return StreamEx.of(selectedNodes)
.map(FragmentNode::getNavigatable)
.nonNull()
.toArray(Navigatable[]::new);
});
}
public void setContent(Content content) {
@@ -41,7 +41,6 @@ import com.intellij.usages.UsagePresentation;
import com.intellij.util.EditSourceOnDoubleClickHandler;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.tree.TreeUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -266,7 +265,7 @@ public final class MigrationPanel extends JPanel implements Disposable {
Disposer.register(content, this);
}
private static final class MyTree extends Tree implements DataProvider {
private static final class MyTree extends Tree implements UiDataProvider {
@Override
protected void paintComponent(final Graphics g) {
DuplicateNodeRenderer.paintDuplicateNodesBackground(g, this);
@@ -274,24 +273,18 @@ public final class MigrationPanel extends JPanel implements Disposable {
}
@Override
public Object getData(@NotNull @NonNls final String dataId) {
if (PlatformCoreDataKeys.BGT_DATA_PROVIDER.is(dataId)) {
final DefaultMutableTreeNode[] selectedNodes = getSelectedNodes(DefaultMutableTreeNode.class, null);
if (selectedNodes.length == 1 && selectedNodes[0].getUserObject() instanceof MigrationNode node) {
return (DataProvider)slowId -> CommonDataKeys.PSI_ELEMENT.is(dataId) ? node.getInfo().getElement() : null;
public void uiDataSnapshot(@NotNull DataSink sink) {
DefaultMutableTreeNode[] selectedNodes = getSelectedNodes(DefaultMutableTreeNode.class, null);
if (selectedNodes.length == 1 && selectedNodes[0].getUserObject() instanceof MigrationNode node) {
sink.lazy(CommonDataKeys.PSI_ELEMENT, () -> node.getInfo().getElement());
}
Set<TypeMigrationUsageInfo> usageInfos = new HashSet<>();
for (DefaultMutableTreeNode selectedNode : selectedNodes) {
if (selectedNode.getUserObject() instanceof MigrationNode node) {
collectInfos(usageInfos, node);
}
}
if (MIGRATION_USAGES_KEY.is(dataId)) {
DefaultMutableTreeNode[] selectedNodes = getSelectedNodes(DefaultMutableTreeNode.class, null);
final Set<TypeMigrationUsageInfo> usageInfos = new HashSet<>();
for (DefaultMutableTreeNode selectedNode : selectedNodes) {
if (selectedNode.getUserObject() instanceof MigrationNode node) {
collectInfos(usageInfos, node);
}
}
return usageInfos.toArray(new TypeMigrationUsageInfo[0]);
}
return null;
sink.set(MIGRATION_USAGES_KEY, usageInfos.toArray(new TypeMigrationUsageInfo[0]));
}
private static void collectInfos(final Set<? super TypeMigrationUsageInfo> usageInfos, final MigrationNode currentNode) {
@@ -25,7 +25,6 @@ import com.intellij.ui.content.Content;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.EditSourceOnDoubleClickHandler;
import com.intellij.util.ui.tree.TreeUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -38,7 +37,7 @@ import java.awt.*;
import java.util.List;
import java.util.*;
public final class CyclicDependenciesPanel extends JPanel implements Disposable, DataProvider {
public final class CyclicDependenciesPanel extends JPanel implements Disposable, UiDataProvider {
private static final Set<PsiFile> EMPTY_FILE_SET = new HashSet<>(0);
private final HashMap<PsiPackage, Set<List<PsiPackage>>> myDependencies;
@@ -337,11 +336,8 @@ public final class CyclicDependenciesPanel extends JPanel implements Disposable,
}
@Override
public @Nullable @NonNls Object getData(@NotNull @NonNls String dataId) {
if (PlatformCoreDataKeys.HELP_ID.is(dataId)) {
return "dependency.viewer.tool.window";
}
return null;
public void uiDataSnapshot(@NotNull DataSink sink) {
sink.set(PlatformCoreDataKeys.HELP_ID, "dependency.viewer.tool.window");
}
private class MyTreeCellRenderer extends ColoredTreeCellRenderer {
@@ -32,7 +32,6 @@ import com.intellij.util.PlatformIcons;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
@@ -51,7 +50,7 @@ import static com.intellij.icons.AllIcons.Debugger.ThreadStates.*;
* @author Jeka
* @author Konstantin Bulenkov
*/
public final class ThreadDumpPanel extends JPanel implements DataProvider {
public final class ThreadDumpPanel extends JPanel implements UiDataProvider {
private static final Icon PAUSE_ICON_DAEMON = LayeredIcon.layeredIcon(() -> new Icon[]{AllIcons.Actions.Pause, Daemon_sign});
private static final Icon LOCKED_ICON_DAEMON = LayeredIcon.layeredIcon(() -> new Icon[]{AllIcons.Debugger.MuteBreakpoints, Daemon_sign});
private static final Icon RUNNING_ICON_DAEMON = LayeredIcon.layeredIcon(() -> new Icon[]{AllIcons.Actions.Resume, Daemon_sign});
@@ -163,11 +162,8 @@ public final class ThreadDumpPanel extends JPanel implements DataProvider {
}
@Override
public @Nullable Object getData(@NotNull @NonNls String dataId) {
if (PlatformDataKeys.EXPORTER_TO_TEXT_FILE.is(dataId)) {
return myExporterToTextFile;
}
return null;
public void uiDataSnapshot(@NotNull DataSink sink) {
sink.set(PlatformDataKeys.EXPORTER_TO_TEXT_FILE, myExporterToTextFile);
}
private void updateThreadList() {
@@ -373,19 +373,17 @@ public final class MethodParameterPanel extends AbstractInjectionPanel<MethodPar
}
}
private static class MyView extends TreeTableView implements DataProvider {
private static class MyView extends TreeTableView implements UiDataProvider {
MyView(ListTreeTableModelOnColumns treeTableModel) {
super(treeTableModel);
}
@Nullable
@Override
public Object getData(@NotNull String dataId) {
if (CommonDataKeys.PSI_ELEMENT.is(dataId)) {
Object userObject = TreeUtil.getUserObject(ContainerUtil.getFirstItem(getSelection()));
return userObject instanceof PsiElement ? userObject : null;
}
return null;
public void uiDataSnapshot(@NotNull DataSink sink) {
Object userObject = TreeUtil.getUserObject(ContainerUtil.getFirstItem(getSelection()));
sink.lazy(CommonDataKeys.PSI_ELEMENT, () -> {
return userObject instanceof PsiElement o ? o : null;
});
}
}