mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ui: remove SwitchManager API - QuickActionProvider
* SimpleToolWindowPanel.setProvideQuickActions - used in multiple plugins * ProjectViewImpl.getActions(boolean) - used in 'Autoscroll Save' plugin * QuickActionProvider.KEY - used in 'Armory' plugin
This commit is contained in:
@@ -15,19 +15,19 @@
|
||||
*/
|
||||
package com.intellij.openapi.actionSystem;
|
||||
|
||||
import com.intellij.ui.switcher.QuickActionProvider;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a toolbar with a visual presentation.
|
||||
*
|
||||
* @see ActionManager#createActionToolbar(String, ActionGroup, boolean)
|
||||
*/
|
||||
public interface ActionToolbar extends QuickActionProvider {
|
||||
public interface ActionToolbar {
|
||||
String ACTION_TOOLBAR_PROPERTY_KEY = "ACTION_TOOLBAR";
|
||||
|
||||
/**
|
||||
@@ -115,6 +115,9 @@ public interface ActionToolbar extends QuickActionProvider {
|
||||
|
||||
void setSecondaryActionsTooltip(String secondaryActionsTooltip);
|
||||
|
||||
@NotNull
|
||||
List<AnAction> getActions();
|
||||
|
||||
void setMiniMode(boolean minimalMode);
|
||||
|
||||
DataContext getToolbarDataContext();
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.actionSystem.DataKey;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Deprecated
|
||||
public interface QuickActionProvider {
|
||||
|
||||
DataKey<QuickActionProvider> KEY = DataKey.create("QuickActionProvider");
|
||||
|
||||
@@ -47,13 +47,11 @@ import com.intellij.ui.docking.DockManager;
|
||||
import com.intellij.ui.docking.DockableContent;
|
||||
import com.intellij.ui.docking.DragSession;
|
||||
import com.intellij.ui.docking.impl.DockManagerImpl;
|
||||
import com.intellij.ui.switcher.QuickActionProvider;
|
||||
import com.intellij.ui.tabs.JBTabs;
|
||||
import com.intellij.ui.tabs.TabInfo;
|
||||
import com.intellij.ui.tabs.TabsListener;
|
||||
import com.intellij.ui.tabs.impl.JBTabsImpl;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.AbstractLayoutManager;
|
||||
import com.intellij.util.ui.GraphicsUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
@@ -77,7 +75,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Facade, ViewContextEx, PropertyChangeListener,
|
||||
QuickActionProvider, DockContainer.Dialog {
|
||||
DockContainer.Dialog {
|
||||
public static final DataKey<RunnerContentUi> KEY = DataKey.create("DebuggerContentUI");
|
||||
public static final Key<Boolean> LIGHTWEIGHT_CONTENT_MARKER = Key.create("LightweightContent");
|
||||
|
||||
@@ -1353,7 +1351,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
|
||||
}
|
||||
}
|
||||
|
||||
private class MyComponent extends NonOpaquePanel implements DataProvider, QuickActionProvider {
|
||||
private class MyComponent extends NonOpaquePanel implements DataProvider {
|
||||
private boolean myWasEverAdded;
|
||||
|
||||
public MyComponent(LayoutManager layout) {
|
||||
@@ -1366,10 +1364,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getData(@NonNls final String dataId) {
|
||||
if (KEY.is(dataId)) {
|
||||
return RunnerContentUi.this;
|
||||
}
|
||||
else if (CloseAction.CloseTarget.KEY.is(dataId)) {
|
||||
if (CloseAction.CloseTarget.KEY.is(dataId)) {
|
||||
Content content = getContentManager().getSelectedContent();
|
||||
if (content != null && content.getManager().canCloseContents() && content.isCloseable()) {
|
||||
return new CloseAction.CloseTarget() {
|
||||
@@ -1389,17 +1384,6 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Override
|
||||
public String getName() {
|
||||
return RunnerContentUi.this.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AnAction> getActions(boolean originalProvider) {
|
||||
return RunnerContentUi.this.getActions(originalProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNotify() {
|
||||
super.addNotify();
|
||||
@@ -1687,21 +1671,6 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
|
||||
return myRunnerUi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return mySessionName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AnAction> getActions(boolean originalProvider) {
|
||||
ArrayList<AnAction> result = new ArrayList<>();
|
||||
if (myLeftToolbarActions != null) {
|
||||
AnAction[] kids = myLeftToolbarActions.getChildren(null);
|
||||
ContainerUtil.addAll(result, kids);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private int findFreeWindow() {
|
||||
int i;
|
||||
for (i = 1; i < Integer.MAX_VALUE; i++) {
|
||||
|
||||
+1
-2
@@ -36,7 +36,6 @@ import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.content.ContentFactory;
|
||||
import com.intellij.ui.content.ContentManager;
|
||||
import com.intellij.ui.content.ContentManagerListener;
|
||||
import com.intellij.ui.switcher.QuickActionProvider;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -377,7 +376,7 @@ public class RunnerLayoutUiImpl implements Disposable.Parent, RunnerLayoutUi, La
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
if (QuickActionProvider.KEY.is(dataId) || RunnerContentUi.KEY.is(dataId)) {
|
||||
if (RunnerContentUi.KEY.is(dataId)) {
|
||||
return myContentUI;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -556,7 +556,7 @@ public class SearchReplaceComponent extends EditorHeaderComponent implements Dat
|
||||
}
|
||||
|
||||
private void updateBindings(@NotNull ActionToolbarImpl toolbar, @NotNull JComponent shortcutHolder) {
|
||||
updateBindings(toolbar.getActions(true), shortcutHolder);
|
||||
updateBindings(toolbar.getActions(), shortcutHolder);
|
||||
}
|
||||
|
||||
private void updateBindings(@NotNull List<? extends AnAction> actions, @NotNull JComponent shortcutHolder) {
|
||||
|
||||
@@ -82,7 +82,6 @@ import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.content.ContentManager;
|
||||
import com.intellij.ui.content.ContentManagerAdapter;
|
||||
import com.intellij.ui.content.ContentManagerEvent;
|
||||
import com.intellij.ui.switcher.QuickActionProvider;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IJSwingUtilities;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
@@ -107,7 +106,7 @@ import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
@State(name = "ProjectView", storages = @Storage(StoragePathMacros.WORKSPACE_FILE))
|
||||
public class ProjectViewImpl extends ProjectView implements PersistentStateComponent<Element>, Disposable, QuickActionProvider, BusyObject {
|
||||
public class ProjectViewImpl extends ProjectView implements PersistentStateComponent<Element>, Disposable, BusyObject {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.projectView.impl.ProjectViewImpl");
|
||||
private static final Key<String> ID_KEY = Key.create("pane-id");
|
||||
private static final Key<String> SUB_ID_KEY = Key.create("pane-sub-id");
|
||||
@@ -255,87 +254,14 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
|
||||
private void constructUi() {
|
||||
myViewContentPanel = new JPanel();
|
||||
myPanel = new SimpleToolWindowPanel(true).setProvideQuickActions(false);
|
||||
myPanel = new SimpleToolWindowPanel(true);
|
||||
myPanel.setContent(myViewContentPanel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Project";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public List<AnAction> getActions(boolean originalProvider) {
|
||||
ArrayList<AnAction> result = new ArrayList<>();
|
||||
|
||||
DefaultActionGroup views = new DefaultActionGroup("Change View", true);
|
||||
boolean lastHeaderHadKids = false;
|
||||
for (int i = 0; i < myContentManager.getContentCount(); i++) {
|
||||
Content each = myContentManager.getContent(i);
|
||||
if (each != null) {
|
||||
if (each.getUserData(SUB_ID_KEY) == null) {
|
||||
if (lastHeaderHadKids) {
|
||||
views.add(new Separator());
|
||||
} else {
|
||||
if (i + 1 < myContentManager.getContentCount()) {
|
||||
Content next = myContentManager.getContent(i + 1);
|
||||
if (next != null) {
|
||||
if (next.getUserData(SUB_ID_KEY) != null) {
|
||||
views.add(new Separator());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
lastHeaderHadKids = true;
|
||||
}
|
||||
|
||||
views.add(new ChangeViewAction(each.getUserData(ID_KEY), each.getUserData(SUB_ID_KEY)));
|
||||
}
|
||||
}
|
||||
result.add(views);
|
||||
result.add(new Separator());
|
||||
|
||||
|
||||
List<AnAction> secondary = new ArrayList<>();
|
||||
if (myActionGroup != null) {
|
||||
AnAction[] kids = myActionGroup.getChildren(null);
|
||||
for (AnAction each : kids) {
|
||||
if (myActionGroup.isPrimary(each)) {
|
||||
result.add(each);
|
||||
}
|
||||
else {
|
||||
secondary.add(each);
|
||||
}
|
||||
}
|
||||
}
|
||||
result.add(new Separator());
|
||||
result.addAll(secondary);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private class ChangeViewAction extends AnAction {
|
||||
private final String myId;
|
||||
private final String mySubId;
|
||||
|
||||
private ChangeViewAction(@NotNull String id, String subId) {
|
||||
myId = id;
|
||||
mySubId = subId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
AbstractProjectViewPane pane = getProjectViewPaneById(myId);
|
||||
e.getPresentation().setText(pane.getTitle() + (mySubId != null ? (" - " + pane.getPresentableSubIdName(mySubId)) : ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
changeView(myId, mySubId);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1090,10 +1016,6 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
return selectedElements.isEmpty() ? null : selectedElements.toArray(new NamedLibraryElement[selectedElements.size()]);
|
||||
}
|
||||
|
||||
if (QuickActionProvider.KEY.is(dataId)) {
|
||||
return ProjectViewImpl.this;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.intellij.openapi.ui;
|
||||
import com.intellij.openapi.actionSystem.ActionToolbar;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.ui.switcher.QuickActionProvider;
|
||||
import com.intellij.util.containers.JBIterable;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -30,14 +29,13 @@ import java.awt.event.ContainerAdapter;
|
||||
import java.awt.event.ContainerEvent;
|
||||
import java.util.List;
|
||||
|
||||
public class SimpleToolWindowPanel extends JPanel implements QuickActionProvider, DataProvider {
|
||||
public class SimpleToolWindowPanel extends JPanel implements DataProvider {
|
||||
|
||||
private JComponent myToolbar;
|
||||
private JComponent myContent;
|
||||
|
||||
private boolean myBorderless;
|
||||
protected boolean myVertical;
|
||||
private boolean myProvideQuickActions;
|
||||
|
||||
public SimpleToolWindowPanel(boolean vertical) {
|
||||
this(vertical, false);
|
||||
@@ -47,7 +45,6 @@ public class SimpleToolWindowPanel extends JPanel implements QuickActionProvider
|
||||
setLayout(new BorderLayout(vertical ? 0 : 1, vertical ? 1 : 0));
|
||||
myBorderless = borderless;
|
||||
myVertical = vertical;
|
||||
setProvideQuickActions(true);
|
||||
|
||||
addContainerListener(new ContainerAdapter() {
|
||||
@Override
|
||||
@@ -97,19 +94,19 @@ public class SimpleToolWindowPanel extends JPanel implements QuickActionProvider
|
||||
|
||||
@Nullable
|
||||
public Object getData(@NonNls String dataId) {
|
||||
return QuickActionProvider.KEY.is(dataId) && myProvideQuickActions ? this : null;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public SimpleToolWindowPanel setProvideQuickActions(boolean provide) {
|
||||
myProvideQuickActions = provide;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<AnAction> getActions(boolean originalProvider) {
|
||||
public List<AnAction> getActions() {
|
||||
JBIterable<ActionToolbar> toolbars = UIUtil.uiTraverser(myToolbar).traverse().filter(ActionToolbar.class);
|
||||
if (toolbars.size() == 0)
|
||||
return null;
|
||||
return toolbars.flatten(toolbar -> toolbar.getActions(originalProvider)).toList();
|
||||
return toolbars.flatten(toolbar -> toolbar.getActions()).toList();
|
||||
}
|
||||
|
||||
public JComponent getComponent() {
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.*;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.switcher.QuickActionProvider;
|
||||
import com.intellij.ui.tabs.*;
|
||||
import com.intellij.ui.tabs.impl.singleRow.ScrollableSingleRowLayout;
|
||||
import com.intellij.ui.tabs.impl.singleRow.SingleRowLayout;
|
||||
@@ -61,7 +60,7 @@ import java.util.List;
|
||||
|
||||
public class JBTabsImpl extends JComponent
|
||||
implements JBTabs, PropertyChangeListener, TimerListener, DataProvider, PopupMenuListener, Disposable, JBTabsPresentation, Queryable,
|
||||
UISettingsListener, QuickActionProvider, Accessible {
|
||||
UISettingsListener, Accessible {
|
||||
|
||||
public static final DataKey<JBTabsImpl> NAVIGATION_ACTIONS_KEY = DataKey.create("JBTabs");
|
||||
@NonNls public static final Key<Integer> SIDE_TABS_SIZE_LIMIT_KEY = Key.create("SIDE_TABS_SIZE_LIMIT_KEY");
|
||||
@@ -3117,29 +3116,9 @@ public class JBTabsImpl extends JComponent
|
||||
if (value != null) return value;
|
||||
}
|
||||
|
||||
if (QuickActionProvider.KEY.getName().equals(dataId)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
return NAVIGATION_ACTIONS_KEY.is(dataId) ? this : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AnAction> getActions(boolean originalProvider) {
|
||||
ArrayList<AnAction> result = new ArrayList<>();
|
||||
|
||||
TabInfo selection = getSelectedInfo();
|
||||
if (selection != null) {
|
||||
ActionGroup group = selection.getGroup();
|
||||
if (group != null) {
|
||||
AnAction[] children = group.getChildren(null);
|
||||
Collections.addAll(result, children);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataProvider getDataProvider() {
|
||||
return myDataProvider;
|
||||
|
||||
@@ -145,7 +145,7 @@ public class ToggleToolbarAction extends ToggleAction implements DumbAware {
|
||||
result.add(Separator.getInstance());
|
||||
}
|
||||
|
||||
List<AnAction> actions = toolbar.getActions(false);
|
||||
List<AnAction> actions = toolbar.getActions();
|
||||
for (AnAction action : actions) {
|
||||
if (action instanceof ToggleAction && !result.contains(action)) {
|
||||
result.add(action);
|
||||
|
||||
+2
-1
@@ -1227,8 +1227,9 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
mySecondaryActions.getTemplatePresentation().setDescription(secondaryActionsTooltip);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<AnAction> getActions(boolean originalProvider) {
|
||||
public List<AnAction> getActions() {
|
||||
ArrayList<AnAction> result = new ArrayList<>();
|
||||
|
||||
ArrayList<AnAction> secondary = new ArrayList<>();
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@ public class StudyProjectComponent implements ProjectComponent {
|
||||
private void registerShortcuts() {
|
||||
StudyToolWindow window = StudyUtils.getStudyToolWindow(myProject);
|
||||
if (window != null) {
|
||||
List<AnAction> actionsOnToolbar = window.getActions(true);
|
||||
List<AnAction> actionsOnToolbar = window.getActions();
|
||||
if (actionsOnToolbar != null) {
|
||||
for (AnAction action : actionsOnToolbar) {
|
||||
if (action instanceof StudyActionWithShortcut) {
|
||||
|
||||
Reference in New Issue
Block a user