mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
migrate DataManager.registerDataProvider: platform
GitOrigin-RevId: c7805a21defb3a6c7192c65e4f38ba46e894f4e5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6a5fd79a31
commit
1dee3a5d6d
@@ -17,10 +17,10 @@ import com.intellij.collaboration.ui.util.bindIconIn
|
||||
import com.intellij.collaboration.ui.util.bindTextIn
|
||||
import com.intellij.collaboration.ui.util.bindVisibilityIn
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.ide.DataManager
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||
import com.intellij.openapi.actionSystem.CustomizedDataContext
|
||||
import com.intellij.openapi.actionSystem.DataSink
|
||||
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys
|
||||
import com.intellij.openapi.actionSystem.UiDataProvider
|
||||
import com.intellij.openapi.editor.colors.EditorColors
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager
|
||||
import com.intellij.openapi.ui.MessageDialogBuilder
|
||||
@@ -69,33 +69,32 @@ object CodeReviewCommentUIUtil {
|
||||
val scheme = EditorColorsManager.getInstance().globalScheme
|
||||
scheme.getColor(EditorColors.TEARLINE_COLOR) ?: JBColor.border()
|
||||
}
|
||||
return ClippingRoundedPanel(EDITOR_INLAY_PANEL_ARC, borderColor, BorderLayout()).apply {
|
||||
val roundedPanel = ClippingRoundedPanel(EDITOR_INLAY_PANEL_ARC, borderColor, BorderLayout()).apply {
|
||||
background = JBColor.lazy {
|
||||
val scheme = EditorColorsManager.getInstance().globalScheme
|
||||
scheme.defaultBackground
|
||||
}
|
||||
add(component)
|
||||
}.also {
|
||||
component.addComponentListener(object : ComponentAdapter() {
|
||||
override fun componentResized(e: ComponentEvent?) =
|
||||
it.dispatchEvent(ComponentEvent(component, ComponentEvent.COMPONENT_RESIZED))
|
||||
add(UiDataProvider.wrapComponent(component) { sink ->
|
||||
suppressOuterEditorData(sink)
|
||||
})
|
||||
DataManager.registerDataProvider(it) { dataId ->
|
||||
when {
|
||||
CommonDataKeys.EDITOR.`is`(dataId) -> CustomizedDataContext.EXPLICIT_NULL
|
||||
CommonDataKeys.HOST_EDITOR.`is`(dataId) -> CustomizedDataContext.EXPLICIT_NULL
|
||||
CommonDataKeys.EDITOR_EVEN_IF_INACTIVE.`is`(dataId) -> CustomizedDataContext.EXPLICIT_NULL
|
||||
CommonDataKeys.CARET.`is`(dataId) -> CustomizedDataContext.EXPLICIT_NULL
|
||||
CommonDataKeys.VIRTUAL_FILE.`is`(dataId) -> CustomizedDataContext.EXPLICIT_NULL
|
||||
CommonDataKeys.VIRTUAL_FILE_ARRAY.`is`(dataId) -> CustomizedDataContext.EXPLICIT_NULL
|
||||
CommonDataKeys.LANGUAGE.`is`(dataId) -> CustomizedDataContext.EXPLICIT_NULL
|
||||
CommonDataKeys.PSI_FILE.`is`(dataId) -> CustomizedDataContext.EXPLICIT_NULL
|
||||
CommonDataKeys.PSI_ELEMENT.`is`(dataId) -> CustomizedDataContext.EXPLICIT_NULL
|
||||
PlatformCoreDataKeys.FILE_EDITOR.`is`(dataId) -> CustomizedDataContext.EXPLICIT_NULL
|
||||
PlatformCoreDataKeys.PSI_ELEMENT_ARRAY.`is`(dataId) -> CustomizedDataContext.EXPLICIT_NULL
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
component.addComponentListener(object : ComponentAdapter() {
|
||||
override fun componentResized(e: ComponentEvent?) {
|
||||
roundedPanel.dispatchEvent(ComponentEvent(component, ComponentEvent.COMPONENT_RESIZED))
|
||||
}
|
||||
})
|
||||
return roundedPanel
|
||||
}
|
||||
|
||||
private fun suppressOuterEditorData(sink: DataSink) {
|
||||
arrayOf(CommonDataKeys.EDITOR, CommonDataKeys.HOST_EDITOR, CommonDataKeys.EDITOR_EVEN_IF_INACTIVE,
|
||||
CommonDataKeys.CARET,
|
||||
CommonDataKeys.VIRTUAL_FILE, CommonDataKeys.VIRTUAL_FILE_ARRAY,
|
||||
CommonDataKeys.LANGUAGE,
|
||||
CommonDataKeys.PSI_FILE, CommonDataKeys.PSI_ELEMENT,
|
||||
PlatformCoreDataKeys.FILE_EDITOR,
|
||||
PlatformCoreDataKeys.PSI_ELEMENT_ARRAY).forEach {
|
||||
sink.setNull(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,13 +24,14 @@ import com.intellij.diff.contents.EmptyContent;
|
||||
import com.intellij.diff.contents.FileContent;
|
||||
import com.intellij.diff.requests.ContentDiffRequest;
|
||||
import com.intellij.diff.requests.DiffRequest;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.diff.DiffElement;
|
||||
import com.intellij.ide.diff.DirDiffSettings;
|
||||
import com.intellij.ide.diff.VirtualFileDiffElement;
|
||||
import com.intellij.ide.highlighter.ArchiveFileType;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.DataSink;
|
||||
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys;
|
||||
import com.intellij.openapi.actionSystem.UiDataProvider;
|
||||
import com.intellij.openapi.diff.impl.dir.DirDiffPanel;
|
||||
import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
|
||||
import com.intellij.openapi.diff.impl.dir.DirDiffWindow;
|
||||
@@ -42,14 +43,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
class DirDiffViewer implements FrameDiffTool.DiffViewer {
|
||||
|
||||
private final DirDiffPanel myDirDiffPanel;
|
||||
private final JPanel myPanel;
|
||||
private final JComponent myComponent;
|
||||
private final String myHelpID;
|
||||
|
||||
DirDiffViewer(@NotNull DiffContext context, @NotNull ContentDiffRequest request) {
|
||||
@@ -82,13 +82,9 @@ class DirDiffViewer implements FrameDiffTool.DiffViewer {
|
||||
}
|
||||
});
|
||||
|
||||
myPanel = new JPanel(new BorderLayout());
|
||||
myPanel.add(myDirDiffPanel.getPanel(), BorderLayout.CENTER);
|
||||
DataManager.registerDataProvider(myPanel, dataId -> {
|
||||
if (PlatformCoreDataKeys.HELP_ID.is(dataId)) {
|
||||
return myHelpID;
|
||||
}
|
||||
return myDirDiffPanel.getData(dataId);
|
||||
myComponent = UiDataProvider.wrapComponent(myDirDiffPanel.getPanel(), sink -> {
|
||||
sink.set(PlatformCoreDataKeys.HELP_ID, myHelpID);
|
||||
DataSink.uiDataSnapshot(sink, myDirDiffPanel);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -109,7 +105,7 @@ class DirDiffViewer implements FrameDiffTool.DiffViewer {
|
||||
@NotNull
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
return myPanel;
|
||||
return myComponent;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.diff.impl.dir;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys;
|
||||
import com.intellij.openapi.actionSystem.UiDataProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.FrameWrapper;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
@@ -14,22 +14,17 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public final class DirDiffFrame extends FrameWrapper {
|
||||
private final DirDiffPanel myPanel;
|
||||
|
||||
public DirDiffFrame(Project project, DirDiffTableModel model) {
|
||||
super(project, "DirDiffDialog");
|
||||
setSize(JBUI.size(800, 600));
|
||||
setTitle(model.getTitle());
|
||||
myPanel = new DirDiffPanel(model, new DirDiffWindow.Frame(this));
|
||||
Disposer.register(this, myPanel);
|
||||
setComponent(myPanel.getPanel());
|
||||
setPreferredFocusedComponent(myPanel.getTable());
|
||||
DirDiffPanel panel = new DirDiffPanel(model, new DirDiffWindow.Frame(this));
|
||||
Disposer.register(this, panel);
|
||||
setComponent(UiDataProvider.wrapComponent(panel.getPanel(), sink -> {
|
||||
sink.set(PlatformCoreDataKeys.HELP_ID, "reference.dialogs.diff.folder");
|
||||
}));
|
||||
setPreferredFocusedComponent(panel.getTable());
|
||||
closeOnEsc();
|
||||
DataManager.registerDataProvider(myPanel.getPanel(), dataId -> {
|
||||
if (PlatformCoreDataKeys.HELP_ID.is(dataId)) {
|
||||
return "reference.dialogs.diff.folder";
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.intellij.diff.requests.SimpleDiffRequest;
|
||||
import com.intellij.diff.tools.util.DiffDataKeys;
|
||||
import com.intellij.diff.tools.util.PrevNextDifferenceIterable;
|
||||
import com.intellij.diff.util.DiffPlaces;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.HelpTooltip;
|
||||
import com.intellij.ide.diff.DiffElement;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
@@ -45,7 +44,6 @@ import com.intellij.util.ui.NamedColorUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.components.BorderLayoutPanel;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -67,7 +65,7 @@ import java.util.concurrent.Callable;
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
@SuppressWarnings("unchecked")
|
||||
public class DirDiffPanel implements Disposable, DataProvider {
|
||||
public class DirDiffPanel implements Disposable {
|
||||
private static final Logger LOG = Logger.getInstance(DirDiffPanel.class);
|
||||
|
||||
public static final DataKey<DirDiffTableModel> DIR_DIFF_MODEL = DataKey.create("DIR_DIFF_MODEL");
|
||||
@@ -205,7 +203,6 @@ public class DirDiffPanel implements Disposable, DataProvider {
|
||||
UIUtil.applyStyle(UIUtil.ComponentStyle.MINI, label);
|
||||
filesPanel.addToBottom(label);
|
||||
}
|
||||
DataManager.registerDataProvider(filesPanel, this);
|
||||
PopupHandler.installPopupMenu(myTable, "DirDiffMenu", "DirDiffPanel");
|
||||
|
||||
myFilterPanel = new JPanel(new BorderLayout());
|
||||
@@ -222,8 +219,8 @@ public class DirDiffPanel implements Disposable, DataProvider {
|
||||
headerPanel.add(targetPanel, gb.next());
|
||||
|
||||
Splitter tableSplitter = new OnePixelSplitter(true, SPLITTER_PROPORTION_KEY, 0.4f);
|
||||
tableSplitter.setFirstComponent(JBUI.Panels.simplePanel(filesPanel)
|
||||
.addToTop(headerPanel));
|
||||
JComponent wrapped = UiDataProvider.wrapComponent(filesPanel, sink -> uiDataSnapshot(sink));
|
||||
tableSplitter.setFirstComponent(JBUI.Panels.simplePanel(wrapped).addToTop(headerPanel));
|
||||
|
||||
final JBLoadingPanel loadingPanel = new JBLoadingPanel(new BorderLayout(), wnd.getDisposable());
|
||||
loadingPanel.addListener(new JBLoadingPanelListener.Adapter() {
|
||||
@@ -453,27 +450,13 @@ public class DirDiffPanel implements Disposable, DataProvider {
|
||||
myModel.stopUpdating();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData(@NotNull @NonNls String dataId) {
|
||||
if (CommonDataKeys.PROJECT.is(dataId)) {
|
||||
return myProject;
|
||||
}
|
||||
else if (DIR_DIFF_MODEL.is(dataId)) {
|
||||
return myModel;
|
||||
}
|
||||
else if (DIR_DIFF_TABLE.is(dataId)) {
|
||||
return myTable;
|
||||
}
|
||||
else if (DIR_DIFF_FILTER.is(dataId)) {
|
||||
return myFilter;
|
||||
}
|
||||
else if (DiffDataKeys.NAVIGATABLE_ARRAY.is(dataId)) {
|
||||
return getNavigatableArray();
|
||||
}
|
||||
else if (DiffDataKeys.PREV_NEXT_DIFFERENCE_ITERABLE.is(dataId)) {
|
||||
return new MyPrevNextDifferenceIterable();
|
||||
}
|
||||
return null;
|
||||
private void uiDataSnapshot(@NotNull DataSink sink) {
|
||||
sink.set(CommonDataKeys.PROJECT, myProject);
|
||||
sink.set(DIR_DIFF_MODEL, myModel);
|
||||
sink.set(DIR_DIFF_TABLE, myTable);
|
||||
sink.set(DIR_DIFF_FILTER, myFilter);
|
||||
sink.set(DiffDataKeys.NAVIGATABLE_ARRAY, getNavigatableArray());
|
||||
sink.set(DiffDataKeys.PREV_NEXT_DIFFERENCE_ITERABLE, new MyPrevNextDifferenceIterable());
|
||||
}
|
||||
|
||||
private Navigatable @NotNull [] getNavigatableArray() {
|
||||
|
||||
@@ -10,8 +10,8 @@ import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.execution.ui.RunConfigurationFragmentedEditor;
|
||||
import com.intellij.execution.ui.RunnerAndConfigurationSettingsEditor;
|
||||
import com.intellij.execution.ui.TargetAwareRunConfigurationEditor;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.actionSystem.UiDataProvider;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -84,13 +84,9 @@ public final class ConfigurationSettingsEditorWrapper extends SettingsEditor<Run
|
||||
protected @NotNull JComponent createEditor() {
|
||||
content.componentPlace.setLayout(new BorderLayout());
|
||||
content.componentPlace.add(myEditor.getComponent(), BorderLayout.CENTER);
|
||||
DataManager.registerDataProvider(content.panel, dataId -> {
|
||||
if (CONFIGURATION_EDITOR_KEY.is(dataId)) {
|
||||
return this;
|
||||
}
|
||||
return null;
|
||||
return UiDataProvider.wrapComponent(content.panel, sink -> {
|
||||
sink.set(CONFIGURATION_EDITOR_KEY, this);
|
||||
});
|
||||
return content.panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.intellij.execution.impl.RunConfigurable.Companion.collectNodesRecursi
|
||||
import com.intellij.execution.impl.RunConfigurableNodeKind.*
|
||||
import com.intellij.execution.impl.statistics.RunConfigurationOptionUsagesCollector
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.ide.DataManager
|
||||
import com.intellij.ide.IdeBundle
|
||||
import com.intellij.ide.dnd.TransferableList
|
||||
import com.intellij.openapi.Disposable
|
||||
@@ -486,16 +485,13 @@ open class RunConfigurable constructor(protected val project: Project) : Configu
|
||||
}
|
||||
|
||||
override fun createComponent(): JComponent? {
|
||||
wholePanel = JPanel(BorderLayout())
|
||||
DataManager.registerDataProvider(wholePanel!!) { dataId ->
|
||||
when (dataId) {
|
||||
RunConfigurationSelector.KEY.name -> RunConfigurationSelector { configuration -> selectConfiguration(configuration) }
|
||||
CommonDataKeys.PROJECT.name -> project
|
||||
RunConfigurationCreator.KEY.name -> this
|
||||
else -> null
|
||||
wholePanel = object : JPanel(BorderLayout()), UiDataProvider {
|
||||
override fun uiDataSnapshot(sink: DataSink) {
|
||||
sink[RunConfigurationSelector.KEY] = RunConfigurationSelector { selectConfiguration(it) }
|
||||
sink[CommonDataKeys.PROJECT] = project
|
||||
sink[RunConfigurationCreator.KEY] = this@RunConfigurable
|
||||
}
|
||||
}
|
||||
|
||||
if (SystemInfo.isMac) {
|
||||
val touchbarActions = DefaultActionGroup(toolbarAddAction)
|
||||
TouchbarActionCustomizations.setShowText(touchbarActions, true)
|
||||
|
||||
@@ -13,6 +13,8 @@ import com.intellij.execution.ui.RunnerAndConfigurationSettingsEditor;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.actionSystem.DataSink;
|
||||
import com.intellij.openapi.actionSystem.UiDataProvider;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.NonBlockingReadAction;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
@@ -234,32 +236,27 @@ public final class SingleConfigurationConfigurable<Config extends RunConfigurati
|
||||
public JComponent createComponent() {
|
||||
myComponent.myNameText.setEnabled(!myBrokenConfiguration);
|
||||
JComponent result = myComponent.getWholePanel();
|
||||
DataManager.registerDataProvider(result, dataId -> {
|
||||
if (myComponent == null) {
|
||||
return null; // disposed
|
||||
}
|
||||
if (ConfigurationSettingsEditorWrapper.CONFIGURATION_EDITOR_KEY.is(dataId)) {
|
||||
return getEditor();
|
||||
}
|
||||
if (RUN_ON_TARGET_NAME_KEY.is(dataId)) {
|
||||
return TargetEnvironmentConfigurations.getEffectiveTargetName(myRunOnTargetPanel.getDefaultTargetName(), myProject);
|
||||
}
|
||||
if (RunConfigurationSelector.KEY.is(dataId)) {
|
||||
return new RunConfigurationSelector() {
|
||||
@Override
|
||||
public void select(@NotNull RunConfiguration configuration) {
|
||||
RunnerAndConfigurationSettingsImpl settings = RunManagerImpl.getInstanceImpl(myProject).getSettings(configuration);
|
||||
RunDialog.editConfiguration(myProject,
|
||||
Objects.requireNonNull(settings),
|
||||
ExecutionBundle.message("edit.run.configuration.for.item.dialog.title", configuration.getName()));
|
||||
}
|
||||
};
|
||||
}
|
||||
return null;
|
||||
});
|
||||
Dimension size = result.getPreferredSize();
|
||||
result.setPreferredSize(new Dimension(Math.min(size.width, 800), Math.min(size.height, 600)));
|
||||
return result;
|
||||
return UiDataProvider.wrapComponent(result, sink -> uiDataSnapshot(sink));
|
||||
}
|
||||
|
||||
private void uiDataSnapshot(@NotNull DataSink sink) {
|
||||
if (myComponent == null) return;
|
||||
|
||||
sink.set(ConfigurationSettingsEditorWrapper.CONFIGURATION_EDITOR_KEY,
|
||||
getEditor() instanceof ConfigurationSettingsEditorWrapper o ? o : null);
|
||||
sink.set(RUN_ON_TARGET_NAME_KEY,
|
||||
TargetEnvironmentConfigurations.getEffectiveTargetName(myRunOnTargetPanel.getDefaultTargetName(), myProject));
|
||||
sink.set(RunConfigurationSelector.KEY, new RunConfigurationSelector() {
|
||||
@Override
|
||||
public void select(@NotNull RunConfiguration configuration) {
|
||||
RunnerAndConfigurationSettingsImpl settings = RunManagerImpl.getInstanceImpl(myProject).getSettings(configuration);
|
||||
RunDialog.editConfiguration(myProject,
|
||||
Objects.requireNonNull(settings),
|
||||
ExecutionBundle.message("edit.run.configuration.for.item.dialog.title", configuration.getName()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
JComponent getValidationComponent() {
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.services.*;
|
||||
import com.intellij.execution.services.ServiceEventListener.ServiceEvent;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.lightEdit.LightEditUtil;
|
||||
import com.intellij.ide.projectView.PresentationData;
|
||||
import com.intellij.ide.util.treeView.TreeState;
|
||||
@@ -261,7 +260,6 @@ public final class ServiceViewManagerImpl implements ServiceViewManager, Persist
|
||||
myAutoScrollToSourceHandler = ServiceViewSourceScrollHelper.createAutoScrollToSourceHandler(myProject);
|
||||
}
|
||||
ToolWindowEx toolWindowEx = (ToolWindowEx)toolWindow;
|
||||
Wrapper toolWindowHeaderSideComponent = setToolWindowHeaderSideComponent(toolWindowEx);
|
||||
ServiceViewSourceScrollHelper.installAutoScrollSupport(myProject, toolWindowEx, myAutoScrollToSourceHandler);
|
||||
|
||||
Pair<ServiceViewState, List<ServiceViewState>> states = getServiceViewStates(toolWindowId);
|
||||
@@ -270,8 +268,9 @@ public final class ServiceViewManagerImpl implements ServiceViewManager, Persist
|
||||
mainView.setAutoScrollToSourceHandler(myAutoScrollToSourceHandler);
|
||||
|
||||
ContentManager contentManager = toolWindow.getContentManager();
|
||||
ServiceViewContentHolder holder =
|
||||
new ServiceViewContentHolder(mainView, contentManager, contributors, toolWindowId, toolWindowHeaderSideComponent);
|
||||
Wrapper toolWindowHeaderSideComponent = setToolWindowHeaderSideComponent(toolWindowEx, contentManager);
|
||||
ServiceViewContentHolder holder = new ServiceViewContentHolder(
|
||||
mainView, contentManager, contributors, toolWindowId, toolWindowHeaderSideComponent);
|
||||
myContentHolders.add(holder);
|
||||
contentManager.addContentManagerListener(new ServiceViewContentMangerListener(myModelFilter, myAutoScrollToSourceHandler, holder));
|
||||
myProject.getMessageBus().connect(contentManager).subscribe(ToolWindowManagerListener.TOPIC, new ToolWindowManagerListener() {
|
||||
@@ -296,20 +295,12 @@ public final class ServiceViewManagerImpl implements ServiceViewManager, Persist
|
||||
}
|
||||
}
|
||||
});
|
||||
if (toolWindowHeaderSideComponent != null) {
|
||||
DataManager.registerDataProvider(toolWindowHeaderSideComponent, dataId -> {
|
||||
Content content = contentManager.getSelectedContent();
|
||||
ServiceView serviceView = content == null ? null : getServiceView(content);
|
||||
DataProvider dataProvider = serviceView == null ? null : DataManager.getDataProvider(serviceView);
|
||||
return dataProvider == null ? null : dataProvider.getData(dataId);
|
||||
});
|
||||
}
|
||||
addMainContent(toolWindow.getContentManager(), mainView);
|
||||
loadViews(contentManager, mainView, contributors, states.second);
|
||||
ServiceViewDragHelper.installDnDSupport(myProject, toolWindowEx.getDecorator(), contentManager);
|
||||
}
|
||||
|
||||
private static Wrapper setToolWindowHeaderSideComponent(ToolWindowEx toolWindowEx) {
|
||||
private static Wrapper setToolWindowHeaderSideComponent(ToolWindowEx toolWindowEx, ContentManager contentManager) {
|
||||
if (!Registry.is("ide.services.tool.window.header.nav.bar", true) ||
|
||||
AppMode.isRemoteDevHost()) {
|
||||
return null;
|
||||
@@ -318,7 +309,11 @@ public final class ServiceViewManagerImpl implements ServiceViewManager, Persist
|
||||
if (decorator == null) return null;
|
||||
|
||||
Wrapper wrapper = new Wrapper();
|
||||
decorator.getHeader().setSideComponent(wrapper);
|
||||
decorator.getHeader().setSideComponent(UiDataProvider.wrapComponent(wrapper, sink -> {
|
||||
Content content = contentManager.getSelectedContent();
|
||||
ServiceView serviceView = content == null ? null : getServiceView(content);
|
||||
DataSink.uiDataSnapshot(sink, serviceView);
|
||||
}));
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.services.ServiceViewActionUtils;
|
||||
import com.intellij.execution.services.ServiceViewUIUtils;
|
||||
import com.intellij.openapi.actionSystem.ActionToolbar;
|
||||
import com.intellij.openapi.actionSystem.DataSink;
|
||||
import com.intellij.openapi.actionSystem.UiDataProvider;
|
||||
import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -53,8 +52,10 @@ final class ServiceViewTreeUi implements ServiceViewUi {
|
||||
myMainPanel.add(myContentPanel, BorderLayout.CENTER);
|
||||
myContentPanel.setContent(mySplitter);
|
||||
|
||||
myMasterPanel = new MyPanel();
|
||||
mySplitter.setFirstComponent(myMasterPanel);
|
||||
myMasterPanel = new JPanel(new BorderLayout());
|
||||
mySplitter.setFirstComponent(UiDataProvider.wrapComponent(myMasterPanel, sink -> {
|
||||
sink.set(ServiceViewActionUtils.IS_FROM_TREE_KEY, true);
|
||||
}));
|
||||
|
||||
myDetailsPanel = new JPanel(new BorderLayout());
|
||||
myContentComponentPanel = new JPanel(new BorderLayout());
|
||||
@@ -241,13 +242,4 @@ final class ServiceViewTreeUi implements ServiceViewUi {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyPanel extends JPanel implements UiDataProvider {
|
||||
MyPanel() { super(new BorderLayout()); }
|
||||
|
||||
@Override
|
||||
public void uiDataSnapshot(@NotNull DataSink sink) {
|
||||
sink.set(ServiceViewActionUtils.IS_FROM_TREE_KEY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,14 +63,8 @@ public interface ServiceViewDescriptor {
|
||||
if (navigatable == null) return false;
|
||||
|
||||
DataContext dataContext = DataManager.getInstance().getDataContext(event.getComponent());
|
||||
DataContext wrapper = CustomizedDataContext.withProvider(dataContext, new DataProvider() {
|
||||
@Override
|
||||
public @Nullable Object getData(@NotNull String dataId) {
|
||||
if (CommonDataKeys.NAVIGATABLE.is(dataId)) {
|
||||
return navigatable;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
DataContext wrapper = CustomizedDataContext.withSnapshot(dataContext, sink -> {
|
||||
sink.set(CommonDataKeys.NAVIGATABLE, navigatable);
|
||||
});
|
||||
OpenSourceUtil.openSourcesFrom(wrapper, false);
|
||||
return true;
|
||||
|
||||
@@ -81,10 +81,6 @@ import java.util.List;
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DocumentationComponent extends JPanel implements Disposable, UiCompatibleDataProvider, WidthBasedLayout {
|
||||
private static final Logger LOG = Logger.getInstance(DocumentationComponent.class);
|
||||
static final DataProvider HELP_DATA_PROVIDER =
|
||||
dataId -> PlatformCoreDataKeys.HELP_ID.is(dataId)
|
||||
? "reference.toolWindows.Documentation"
|
||||
: null;
|
||||
|
||||
public static final ColorKey COLOR_KEY = EditorColors.DOCUMENTATION_COLOR;
|
||||
public static final Color SECTION_COLOR = Gray.get(0x90);
|
||||
@@ -294,9 +290,6 @@ public class DocumentationComponent extends JPanel implements Disposable, UiComp
|
||||
else if (myManager.myToolWindow != null) {
|
||||
Disposer.register(myManager.myToolWindow.getContentManager(), this);
|
||||
}
|
||||
DataManager.registerDataProvider(myEditorPane, HELP_DATA_PROVIDER);
|
||||
DataManager.registerDataProvider(myScrollPane, HELP_DATA_PROVIDER);
|
||||
|
||||
updateControlState();
|
||||
}
|
||||
|
||||
@@ -356,6 +349,7 @@ public class DocumentationComponent extends JPanel implements Disposable, UiComp
|
||||
|
||||
@Override
|
||||
public void uiDataSnapshot(@NotNull DataSink sink) {
|
||||
sink.set(PlatformCoreDataKeys.HELP_ID, "reference.toolWindows.Documentation");
|
||||
// Javadocs often contain symbols (non-breakable white space). We don't want to copy them as is and replace
|
||||
// with raw white spaces. See IDEA-86633 for more details.
|
||||
String selectedText = myEditorPane.getSelectedText();
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.intellij.codeInsight.hint.HintManagerImpl;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupPositionStrategy;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.IdeEventQueue;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.idea.ActionsBundle;
|
||||
@@ -99,14 +98,9 @@ final class LookupUi {
|
||||
menuAction.add(new ShowCompletionSettingsAction());
|
||||
|
||||
myMenuButton = new ActionButton(menuAction, null, ActionPlaces.EDITOR_POPUP, ActionToolbar.NAVBAR_MINIMUM_BUTTON_SIZE);
|
||||
DataManager.registerDataProvider(myMenuButton, dataId -> {
|
||||
if (CommonDataKeys.PROJECT.is(dataId)) {
|
||||
return this.lookup.getProject();
|
||||
}
|
||||
if (CommonDataKeys.EDITOR.is(dataId)) {
|
||||
return this.lookup.getEditor();
|
||||
}
|
||||
return null;
|
||||
JComponent menuButtonWrapper = UiDataProvider.wrapComponent(myMenuButton, sink -> {
|
||||
sink.set(CommonDataKeys.PROJECT, this.lookup.getProject());
|
||||
sink.set(CommonDataKeys.EDITOR, this.lookup.getEditor());
|
||||
});
|
||||
|
||||
AnAction hintAction = new HintAction();
|
||||
@@ -121,7 +115,7 @@ final class LookupUi {
|
||||
myBottomPanel.add(myAdvertiser.getAdComponent());
|
||||
myBottomPanel.add(processIcon);
|
||||
myBottomPanel.add(hintButton);
|
||||
myBottomPanel.add(myMenuButton);
|
||||
myBottomPanel.add(menuButtonWrapper);
|
||||
if (ExperimentalUI.isNewUI()) {
|
||||
myBottomPanel.setBackground(JBUI.CurrentTheme.CompletionPopup.Advertiser.background());
|
||||
myBottomPanel.setBorder(JBUI.CurrentTheme.CompletionPopup.Advertiser.border());
|
||||
|
||||
@@ -541,7 +541,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
private static final String ATTRIBUTE_ID = "id";
|
||||
private JPanel viewContentPanel;
|
||||
private static final Comparator<AbstractProjectViewPane> PANE_WEIGHT_COMPARATOR = Comparator.comparingInt(AbstractProjectViewPane::getWeight);
|
||||
private final MyPanel myDataProvider;
|
||||
private final JComponent myDataProvider;
|
||||
private final SplitterProportionsData splitterProportions = new SplitterProportionsDataImpl();
|
||||
private final Map<String, Element> myUninitializedPaneState = new HashMap<>();
|
||||
private final Map<String, MySelectInTarget> mySelectInTargets = new ConcurrentHashMap<>();
|
||||
@@ -558,8 +558,9 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
|
||||
autoScrollFromSourceHandler = new MyAutoScrollFromSourceHandler();
|
||||
|
||||
myDataProvider = new MyPanel();
|
||||
myDataProvider.add(panel, BorderLayout.CENTER);
|
||||
myDataProvider = UiDataProvider.wrapComponent(panel, sink -> uiDataSnapshot(sink));
|
||||
ClientProperty.put(myDataProvider, UIUtil.NOT_IN_HIERARCHY_COMPONENTS, buildNotInHierarchyIterable());
|
||||
|
||||
copyPasteDelegator = new CopyPasteDelegator(this.project, panel);
|
||||
myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() {
|
||||
@Override
|
||||
@@ -1377,36 +1378,30 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
return ActionCallback.REJECTED;
|
||||
}
|
||||
|
||||
private final class MyPanel extends JPanel implements UiDataProvider {
|
||||
MyPanel() {
|
||||
super(new BorderLayout());
|
||||
Collection<AbstractProjectViewPane> snapshot = new ArrayList<>(idToPane.values());
|
||||
ComponentUtil.putClientProperty(this, UIUtil.NOT_IN_HIERARCHY_COMPONENTS,
|
||||
(Iterable<? extends Component>)(Iterable<JComponent>)() -> JBIterable.from(snapshot)
|
||||
.map(pane -> {
|
||||
JComponent last = null;
|
||||
for (Component c : UIUtil.uiParents(pane.getComponentToFocus(), false)) {
|
||||
if (c == this || !(c instanceof JComponent)) return null;
|
||||
last = (JComponent)c;
|
||||
}
|
||||
return last;
|
||||
})
|
||||
.filter(Conditions.notNull())
|
||||
.iterator());
|
||||
}
|
||||
private @NotNull Iterable<? extends Component> buildNotInHierarchyIterable() {
|
||||
return () -> JBIterable.from(new ArrayList<>(idToPane.values()))
|
||||
.map(pane -> {
|
||||
JComponent last = null;
|
||||
for (Component c : UIUtil.uiParents(pane.getComponentToFocus(), false)) {
|
||||
if (c == myDataProvider || !(c instanceof JComponent)) return null;
|
||||
last = (JComponent)c;
|
||||
}
|
||||
return last;
|
||||
})
|
||||
.filter(Component.class)
|
||||
.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uiDataSnapshot(@NotNull DataSink sink) {
|
||||
sink.set(PlatformDataKeys.CUT_PROVIDER, copyPasteDelegator.getCutProvider());
|
||||
sink.set(PlatformDataKeys.COPY_PROVIDER, copyPasteDelegator.getCopyProvider());
|
||||
sink.set(PlatformDataKeys.PASTE_PROVIDER, copyPasteDelegator.getPasteProvider());
|
||||
sink.set(LangDataKeys.IDE_VIEW, myIdeView);
|
||||
sink.set(PlatformCoreDataKeys.HELP_ID, HelpID.PROJECT_VIEWS);
|
||||
sink.set(QuickActionProvider.KEY, ProjectViewImpl.this);
|
||||
AbstractProjectViewPane selectedPane = getCurrentProjectViewPane();
|
||||
if (selectedPane != null) {
|
||||
DataSink.uiDataSnapshot(sink, selectedPane);
|
||||
}
|
||||
private void uiDataSnapshot(@NotNull DataSink sink) {
|
||||
sink.set(PlatformDataKeys.CUT_PROVIDER, copyPasteDelegator.getCutProvider());
|
||||
sink.set(PlatformDataKeys.COPY_PROVIDER, copyPasteDelegator.getCopyProvider());
|
||||
sink.set(PlatformDataKeys.PASTE_PROVIDER, copyPasteDelegator.getPasteProvider());
|
||||
sink.set(LangDataKeys.IDE_VIEW, myIdeView);
|
||||
sink.set(PlatformCoreDataKeys.HELP_ID, HelpID.PROJECT_VIEWS);
|
||||
sink.set(QuickActionProvider.KEY, ProjectViewImpl.this);
|
||||
AbstractProjectViewPane selectedPane = getCurrentProjectViewPane();
|
||||
if (selectedPane != null) {
|
||||
DataSink.uiDataSnapshot(sink, selectedPane);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -541,8 +541,6 @@ public final class FileStructurePopup implements Disposable, TreeActionsOwner {
|
||||
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
|
||||
scrollPane.setBorder(IdeBorderFactory.createBorder(JBUI.CurrentTheme.Popup.toolbarBorderColor(), SideBorder.TOP | SideBorder.BOTTOM));
|
||||
panel.add(scrollPane, BorderLayout.CENTER);
|
||||
DataManager.registerDataProvider(panel, this::getData);
|
||||
|
||||
panel.addFocusListener(new FocusAdapter() {
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
@@ -550,59 +548,35 @@ public final class FileStructurePopup implements Disposable, TreeActionsOwner {
|
||||
}
|
||||
});
|
||||
|
||||
return panel;
|
||||
return UiDataProvider.wrapComponent(panel, sink -> uiDataSnapshot(sink));
|
||||
}
|
||||
|
||||
private @Nullable Object getData(@NotNull String dataId) {
|
||||
if (CommonDataKeys.PROJECT.is(dataId)) {
|
||||
return myProject;
|
||||
private void uiDataSnapshot(@NotNull DataSink sink) {
|
||||
sink.set(CommonDataKeys.PROJECT, myProject);
|
||||
sink.set(PlatformCoreDataKeys.FILE_EDITOR, myFileEditor);
|
||||
if (myFileEditor instanceof TextEditor o) {
|
||||
sink.set(OpenFileDescriptor.NAVIGATE_IN_EDITOR, o.getEditor());
|
||||
}
|
||||
if (PlatformCoreDataKeys.FILE_EDITOR.is(dataId)) {
|
||||
return myFileEditor;
|
||||
}
|
||||
if (OpenFileDescriptor.NAVIGATE_IN_EDITOR.is(dataId)) {
|
||||
if (myFileEditor instanceof TextEditor) {
|
||||
return ((TextEditor)myFileEditor).getEditor();
|
||||
}
|
||||
}
|
||||
if (PlatformCoreDataKeys.BGT_DATA_PROVIDER.is(dataId)) {
|
||||
TreePath[] selection = myTree.getSelectionPaths();
|
||||
return (DataProvider)slowId -> getSlowData(slowId, selection);
|
||||
}
|
||||
if (LangDataKeys.POSITION_ADJUSTER_POPUP.is(dataId)) {
|
||||
return myPopup;
|
||||
}
|
||||
if (PlatformDataKeys.COPY_PROVIDER.is(dataId)) {
|
||||
return myCopyPasteDelegator.getCopyProvider();
|
||||
}
|
||||
if (PlatformDataKeys.TREE_EXPANDER.is(dataId)) {
|
||||
return myTreeExpander;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
sink.set(LangDataKeys.POSITION_ADJUSTER_POPUP, myPopup);
|
||||
sink.set(PlatformDataKeys.COPY_PROVIDER, myCopyPasteDelegator.getCopyProvider());
|
||||
sink.set(PlatformDataKeys.TREE_EXPANDER, myTreeExpander);
|
||||
|
||||
private static @Nullable Object getSlowData(@NotNull String dataId, TreePath @Nullable [] selection) {
|
||||
TreePath[] selection = myTree.getSelectionPaths();
|
||||
JBIterable<Object> selectedElements = JBIterable.of(selection)
|
||||
.filterMap(o -> StructureViewComponent.unwrapValue(o.getLastPathComponent()));
|
||||
if (CommonDataKeys.PSI_ELEMENT.is(dataId)) {
|
||||
sink.lazy(CommonDataKeys.PSI_ELEMENT, () -> {
|
||||
return selectedElements.filter(PsiElement.class).first();
|
||||
}
|
||||
if (PlatformCoreDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
|
||||
});
|
||||
sink.lazy(PlatformCoreDataKeys.PSI_ELEMENT_ARRAY, () -> {
|
||||
return PsiUtilCore.toPsiElementArray(selectedElements.filter(PsiElement.class).toList());
|
||||
}
|
||||
if (CommonDataKeys.NAVIGATABLE.is(dataId)) {
|
||||
});
|
||||
sink.lazy(CommonDataKeys.NAVIGATABLE, () -> {
|
||||
return selectedElements.filter(Navigatable.class).first();
|
||||
}
|
||||
if (CommonDataKeys.NAVIGATABLE_ARRAY.is(dataId)) {
|
||||
});
|
||||
sink.lazy(CommonDataKeys.NAVIGATABLE_ARRAY, () -> {
|
||||
List<Navigatable> result = selectedElements.filter(Navigatable.class).toList();
|
||||
return result.isEmpty() ? null : result.toArray(Navigatable.EMPTY_NAVIGATABLE_ARRAY);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private @NotNull JBIterable<Object> getSelectedElements() {
|
||||
return JBIterable.of(myTree.getSelectionPaths())
|
||||
.filterMap(o -> StructureViewComponent.unwrapValue(o.getLastPathComponent()));
|
||||
});
|
||||
}
|
||||
|
||||
private @NotNull JComponent createSettingsButton() {
|
||||
|
||||
@@ -3,14 +3,10 @@ package com.intellij.internal;
|
||||
|
||||
import com.intellij.codeInsight.hint.ImplementationViewComponent;
|
||||
import com.intellij.codeInsight.hint.PsiImplementationViewElement;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.ui.search.SearchUtil;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.ide.util.PropertyName;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.CustomShortcutSet;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
@@ -104,28 +100,7 @@ public final class ImageDuplicateResultsDialog extends DialogWrapper {
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
DataManager.registerDataProvider(panel, dataId -> {
|
||||
final TreePath path = myTree.getSelectionPath();
|
||||
if (path != null) {
|
||||
Object component = path.getLastPathComponent();
|
||||
VirtualFile file = null;
|
||||
if (component instanceof MyFileNode) {
|
||||
component = ((MyFileNode)component).getParent();
|
||||
}
|
||||
if (component instanceof MyDuplicatesNode) {
|
||||
file = ((MyDuplicatesNode)component).getUserObject().iterator().next();
|
||||
}
|
||||
if (CommonDataKeys.VIRTUAL_FILE.is(dataId)) {
|
||||
return file;
|
||||
}
|
||||
if (CommonDataKeys.VIRTUAL_FILE_ARRAY.is(dataId) && file != null) {
|
||||
return new VirtualFile[]{file};
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
JBList<String> list = new JBList<>(new ResourceModules().getModuleNames());
|
||||
final NotNullFunction<Object, JComponent> modulesRenderer =
|
||||
dom -> new JLabel(dom instanceof Module ? ((Module)dom).getName() : dom.toString(), PlatformIcons.SOURCE_FOLDERS_ICON, SwingConstants.LEFT);
|
||||
@@ -221,7 +196,16 @@ public final class ImageDuplicateResultsDialog extends DialogWrapper {
|
||||
final JLabel label = new JLabel(
|
||||
"<html>Press <b>Enter</b> to preview image<br>Total images found: " + myImages.size() + ". Total duplicates found: " + total+"</html>");
|
||||
panel.add(label, BorderLayout.SOUTH);
|
||||
return panel;
|
||||
return UiDataProvider.wrapComponent(panel, sink -> uiDataSnapshot(sink));
|
||||
}
|
||||
|
||||
private void uiDataSnapshot(@NotNull DataSink sink) {
|
||||
TreePath path = myTree.getSelectionPath();
|
||||
Object component = path == null ? null : path.getLastPathComponent();
|
||||
if (component instanceof MyFileNode o) component = o.getParent();
|
||||
VirtualFile file = component instanceof MyDuplicatesNode o ? o.getUserObject().iterator().next() : null;
|
||||
sink.set(CommonDataKeys.VIRTUAL_FILE, file);
|
||||
sink.set(CommonDataKeys.VIRTUAL_FILE_ARRAY, file == null ? null : new VirtualFile[]{file});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.intellij.codeInsight.documentation.DocumentationManager.NEW_JAVADOC_L
|
||||
import com.intellij.codeInsight.documentation.ToggleShowDocsOnHoverAction
|
||||
import com.intellij.codeInsight.hint.HintManagerImpl.ActionToIgnore
|
||||
import com.intellij.codeInsight.hint.LineTooltipRenderer
|
||||
import com.intellij.ide.DataManager
|
||||
import com.intellij.lang.documentation.ide.actions.*
|
||||
import com.intellij.lang.documentation.ide.impl.DocumentationBrowser
|
||||
import com.intellij.lang.documentation.ide.impl.DocumentationToolWindowManager
|
||||
@@ -96,16 +95,18 @@ internal class DocumentationPopupUI(
|
||||
ui.trackDocumentationBackgroundChange(this) {
|
||||
corner.background = it
|
||||
}
|
||||
component = DocumentationPopupPane(ui.scrollPane).also { pane ->
|
||||
pane.add(scrollPaneWithCorner(this, ui.scrollPane, corner), BorderLayout.CENTER)
|
||||
pane.add(ui.switcherToolbarComponent, BorderLayout.NORTH)
|
||||
updatePaddings(corner)
|
||||
corner.addComponentListener(object : ComponentAdapter() {
|
||||
override fun componentResized(e: ComponentEvent?) {
|
||||
updatePaddings(corner)
|
||||
popupUpdateFlow.tryEmit(PopupUpdateEvent.ToolbarSizeChanged)
|
||||
}
|
||||
})
|
||||
val pane = DocumentationPopupPane(ui.scrollPane)
|
||||
pane.add(scrollPaneWithCorner(this, ui.scrollPane, corner), BorderLayout.CENTER)
|
||||
pane.add(ui.switcherToolbarComponent, BorderLayout.NORTH)
|
||||
updatePaddings(corner)
|
||||
corner.addComponentListener(object : ComponentAdapter() {
|
||||
override fun componentResized(e: ComponentEvent?) {
|
||||
updatePaddings(corner)
|
||||
popupUpdateFlow.tryEmit(PopupUpdateEvent.ToolbarSizeChanged)
|
||||
}
|
||||
})
|
||||
component = UiDataProvider.wrapComponent(pane) { sink ->
|
||||
sink[DOCUMENTATION_POPUP] = myPopup
|
||||
}
|
||||
|
||||
openInToolwindowAction.registerCustomShortcutSet(component, this)
|
||||
@@ -134,18 +135,7 @@ internal class DocumentationPopupUI(
|
||||
fun setPopup(popup: AbstractPopup) {
|
||||
Disposer.register(popup, this)
|
||||
myPopup = popup
|
||||
|
||||
DataManager.registerDataProvider(component) { dataId ->
|
||||
if (DOCUMENTATION_POPUP.`is`(dataId)) {
|
||||
popup
|
||||
}
|
||||
else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
val editorPane = ui.editorPane
|
||||
editorPane.setHint(popup)
|
||||
ui.editorPane.setHint(popup)
|
||||
}
|
||||
|
||||
fun updatePopup(updater: suspend (PopupUpdateEvent) -> Unit) {
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ContentEntryTreeEditor {
|
||||
private final List<ModuleSourceRootEditHandler<?>> myEditHandlers;
|
||||
protected final Tree myTree;
|
||||
private FileSystemTreeImpl myFileSystemTree;
|
||||
private final JPanel myTreePanel;
|
||||
private final JComponent myComponent;
|
||||
protected final DefaultActionGroup myEditingActionsGroup;
|
||||
private ContentEntryEditor myContentEntryEditor;
|
||||
private final MyContentEntryEditorListener myContentEntryEditorListener = new MyContentEntryEditorListener();
|
||||
@@ -99,12 +99,14 @@ public class ContentEntryTreeEditor {
|
||||
new JBLabel(XmlStringUtil.wrapInHtml(ProjectBundle.message("label.content.entry.separate.name.patterns")));
|
||||
excludePatternsLegendLabel.setForeground(JBColor.GRAY);
|
||||
excludePatternsPanel.add(excludePatternsLegendLabel, gridBag.nextLine().next().next().fillCellHorizontally());
|
||||
myTreePanel = new MyPanel(new BorderLayout());
|
||||
final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree, true);
|
||||
myTreePanel.add(scrollPane, BorderLayout.CENTER);
|
||||
myTreePanel.add(excludePatternsPanel, BorderLayout.SOUTH);
|
||||
|
||||
myTreePanel.setVisible(false);
|
||||
JPanel treePanel = new JPanel(new BorderLayout());
|
||||
treePanel.add(ScrollPaneFactory.createScrollPane(myTree, true), BorderLayout.CENTER);
|
||||
treePanel.add(excludePatternsPanel, BorderLayout.SOUTH);
|
||||
myComponent = UiDataProvider.wrapComponent(treePanel, sink -> {
|
||||
sink.set(FileSystemTree.DATA_KEY, myFileSystemTree);
|
||||
sink.set(CommonDataKeys.VIRTUAL_FILE_ARRAY, myFileSystemTree == null ? null : myFileSystemTree.getSelectedFiles());
|
||||
});
|
||||
myComponent.setVisible(false);
|
||||
myDescriptor = FileChooserDescriptorFactory.createMultipleFoldersDescriptor();
|
||||
myDescriptor.setShowFileSystemRoots(false);
|
||||
}
|
||||
@@ -146,13 +148,13 @@ public class ContentEntryTreeEditor {
|
||||
myContentEntryEditor = null;
|
||||
}
|
||||
if (contentEntryEditor == null) {
|
||||
myTreePanel.setVisible(false);
|
||||
myComponent.setVisible(false);
|
||||
if (myFileSystemTree != null) {
|
||||
Disposer.dispose(myFileSystemTree);
|
||||
}
|
||||
return;
|
||||
}
|
||||
myTreePanel.setVisible(true);
|
||||
myComponent.setVisible(true);
|
||||
myContentEntryEditor = contentEntryEditor;
|
||||
myContentEntryEditor.addContentEntryEditorListener(myContentEntryEditorListener);
|
||||
|
||||
@@ -196,7 +198,7 @@ public class ContentEntryTreeEditor {
|
||||
|
||||
public JComponent createComponent() {
|
||||
createEditingActions();
|
||||
return myTreePanel;
|
||||
return myComponent;
|
||||
}
|
||||
|
||||
public void select(VirtualFile file) {
|
||||
@@ -260,18 +262,6 @@ public class ContentEntryTreeEditor {
|
||||
}
|
||||
}
|
||||
|
||||
private final class MyPanel extends JPanel implements UiDataProvider {
|
||||
private MyPanel(final LayoutManager layout) {
|
||||
super(layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uiDataSnapshot(@NotNull DataSink sink) {
|
||||
sink.set(FileSystemTree.DATA_KEY, myFileSystemTree);
|
||||
sink.set(CommonDataKeys.VIRTUAL_FILE_ARRAY, myFileSystemTree == null ? null : myFileSystemTree.getSelectedFiles());
|
||||
}
|
||||
}
|
||||
|
||||
public DefaultActionGroup getEditingActionsGroup() {
|
||||
return myEditingActionsGroup;
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ import com.intellij.history.integration.LocalHistoryBundle;
|
||||
import com.intellij.history.integration.ui.models.HistoryDialogModel;
|
||||
import com.intellij.history.integration.ui.models.RevisionItem;
|
||||
import com.intellij.ide.CopyProvider;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.UiDataProvider;
|
||||
import com.intellij.openapi.ide.CopyPasteManager;
|
||||
import com.intellij.openapi.util.NlsContexts;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -43,6 +43,7 @@ import java.util.*;
|
||||
public final class RevisionsList {
|
||||
public static final int RECENT_PERIOD = 12;
|
||||
private final JBTable table;
|
||||
private final JComponent component;
|
||||
private volatile Set<Long> filteredRevisions;
|
||||
|
||||
public RevisionsList(SelectionListener l) {
|
||||
@@ -63,16 +64,13 @@ public final class RevisionsList {
|
||||
addSelectionListener(l);
|
||||
|
||||
CopyProvider copyProvider = new MyCellRenderer.MyCopyProvider(table);
|
||||
DataManager.registerDataProvider(table, dataId -> {
|
||||
if (PlatformDataKeys.COPY_PROVIDER.is(dataId)) {
|
||||
return copyProvider;
|
||||
}
|
||||
return null;
|
||||
component = UiDataProvider.wrapComponent(table, sink -> {
|
||||
sink.set(PlatformDataKeys.COPY_PROVIDER, copyProvider);
|
||||
});
|
||||
}
|
||||
|
||||
public JComponent getComponent() {
|
||||
return table;
|
||||
public @NotNull JComponent getComponent() {
|
||||
return component;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
|
||||
@@ -121,31 +121,20 @@ public final class LightEditModeNotificationWidget implements CustomStatusBarWid
|
||||
|
||||
private void showPopupMenu(@NotNull JComponent actionLink) {
|
||||
if (!myPopupState.isRecentlyHidden()) {
|
||||
addDataProvider(actionLink, dataId -> {
|
||||
if (CommonDataKeys.VIRTUAL_FILE.is(dataId)) {
|
||||
return LightEditService.getInstance().getSelectedFile();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.STATUS_BAR_PLACE,
|
||||
createAccessFullIdeActionGroup());
|
||||
popupMenu.setTargetComponent(actionLink);
|
||||
DataContext dataContext = CustomizedDataContext.withSnapshot(
|
||||
DataManager.getInstance().getDataContext(actionLink), sink -> {
|
||||
sink.set(CommonDataKeys.VIRTUAL_FILE,
|
||||
LightEditService.getInstance().getSelectedFile());
|
||||
});
|
||||
ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(
|
||||
ActionPlaces.STATUS_BAR_PLACE, createAccessFullIdeActionGroup());
|
||||
popupMenu.setDataContext(() -> dataContext);
|
||||
JPopupMenu menu = popupMenu.getComponent();
|
||||
myPopupState.prepareToShow(menu);
|
||||
JBPopupMenu.showAbove(actionLink, menu);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addDataProvider(@NotNull JComponent component, @NotNull DataProvider dataProvider) {
|
||||
DataProvider prev = DataManager.getDataProvider(component);
|
||||
DataProvider result = dataProvider;
|
||||
if (prev != null) {
|
||||
DataManager.removeDataProvider(component);
|
||||
result = CompositeDataProvider.compose(prev, dataProvider);
|
||||
}
|
||||
DataManager.registerDataProvider(component, result);
|
||||
}
|
||||
|
||||
private static @NotNull ActionGroup createAccessFullIdeActionGroup() {
|
||||
ActionManager actionManager = ActionManager.getInstance();
|
||||
return new DefaultActionGroup(
|
||||
|
||||
@@ -33,13 +33,16 @@ class XSplitterWatchesViewImpl(
|
||||
private fun tryGetBottomComponentProvider(session: XDebugSessionImpl) = session.debugProcess.getBottomLocalsComponentProvider()
|
||||
}
|
||||
|
||||
lateinit var splitter: OnePixelSplitter
|
||||
private set
|
||||
|
||||
override fun createMainPanel(localsPanelComponent: JComponent): JPanel {
|
||||
val session = mySession.get() ?: error("Not null session is expected here")
|
||||
val bottomLocalsComponentProvider = tryGetBottomComponentProvider(session)
|
||||
?: error("BottomLocalsComponentProvider is not implemented to use SplitterWatchesVariablesView")
|
||||
|
||||
val evaluatorComponent = bottomLocalsComponentProvider.createBottomLocalsComponent()
|
||||
val splitter = OnePixelSplitter(true, proportionKey, 0.01f, 0.99f)
|
||||
splitter = OnePixelSplitter(true, proportionKey, 0.01f, 0.99f)
|
||||
|
||||
splitter.firstComponent = localsPanelComponent
|
||||
splitter.secondComponent = evaluatorComponent
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.xdebugger.impl.frame;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
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.util.Key;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
@@ -18,7 +18,6 @@ import com.intellij.xdebugger.impl.inline.InlineDebugRenderer;
|
||||
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueContainerNode;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -28,15 +27,14 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class XVariablesView extends XVariablesViewBase implements DataProvider {
|
||||
protected final JPanel myComponent;
|
||||
public class XVariablesView extends XVariablesViewBase {
|
||||
protected final JComponent myComponent;
|
||||
protected final WeakReference<XDebugSessionImpl> mySession;
|
||||
|
||||
public XVariablesView(@NotNull XDebugSessionImpl session) {
|
||||
super(session.getProject(), session.getDebugProcess().getEditorsProvider(), session.getValueMarkers());
|
||||
mySession = new WeakReference<>(session);
|
||||
myComponent = createMainPanel(super.getPanel());
|
||||
DataManager.registerDataProvider(myComponent, this);
|
||||
myComponent = UiDataProvider.wrapComponent(createMainPanel(super.getPanel()), sink -> uiDataSnapshot(sink));
|
||||
}
|
||||
|
||||
protected JPanel createMainPanel(JComponent localsPanel) {
|
||||
@@ -44,7 +42,7 @@ public class XVariablesView extends XVariablesViewBase implements DataProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel getPanel() {
|
||||
public JComponent getPanel() {
|
||||
return myComponent;
|
||||
}
|
||||
|
||||
@@ -116,19 +114,12 @@ public class XVariablesView extends XVariablesViewBase implements DataProvider {
|
||||
super.clear();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getData(@NotNull @NonNls String dataId) {
|
||||
if (CommonDataKeys.VIRTUAL_FILE.is(dataId)) {
|
||||
XDebugSessionImpl session = mySession.get();
|
||||
if (session != null) {
|
||||
XSourcePosition position = session.getCurrentPosition();
|
||||
if (position != null) {
|
||||
return position.getFile();
|
||||
}
|
||||
}
|
||||
protected void uiDataSnapshot(@NotNull DataSink sink) {
|
||||
XDebugSessionImpl session = mySession.get();
|
||||
XSourcePosition position = session == null ? null : session.getCurrentPosition();
|
||||
if (position != null) {
|
||||
sink.lazy(CommonDataKeys.VIRTUAL_FILE, () -> position.getFile());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class InlineVariablesInfo {
|
||||
|
||||
@@ -58,7 +58,6 @@ import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
|
||||
import com.intellij.xdebugger.impl.ui.tree.actions.XWatchTransferable;
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.*;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -527,13 +526,10 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget,
|
||||
return expressions;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getData(@NotNull @NonNls String dataId) {
|
||||
if (XWatchesView.DATA_KEY.is(dataId)) {
|
||||
return this;
|
||||
}
|
||||
return super.getData(dataId);
|
||||
protected void uiDataSnapshot(@NotNull DataSink sink) {
|
||||
super.uiDataSnapshot(sink);
|
||||
sink.set(XWatchesView.DATA_KEY, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -79,7 +79,7 @@ public class XToggleEvaluateExpressionFieldAction extends DumbAwareToggleAction
|
||||
private static void findAllFieldsAndUpdateState(DataContext context, boolean state) {
|
||||
XWatchesView view = context.getData(XWatchesView.DATA_KEY);
|
||||
if (view instanceof XWatchesViewImpl) {
|
||||
JPanel panel = ((XWatchesViewImpl)view).getPanel();
|
||||
JComponent panel = ((XWatchesViewImpl)view).getPanel();
|
||||
UIUtil.uiTraverser(panel)
|
||||
.filter(c -> c instanceof JComponent && ClientProperty.get(c, EVALUATE_EXPRESSION_FIELD) != null)
|
||||
.forEach(c -> c.setVisible(state));
|
||||
|
||||
Reference in New Issue
Block a user