This commit is contained in:
Roman Shevchenko
2012-02-19 16:18:07 +01:00
parent 1b51e0649f
commit 7b688fe314
4 changed files with 51 additions and 51 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 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.
@@ -159,9 +159,21 @@ public abstract class ActionManager implements ApplicationComponent {
public abstract void removeTimerListener(TimerListener listener);
public abstract void addTransparrentTimerListener(int delay, TimerListener listener);
public abstract void addTransparentTimerListener(int delay, TimerListener listener);
public abstract void removeTransparrentTimerListener(TimerListener listener);
/** @deprecated use {@linkplain #addTransparentTimerListener(int, TimerListener)} (to remove in IDEA 13) */
@SuppressWarnings("UnusedDeclaration")
public void addTransparrentTimerListener(int delay, TimerListener listener) {
addTransparentTimerListener(delay, listener);
}
public abstract void removeTransparentTimerListener(TimerListener listener);
/** @deprecated use {@linkplain #removeTransparentTimerListener(TimerListener)} (to remove in IDEA 13) */
@SuppressWarnings("UnusedDeclaration")
public void removeTransparrentTimerListener(TimerListener listener) {
removeTransparentTimerListener(listener);
}
public abstract ActionCallback tryToExecute(@NotNull AnAction action, @NotNull InputEvent inputEvent, @Nullable Component contextComponent,
@Nullable String place, boolean now);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 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.
@@ -88,17 +88,17 @@ public abstract class AnAction implements PossiblyDumbAware {
* Creates a new action with the specified text. Description and icon are
* set to <code>null</code>.
*
* @param text Serves as a tooltip when the presention is a button and the name of the
* @param text Serves as a tooltip when the presentation is a button and the name of the
* menu item when the presentation is a menu item.
*/
public AnAction(String text){
public AnAction(@Nullable String text){
this(text, null, null);
}
/**
* Constructs a new action with the specified text, description and icon.
*
* @param text Serves as a tooltip when the presention is a button and the name of the
* @param text Serves as a tooltip when the presentation is a button and the name of the
* menu item when the presentation is a menu item
*
* @param description Describes current action, this description will appear on
@@ -106,7 +106,7 @@ public abstract class AnAction implements PossiblyDumbAware {
*
* @param icon Action's icon
*/
public AnAction(String text, String description, @Nullable Icon icon){
public AnAction(String text, @Nullable String description, @Nullable Icon icon){
myShortcutSet = ourEmptyShortcutSet;
myEnabledInModalContext = false;
Presentation presentation = getTemplatePresentation();
@@ -118,7 +118,7 @@ public abstract class AnAction implements PossiblyDumbAware {
/**
* Returns the shortcut set associated with this action.
*
* @return shorcut set associated with this action
* @return shortcut set associated with this action
*/
public final ShortcutSet getShortcutSet(){
return myShortcutSet;
@@ -127,15 +127,15 @@ public abstract class AnAction implements PossiblyDumbAware {
/**
* Registers a set of shortcuts that will be processed when the specified component
* is the ancestor of focused component. Note that the action doesn't have
* to be registered in action manager in order for that shorcut to work.
* to be registered in action manager in order for that shortcut to work.
*
* @param shortcutSet the shortcuts for the action.
* @param component the component for which the shortcuts will be active.
*/
public final void registerCustomShortcutSet(@NotNull ShortcutSet shortcutSet, JComponent component){
public final void registerCustomShortcutSet(@NotNull ShortcutSet shortcutSet, @Nullable JComponent component){
myShortcutSet = shortcutSet;
if (component != null){
ArrayList<AnAction> actionList = (ArrayList<AnAction>)component.getClientProperty(ourClientProperty);
@SuppressWarnings("unchecked") ArrayList<AnAction> actionList = (ArrayList<AnAction>)component.getClientProperty(ourClientProperty);
if (actionList == null){
actionList = new ArrayList<AnAction>(1);
component.putClientProperty(ourClientProperty, actionList);
@@ -161,7 +161,7 @@ public abstract class AnAction implements PossiblyDumbAware {
public final void unregisterCustomShortcutSet(JComponent component){
if (component != null){
ArrayList<AnAction> actionList = (ArrayList<AnAction>)component.getClientProperty(ourClientProperty);
@SuppressWarnings("unchecked") ArrayList<AnAction> actionList = (ArrayList<AnAction>)component.getClientProperty(ourClientProperty);
if (actionList != null){
actionList.remove(this);
}
@@ -221,9 +221,10 @@ public abstract class AnAction implements PossiblyDumbAware {
}
/**
* Same as {@link #update(AnActionEvent)} but is calls immediately before actionPerformed() as final check
* guard. Default implementation delegates to {@link #update(AnActionEvent)}.
* @param e
* Same as {@link #update(AnActionEvent)} but is calls immediately before actionPerformed() as final check guard.
* Default implementation delegates to {@link #update(AnActionEvent)}.
*
* @param e Carries information on the invocation place and data available
*/
public void beforeActionPerformedUpdate(AnActionEvent e) {
boolean worksInInjected = isInInjectedContext();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 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.
@@ -149,7 +149,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
}
public void addTimerListener(int delay, final TimerListener listener) {
_addTimerListener(delay, listener, false);
_addTimerListener(listener, false);
}
public void removeTimerListener(TimerListener listener) {
@@ -157,31 +157,30 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
}
@Override
public void addTransparrentTimerListener(int delay, TimerListener listener) {
_addTimerListener(delay, listener, true);
public void addTransparentTimerListener(int delay, TimerListener listener) {
_addTimerListener(listener, true);
}
@Override
public void removeTransparrentTimerListener(TimerListener listener) {
public void removeTransparentTimerListener(TimerListener listener) {
_removeTimerListener(listener, true);
}
private void _addTimerListener(int delay, final TimerListener listener, boolean transparrent) {
private void _addTimerListener(final TimerListener listener, boolean transparent) {
if (ApplicationManager.getApplication().isUnitTestMode()) return;
if (myTimer == null) {
myTimer = new MyTimer();
myTimer.start();
}
myTimer.addTimerListener(listener, transparrent);
myTimer.addTimerListener(listener, transparent);
}
private void _removeTimerListener(TimerListener listener, boolean transparrent) {
private void _removeTimerListener(TimerListener listener, boolean transparent) {
if (ApplicationManager.getApplication().isUnitTestMode()) return;
LOG.assertTrue(myTimer != null);
myTimer.removeTimerListener(listener, transparrent);
myTimer.removeTimerListener(listener, transparent);
}
public ActionPopupMenu createActionPopupMenu(String place, @NotNull ActionGroup group, @Nullable PresentationFactory presentationFactory) {
@@ -397,6 +396,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
return stub;
}
@Nullable
private static ResourceBundle getActionsResourceBundle(ClassLoader loader, IdeaPluginDescriptor plugin) {
@NonNls final String resBundleName = plugin != null && !plugin.getPluginId().getIdString().equals("com.intellij") ? plugin.getResourceBundleBaseName() : ACTIONS_BUNDLE;
ResourceBundle bundle = null;
@@ -708,7 +708,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
* case separator will be added to group described in the <add-to-group ....> subelement.
* @param element XML element which represent separator.
*/
private void processSeparatorNode(DefaultActionGroup parentGroup, Element element, PluginId pluginId) {
private void processSeparatorNode(@Nullable DefaultActionGroup parentGroup, Element element, PluginId pluginId) {
if (!SEPARATOR_ELEMENT_NAME.equals(element.getName())) {
reportActionError(pluginId, "unexpected name of element \"" + element.getName() + "\"");
return;
@@ -836,19 +836,6 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
return action;
}
private void processActionsElement(Element element, ClassLoader loader, PluginId pluginId) {
if (!ACTIONS_ELEMENT_NAME.equals(element.getName())) {
reportActionError(pluginId, "unexpected name of element \"" + element.getName() + "\"");
return;
}
synchronized (myLock) {
for (final Object o : element.getChildren()) {
Element child = (Element)o;
processActionsChildElement(loader, pluginId, child);
}
}
}
private void processActionsChildElement(final ClassLoader loader, final PluginId pluginId, final Element child) {
String name = child.getName();
if (ACTION_ELEMENT_NAME.equals(name)) {
@@ -1044,6 +1031,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
if (action != null) {
myPrevPerformedActionId = myLastPreformedActionId;
myLastPreformedActionId = getId(action);
//noinspection AssignmentToStaticFieldFromInstanceMethod
IdeaLogger.ourLastActionId = myLastPreformedActionId;
}
AnActionListener[] listeners = getActionListeners();
@@ -1056,6 +1044,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
if (action != null) {
myPrevPerformedActionId = myLastPreformedActionId;
myLastPreformedActionId = getId(action);
//noinspection AssignmentToStaticFieldFromInstanceMethod
IdeaLogger.ourLastActionId = myLastPreformedActionId;
}
AnActionListener[] listeners = getActionListeners();
@@ -1063,9 +1052,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
try {
listener.afterActionPerformed(action, dataContext, event);
}
catch(AbstractMethodError e) {
// ignore
}
catch(AbstractMethodError ignored) { }
}
}
@@ -1167,11 +1154,10 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
myActionsPreloaded++;
if (myActionsPreloaded % 10 == 0) {
try {
//noinspection BusyWait
Thread.sleep(300);
}
catch (InterruptedException e) {
// ignore
}
catch (InterruptedException ignored) { }
}
}
}
@@ -1281,6 +1267,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
if (now) {
doRunnable.run();
} else {
//noinspection SSBasedInspection
SwingUtilities.invokeLater(doRunnable);
}
@@ -1289,7 +1276,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
}
private void tryToExecuteNow(final AnAction action, final InputEvent inputEvent, final Component contextComponent, final String place, final ActionCallback result) {
final Presentation presentation = (Presentation)action.getTemplatePresentation().clone();
final Presentation presentation = action.getTemplatePresentation().clone();
IdeFocusManager.findInstanceByContext(getContextBy(contextComponent)).doWhenFocusSettlesDown(new Runnable() {
public void run() {
@@ -1335,7 +1322,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
}
}
}
}, WindowEvent.WINDOW_EVENT_MASK, result);
}, AWTEvent.WINDOW_EVENT_MASK, result);
action.actionPerformed(event);
result.setDone();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 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.
@@ -160,7 +160,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
public void addNotify() {
super.addNotify();
myActionManager.addTimerListener(500, myWeakTimerListener);
myActionManager.addTransparrentTimerListener(500, myWeakTimerListener);
myActionManager.addTransparentTimerListener(500, myWeakTimerListener);
}
private boolean doMacEnhancementsForMainToolbar() {
@@ -175,7 +175,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
public void removeNotify() {
super.removeNotify();
myActionManager.removeTimerListener(myWeakTimerListener);
myActionManager.removeTransparrentTimerListener(myWeakTimerListener);
myActionManager.removeTransparentTimerListener(myWeakTimerListener);
}
public JComponent getComponent() {