From 4d5b8847ebabbe632d6826d4ebd53fd90f027994 Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Mon, 24 Jun 2024 19:43:07 +0400 Subject: [PATCH] migrate `getData` to `uiDataSnapshot`: vcs GitOrigin-RevId: 0dc4a83894cd35777959eab7235d2603117a1c9e --- .../CodeReviewChangeListComponentFactory.kt | 16 +-- .../changes/CodeReviewChangesTreeFactory.kt | 6 +- .../diff/impl/GenericDataProvider.java | 5 +- platform/diff-impl/resources/api-dump.txt | 2 +- .../diff/impl/DiffRequestProcessor.java | 85 +++++----------- .../com/intellij/diff/impl/DiffWindow.java | 10 +- .../lvcs/impl/ui/ActivityChangesBrowser.kt | 10 +- platform/vcs-impl/api-dump-unreviewed.txt | 17 ++-- .../vcs/changes/ChangesViewManager.java | 11 +-- .../vcs/changes/SpecificFilesViewDialog.java | 62 +++--------- .../committed/CommittedChangesBrowser.java | 30 ++---- .../SavedPatchesChangesBrowser.kt | 69 ++++++------- .../shelf/ShelvedChangesViewManager.java | 97 ++++++++----------- .../vcs/changes/ui/ChangesBrowserBase.java | 12 +-- .../changes/ui/CommitChangeListDialog.java | 8 +- .../ui/MultipleLocalChangeListsBrowser.java | 26 ++--- .../vcs/changes/ui/SelectFilesDialog.java | 15 +-- .../vcs/changes/ui/VcsTreeModelData.java | 66 ++++--------- .../ui/browser/FilterableChangesBrowser.java | 10 +- platform/vcs-log/impl/api-dump-unreviewed.txt | 2 +- .../vcs/log/ui/frame/VcsLogChangesBrowser.kt | 43 +++----- .../src/git4idea/index/ui/GitStageTree.kt | 45 ++++----- .../ui/branch/popup/GitBranchesTreePopup.kt | 19 +--- ...ConfiguratorChangesDiffRequestProcessor.kt | 8 +- .../idea/svn/dialogs/CopiesPanel.java | 12 +-- .../svn/integrate/AlienChangeListBrowser.kt | 7 +- 26 files changed, 246 insertions(+), 447 deletions(-) diff --git a/platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/changes/CodeReviewChangeListComponentFactory.kt b/platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/changes/CodeReviewChangeListComponentFactory.kt index 1bf623f81f35..26e59b3991dc 100644 --- a/platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/changes/CodeReviewChangeListComponentFactory.kt +++ b/platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/changes/CodeReviewChangeListComponentFactory.kt @@ -11,12 +11,13 @@ import com.intellij.collaboration.util.filePath import com.intellij.collaboration.util.fileStatus import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.actionSystem.DataKey +import com.intellij.openapi.actionSystem.DataSink import com.intellij.openapi.fileEditor.OpenFileDescriptor import com.intellij.openapi.vcs.FilePath import com.intellij.openapi.vcs.changes.ChangesUtil import com.intellij.openapi.vcs.changes.ui.* -import com.intellij.openapi.vcs.changes.ui.VcsTreeModelData.getDataOrSuper import com.intellij.openapi.vcs.changes.ui.VcsTreeModelData.selected +import com.intellij.openapi.vcs.changes.ui.VcsTreeModelData.uiDataSnapshot import com.intellij.openapi.vfs.VirtualFile import com.intellij.ui.ClientProperty import com.intellij.ui.ExpandableItemsHandler @@ -93,13 +94,12 @@ object CodeReviewChangeListComponentFactory { object : AsyncChangesTree(vm.project, false, false) { override val changesTreeModel: AsyncChangesTreeModel = treeModel - override fun getData(dataId: String): Any? { - return when { - CommonDataKeys.NAVIGATABLE.`is`(dataId) -> getSelectedFiles().singleOrNull()?.let { OpenFileDescriptor(project, it) } - CommonDataKeys.NAVIGATABLE_ARRAY.`is`(dataId) -> ChangesUtil.getNavigatableArray(project, getSelectedFiles()) - SELECTED_CHANGES.`is`(dataId) -> getSelectedChanges() - else -> return getDataOrSuper(project, this, dataId, super.getData(dataId)) - } + override fun uiDataSnapshot(sink: DataSink) { + super.uiDataSnapshot(sink) + uiDataSnapshot(sink, project, this) + sink[CommonDataKeys.NAVIGATABLE] = getSelectedFiles().singleOrNull()?.let { OpenFileDescriptor(project, it) } + sink[CommonDataKeys.NAVIGATABLE_ARRAY] = ChangesUtil.getNavigatableArray(project, getSelectedFiles()) + sink[SELECTED_CHANGES] = getSelectedChanges() } private fun getSelectedChanges(): List = diff --git a/platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/changes/CodeReviewChangesTreeFactory.kt b/platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/changes/CodeReviewChangesTreeFactory.kt index 16f15dd1291c..5470d217eb35 100644 --- a/platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/changes/CodeReviewChangesTreeFactory.kt +++ b/platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/changes/CodeReviewChangesTreeFactory.kt @@ -4,6 +4,7 @@ package com.intellij.collaboration.ui.codereview.changes import com.intellij.collaboration.ui.SingleValueModel import com.intellij.openapi.actionSystem.ActionGroup import com.intellij.openapi.actionSystem.ActionManager +import com.intellij.openapi.actionSystem.DataSink import com.intellij.openapi.actionSystem.DefaultActionGroup import com.intellij.openapi.actionSystem.IdeActions import com.intellij.openapi.project.Project @@ -36,7 +37,10 @@ class CodeReviewChangesTreeFactory(private val project: Project, } } - override fun getData(dataId: String) = VcsTreeModelData.getDataOrSuper(project, this, dataId, super.getData(dataId)) + override fun uiDataSnapshot(sink: DataSink) { + super.uiDataSnapshot(sink) + VcsTreeModelData.uiDataSnapshot(sink, project, this) + } }.apply { emptyText.text = emptyTextText diff --git a/platform/diff-api/src/com/intellij/openapi/diff/impl/GenericDataProvider.java b/platform/diff-api/src/com/intellij/openapi/diff/impl/GenericDataProvider.java index b39bbd518967..ddd538414847 100644 --- a/platform/diff-api/src/com/intellij/openapi/diff/impl/GenericDataProvider.java +++ b/platform/diff-api/src/com/intellij/openapi/diff/impl/GenericDataProvider.java @@ -3,6 +3,7 @@ package com.intellij.openapi.diff.impl; import com.intellij.openapi.actionSystem.DataKey; import com.intellij.openapi.actionSystem.DataProvider; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -10,8 +11,10 @@ import java.util.HashMap; import java.util.Map; /** - * Prefer using {@link com.intellij.diff.util.DiffUtil#putDataKey} instead + * @deprecated Prefer using {@link com.intellij.diff.util.DiffUtil#putDataKey} instead */ +@ApiStatus.NonExtendable +@Deprecated public class GenericDataProvider implements DataProvider { private final Map myGenericData; private final DataProvider myParentProvider; diff --git a/platform/diff-impl/resources/api-dump.txt b/platform/diff-impl/resources/api-dump.txt index 2590e82336a7..2c49fe367d51 100644 --- a/platform/diff-impl/resources/api-dump.txt +++ b/platform/diff-impl/resources/api-dump.txt @@ -457,6 +457,7 @@ a:com.intellij.diff.impl.DiffRequestProcessor - p:buildToolbar(java.util.List):V - p:collectPopupActions(java.util.List):V - p:collectToolbarActions(java.util.List):V +- p:createAfterNavigateCallback():java.lang.Runnable - p:createGoToChangeAction():com.intellij.openapi.actionSystem.AnAction - dispose():V - fireProcessorActivated():V @@ -465,7 +466,6 @@ a:com.intellij.diff.impl.DiffRequestProcessor - getComponent():javax.swing.JComponent - getContext():com.intellij.diff.DiffContext - getContextUserData(com.intellij.openapi.util.Key):java.lang.Object -- p:getData(java.lang.String):java.lang.Object - getDisposable():com.intellij.openapi.util.CheckedDisposable - getEmbeddedEditors():java.util.List - getFilesToRefresh():java.util.List diff --git a/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java b/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java index ba8213a25e41..09f8c2fe1580 100644 --- a/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java +++ b/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java @@ -77,8 +77,10 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; -import java.util.*; +import java.util.Map; import static com.intellij.diff.util.DiffUtil.recursiveRegisterShortcutSet; import static com.intellij.util.ObjectUtils.chooseNotNull; @@ -93,7 +95,8 @@ import static com.intellij.util.ObjectUtils.chooseNotNull; * @see com.intellij.openapi.vcs.changes.ChangeViewDiffRequestProcessor * @see DiffViewerVirtualFile */ -public abstract class DiffRequestProcessor implements DiffEditorViewer, CheckedDisposable { +public abstract class DiffRequestProcessor + implements DiffEditorViewer, CheckedDisposable { private static final Logger LOG = Logger.getInstance(DiffRequestProcessor.class); private static final DataKey ACTIVE_DIFF_TOOL = DataKey.create("active_diff_tool"); @@ -470,8 +473,8 @@ public abstract class DiffRequestProcessor implements DiffEditorViewer, CheckedD myContext.putUserData(key, value); } - protected @Nullable Object getData(@NotNull @NonNls String dataId) { - return null; + protected @Nullable Runnable createAfterNavigateCallback() { + return () -> DiffUtil.minimizeDiffIfOpenedInWindow(myPanel); } protected @NotNull List getNavigationActions() { @@ -1339,18 +1342,12 @@ public abstract class DiffRequestProcessor implements DiffEditorViewer, CheckedD @Override public void uiDataSnapshot(@NotNull DataSink sink) { - sink.set(OpenInEditorAction.AFTER_NAVIGATE_CALLBACK, - () -> DiffUtil.minimizeDiffIfOpenedInWindow(DiffRequestProcessor.this.myPanel)); + sink.set(OpenInEditorAction.AFTER_NAVIGATE_CALLBACK, createAfterNavigateCallback()); - for (DataProvider provider : Arrays.asList(DiffRequestProcessor.this::getData, - myContext.getUserData(DiffUserDataKeys.DATA_PROVIDER), - myActiveRequest.getUserData(DiffUserDataKeys.DATA_PROVIDER), - myState::getData)) { - DataSink.uiDataSnapshot(sink, provider); - } - - DataProvider contentProvider = DataManagerImpl.getDataProviderEx(myContentPanel.getTargetComponent()); - DataSink.uiDataSnapshot(sink, contentProvider); + DataSink.uiDataSnapshot(sink, myContext.getUserData(DiffUserDataKeys.DATA_PROVIDER)); + DataSink.uiDataSnapshot(sink, myActiveRequest.getUserData(DiffUserDataKeys.DATA_PROVIDER)); + DataSink.uiDataSnapshot(sink, myState); + DataSink.uiDataSnapshot(sink, DataManagerImpl.getDataProviderEx(myContentPanel.getTargetComponent())); sink.set(CommonDataKeys.PROJECT, myProject); sink.set(DiffDataKeys.DIFF_CONTEXT, myContext); @@ -1487,18 +1484,18 @@ public abstract class DiffRequestProcessor implements DiffEditorViewer, CheckedD // States // - private interface ViewerState { + private interface ViewerState extends UiDataProvider { @RequiresEdt - void init(); + default void init() { } @RequiresEdt - void destroy(); + default void destroy() { } @Nullable - JComponent getPreferredFocusedComponent(); + default JComponent getPreferredFocusedComponent() { return null; } - @Nullable - Object getData(@NotNull @NonNls String dataId); + @Override + default void uiDataSnapshot(@NotNull DataSink sink) { } @NotNull DiffTool getActiveTool(); @@ -1507,24 +1504,6 @@ public abstract class DiffRequestProcessor implements DiffEditorViewer, CheckedD private static final class EmptyState implements ViewerState { private static final EmptyState INSTANCE = new EmptyState(); - @Override - public void init() { - } - - @Override - public void destroy() { - } - - @Override - public @Nullable JComponent getPreferredFocusedComponent() { - return null; - } - - @Override - public @Nullable Object getData(@NotNull @NonNls String dataId) { - return null; - } - @Override public @NotNull DiffTool getActiveTool() { return ErrorDiffTool.INSTANCE; @@ -1561,16 +1540,6 @@ public abstract class DiffRequestProcessor implements DiffEditorViewer, CheckedD } } - @Override - public @Nullable JComponent getPreferredFocusedComponent() { - return null; - } - - @Override - public @Nullable Object getData(@NotNull @NonNls String dataId) { - return null; - } - @Override public @NotNull DiffTool getActiveTool() { return myDiffTool != null ? myDiffTool : ErrorDiffTool.INSTANCE; @@ -1631,11 +1600,8 @@ public abstract class DiffRequestProcessor implements DiffEditorViewer, CheckedD } @Override - public @Nullable Object getData(@NotNull @NonNls String dataId) { - if (DiffDataKeys.DIFF_VIEWER.is(dataId)) { - return myViewer; - } - return null; + public void uiDataSnapshot(@NotNull DataSink sink) { + sink.set(DiffDataKeys.DIFF_VIEWER, myViewer); } } @@ -1711,14 +1677,9 @@ public abstract class DiffRequestProcessor implements DiffEditorViewer, CheckedD } @Override - public @Nullable Object getData(@NotNull @NonNls String dataId) { - if (DiffDataKeys.WRAPPING_DIFF_VIEWER.is(dataId)) { - return myWrapperViewer; - } - if (DiffDataKeys.DIFF_VIEWER.is(dataId)) { - return myViewer; - } - return null; + public void uiDataSnapshot(@NotNull DataSink sink) { + sink.set(DiffDataKeys.WRAPPING_DIFF_VIEWER, myWrapperViewer); + sink.set(DiffDataKeys.DIFF_VIEWER, myViewer); } } diff --git a/platform/diff-impl/src/com/intellij/diff/impl/DiffWindow.java b/platform/diff-impl/src/com/intellij/diff/impl/DiffWindow.java index 0214bbf817a1..728d8ce2b3f6 100644 --- a/platform/diff-impl/src/com/intellij/diff/impl/DiffWindow.java +++ b/platform/diff-impl/src/com/intellij/diff/impl/DiffWindow.java @@ -16,7 +16,6 @@ package com.intellij.diff.impl; import com.intellij.diff.DiffDialogHints; -import com.intellij.diff.actions.impl.OpenInEditorAction; import com.intellij.diff.chains.DiffRequestChain; import com.intellij.diff.util.DiffUtil; import com.intellij.openapi.project.Project; @@ -43,13 +42,8 @@ public class DiffWindow extends DiffWindowBase { } @Override - protected @Nullable Object getData(@NotNull String dataId) { - if (OpenInEditorAction.AFTER_NAVIGATE_CALLBACK.is(dataId)) { - return (Runnable)() -> { - DiffUtil.closeWindow(getWrapper().getWindow(), true, true); - }; - } - return super.getData(dataId); + protected @NotNull Runnable createAfterNavigateCallback() { + return () -> DiffUtil.closeWindow(getWrapper().getWindow(), true, true); } @Override diff --git a/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ui/ActivityChangesBrowser.kt b/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ui/ActivityChangesBrowser.kt index a14b3fd88d16..89615beb6c41 100644 --- a/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ui/ActivityChangesBrowser.kt +++ b/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ui/ActivityChangesBrowser.kt @@ -5,6 +5,7 @@ import com.intellij.history.integration.LocalHistoryBundle import com.intellij.openapi.Disposable import com.intellij.openapi.actionSystem.ActionManager import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.DataSink import com.intellij.openapi.components.service import com.intellij.openapi.project.Project import com.intellij.openapi.vcs.FilePath @@ -84,11 +85,10 @@ internal class ActivityChangesBrowser(project: Project, private val isSwitchingD return activityFileChange.createProducer(myProject) } - override fun getData(dataId: String): Any? { - if (ActivityViewDataKeys.SELECTED_DIFFERENCES.`is`(dataId)) { - return VcsTreeModelData.selected(myViewer).iterateUserObjects(PresentableChange::class.java) - } - return super.getData(dataId) + override fun uiDataSnapshot(sink: DataSink) { + super.uiDataSnapshot(sink) + sink[ActivityViewDataKeys.SELECTED_DIFFERENCES] = + VcsTreeModelData.selected(myViewer).iterateUserObjects(PresentableChange::class.java) } override fun createToolbarActions(): List { diff --git a/platform/vcs-impl/api-dump-unreviewed.txt b/platform/vcs-impl/api-dump-unreviewed.txt index 1d27558a1967..70ba35010ce2 100644 --- a/platform/vcs-impl/api-dump-unreviewed.txt +++ b/platform/vcs-impl/api-dump-unreviewed.txt @@ -1704,7 +1704,6 @@ f:com.intellij.openapi.vcs.changes.ChangesViewManager$ChangesViewToolWindowPanel - addListener(com.intellij.openapi.vcs.changes.ChangesViewManager$ChangesViewToolWindowPanel$Listener,com.intellij.openapi.Disposable):V - dispose():V - getActions(Z):java.util.List -- getData(java.lang.String):java.lang.Object - isAllowExcludeFromCommit():Z - refreshChangesViewNodeAsync(com.intellij.openapi.vfs.VirtualFile):V - scheduleRefresh():V @@ -1712,6 +1711,7 @@ f:com.intellij.openapi.vcs.changes.ChangesViewManager$ChangesViewToolWindowPanel - selectFile(com.intellij.openapi.vfs.VirtualFile):V - setBusy(Z):V - setGrouping(java.lang.String):V +- uiDataSnapshot(com.intellij.openapi.actionSystem.DataSink):V - updateCommitWorkflow():V - updateProgressText(java.lang.String,Z):V com.intellij.openapi.vcs.changes.ChangesViewManager$ChangesViewToolWindowPanel$Listener @@ -3043,8 +3043,8 @@ c:com.intellij.openapi.vcs.changes.committed.CommittedChangesBrowser - (com.intellij.openapi.project.Project):V - p:createPopupMenuActions():java.util.List - p:createToolbarActions():java.util.List -- getData(java.lang.String):java.lang.Object - setUseCase(com.intellij.openapi.vcs.changes.committed.CommittedChangesBrowserUseCase):V +- uiDataSnapshot(com.intellij.openapi.actionSystem.DataSink):V c:com.intellij.openapi.vcs.changes.committed.CommittedChangesBrowserDialogPanel - javax.swing.JPanel - (com.intellij.openapi.project.Project,com.intellij.openapi.vcs.changes.committed.CommittedChangesTableModel):V @@ -4296,10 +4296,10 @@ f:com.intellij.openapi.vcs.changes.savedPatches.SavedPatchesChangesBrowser - dispose():V - f:getChanges():java.util.Collection - f:getCurrentPatchObject():com.intellij.openapi.vcs.changes.savedPatches.SavedPatchesProvider$PatchObject -- getData(java.lang.String):java.lang.Object - getDiffRequestProducer(java.lang.Object):com.intellij.openapi.vcs.changes.ui.ChangeDiffRequestChain$Producer - f:getDiffWithLocalRequestProducer(java.lang.Object,Z):com.intellij.openapi.vcs.changes.ui.ChangeDiffRequestChain$Producer - f:selectPatchObject(com.intellij.openapi.vcs.changes.savedPatches.SavedPatchesProvider$PatchObject):V +- uiDataSnapshot(com.intellij.openapi.actionSystem.DataSink):V f:com.intellij.openapi.vcs.changes.savedPatches.SavedPatchesDiffPreviewHandler - com.intellij.openapi.vcs.changes.ui.ChangesTreeDiffPreviewHandler - (kotlin.jvm.functions.Function0):V @@ -4930,7 +4930,7 @@ com.intellij.openapi.vcs.changes.ui.ChangeNodeDecorator - a:preDecorate(com.intellij.openapi.vcs.changes.Change,com.intellij.openapi.vcs.changes.ui.ChangesBrowserNodeRenderer,Z):V a:com.intellij.openapi.vcs.changes.ui.ChangesBrowserBase - javax.swing.JPanel -- com.intellij.openapi.actionSystem.DataProvider +- com.intellij.openapi.actionSystem.UiCompatibleDataProvider - sf:DATA_KEY:com.intellij.openapi.actionSystem.DataKey - pf:myProject:com.intellij.openapi.project.Project - pf:myViewer:com.intellij.openapi.vcs.changes.ui.ChangesTree @@ -4948,7 +4948,6 @@ a:com.intellij.openapi.vcs.changes.ui.ChangesBrowserBase - p:createToolbarComponent():javax.swing.JComponent - p:createTreeList(com.intellij.openapi.project.Project,Z,Z):com.intellij.openapi.vcs.changes.ui.ChangesTree - p:createViewerBorder():javax.swing.border.Border -- getData(java.lang.String):java.lang.Object - getDiffAction():com.intellij.openapi.actionSystem.AnAction - p:getDiffRequestProducer(java.lang.Object):com.intellij.openapi.vcs.changes.ui.ChangeDiffRequestChain$Producer - getGrouping():com.intellij.openapi.vcs.changes.ui.ChangesGroupingPolicyFactory @@ -4970,6 +4969,7 @@ a:com.intellij.openapi.vcs.changes.ui.ChangesBrowserBase - showDiff():V - s:showStandaloneDiff(com.intellij.openapi.project.Project,com.intellij.openapi.vcs.changes.ui.ChangesBrowserBase):V - s:showStandaloneDiff(com.intellij.openapi.project.Project,com.intellij.openapi.vcs.changes.ui.ChangesBrowserBase,com.intellij.openapi.ListSelection,com.intellij.util.NullableFunction):V +- uiDataSnapshot(com.intellij.openapi.actionSystem.DataSink):V - p:updateDiffContext(com.intellij.diff.chains.DiffRequestChain):V c:com.intellij.openapi.vcs.changes.ui.ChangesBrowserBase$ShowStandaloneDiff - com.intellij.openapi.actionSystem.AnActionExtensionProvider @@ -5916,7 +5916,7 @@ c:com.intellij.openapi.vcs.changes.ui.SelectFilesDialog$VirtualFileList - com.intellij.openapi.vcs.changes.ui.AsyncChangesTreeImpl$VirtualFiles - (com.intellij.openapi.project.Project,Z,Z,java.util.List):V - p:buildTreeModel(com.intellij.openapi.vcs.changes.ui.ChangesGroupingPolicyFactory,java.util.List):javax.swing.tree.DefaultTreeModel -- getData(java.lang.String):java.lang.Object +- uiDataSnapshot(com.intellij.openapi.actionSystem.DataSink):V f:com.intellij.openapi.vcs.changes.ui.SessionDialog - com.intellij.openapi.ui.DialogWrapper - sf:Companion:com.intellij.openapi.vcs.changes.ui.SessionDialog$Companion @@ -6124,8 +6124,6 @@ a:com.intellij.openapi.vcs.changes.ui.VcsTreeModelData - s:allUnderTag(javax.swing.JTree,java.lang.Object):com.intellij.openapi.vcs.changes.ui.VcsTreeModelData - s:exactlySelected(javax.swing.JTree):com.intellij.openapi.vcs.changes.ui.VcsTreeModelData - s:findTagNode(javax.swing.JTree,java.lang.Object):com.intellij.openapi.vcs.changes.ui.ChangesBrowserNode -- s:getData(com.intellij.openapi.project.Project,javax.swing.JTree,java.lang.String):java.lang.Object -- s:getDataOrSuper(com.intellij.openapi.project.Project,javax.swing.JTree,java.lang.String,java.lang.Object):java.lang.Object - s:getListSelectionOrAll(javax.swing.JTree):com.intellij.openapi.ListSelection - s:included(com.intellij.openapi.vcs.changes.ui.ChangesTree):com.intellij.openapi.vcs.changes.ui.VcsTreeModelData - s:includedUnderTag(com.intellij.openapi.vcs.changes.ui.ChangesTree,java.lang.Object):com.intellij.openapi.vcs.changes.ui.VcsTreeModelData @@ -6140,6 +6138,7 @@ a:com.intellij.openapi.vcs.changes.ui.VcsTreeModelData - f:nodesStream():java.util.stream.Stream - s:selected(javax.swing.JTree):com.intellij.openapi.vcs.changes.ui.VcsTreeModelData - s:selectedUnderTag(javax.swing.JTree,java.lang.Object):com.intellij.openapi.vcs.changes.ui.VcsTreeModelData +- s:uiDataSnapshot(com.intellij.openapi.actionSystem.DataSink,com.intellij.openapi.project.Project,javax.swing.JTree):V - f:userObjects():java.util.List - f:userObjects(java.lang.Class):java.util.List - f:userObjectsStream(java.lang.Class):java.util.stream.Stream @@ -6207,12 +6206,12 @@ a:com.intellij.openapi.vcs.changes.ui.browser.FilterableChangesBrowser - p:createCenterPanel():javax.swing.JComponent - dispose():V - filterChanges(java.util.List,Z):com.intellij.openapi.vcs.changes.ui.browser.ChangesFilterer$FilteredState -- getData(java.lang.String):java.lang.Object - hasActiveChangesFilter():Z - p:onActiveChangesFilterChanges():V - ps:setFilteredChanges(com.intellij.openapi.vcs.changes.ui.TreeModelBuilder,com.intellij.openapi.vcs.changes.ui.browser.ChangesFilterer$FilteredState,com.intellij.openapi.vcs.changes.ui.ChangeNodeDecorator):V - ps:setFilteredOutChanges(com.intellij.openapi.vcs.changes.ui.TreeModelBuilder,java.util.Collection,com.intellij.openapi.vcs.changes.ui.ChangeNodeDecorator):V - ps:setPendingChanges(com.intellij.openapi.vcs.changes.ui.TreeModelBuilder,java.util.Collection,com.intellij.openapi.vcs.changes.ui.ChangeNodeDecorator):V +- uiDataSnapshot(com.intellij.openapi.actionSystem.DataSink):V c:com.intellij.openapi.vcs.changes.ui.browser.LoadingChangesPanel - javax.swing.JPanel - com.intellij.openapi.Disposable diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java index 4a1b08467978..abec90220093 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java @@ -752,14 +752,11 @@ public class ChangesViewManager implements ChangesViewEx, } @Override - public @Nullable Object getData(@NotNull String dataId) { - Object data = super.getData(dataId); - if (data != null) return data; - if (EditorTabDiffPreviewManager.EDITOR_TAB_DIFF_PREVIEW.is(dataId)) { - return myEditorDiffPreview; - } + public void uiDataSnapshot(@NotNull DataSink sink) { + super.uiDataSnapshot(sink); + sink.set(EditorTabDiffPreviewManager.EDITOR_TAB_DIFF_PREVIEW, myEditorDiffPreview); // This makes COMMIT_WORKFLOW_HANDLER available anywhere in "Local Changes" - so commit executor actions are enabled. - return myCommitPanel != null ? myCommitPanel.getDataFromProviders(dataId) : null; + DataSink.uiDataSnapshot(sink, myCommitPanel); } private static void registerShortcuts(@NotNull JComponent component) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/SpecificFilesViewDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/SpecificFilesViewDialog.java index c08246037634..b1310940a1fe 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/SpecificFilesViewDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/SpecificFilesViewDialog.java @@ -20,12 +20,10 @@ import com.intellij.util.concurrency.annotations.RequiresBackgroundThread; import com.intellij.util.ui.JBDimension; import com.intellij.util.ui.tree.TreeUtil; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.tree.TreeNode; import java.awt.*; -import java.util.Arrays; import java.util.List; import static com.intellij.openapi.vcs.changes.ui.ChangesTree.GROUP_BY_ACTION_GROUP; @@ -177,54 +175,20 @@ abstract class SpecificFilesViewDialog extends DialogWrapper { } } - @Nullable @Override - public Object getData(@NotNull String dataId) { - if (PlatformCoreDataKeys.BGT_DATA_PROVIDER.is(dataId)) { - VcsTreeModelData treeSelection = VcsTreeModelData.selected(this); - VcsTreeModelData exactSelection = VcsTreeModelData.exactlySelected(this); - DataProvider ourDataProvider = slowId -> getSlowData(myProject, treeSelection, exactSelection, slowId); - DataProvider treeDataProvider = (DataProvider)VcsTreeModelData.getData(myProject, this, dataId); - DataProvider superDataProvider = (DataProvider)super.getData(dataId); - return CompositeDataProvider.compose(Arrays.asList(ourDataProvider, treeDataProvider, superDataProvider)); - } - - Object ourData = getFastData(dataId); - if (ourData != null) return ourData; - - Object treeData = VcsTreeModelData.getData(myProject, this, dataId); - if (treeData != null) return null; - - return super.getData(dataId); - } - - private @Nullable Object getFastData(@NotNull String dataId) { - if (myShownDataKey.is(dataId)) { - return VcsTreeModelData.selected(this) - .iterateUserObjects(FilePath.class); - } - if (VcsDataKeys.FILE_PATHS.is(dataId)) { - return VcsTreeModelData.selected(this) - .iterateUserObjects(FilePath.class); - } - if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) { - return new VirtualFileDeleteProvider(); - } - if (PlatformCoreDataKeys.HELP_ID.is(dataId)) { - return ChangesListView.HELP_ID; - } - return super.getData(dataId); - } - - @Nullable - private static Object getSlowData(@NotNull Project project, - @NotNull VcsTreeModelData treeSelection, - @NotNull VcsTreeModelData exactSelection, - @NotNull String slowId) { - if (ChangesListView.EXACTLY_SELECTED_FILES_DATA_KEY.is(slowId)) { - return VcsTreeModelData.mapToExactVirtualFile(exactSelection); - } - return null; + public void uiDataSnapshot(@NotNull DataSink sink) { + super.uiDataSnapshot(sink); + VcsTreeModelData treeSelection = VcsTreeModelData.selected(this); + VcsTreeModelData exactSelection = VcsTreeModelData.exactlySelected(this); + VcsTreeModelData.uiDataSnapshot(sink, myProject, this); + sink.lazy(ChangesListView.EXACTLY_SELECTED_FILES_DATA_KEY, () -> + VcsTreeModelData.mapToExactVirtualFile(exactSelection)); + sink.set(myShownDataKey, + treeSelection.iterateUserObjects(FilePath.class)); + sink.set(VcsDataKeys.FILE_PATHS, + treeSelection.iterateUserObjects(FilePath.class)); + sink.set(PlatformDataKeys.DELETE_ELEMENT_PROVIDER, new VirtualFileDeleteProvider()); + sink.set(PlatformCoreDataKeys.HELP_ID, ChangesListView.HELP_ID); } } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesBrowser.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesBrowser.java index da583f2f5a1f..abdc555ac0eb 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesBrowser.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesBrowser.java @@ -1,7 +1,9 @@ // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.vcs.changes.committed; -import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.actionSystem.ActionManager; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.DataSink; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.AbstractVcs; import com.intellij.openapi.vcs.ProjectLevelVcsManager; @@ -11,9 +13,7 @@ import com.intellij.openapi.vcs.changes.ChangesUtil; import com.intellij.openapi.vcs.changes.ui.SimpleAsyncChangesBrowser; import com.intellij.openapi.vcs.changes.ui.VcsTreeModelData; import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.List; @@ -47,22 +47,13 @@ public class CommittedChangesBrowser extends SimpleAsyncChangesBrowser { } @Override - public Object getData(@NotNull @NonNls final String dataId) { - if (CommittedChangesBrowserUseCase.DATA_KEY.is(dataId)) { - return myUseCase; - } - if (PlatformCoreDataKeys.BGT_DATA_PROVIDER.is(dataId)) { - DataProvider superProvider = (DataProvider)super.getData(dataId); + public void uiDataSnapshot(@NotNull DataSink sink) { + super.uiDataSnapshot(sink); + sink.set(CommittedChangesBrowserUseCase.DATA_KEY, myUseCase); - VcsTreeModelData selectedData = VcsTreeModelData.selected(myViewer); - return CompositeDataProvider.compose(slowId -> getSlowData(slowId, selectedData), superProvider); - } - return super.getData(dataId); - } - - private @Nullable Object getSlowData(@NotNull String dataId, @NotNull VcsTreeModelData selectedData) { - if (VcsDataKeys.VCS.is(dataId)) { - AbstractVcs selectionVcs = selectedData.iterateUserObjects(Change.class) + VcsTreeModelData selection = VcsTreeModelData.selected(myViewer); + sink.lazy(VcsDataKeys.VCS, () -> { + AbstractVcs selectionVcs = selection.iterateUserObjects(Change.class) .map(change -> ChangesUtil.getFilePath(change)) .map(root -> ProjectLevelVcsManager.getInstance(myProject).getVcsFor(root)) .filterNotNull() @@ -70,7 +61,6 @@ public class CommittedChangesBrowser extends SimpleAsyncChangesBrowser { .single(); if (selectionVcs != null) return selectionVcs.getKeyInstanceMethod(); return null; - } - return null; + }); } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/savedPatches/SavedPatchesChangesBrowser.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/savedPatches/SavedPatchesChangesBrowser.kt index e1aeef2bb4a4..4aa2e12d3f3b 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/savedPatches/SavedPatchesChangesBrowser.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/savedPatches/SavedPatchesChangesBrowser.kt @@ -5,6 +5,7 @@ import com.intellij.openapi.Disposable import com.intellij.openapi.actionSystem.ActionManager import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.CommonDataKeys +import com.intellij.openapi.actionSystem.DataSink import com.intellij.openapi.project.Project import com.intellij.openapi.util.Disposer import com.intellij.openapi.vcs.FilePath @@ -122,45 +123,35 @@ class SavedPatchesChangesBrowser(project: Project, internal val isShowDiffWithLo .filterNotNull() } - override fun getData(dataId: String): Any? { - if (VcsDataKeys.CHANGES.`is`(dataId)) { - val selected = VcsTreeModelData.selected(myViewer).mapToChange().toList().toTypedArray() - if (selected.isNotEmpty()) return selected - return VcsTreeModelData.all(myViewer).mapToChange().toList().toTypedArray() - } - else if (VcsDataKeys.SELECTED_CHANGES.`is`(dataId) || - VcsDataKeys.SELECTED_CHANGES_IN_DETAILS.`is`(dataId)) { - return VcsTreeModelData.selected(myViewer).mapToChange().toList().toTypedArray() - } - else if (VcsDataKeys.CHANGES_SELECTION.`is`(dataId)) { - return VcsTreeModelData.getListSelectionOrAll(myViewer).map { (it as? SavedPatchesProvider.ChangeObject)?.asChange() } - } - else if (VcsDataKeys.CHANGE_LEAD_SELECTION.`is`(dataId)) { - return VcsTreeModelData.exactlySelected(myViewer).mapToChange().toList().toTypedArray() - } - else if (CommonDataKeys.VIRTUAL_FILE_ARRAY.`is`(dataId)) { - return VcsTreeModelData.selected(myViewer).iterateUserObjects(SavedPatchesProvider.ChangeObject::class.java) - .map { it.filePath.virtualFile } - .filterNotNull() - .toList().toTypedArray() - } - else if (VcsDataKeys.FILE_PATHS.`is`(dataId)) { - return VcsTreeModelData.selected(myViewer).iterateUserObjects(SavedPatchesProvider.ChangeObject::class.java) - .map { it.filePath } - } - else if (CommonDataKeys.NAVIGATABLE_ARRAY.`is`(dataId)) { - val virtualFiles = VcsTreeModelData.selected(myViewer).iterateUserObjects(SavedPatchesProvider.ChangeObject::class.java) - .map { it.filePath.virtualFile } - .filterNotNull() - return ChangesUtil.getNavigatableArray(myProject, virtualFiles) - } - else if (SavedPatchesUi.SAVED_PATCH_SELECTED_CHANGES.`is`(dataId)) { - return VcsTreeModelData.selected(myViewer).iterateUserObjects(SavedPatchesProvider.ChangeObject::class.java) - } - else if (SavedPatchesUi.SAVED_PATCH_CHANGES.`is`(dataId)) { - return VcsTreeModelData.all(myViewer).iterateUserObjects(SavedPatchesProvider.ChangeObject::class.java) - } - return super.getData(dataId) + override fun uiDataSnapshot(sink: DataSink) { + super.uiDataSnapshot(sink) + val selection = VcsTreeModelData.selected(myViewer) + + val changes = selection.mapToChange().toList().toTypedArray() + sink[VcsDataKeys.CHANGES] = + if (changes.isNotEmpty()) changes + else VcsTreeModelData.all(myViewer).mapToChange().toList().toTypedArray() + sink[VcsDataKeys.SELECTED_CHANGES] = changes + sink[VcsDataKeys.SELECTED_CHANGES_IN_DETAILS] = changes + sink[VcsDataKeys.CHANGES_SELECTION] = + VcsTreeModelData.getListSelectionOrAll(myViewer) + .map { (it as? SavedPatchesProvider.ChangeObject)?.asChange() } + sink[VcsDataKeys.CHANGE_LEAD_SELECTION] = + VcsTreeModelData.exactlySelected(myViewer).mapToChange().toList().toTypedArray() + + val changeObjects = selection.iterateUserObjects(SavedPatchesProvider.ChangeObject::class.java) + sink[CommonDataKeys.VIRTUAL_FILE_ARRAY] = changeObjects + .map { it.filePath.virtualFile } + .filterNotNull() + .toList().toTypedArray() + sink[VcsDataKeys.FILE_PATHS] = changeObjects.map { it.filePath } + sink[CommonDataKeys.NAVIGATABLE_ARRAY] = changeObjects + .filterMap { it.filePath.virtualFile } + .let { ChangesUtil.getNavigatableArray(myProject, it) } + sink[SavedPatchesUi.SAVED_PATCH_SELECTED_CHANGES] = changeObjects + + sink[SavedPatchesUi.SAVED_PATCH_CHANGES] = VcsTreeModelData.all(myViewer) + .iterateUserObjects(SavedPatchesProvider.ChangeObject::class.java) } override fun dispose() { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java index 3717bd8db87e..b9ed4b370175 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java @@ -504,61 +504,50 @@ public class ShelvedChangesViewManager implements Disposable { } @Override - public @Nullable Object getData(@NotNull @NonNls String dataId) { - if (SHELVED_CHANGES_TREE.is(dataId)) { - return this; + public void uiDataSnapshot(@NotNull DataSink sink) { + super.uiDataSnapshot(sink); + sink.set(SHELVED_CHANGES_TREE, this); + sink.set(SHELVED_CHANGELIST_KEY, new ArrayList<>( + getSelectedLists(this, l -> !l.isRecycled() && !l.isDeleted()))); + sink.set(SHELVED_RECYCLED_CHANGELIST_KEY, new ArrayList<>( + getSelectedLists(this, l -> l.isRecycled() && !l.isDeleted()))); + sink.set(SHELVED_DELETED_CHANGELIST_KEY, new ArrayList<>( + getSelectedLists(this, l -> l.isDeleted()))); + sink.set(SHELVED_CHANGE_KEY, VcsTreeModelData.selected(this).iterateUserObjects(ShelvedWrapper.class) + .map(s -> s.getShelvedChange()) + .filterNotNull().toList()); + sink.set(SHELVED_BINARY_FILE_KEY, VcsTreeModelData.selected(this).iterateUserObjects(ShelvedWrapper.class) + .map(s -> s.getBinaryFile()) + .filterNotNull().toList()); + if (!isEditing()) { + sink.set(PlatformDataKeys.DELETE_ELEMENT_PROVIDER, myDeleteProvider); } - else if (SHELVED_CHANGELIST_KEY.is(dataId)) { - return new ArrayList<>(getSelectedLists(this, l -> !l.isRecycled() && !l.isDeleted())); + List shelvedChanges = VcsTreeModelData.selected(this).userObjects(ShelvedWrapper.class); + if (!shelvedChanges.isEmpty()) { + sink.set(VcsDataKeys.CHANGES, map2Array(shelvedChanges, Change.class, s -> s.getChangeWithLocal(myProject))); } - else if (SHELVED_RECYCLED_CHANGELIST_KEY.is(dataId)) { - return new ArrayList<>(getSelectedLists(this, l -> l.isRecycled() && !l.isDeleted())); - } - else if (SHELVED_DELETED_CHANGELIST_KEY.is(dataId)) { - return new ArrayList<>(getSelectedLists(this, l -> l.isDeleted())); - } - else if (SHELVED_CHANGE_KEY.is(dataId)) { - return VcsTreeModelData.selected(this).iterateUserObjects(ShelvedWrapper.class) - .map(s -> s.getShelvedChange()) - .filterNotNull().toList(); - } - else if (SHELVED_BINARY_FILE_KEY.is(dataId)) { - return VcsTreeModelData.selected(this).iterateUserObjects(ShelvedWrapper.class) - .map(s -> s.getBinaryFile()) - .filterNotNull().toList(); - } - else if (VcsDataKeys.CHANGES.is(dataId)) { - List shelvedChanges = VcsTreeModelData.selected(this).userObjects(ShelvedWrapper.class); - if (!shelvedChanges.isEmpty()) { - return map2Array(shelvedChanges, Change.class, s -> s.getChangeWithLocal(myProject)); - } - } - else if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId) && !isEditing()) { - return myDeleteProvider; - } - else if (CommonDataKeys.NAVIGATABLE_ARRAY.is(dataId)) { - List shelvedChanges = VcsTreeModelData.selected(this).userObjects(ShelvedWrapper.class); - final ArrayDeque navigatables = new ArrayDeque<>(); - for (final ShelvedWrapper shelvedChange : shelvedChanges) { - if (shelvedChange.getBeforePath() != null && !FileStatus.ADDED.equals(shelvedChange.getFileStatus())) { - final NavigatableAdapter navigatable = new NavigatableAdapter() { - @Override - public void navigate(boolean requestFocus) { - final VirtualFile vf = shelvedChange.getBeforeVFUnderProject(myProject); - if (vf != null) { - navigate(myProject, vf, true); - } + sink.set(CommonDataKeys.NAVIGATABLE_ARRAY, getNavigatables(shelvedChanges) + .toArray(Navigatable.EMPTY_NAVIGATABLE_ARRAY)); + sink.set(PlatformCoreDataKeys.HELP_ID, HELP_ID); + } + + private @NotNull List getNavigatables(@NotNull List shelvedChanges) { + ArrayList navigatables = new ArrayList<>(); + for (ShelvedWrapper shelvedChange : shelvedChanges) { + if (shelvedChange.getBeforePath() != null && !FileStatus.ADDED.equals(shelvedChange.getFileStatus())) { + NavigatableAdapter navigatable = new NavigatableAdapter() { + @Override + public void navigate(boolean requestFocus) { + VirtualFile vf = shelvedChange.getBeforeVFUnderProject(myProject); + if (vf != null) { + navigate(myProject, vf, true); } - }; - navigatables.add(navigatable); - } + } + }; + navigatables.add(navigatable); } - return navigatables.toArray(Navigatable.EMPTY_NAVIGATABLE_ARRAY); } - else if (PlatformCoreDataKeys.HELP_ID.is(dataId)) { - return HELP_ID; - } - return super.getData(dataId); + return navigatables; } public void invalidateDataAndRefresh(@Nullable Runnable onRefreshed) { @@ -913,11 +902,9 @@ public class ShelvedChangesViewManager implements Disposable { } @Override - public @Nullable Object getData(@NotNull String dataId) { - if (EditorTabDiffPreviewManager.EDITOR_TAB_DIFF_PREVIEW.is(dataId)) { - return myEditorDiffPreview; - } - return super.getData(dataId); + public void uiDataSnapshot(@NotNull DataSink sink) { + super.uiDataSnapshot(sink); + sink.set(EditorTabDiffPreviewManager.EDITOR_TAB_DIFF_PREVIEW, myEditorDiffPreview); } private class MyToggleDetailsAction extends ShowDiffPreviewAction { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserBase.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserBase.java index a1418535a143..43bec4e9ff3f 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserBase.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserBase.java @@ -38,7 +38,7 @@ import java.util.List; /** * Consider using {@link AsyncChangesBrowserBase} to avoid potentially-expensive tree building operations on EDT. */ -public abstract class ChangesBrowserBase extends JPanel implements DataProvider { +public abstract class ChangesBrowserBase extends JPanel implements UiCompatibleDataProvider { public static final DataKey DATA_KEY = DataKey.create("com.intellij.openapi.vcs.changes.ui.ChangesBrowserBase"); @@ -253,13 +253,11 @@ public abstract class ChangesBrowserBase extends JPanel implements DataProvider return myViewer.getGrouping(); } - @Nullable @Override - public Object getData(@NotNull String dataId) { - if (DATA_KEY.is(dataId)) { - return this; - } - return VcsTreeModelData.getDataOrSuper(myProject, myViewer, dataId, myViewer.getData(dataId)); + public void uiDataSnapshot(@NotNull DataSink sink) { + sink.set(DATA_KEY, this); + DataSink.uiDataSnapshot(sink, myViewer); + VcsTreeModelData.uiDataSnapshot(sink, myProject, myViewer); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java index 946ac93ff2ed..9c57e24cc47d 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java @@ -1,7 +1,6 @@ // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.openapi.vcs.changes.ui; -import com.intellij.diff.actions.impl.OpenInEditorAction; import com.intellij.diff.util.DiffPlaces; import com.intellij.diff.util.DiffUserDataKeysEx; import com.intellij.ide.HelpIdProvider; @@ -836,11 +835,8 @@ public abstract class CommitChangeListDialog extends DialogWrapper implements Si } @Override - protected @Nullable Object getData(@NotNull String dataId) { - if (OpenInEditorAction.AFTER_NAVIGATE_CALLBACK.is(dataId)) { - return (Runnable)() -> doCancelAction(); - } - return super.getData(dataId); + protected @NotNull Runnable createAfterNavigateCallback() { + return () -> doCancelAction(); } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/MultipleLocalChangeListsBrowser.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/MultipleLocalChangeListsBrowser.java index 0fb44795d879..e7bbc9719051 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/MultipleLocalChangeListsBrowser.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/MultipleLocalChangeListsBrowser.java @@ -283,26 +283,18 @@ class MultipleLocalChangeListsBrowser extends CommitDialogChangesBrowser impleme return super.getDiffRequestProducer(entry); } - @Nullable @Override - public Object getData(@NotNull String dataId) { - if (UNVERSIONED_FILE_PATHS_DATA_KEY.is(dataId)) { - return VcsTreeModelData.selectedUnderTag(myViewer, UNVERSIONED_FILES_TAG) - .iterateUserObjects(FilePath.class); - } - else if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) { - return myDeleteProvider; - } - else if (VcsDataKeys.CHANGE_LISTS.is(dataId)) { - return new ChangeList[]{myChangeList}; - } - else if (EXACTLY_SELECTED_FILES_DATA_KEY.is(dataId)) { - return VcsTreeModelData.mapToExactVirtualFile(VcsTreeModelData.exactlySelected(myViewer)); - } - return super.getData(dataId); + public void uiDataSnapshot(@NotNull DataSink sink) { + super.uiDataSnapshot(sink); + sink.set(UNVERSIONED_FILE_PATHS_DATA_KEY, + VcsTreeModelData.selectedUnderTag(myViewer, UNVERSIONED_FILES_TAG) + .iterateUserObjects(FilePath.class)); + sink.set(PlatformDataKeys.DELETE_ELEMENT_PROVIDER, myDeleteProvider); + sink.set(VcsDataKeys.CHANGE_LISTS, new ChangeList[]{myChangeList}); + sink.set(EXACTLY_SELECTED_FILES_DATA_KEY, + VcsTreeModelData.mapToExactVirtualFile(VcsTreeModelData.exactlySelected(myViewer))); } - @NotNull @Override public List getDisplayedChanges() { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/SelectFilesDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/SelectFilesDialog.java index 724d36e605c8..64c71a2f7ea0 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/SelectFilesDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/SelectFilesDialog.java @@ -118,17 +118,12 @@ public class SelectFilesDialog extends AbstractSelectFilesDialog { myDeleteProvider = (deletableFiles ? new VirtualFileDeleteProvider() : null); } - @Nullable @Override - public Object getData(@NotNull String dataId) { - if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId) && myDeleteProvider != null) { - return myDeleteProvider; - } - else if (CommonDataKeys.VIRTUAL_FILE_ARRAY.is(dataId)) { - return getSelectedChanges().toArray(VirtualFile.EMPTY_ARRAY); - } - - return super.getData(dataId); + public void uiDataSnapshot(@NotNull DataSink sink) { + super.uiDataSnapshot(sink); + sink.set(PlatformDataKeys.DELETE_ELEMENT_PROVIDER, myDeleteProvider); + sink.set(CommonDataKeys.VIRTUAL_FILE_ARRAY, + getSelectedChanges().toArray(VirtualFile.EMPTY_ARRAY)); } @Override diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/VcsTreeModelData.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/VcsTreeModelData.java index fdf78c2fb77f..cd668d29fc19 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/VcsTreeModelData.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/VcsTreeModelData.java @@ -5,8 +5,7 @@ import com.intellij.ide.FileSelectInContext; import com.intellij.ide.SelectInContext; import com.intellij.openapi.ListSelection; import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.CompositeDataProvider; -import com.intellij.openapi.actionSystem.DataProvider; +import com.intellij.openapi.actionSystem.DataSink; import com.intellij.openapi.actionSystem.PlatformCoreDataKeys; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.FilePath; @@ -303,54 +302,23 @@ public abstract class VcsTreeModelData { } } + public static void uiDataSnapshot(@NotNull DataSink sink, @Nullable Project project, @NotNull JTree tree) { + sink.set(CommonDataKeys.PROJECT, project); - @Nullable - public static Object getData(@Nullable Project project, @NotNull JTree tree, @NotNull String dataId) { - return getDataOrSuper(project, tree, dataId, null); - } - - @Nullable - public static Object getDataOrSuper(@Nullable Project project, @NotNull JTree tree, @NotNull String dataId, - @Nullable Object superProviderData) { - if (PlatformCoreDataKeys.BGT_DATA_PROVIDER.is(dataId)) { - VcsTreeModelData treeSelection = selected(tree); - VcsTreeModelData exactSelection = exactlySelected(tree); - return CompositeDataProvider.compose(slowId -> getSlowData(project, treeSelection, exactSelection, slowId), - (DataProvider)superProviderData); - } - - Object data = getFastData(project, tree, dataId); - if (data != null) { - return data; - } - - return superProviderData; - } - - @Nullable - private static Object getFastData(@Nullable Project project, @NotNull JTree tree, @NotNull String dataId) { - if (CommonDataKeys.PROJECT.is(dataId)) { - return project; - } - else if (VcsDataKeys.CHANGES.is(dataId)) { - Change[] changes = mapToChange(selected(tree)).toArray(Change.EMPTY_CHANGE_ARRAY); - if (changes.length != 0) return changes; - return mapToChange(all(tree)).toArray(Change.EMPTY_CHANGE_ARRAY); - } - else if (VcsDataKeys.SELECTED_CHANGES.is(dataId) || - VcsDataKeys.SELECTED_CHANGES_IN_DETAILS.is(dataId)) { - return mapToChange(selected(tree)).toArray(Change.EMPTY_CHANGE_ARRAY); - } - else if (VcsDataKeys.CHANGES_SELECTION.is(dataId)) { - return getListSelectionOrAll(tree).map(entry -> ObjectUtils.tryCast(entry, Change.class)); - } - else if (VcsDataKeys.CHANGE_LEAD_SELECTION.is(dataId)) { - return mapToChange(exactlySelected(tree)).toArray(Change.EMPTY_CHANGE_ARRAY); - } - else if (VcsDataKeys.FILE_PATHS.is(dataId)) { - return mapToFilePath(selected(tree)); - } - return null; + Change[] changes = mapToChange(selected(tree)).toArray(Change.EMPTY_CHANGE_ARRAY); + sink.set(VcsDataKeys.CHANGES, + changes.length != 0 ? changes : mapToChange(all(tree)).toArray(Change.EMPTY_CHANGE_ARRAY)); + sink.set(VcsDataKeys.SELECTED_CHANGES, changes); + sink.set(VcsDataKeys.SELECTED_CHANGES_IN_DETAILS, changes); + sink.set(VcsDataKeys.CHANGES_SELECTION, + getListSelectionOrAll(tree).map(entry -> ObjectUtils.tryCast(entry, Change.class))); + sink.set(VcsDataKeys.CHANGE_LEAD_SELECTION, + mapToChange(exactlySelected(tree)).toArray(Change.EMPTY_CHANGE_ARRAY)); + sink.set(VcsDataKeys.FILE_PATHS, mapToFilePath(selected(tree))); + VcsTreeModelData treeSelection = selected(tree); + VcsTreeModelData exactSelection = exactlySelected(tree); + sink.set(PlatformCoreDataKeys.BGT_DATA_PROVIDER, + slowId -> getSlowData(project, treeSelection, exactSelection, slowId)); } @Nullable diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/browser/FilterableChangesBrowser.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/browser/FilterableChangesBrowser.java index 747649a11496..042b9575c93e 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/browser/FilterableChangesBrowser.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/browser/FilterableChangesBrowser.java @@ -2,6 +2,7 @@ package com.intellij.openapi.vcs.changes.ui.browser; import com.intellij.openapi.Disposable; +import com.intellij.openapi.actionSystem.DataSink; import com.intellij.openapi.progress.util.ProgressIndicatorWithDelayedPresentation; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; @@ -74,13 +75,10 @@ public abstract class FilterableChangesBrowser extends ChangesBrowserBase implem } } - @Nullable @Override - public Object getData(@NotNull String dataId) { - if (ChangesFilterer.DATA_KEY.is(dataId)) { - return myChangesFilterer; - } - return super.getData(dataId); + public void uiDataSnapshot(@NotNull DataSink sink) { + super.uiDataSnapshot(sink); + sink.set(ChangesFilterer.DATA_KEY, myChangesFilterer); } @Override diff --git a/platform/vcs-log/impl/api-dump-unreviewed.txt b/platform/vcs-log/impl/api-dump-unreviewed.txt index 8f5ca7008708..5cd87ed6d0e5 100644 --- a/platform/vcs-log/impl/api-dump-unreviewed.txt +++ b/platform/vcs-log/impl/api-dump-unreviewed.txt @@ -1585,7 +1585,6 @@ f:com.intellij.vcs.log.ui.frame.VcsLogChangesBrowser - f:addListener(com.intellij.vcs.log.ui.frame.VcsLogChangesBrowser$Listener,com.intellij.openapi.Disposable):V - f:createChangeProcessor(Z):com.intellij.diff.impl.DiffEditorViewer - dispose():V -- getData(java.lang.String):java.lang.Object - getDiffRequestProducer(java.lang.Object):com.intellij.openapi.vcs.changes.ui.ChangeDiffRequestChain$Producer - f:getDiffRequestProducer(java.lang.Object,Z):com.intellij.openapi.vcs.changes.ui.ChangeDiffRequestChain$Producer - f:getDirectChanges():java.util.List @@ -1598,6 +1597,7 @@ f:com.intellij.vcs.log.ui.frame.VcsLogChangesBrowser - f:setEmptyWithText(java.util.function.Consumer):V - f:setSelectedDetails(java.util.List):V - f:setToolbarHeightReferent(javax.swing.JComponent):V +- uiDataSnapshot(com.intellij.openapi.actionSystem.DataSink):V f:com.intellij.vcs.log.ui.frame.VcsLogChangesBrowser$Companion - f:createDiffRequestProducer(com.intellij.openapi.project.Project,com.intellij.openapi.vcs.changes.Change,java.util.Map,Z):com.intellij.openapi.vcs.changes.ui.ChangeDiffRequestChain$Producer com.intellij.vcs.log.ui.frame.VcsLogChangesBrowser$Listener diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogChangesBrowser.kt b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogChangesBrowser.kt index 84acb36732e4..8378c963ad76 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogChangesBrowser.kt +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogChangesBrowser.kt @@ -16,6 +16,7 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.util.Disposer import com.intellij.openapi.util.Key import com.intellij.openapi.util.text.StringUtil +import com.intellij.openapi.vcs.AbstractVcs import com.intellij.openapi.vcs.FilePath import com.intellij.openapi.vcs.ProjectLevelVcsManager import com.intellij.openapi.vcs.VcsDataKeys @@ -267,42 +268,26 @@ class VcsLogChangesBrowser internal constructor(project: Project, val selectedChanges: List get() = VcsTreeModelData.selected(myViewer).userObjects(Change::class.java) - override fun getData(dataId: String): Any? { - if (HAS_AFFECTED_FILES.`is`(dataId)) { - return affectedPaths != null - } - if (PlatformCoreDataKeys.BGT_DATA_PROVIDER.`is`(dataId)) { - val roots = HashSet(commitModel.roots) - val selectedData = VcsTreeModelData.selected(myViewer) - val superProvider = super.getData(dataId) as DataProvider? - return CompositeDataProvider.compose({ slowId -> getSlowData(slowId, roots, selectedData) }, superProvider) - } - else if (QuickActionProvider.KEY.`is`(dataId)) { - return ComponentQuickActionProvider(this@VcsLogChangesBrowser) - } - return super.getData(dataId) - } + override fun uiDataSnapshot(sink: DataSink) { + super.uiDataSnapshot(sink) + sink[HAS_AFFECTED_FILES] = affectedPaths != null + sink[QuickActionProvider.KEY] = ComponentQuickActionProvider(this@VcsLogChangesBrowser) - private fun getSlowData(dataId: String, - roots: Set, - selectedData: VcsTreeModelData): Any? { - if (VcsDataKeys.VCS.`is`(dataId)) { - val rootsVcs = JBIterable.from(roots) - .map { root -> ProjectLevelVcsManager.getInstance(myProject).getVcsFor(root) } + val roots = HashSet(commitModel.roots) + val selectedData = VcsTreeModelData.selected(myViewer) + sink.lazy(VcsDataKeys.VCS) { + val rootsVcs = JBIterable.from(roots) + .map { root -> ProjectLevelVcsManager.getInstance(myProject).getVcsFor(root) } .filterNotNull() .unique() .single() - if (rootsVcs != null) return rootsVcs.keyInstanceMethod - - val selectionVcs = selectedData.iterateUserObjects(Change::class.java) - .map { change -> ChangesUtil.getFilePath(change) } - .map { root -> ProjectLevelVcsManager.getInstance(myProject).getVcsFor(root) } + rootsVcs?.keyInstanceMethod ?: selectedData.iterateUserObjects(Change::class.java) + .map { change -> ChangesUtil.getFilePath(change) } + .map { root -> ProjectLevelVcsManager.getInstance(myProject).getVcsFor(root) } .filterNotNull() .unique() - .single() - return selectionVcs?.keyInstanceMethod + .single()?.keyInstanceMethod } - return null } public override fun getDiffRequestProducer(userObject: Any): ChangeDiffRequestChain.Producer? { diff --git a/plugins/git4idea/src/git4idea/index/ui/GitStageTree.kt b/plugins/git4idea/src/git4idea/index/ui/GitStageTree.kt index 71a266899c0b..4d054ee041f6 100644 --- a/plugins/git4idea/src/git4idea/index/ui/GitStageTree.kt +++ b/plugins/git4idea/src/git4idea/index/ui/GitStageTree.kt @@ -121,33 +121,28 @@ abstract class GitStageTree(project: Project, } } - override fun getData(dataId: String): Any? { - return when { - GitStageDataKeys.GIT_STAGE_TREE.`is`(dataId) -> this - GitStageDataKeys.GIT_STAGE_UI_SETTINGS.`is`(dataId) -> settings - GitStageDataKeys.GIT_FILE_STATUS_NODES.`is`(dataId) -> selectedStatusNodes() - VcsDataKeys.FILE_PATHS.`is`(dataId) -> { - selectedStatusNodes().map { it.filePath } + selectedChanges().map { ChangesUtil.getFilePath(it) } - } - VcsDataKeys.CHANGES.`is`(dataId) -> selectedChanges().toArray(Change.EMPTY_CHANGE_ARRAY) - PlatformDataKeys.DELETE_ELEMENT_PROVIDER.`is`(dataId) -> if (!selectedStatusNodes().isEmpty) VirtualFileDeleteProvider() else null - PlatformCoreDataKeys.BGT_DATA_PROVIDER.`is`(dataId) -> { - val superProvider = super.getData(dataId) as DataProvider? - val selectedNodes = selectedStatusNodes() - val selectedChanges = selectedChanges() - return CompositeDataProvider.compose({ slowId -> getSlowData(selectedNodes, selectedChanges, slowId) }, superProvider) - } - else -> super.getData(dataId) - } - } + override fun uiDataSnapshot(sink: DataSink) { + super.uiDataSnapshot(sink) + sink[GitStageDataKeys.GIT_STAGE_TREE] = this + sink[GitStageDataKeys.GIT_STAGE_UI_SETTINGS] = settings + sink[GitStageDataKeys.GIT_FILE_STATUS_NODES] = selectedStatusNodes() + sink[VcsDataKeys.FILE_PATHS] = + selectedStatusNodes().map { it.filePath } + + selectedChanges().map { ChangesUtil.getFilePath(it) } + sink[VcsDataKeys.CHANGES] = selectedChanges().toArray(Change.EMPTY_CHANGE_ARRAY) + sink[PlatformDataKeys.DELETE_ELEMENT_PROVIDER] = if (!selectedStatusNodes().isEmpty) VirtualFileDeleteProvider() else null - private fun getSlowData(selectedNodes: JBIterable, selectedChanges: JBIterable, slowId: String): Any? { - return when { - VcsDataKeys.VIRTUAL_FILES.`is`(slowId) -> selectedVirtualFiles(selectedNodes, selectedChanges) - CommonDataKeys.VIRTUAL_FILE_ARRAY.`is`(slowId) -> selectedVirtualFiles(selectedNodes, selectedChanges).toList().toTypedArray() - CommonDataKeys.NAVIGATABLE_ARRAY.`is`(slowId) -> selectedVirtualFiles(selectedNodes, selectedChanges) + val selectedNodes = selectedStatusNodes() + val selectedChanges = selectedChanges() + sink.lazy(VcsDataKeys.VIRTUAL_FILES) { + selectedVirtualFiles(selectedNodes, selectedChanges) + } + sink.lazy(CommonDataKeys.VIRTUAL_FILE_ARRAY) { + selectedVirtualFiles(selectedNodes, selectedChanges).toList().toTypedArray() + } + sink.lazy(CommonDataKeys.NAVIGATABLE_ARRAY) { + selectedVirtualFiles(selectedNodes, selectedChanges) .map { OpenFileDescriptor(project, it) }.toList().toTypedArray() - else -> null } } diff --git a/plugins/git4idea/src/git4idea/ui/branch/popup/GitBranchesTreePopup.kt b/plugins/git4idea/src/git4idea/ui/branch/popup/GitBranchesTreePopup.kt index 2d0ab74cdafd..87b61390627c 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/popup/GitBranchesTreePopup.kt +++ b/plugins/git4idea/src/git4idea/ui/branch/popup/GitBranchesTreePopup.kt @@ -4,7 +4,6 @@ package git4idea.ui.branch.popup import com.intellij.dvcs.DvcsUtil import com.intellij.dvcs.branch.* import com.intellij.dvcs.ui.DvcsBundle -import com.intellij.ide.DataManager import com.intellij.ide.util.treeView.TreeState import com.intellij.navigation.ItemPresentation import com.intellij.openapi.Disposable @@ -127,12 +126,9 @@ class GitBranchesTreePopup(project: Project, step: GitBranchesTreePopupStep, par .initBranchSyncPolicyIfNotInitialized() } installBranchSettingsListener() - DataManager.registerDataProvider(component, DataProvider { dataId -> - when { - POPUP_KEY.`is`(dataId) -> this - GitBranchActionsUtil.REPOSITORIES_KEY.`is`(dataId) -> treeStep.affectedRepositories - else -> null - } + setDataProvider(EdtNoGetDataProvider { sink -> + sink[POPUP_KEY] = this@GitBranchesTreePopup + sink[GitBranchActionsUtil.REPOSITORIES_KEY] = treeStep.repositories }) } @@ -387,16 +383,9 @@ class GitBranchesTreePopup(project: Project, step: GitBranchesTreePopupStep, par val toolbarGroup = DefaultActionGroup(GitBranchPopupFetchAction(javaClass), settingsGroup) return am.createActionToolbar(TOP_LEVEL_ACTION_PLACE, toolbarGroup, true) .apply { - targetComponent = component + targetComponent = content setReservePlaceAutoPopupIcon(false) component.isOpaque = false - DataManager.registerDataProvider(component, DataProvider { dataId -> - when { - POPUP_KEY.`is`(dataId) -> this@GitBranchesTreePopup - GitBranchActionsUtil.REPOSITORIES_KEY.`is`(dataId) -> treeStep.repositories - else -> null - } - }) } } diff --git a/plugins/kotlin/project-configuration/src/org/jetbrains/kotlin/idea/configuration/ui/changes/KotlinConfiguratorChangesDiffRequestProcessor.kt b/plugins/kotlin/project-configuration/src/org/jetbrains/kotlin/idea/configuration/ui/changes/KotlinConfiguratorChangesDiffRequestProcessor.kt index c315a7fd1a1d..ffd42bccd8cc 100644 --- a/plugins/kotlin/project-configuration/src/org/jetbrains/kotlin/idea/configuration/ui/changes/KotlinConfiguratorChangesDiffRequestProcessor.kt +++ b/plugins/kotlin/project-configuration/src/org/jetbrains/kotlin/idea/configuration/ui/changes/KotlinConfiguratorChangesDiffRequestProcessor.kt @@ -1,7 +1,6 @@ // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.idea.configuration.ui.changes -import com.intellij.diff.actions.impl.OpenInEditorAction import com.intellij.diff.chains.DiffRequestProducer import com.intellij.diff.impl.CacheDiffRequestProcessor import com.intellij.openapi.project.Project @@ -22,10 +21,7 @@ class KotlinConfiguratorChangesDiffRequestProcessor( return currentProvider } - override fun getData(dataId: String): Any? { - if (OpenInEditorAction.AFTER_NAVIGATE_CALLBACK.`is`(dataId)) { - return Runnable { onNavigate() } - } - return super.getData(dataId) + override fun createAfterNavigateCallback(): Runnable { + return Runnable { onNavigate() } } } \ No newline at end of file diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java index e63cb925c71b..d72a4f4a2424 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java @@ -3,10 +3,7 @@ package org.jetbrains.idea.svn.dialogs; import com.intellij.configurationStore.StoreUtil; import com.intellij.notification.*; -import com.intellij.openapi.actionSystem.ActionGroup; -import com.intellij.openapi.actionSystem.ActionManager; -import com.intellij.openapi.actionSystem.ActionToolbar; -import com.intellij.openapi.actionSystem.PlatformCoreDataKeys; +import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressManager; @@ -49,7 +46,6 @@ import java.io.File; import java.util.*; import static com.intellij.notification.NotificationAction.createSimpleExpiring; -import static com.intellij.notification.NotificationDisplayType.STICKY_BALLOON; import static com.intellij.openapi.application.ApplicationManager.getApplication; import static com.intellij.openapi.ui.Messages.showWarningDialog; import static com.intellij.openapi.util.text.StringUtil.notNullize; @@ -115,9 +111,9 @@ public class CopiesPanel extends SimpleToolWindowPanel { } @Override - public @Nullable 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); } private void rootsReloaded(boolean rootsChanged) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/AlienChangeListBrowser.kt b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/AlienChangeListBrowser.kt index cf70d56e9289..5ffc3949efb3 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/AlienChangeListBrowser.kt +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/AlienChangeListBrowser.kt @@ -1,6 +1,7 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.idea.svn.integrate +import com.intellij.openapi.actionSystem.DataSink import com.intellij.openapi.project.Project import com.intellij.openapi.vcs.FilePath import com.intellij.openapi.vcs.VcsDataKeys @@ -38,8 +39,8 @@ class AlienChangeListBrowser(project: Project, private val changeList: LocalChan override fun updateDisplayedChangeLists() {} - override fun getData(dataId: String) = when (dataId) { - VcsDataKeys.CHANGE_LISTS.name -> arrayOf(changeList) - else -> super.getData(dataId) + override fun uiDataSnapshot(sink: DataSink) { + super.uiDataSnapshot(sink) + sink[VcsDataKeys.CHANGE_LISTS] = arrayOf(changeList) } }