mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
migrate getData to uiDataSnapshot: community
GitOrigin-RevId: 35480f3ec10b5c64385f2cc7317a327e60a3e56d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c98b16d7a2
commit
f784d44b80
+3
-1
@@ -189,7 +189,9 @@ public class ArtifactEditorImpl implements ArtifactEditorEx, UiDataProvider {
|
||||
|
||||
public JComponent createMainComponent() {
|
||||
myLayoutTreeComponent.initTree();
|
||||
DataManager.registerDataProvider(myMainPanel, (EdtNoGetDataProvider)this::uiDataSnapshot);
|
||||
DataManager.registerDataProvider(myMainPanel, (EdtNoGetDataProvider)sink -> {
|
||||
DataSink.uiDataSnapshot(sink, ArtifactEditorImpl.this);
|
||||
});
|
||||
|
||||
myErrorPanelPlace.add(myValidationManager.getMainErrorPanel(), BorderLayout.CENTER);
|
||||
|
||||
|
||||
@@ -10801,7 +10801,6 @@ c:com.intellij.execution.console.IdeConsoleRootType
|
||||
c:com.intellij.execution.console.LanguageConsoleImpl
|
||||
- com.intellij.execution.impl.ConsoleViewImpl
|
||||
- com.intellij.execution.console.LanguageConsoleView
|
||||
- com.intellij.openapi.actionSystem.DataProvider
|
||||
- sf:Companion:com.intellij.execution.console.LanguageConsoleImpl$Companion
|
||||
- <init>(com.intellij.execution.console.LanguageConsoleImpl$Helper):V
|
||||
- <init>(com.intellij.openapi.project.Project,java.lang.String,com.intellij.lang.Language):V
|
||||
@@ -10845,8 +10844,10 @@ f:com.intellij.execution.console.LanguageConsoleImpl$Companion
|
||||
- f:printWithHighlighting(com.intellij.execution.console.LanguageConsoleView,com.intellij.openapi.editor.Editor,com.intellij.openapi.util.TextRange):java.lang.String
|
||||
f:com.intellij.execution.console.LanguageConsoleImpl$ConsoleEditorsPanel
|
||||
- javax.swing.JPanel
|
||||
- com.intellij.openapi.actionSystem.UiDataProvider
|
||||
- <init>(com.intellij.execution.console.LanguageConsoleImpl):V
|
||||
- f:getConsole():com.intellij.execution.console.LanguageConsoleImpl
|
||||
- uiDataSnapshot(com.intellij.openapi.actionSystem.DataSink):V
|
||||
c:com.intellij.execution.console.LanguageConsoleImpl$Helper
|
||||
- file:com.intellij.psi.PsiFile
|
||||
- f:project:com.intellij.openapi.project.Project
|
||||
@@ -10854,7 +10855,6 @@ c:com.intellij.execution.console.LanguageConsoleImpl$Helper
|
||||
- f:virtualFile:com.intellij.openapi.vfs.VirtualFile
|
||||
- <init>(com.intellij.openapi.project.Project,com.intellij.openapi.vfs.VirtualFile):V
|
||||
- f:getDocument():com.intellij.openapi.editor.Document
|
||||
- pf:getEditorData(com.intellij.openapi.editor.ex.EditorEx,java.lang.String):java.lang.Object
|
||||
- getFile():com.intellij.psi.PsiFile
|
||||
- f:getFileSafe():com.intellij.psi.PsiFile
|
||||
- f:setLanguage(com.intellij.lang.Language):V
|
||||
|
||||
+2
-8
@@ -72,14 +72,8 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Dumb
|
||||
|
||||
private static @NotNull AnActionEvent getEventWithReporter(@NotNull AnActionEvent e) {
|
||||
GotoDeclarationReporter reporter = new GotoDeclarationFUSReporter();
|
||||
CustomizedDataContext context = CustomizedDataContext.create(e.getDataContext(), new DataProvider() {
|
||||
@Override
|
||||
public @Nullable Object getData(@NotNull String dataId) {
|
||||
if (GO_TO_DECLARATION_REPORTER_DATA_KEY.is(dataId)) {
|
||||
return reporter;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
DataContext context = CustomizedDataContext.withSnapshot(e.getDataContext(), sink -> {
|
||||
sink.set(GO_TO_DECLARATION_REPORTER_DATA_KEY, reporter);
|
||||
});
|
||||
return e.withDataContext(context);
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfo
|
||||
import com.intellij.execution.impl.ConsoleViewImpl
|
||||
import com.intellij.execution.impl.ConsoleViewUtil
|
||||
import com.intellij.execution.ui.ConsoleViewContentType
|
||||
import com.intellij.ide.DataManager
|
||||
import com.intellij.ide.highlighter.HighlighterFactory
|
||||
import com.intellij.injected.editor.EditorWindow
|
||||
import com.intellij.lang.Language
|
||||
import com.intellij.lang.annotation.HighlightSeverity
|
||||
import com.intellij.openapi.actionSystem.DataProvider
|
||||
import com.intellij.openapi.actionSystem.DataSink
|
||||
import com.intellij.openapi.actionSystem.UiDataProvider
|
||||
import com.intellij.openapi.actionSystem.ex.ActionUtil.copyRegisteredShortcuts
|
||||
import com.intellij.openapi.application.ReadAction
|
||||
import com.intellij.openapi.command.undo.UndoUtil
|
||||
@@ -32,7 +32,6 @@ import com.intellij.openapi.editor.markup.MarkupModel
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx.Companion.getInstanceEx
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.util.NlsContexts
|
||||
@@ -70,7 +69,7 @@ import kotlin.math.min
|
||||
* In case of REPL consider to use [LanguageConsoleBuilder]
|
||||
*/
|
||||
open class LanguageConsoleImpl(private val myHelper: Helper) : ConsoleViewImpl(
|
||||
myHelper.project, GlobalSearchScope.allScope(myHelper.project), true, true), LanguageConsoleView, DataProvider {
|
||||
myHelper.project, GlobalSearchScope.allScope(myHelper.project), true, true), LanguageConsoleView {
|
||||
private val consoleExecutionEditor = ConsoleExecutionEditor(myHelper)
|
||||
override val historyViewer: EditorEx
|
||||
private val myPanel: JPanel = ConsoleEditorsPanel(this)
|
||||
@@ -197,7 +196,6 @@ open class LanguageConsoleImpl(private val myHelper: Helper) : ConsoleViewImpl(
|
||||
myPanel.add(consoleExecutionEditor.component)
|
||||
myPanel.add(myScrollBar)
|
||||
myPanel.background = JBColor.lazy { consoleExecutionEditor.editor.backgroundColor }
|
||||
DataManager.registerDataProvider(myPanel, this)
|
||||
}
|
||||
|
||||
private fun setupComponents() {
|
||||
@@ -428,24 +426,16 @@ open class LanguageConsoleImpl(private val myHelper: Helper) : ConsoleViewImpl(
|
||||
|
||||
editor.setHorizontalScrollbarVisible(true)
|
||||
editor.setVerticalScrollbarVisible(true)
|
||||
|
||||
DataManager.registerDataProvider(editor.component) { dataId -> getEditorData(editor, dataId) }
|
||||
}
|
||||
|
||||
val fileSafe: PsiFile
|
||||
get() = if (file == null || !file!!.isValid) getFile().also { file = it } else file!!
|
||||
|
||||
protected fun getEditorData(editor: EditorEx, dataId: String): Any? {
|
||||
if (OpenFileDescriptor.NAVIGATE_IN_EDITOR.`is`(dataId)) {
|
||||
return editor
|
||||
}
|
||||
else if (project.isInitialized) {
|
||||
val caret = editor.caretModel.currentCaret
|
||||
return getInstanceEx(project).getData(dataId, editor, caret)
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
class ConsoleEditorsPanel(val console: LanguageConsoleImpl) : JPanel()
|
||||
class ConsoleEditorsPanel(val console: LanguageConsoleImpl) : JPanel(), UiDataProvider {
|
||||
override fun uiDataSnapshot(sink: DataSink) {
|
||||
DataSink.uiDataSnapshot(sink, console)
|
||||
sink[OpenFileDescriptor.NAVIGATE_IN_EDITOR] = console.consoleExecutionEditor.editor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,6 +371,8 @@ public class JBList<E> extends JList<E> implements ComponentWithEmptyText, Compo
|
||||
setCellRenderer(new SelectionAwareListCellRenderer<>(fun));
|
||||
}
|
||||
|
||||
/** @deprecated Implement {@link com.intellij.openapi.actionSystem.UiDataProvider} instead */
|
||||
@Deprecated(forRemoval = true)
|
||||
public void setDataProvider(@NotNull DataProvider provider) {
|
||||
DataManager.registerDataProvider(this, provider);
|
||||
}
|
||||
|
||||
@@ -1247,6 +1247,7 @@ com.intellij.xdebugger.impl.frame.XDebuggerFramesList$ItemWithSeparatorAbove
|
||||
- setWithSeparator(Z):V
|
||||
f:com.intellij.xdebugger.impl.frame.XDebuggerThreadsList
|
||||
- com.intellij.ui.components.JBList
|
||||
- com.intellij.openapi.actionSystem.UiDataProvider
|
||||
- sf:Companion:com.intellij.xdebugger.impl.frame.XDebuggerThreadsList$Companion
|
||||
- <init>(javax.swing.ListCellRenderer):V
|
||||
- f:clear():V
|
||||
@@ -1255,6 +1256,7 @@ f:com.intellij.xdebugger.impl.frame.XDebuggerThreadsList
|
||||
- f:getStackUnderMouse():com.intellij.xdebugger.impl.frame.StackInfo
|
||||
- locationToIndex(java.awt.Point):I
|
||||
- setModel(javax.swing.ListModel):V
|
||||
- uiDataSnapshot(com.intellij.openapi.actionSystem.DataSink):V
|
||||
f:com.intellij.xdebugger.impl.frame.XDebuggerThreadsList$Companion
|
||||
- f:create(javax.swing.ListCellRenderer):com.intellij.xdebugger.impl.frame.XDebuggerThreadsList
|
||||
- f:createDefault():com.intellij.xdebugger.impl.frame.XDebuggerThreadsList
|
||||
|
||||
+9
-7
@@ -2,6 +2,8 @@
|
||||
package com.intellij.xdebugger.impl.frame
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataKey
|
||||
import com.intellij.openapi.actionSystem.DataSink
|
||||
import com.intellij.openapi.actionSystem.UiDataProvider
|
||||
import com.intellij.openapi.ui.popup.ListItemDescriptor
|
||||
import com.intellij.ui.CollectionListModel
|
||||
import com.intellij.ui.ColoredListCellRenderer
|
||||
@@ -24,9 +26,8 @@ import javax.swing.*
|
||||
import javax.swing.plaf.FontUIResource
|
||||
|
||||
|
||||
class XDebuggerThreadsList(private val renderer: ListCellRenderer<StackInfo>) : JBList<StackInfo>(
|
||||
CollectionListModel()
|
||||
) {
|
||||
class XDebuggerThreadsList(private val renderer: ListCellRenderer<StackInfo>
|
||||
) : JBList<StackInfo>(CollectionListModel()), UiDataProvider {
|
||||
private var mySelectedFrame: StackInfo? = null
|
||||
|
||||
var stackUnderMouse: StackInfo? = null
|
||||
@@ -56,12 +57,13 @@ class XDebuggerThreadsList(private val renderer: ListCellRenderer<StackInfo>) :
|
||||
if (font != null) {
|
||||
setFont(FontUIResource(font.name, font.style, font.size))
|
||||
}
|
||||
setDataProvider {
|
||||
return@setDataProvider if (THREADS_LIST.`is`(it)) this@XDebuggerThreadsList else null
|
||||
}
|
||||
}
|
||||
|
||||
private fun doInit() {
|
||||
override fun uiDataSnapshot(sink: DataSink) {
|
||||
sink[THREADS_LIST] = this
|
||||
}
|
||||
|
||||
private fun doInit() {
|
||||
selectionModel.selectionMode = ListSelectionModel.SINGLE_SELECTION
|
||||
cellRenderer = renderer
|
||||
selectionModel.addListSelectionListener { e ->
|
||||
|
||||
Reference in New Issue
Block a user