summaryrefslogtreecommitdiff
path: root/platform/platform-impl/src/com/intellij/openapi/actionSystem
diff options
context:
space:
mode:
Diffstat (limited to 'platform/platform-impl/src/com/intellij/openapi/actionSystem')
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/AbbreviationManagerImpl.java31
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java7
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java64
3 files changed, 55 insertions, 47 deletions
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/AbbreviationManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/AbbreviationManagerImpl.java
index a7b2e7bc9d02..0d116c7a927f 100644
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/AbbreviationManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/AbbreviationManagerImpl.java
@@ -38,40 +38,33 @@ import java.util.*;
)}
)
public class AbbreviationManagerImpl extends AbbreviationManager implements
- ExportableApplicationComponent, PersistentStateComponent<Element> {
+ ExportableComponent, PersistentStateComponent<Element> {
private final Map<String, List<String>> myAbbreviation2ActionId = new THashMap<String, List<String>>();
private final Map<String, LinkedHashSet<String>> myActionId2Abbreviations = new THashMap<String, LinkedHashSet<String>>();
private final Map<String, LinkedHashSet<String>> myPluginsActionId2Abbreviations = new THashMap<String, LinkedHashSet<String>>();
- @Override
- public void initComponent() {
-
- }
-
- @Override
- public void disposeComponent() {
-
- }
-
- @NotNull
- @Override
- public String getComponentName() {
- return "AbbreviationManager";
- }
-
@Nullable
@Override
public Element getState() {
final Element actions = new Element("actions");
- final Element abbreviations = new Element("abbreviations");
- actions.addContent(abbreviations);
+ if (myActionId2Abbreviations.isEmpty()) {
+ return actions;
+ }
+
+ Element abbreviations = null;
for (String key : myActionId2Abbreviations.keySet()) {
final LinkedHashSet<String> abbrs = myActionId2Abbreviations.get(key);
final LinkedHashSet<String> pluginAbbrs = myPluginsActionId2Abbreviations.get(key);
if (abbrs == pluginAbbrs || (abbrs != null && abbrs.equals(pluginAbbrs))) {
continue;
}
+
if (abbrs != null) {
+ if (abbreviations == null) {
+ abbreviations = new Element("abbreviations");
+ actions.addContent(abbreviations);
+ }
+
final Element action = new Element("action");
action.setAttribute("id", key);
abbreviations.addContent(action);
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java
index 78043075b166..723956ef9daa 100644
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java
@@ -49,6 +49,7 @@ import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.IdeFrame;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ObjectUtils;
+import com.intellij.util.ReflectionUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import com.intellij.util.messages.MessageBusConnection;
@@ -66,7 +67,6 @@ import javax.swing.*;
import javax.swing.Timer;
import java.awt.*;
import java.awt.event.*;
-import java.lang.reflect.Constructor;
import java.util.*;
import java.util.List;
@@ -259,9 +259,8 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
Object obj;
String className = stub.getClassName();
try {
- Constructor<?> constructor = Class.forName(className, true, stub.getLoader()).getDeclaredConstructor();
- constructor.setAccessible(true);
- obj = constructor.newInstance();
+ Class<?> aClass = Class.forName(className, true, stub.getLoader());
+ obj = ReflectionUtil.newInstance(aClass);
}
catch (ClassNotFoundException e) {
PluginId pluginId = stub.getPluginId();
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java
index a0b495726f30..529d5ba1c62f 100644
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -65,6 +65,8 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.actionSystem.impl.ActionToolbarImpl");
private static final List<ActionToolbarImpl> ourToolbars = new LinkedList<ActionToolbarImpl>();
+ private static final String RIGHT_ALIGN_KEY = "RIGHT_ALIGN";
+
public static void updateAllToolbarsImmediately() {
for (ActionToolbarImpl toolbar : new ArrayList<ActionToolbarImpl>(ourToolbars)) {
toolbar.updateActionsImmediately();
@@ -107,7 +109,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
private final ActionButtonLook myButtonLook = null;
private final ActionButtonLook myMinimalButtonLook = new InplaceActionButtonLook();
private final DataManager myDataManager;
- protected final ActionManagerEx myActionManager;
+ @NotNull protected final ActionManagerEx myActionManager;
private Rectangle myAutoPopupRec;
@@ -135,7 +137,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
@NotNull final ActionGroup actionGroup,
final boolean horizontal,
DataManager dataManager,
- ActionManagerEx actionManager,
+ @NotNull ActionManagerEx actionManager,
KeymapManagerEx keymapManager) {
this(place, actionGroup, horizontal, false, dataManager, actionManager, keymapManager, false);
}
@@ -144,7 +146,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
final boolean horizontal,
final boolean decorateButtons,
DataManager dataManager,
- ActionManagerEx actionManager,
+ @NotNull ActionManagerEx actionManager,
KeymapManagerEx keymapManager) {
this(place, actionGroup, horizontal, decorateButtons, dataManager, actionManager, keymapManager, false);
}
@@ -154,7 +156,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
final boolean horizontal,
final boolean decorateButtons,
DataManager dataManager,
- ActionManagerEx actionManager,
+ @NotNull ActionManagerEx actionManager,
KeymapManagerEx keymapManager,
boolean updateActionsNow) {
super(null);
@@ -272,11 +274,16 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
}
private void fillToolBar(final List<AnAction> actions, boolean layoutSecondaries) {
+ final List<AnAction> rightAligned = new ArrayList<AnAction>();
if (myAddSeparatorFirst) {
add(new MySeparator());
}
for (int i = 0; i < actions.size(); i++) {
final AnAction action = actions.get(i);
+ if (action instanceof RightAlignedToolbarAction) {
+ rightAligned.add(action);
+ continue;
+ }
// if (action instanceof Separator && isNavBar()) {
// continue;
// }
@@ -311,18 +318,23 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
add(mySecondaryActionsButton);
}
- if ((ActionPlaces.MAIN_TOOLBAR.equals(myPlace) || ActionPlaces.NAVIGATION_BAR_TOOLBAR.equals(myPlace))) {
- final AnAction searchEverywhereAction = ActionManager.getInstance().getAction("SearchEverywhere");
- if (searchEverywhereAction != null) {
- try {
- final CustomComponentAction searchEveryWhereAction = (CustomComponentAction)searchEverywhereAction;
- final JComponent searchEverywhere = searchEveryWhereAction.createCustomComponent(searchEverywhereAction.getTemplatePresentation());
- searchEverywhere.putClientProperty("SEARCH_EVERYWHERE", Boolean.TRUE);
- add(searchEverywhere);
- }
- catch (Exception ignore) {}
- }
- }
+ for (AnAction action : rightAligned) {
+ JComponent button = action instanceof CustomComponentAction ? getCustomComponent(action) : createToolbarButton(action);
+ button.putClientProperty(RIGHT_ALIGN_KEY, Boolean.TRUE);
+ add(button);
+ }
+ //if ((ActionPlaces.MAIN_TOOLBAR.equals(myPlace) || ActionPlaces.NAVIGATION_BAR_TOOLBAR.equals(myPlace))) {
+ // final AnAction searchEverywhereAction = ActionManager.getInstance().getAction("SearchEverywhere");
+ // if (searchEverywhereAction != null) {
+ // try {
+ // final CustomComponentAction searchEveryWhereAction = (CustomComponentAction)searchEverywhereAction;
+ // final JComponent searchEverywhere = searchEveryWhereAction.createCustomComponent(searchEverywhereAction.getTemplatePresentation());
+ // searchEverywhere.putClientProperty("SEARCH_EVERYWHERE", Boolean.TRUE);
+ // add(searchEverywhere);
+ // }
+ // catch (Exception ignore) {}
+ // }
+ //}
}
private JComponent getCustomComponent(AnAction action) {
@@ -730,14 +742,18 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
throw new IllegalStateException("unknown layoutPolicy: " + myLayoutPolicy);
}
+
if (getComponentCount() > 0 && size2Fit.width < Integer.MAX_VALUE) {
- final Component component = getComponent(getComponentCount() - 1);
- if (component instanceof JComponent && ((JComponent)component).getClientProperty("SEARCH_EVERYWHERE") == Boolean.TRUE) {
- int max = 0;
- for (int i = 0; i < bounds.size() - 2; i++) {
- max = Math.max(max, bounds.get(i).height);
+ int maxHeight = 0;
+ for (int i = 0; i < bounds.size() - 2; i++) {
+ maxHeight = Math.max(maxHeight, bounds.get(i).height);
+ }
+
+ for (int i = getComponentCount() - 1, j = 1; i > 0; i--, j++) {
+ final Component component = getComponent(i);
+ if (component instanceof JComponent && ((JComponent)component).getClientProperty(RIGHT_ALIGN_KEY) == Boolean.TRUE) {
+ bounds.set(bounds.size() - j, new Rectangle(size2Fit.width - j * 25, 0, 25, maxHeight));
}
- bounds.set(bounds.size() - 1, new Rectangle(size2Fit.width - 25, 0, 25, max));
}
}
}
@@ -1185,7 +1201,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
final ActionGroup actionGroup,
final boolean horizontal,
final DataManager dataManager,
- final ActionManagerEx actionManager,
+ @NotNull ActionManagerEx actionManager,
final KeymapManagerEx keymapManager,
JComponent parent) {
super(place, actionGroup, horizontal, false, dataManager, actionManager, keymapManager, true);