mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -38,4 +38,16 @@
|
||||
name='org.picocontainer.defaults.InstantiatingComponentAdapter InstantiatingComponentAdapter(java.lang.Object, java.lang.Class, org.picocontainer.Parameter[], boolean, org.picocontainer.ComponentMonitor, org.picocontainer.defaults.LifecycleStrategy) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='org.picocontainer.defaults.InstantiatingComponentAdapter java.lang.Object newInstance(java.lang.reflect.Constructor, java.lang.Object[])'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='org.picocontainer.defaults.InstantiatingComponentAdapter java.lang.Object newInstance(java.lang.reflect.Constructor, java.lang.Object[]) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='org.picocontainer.defaults.InstantiatingComponentAdapter java.lang.reflect.Constructor getGreediestSatisfiableConstructor(org.picocontainer.PicoContainer)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
@@ -39,7 +39,7 @@ public abstract class ActionManager {
|
||||
* @return An instance of {@code ActionPopupMenu}
|
||||
*/
|
||||
@NotNull
|
||||
public abstract ActionPopupMenu createActionPopupMenu(@NonNls String place, @NotNull ActionGroup group);
|
||||
public abstract ActionPopupMenu createActionPopupMenu(@NonNls @NotNull String place, @NotNull ActionGroup group);
|
||||
|
||||
/**
|
||||
* Factory method that creates an {@code ActionToolbar} from the
|
||||
@@ -114,6 +114,7 @@ public abstract class ActionManager {
|
||||
* @return all action {@code id}s which have the specified prefix.
|
||||
* @since 5.1
|
||||
*/
|
||||
@NotNull
|
||||
public abstract String[] getActionIds(@NotNull String idPrefix);
|
||||
|
||||
/**
|
||||
@@ -136,19 +137,20 @@ public abstract class ActionManager {
|
||||
* @since 5.1
|
||||
*/
|
||||
@NotNull
|
||||
public abstract JComponent createButtonToolbar(final String actionPlace, @NotNull ActionGroup messageActionGroup);
|
||||
public abstract JComponent createButtonToolbar(@NotNull String actionPlace, @NotNull ActionGroup messageActionGroup);
|
||||
|
||||
@Nullable
|
||||
public abstract AnAction getActionOrStub(@NonNls String id);
|
||||
public abstract AnAction getActionOrStub(@NotNull @NonNls String id);
|
||||
|
||||
public abstract void addTimerListener(int delay, TimerListener listener);
|
||||
public abstract void addTimerListener(int delay, @NotNull TimerListener listener);
|
||||
|
||||
public abstract void removeTimerListener(TimerListener listener);
|
||||
public abstract void removeTimerListener(@NotNull TimerListener listener);
|
||||
|
||||
public abstract void addTransparentTimerListener(int delay, TimerListener listener);
|
||||
public abstract void addTransparentTimerListener(int delay, @NotNull TimerListener listener);
|
||||
|
||||
public abstract void removeTransparentTimerListener(TimerListener listener);
|
||||
public abstract void removeTransparentTimerListener(@NotNull TimerListener listener);
|
||||
|
||||
@NotNull
|
||||
public abstract ActionCallback tryToExecute(@NotNull AnAction action, @NotNull InputEvent inputEvent, @Nullable Component contextComponent,
|
||||
@Nullable String place, boolean now);
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ public interface ActionToolbar {
|
||||
|
||||
void setReservePlaceAutoPopupIcon(boolean reserve);
|
||||
|
||||
void setSecondaryActionsTooltip(String secondaryActionsTooltip);
|
||||
void setSecondaryActionsTooltip(@NotNull String secondaryActionsTooltip);
|
||||
|
||||
void setSecondaryActionsIcon(Icon icon);
|
||||
|
||||
@@ -109,6 +109,7 @@ public interface ActionToolbar {
|
||||
|
||||
void setMiniMode(boolean minimalMode);
|
||||
|
||||
@NotNull
|
||||
DataContext getToolbarDataContext();
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -14,13 +14,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
public interface AnActionListener {
|
||||
Topic<AnActionListener> TOPIC = new Topic<>("action changes", AnActionListener.class);
|
||||
|
||||
default void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
default void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Note that using {@code dataContext} in implementing methods is unsafe - it could have been invalidated by the performed action.
|
||||
*/
|
||||
default void afterActionPerformed(AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
default void afterActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
}
|
||||
|
||||
default void beforeEditorTyping(char c, @NotNull DataContext dataContext) {
|
||||
|
||||
@@ -22,10 +22,11 @@ import java.awt.event.MouseEvent;
|
||||
import java.util.EventObject;
|
||||
|
||||
public class EditorMouseEvent extends EventObject {
|
||||
@NotNull
|
||||
private final MouseEvent myMouseEvent;
|
||||
private final EditorMouseEventArea myEditorArea;
|
||||
|
||||
public EditorMouseEvent(@NotNull Editor editor, MouseEvent mouseEvent, EditorMouseEventArea area) {
|
||||
public EditorMouseEvent(@NotNull Editor editor, @NotNull MouseEvent mouseEvent, EditorMouseEventArea area) {
|
||||
super(editor);
|
||||
|
||||
myMouseEvent = mouseEvent;
|
||||
@@ -37,6 +38,7 @@ public class EditorMouseEvent extends EventObject {
|
||||
return (Editor) getSource();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public MouseEvent getMouseEvent() {
|
||||
return myMouseEvent;
|
||||
}
|
||||
|
||||
+2
-6
@@ -27,9 +27,6 @@ public class EPAvailabilityListenerExtension implements PluginAware {
|
||||
private String myListenerClass;
|
||||
private PluginDescriptor myPluginDescriptor;
|
||||
|
||||
public EPAvailabilityListenerExtension() {
|
||||
}
|
||||
|
||||
public EPAvailabilityListenerExtension(@NotNull String extensionPointName, @NotNull String listenerClass) {
|
||||
myExtensionPointName = extensionPointName;
|
||||
myListenerClass = listenerClass;
|
||||
@@ -62,12 +59,11 @@ public class EPAvailabilityListenerExtension implements PluginAware {
|
||||
return myPluginDescriptor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Class loadListenerClass() throws ClassNotFoundException {
|
||||
if (myPluginDescriptor != null && myPluginDescriptor.getPluginClassLoader() != null) {
|
||||
return Class.forName(getListenerClass(), true, myPluginDescriptor.getPluginClassLoader());
|
||||
}
|
||||
else {
|
||||
return Class.forName(getListenerClass());
|
||||
}
|
||||
return Class.forName(getListenerClass());
|
||||
}
|
||||
}
|
||||
|
||||
+38
-55
@@ -29,12 +29,6 @@ public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
private static final Logger LOG = Logger.getInstance(ExtensionsAreaImpl.class);
|
||||
public static final String ATTRIBUTE_AREA = "area";
|
||||
|
||||
private static final Map<String,String> ourDefaultEPs = new THashMap<>();
|
||||
|
||||
static {
|
||||
ourDefaultEPs.put(EPAvailabilityListenerExtension.EXTENSION_POINT_NAME, EPAvailabilityListenerExtension.class.getName());
|
||||
}
|
||||
|
||||
private static final boolean DEBUG_REGISTRATION = Boolean.FALSE.booleanValue(); // not compile-time constant to avoid yellow code
|
||||
|
||||
private final AreaPicoContainer myPicoContainer;
|
||||
@@ -53,11 +47,6 @@ public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
initialize();
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
ExtensionsAreaImpl(MutablePicoContainer parentPicoContainer) {
|
||||
this(null, null, parentPicoContainer);
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public final void notifyAreaReplaced(@NotNull ExtensionsAreaImpl newArea) {
|
||||
Set<String> processedEPs = ContainerUtil.newTroveSet();
|
||||
@@ -105,10 +94,6 @@ public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
return myAreaClass;
|
||||
}
|
||||
|
||||
public void registerExtensionPoint(@NotNull String pluginName, @NotNull Element extensionPointElement) {
|
||||
registerExtensionPoint(new DefaultPluginDescriptor(PluginId.getId(pluginName)), extensionPointElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerExtensionPoint(@NotNull PluginDescriptor pluginDescriptor, @NotNull Element extensionPointElement) {
|
||||
assert pluginDescriptor.getPluginId() != null;
|
||||
@@ -181,7 +166,7 @@ public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
return new ExtensionComponentAdapter(implementationClassName, myPicoContainer, pluginDescriptor, orderId, order, isNeedToDeserialize ? extensionElement : null);
|
||||
}
|
||||
|
||||
private static boolean shouldDeserializeInstance(Element extensionElement) {
|
||||
private static boolean shouldDeserializeInstance(@NotNull Element extensionElement) {
|
||||
// has content
|
||||
if (!extensionElement.getContent().isEmpty()) return true;
|
||||
// has custom attributes
|
||||
@@ -214,54 +199,49 @@ public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
return myPicoContainer;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void initialize() {
|
||||
for (Map.Entry<String, String> entry : ourDefaultEPs.entrySet()) {
|
||||
String epName = entry.getKey();
|
||||
registerExtensionPoint(epName, entry.getValue());
|
||||
}
|
||||
|
||||
getExtensionPoint(EPAvailabilityListenerExtension.EXTENSION_POINT_NAME).addExtensionPointListener(new ExtensionPointListener() {
|
||||
@Override
|
||||
public void extensionRemoved(@NotNull Object extension, final PluginDescriptor pluginDescriptor) {
|
||||
EPAvailabilityListenerExtension epListenerExtension = (EPAvailabilityListenerExtension) extension;
|
||||
synchronized (myAvailabilityListeners) {
|
||||
Collection<ExtensionPointAvailabilityListener> listeners = myAvailabilityListeners.get(epListenerExtension.getExtensionPointName());
|
||||
for (Iterator<ExtensionPointAvailabilityListener> iterator = listeners.iterator(); iterator.hasNext();) {
|
||||
ExtensionPointAvailabilityListener listener = iterator.next();
|
||||
if (listener.getClass().getName().equals(epListenerExtension.getListenerClass())) {
|
||||
iterator.remove();
|
||||
return;
|
||||
ExtensionPointImpl<EPAvailabilityListenerExtension> point =
|
||||
registerExtensionPoint(EPAvailabilityListenerExtension.EXTENSION_POINT_NAME, EPAvailabilityListenerExtension.class.getName(),
|
||||
new UndefinedPluginDescriptor(), ExtensionPoint.Kind.INTERFACE);
|
||||
point.addExtensionPointListener(new ExtensionPointListener<EPAvailabilityListenerExtension>() {
|
||||
@Override
|
||||
public void extensionAdded(@NotNull EPAvailabilityListenerExtension extension, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
synchronized (myAvailabilityListeners) {
|
||||
Collection<ExtensionPointAvailabilityListener> listeners = myAvailabilityListeners.get(extension.getExtensionPointName());
|
||||
for (Iterator<ExtensionPointAvailabilityListener> iterator = listeners.iterator(); iterator.hasNext();) {
|
||||
ExtensionPointAvailabilityListener listener = iterator.next();
|
||||
if (listener.getClass().getName().equals(extension.getListenerClass())) {
|
||||
iterator.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG.warn("Failed to find EP availability listener: " + extension.getListenerClass());
|
||||
}
|
||||
LOG.warn("Failed to find EP availability listener: " + epListenerExtension.getListenerClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extensionAdded(@NotNull Object extension, final PluginDescriptor pluginDescriptor) {
|
||||
EPAvailabilityListenerExtension epListenerExtension = (EPAvailabilityListenerExtension) extension;
|
||||
try {
|
||||
String epName = epListenerExtension.getExtensionPointName();
|
||||
@Override
|
||||
public void extensionRemoved(@NotNull EPAvailabilityListenerExtension extension, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
try {
|
||||
String epName = extension.getExtensionPointName();
|
||||
|
||||
ExtensionPointAvailabilityListener listener = (ExtensionPointAvailabilityListener) instantiate(epListenerExtension.loadListenerClass());
|
||||
addAvailabilityListener(epName, listener);
|
||||
ExtensionPointAvailabilityListener listener = (ExtensionPointAvailabilityListener) instantiate(extension.loadListenerClass());
|
||||
addAvailabilityListener(epName, listener);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private Object instantiate(Class clazz) {
|
||||
@NotNull
|
||||
private Object instantiate(@NotNull Class clazz) {
|
||||
CachingConstructorInjectionComponentAdapter adapter =
|
||||
new CachingConstructorInjectionComponentAdapter(Integer.toString(System.identityHashCode(new Object())), clazz);
|
||||
|
||||
return adapter.getComponentInstance(getPicoContainer());
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public Throwable getCreationTrace() {
|
||||
return myCreationTrace;
|
||||
}
|
||||
@@ -299,10 +279,11 @@ public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
registerExtensionPoint(extensionPointName, extensionPointBeanClass, new UndefinedPluginDescriptor(), kind);
|
||||
}
|
||||
|
||||
private void registerExtensionPoint(@NotNull String extensionPointName,
|
||||
@NotNull String extensionPointBeanClass,
|
||||
@NotNull PluginDescriptor descriptor,
|
||||
@NotNull ExtensionPoint.Kind kind) {
|
||||
@NotNull
|
||||
private <T> ExtensionPointImpl<T> registerExtensionPoint(@NotNull String extensionPointName,
|
||||
@NotNull String extensionPointBeanClass,
|
||||
@NotNull PluginDescriptor descriptor,
|
||||
@NotNull ExtensionPoint.Kind kind) {
|
||||
if (hasExtensionPoint(extensionPointName)) {
|
||||
final String message =
|
||||
"Duplicate registration for EP: " + extensionPointName + ": original plugin " +
|
||||
@@ -314,14 +295,16 @@ public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
throw new PicoPluginExtensionInitializationException(message, null, extractPluginId(descriptor));
|
||||
}
|
||||
|
||||
registerExtensionPoint(new ExtensionPointImpl(extensionPointName, extensionPointBeanClass, kind, this, myAreaInstance, descriptor));
|
||||
ExtensionPointImpl<T> point = new ExtensionPointImpl<>(extensionPointName, extensionPointBeanClass, kind, this, myAreaInstance, descriptor);
|
||||
registerExtensionPoint(point);
|
||||
return point;
|
||||
}
|
||||
|
||||
private static PluginId extractPluginId(@NotNull PluginDescriptor descriptor) {
|
||||
return descriptor instanceof UndefinedPluginDescriptor ? null : descriptor.getPluginId();
|
||||
}
|
||||
|
||||
public void registerExtensionPoint(@NotNull ExtensionPointImpl extensionPoint) {
|
||||
private void registerExtensionPoint(@NotNull ExtensionPointImpl<?> extensionPoint) {
|
||||
String name = extensionPoint.getName();
|
||||
myExtensionPoints.put(name, extensionPoint);
|
||||
notifyEPRegistered(extensionPoint);
|
||||
|
||||
+18
-15
@@ -47,6 +47,7 @@ public class CachingConstructorInjectionComponentAdapter extends InstantiatingCo
|
||||
return instance;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Object instantiateGuarded(PicoContainer container, Class stackFrame) {
|
||||
Set<CachingConstructorInjectionComponentAdapter> currentStack = ourGuard.get();
|
||||
if (currentStack == null) {
|
||||
@@ -60,14 +61,17 @@ public class CachingConstructorInjectionComponentAdapter extends InstantiatingCo
|
||||
try {
|
||||
currentStack.add(this);
|
||||
return doGetComponentInstance(container);
|
||||
} catch (final CyclicDependencyException e) {
|
||||
}
|
||||
catch (final CyclicDependencyException e) {
|
||||
e.push(stackFrame);
|
||||
throw e;
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
currentStack.remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Object doGetComponentInstance(PicoContainer guardedContainer) {
|
||||
final Constructor constructor;
|
||||
try {
|
||||
@@ -102,7 +106,7 @@ public class CachingConstructorInjectionComponentAdapter extends InstantiatingCo
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Object[] getConstructorArguments(PicoContainer container, Constructor ctor) {
|
||||
private Object[] getConstructorArguments(PicoContainer container, @NotNull Constructor ctor) {
|
||||
Class[] parameterTypes = ctor.getParameterTypes();
|
||||
Object[] result = new Object[parameterTypes.length];
|
||||
Parameter[] currentParameters = parameters != null ? parameters : createDefaultParameters(parameterTypes);
|
||||
@@ -113,6 +117,7 @@ public class CachingConstructorInjectionComponentAdapter extends InstantiatingCo
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Constructor getGreediestSatisfiableConstructor(PicoContainer container) throws
|
||||
PicoIntrospectionException,
|
||||
@@ -162,12 +167,15 @@ public class CachingConstructorInjectionComponentAdapter extends InstantiatingCo
|
||||
}
|
||||
if (!conflicts.isEmpty()) {
|
||||
throw new TooManySatisfiableConstructorsException(getComponentImplementation(), conflicts);
|
||||
} else if (greediestConstructor == null && !unsatisfiableDependencyTypes.isEmpty()) {
|
||||
}
|
||||
if (greediestConstructor == null && !unsatisfiableDependencyTypes.isEmpty()) {
|
||||
throw new UnsatisfiableDependenciesException(this, unsatisfiedDependencyType, unsatisfiableDependencyTypes, container);
|
||||
} else if (greediestConstructor == null) {
|
||||
}
|
||||
if (greediestConstructor == null) {
|
||||
// be nice to the user, show all constructors that were filtered out
|
||||
final Set<Constructor> nonMatching = ContainerUtil.newHashSet(getConstructors());
|
||||
throw new PicoInitializationException("Either do the specified parameters not match any of the following constructors: " + nonMatching.toString() + " or the constructors were not accessible for '" + getComponentImplementation() + "'");
|
||||
final Set<Constructor<?>> nonMatching = ContainerUtil.newHashSet(getConstructors());
|
||||
throw new PicoInitializationException("Either do the specified parameters not match any of the following constructors: " +
|
||||
nonMatching + " or the constructors were not accessible for '" + getComponentImplementation() + "'");
|
||||
}
|
||||
return greediestConstructor;
|
||||
}
|
||||
@@ -175,7 +183,7 @@ public class CachingConstructorInjectionComponentAdapter extends InstantiatingCo
|
||||
private List<Constructor> getSortedMatchingConstructors() {
|
||||
List<Constructor> matchingConstructors = new ArrayList<>();
|
||||
// filter out all constructors that will definitely not match
|
||||
for (Constructor constructor : getConstructors()) {
|
||||
for (Constructor<?> constructor : getConstructors()) {
|
||||
if ((parameters == null || constructor.getParameterTypes().length == parameters.length) &&
|
||||
(allowNonPublicClasses || (constructor.getModifiers() & Modifier.PUBLIC) != 0)) {
|
||||
matchingConstructors.add(constructor);
|
||||
@@ -189,12 +197,7 @@ public class CachingConstructorInjectionComponentAdapter extends InstantiatingCo
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Constructor[] getConstructors() {
|
||||
return (Constructor[]) AccessController.doPrivileged(new PrivilegedAction() {
|
||||
@Override
|
||||
public Object run() {
|
||||
return getComponentImplementation().getDeclaredConstructors();
|
||||
}
|
||||
});
|
||||
private Constructor<?>[] getConstructors() {
|
||||
return AccessController.doPrivileged((PrivilegedAction<Constructor<?>[]>)() -> getComponentImplementation().getDeclaredConstructors());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -251,7 +251,7 @@ public class ExtensionPointImplTest {
|
||||
}
|
||||
|
||||
private static ExtensionsAreaImpl buildExtensionArea() {
|
||||
return new ExtensionsAreaImpl(new DefaultPicoContainer());
|
||||
return new ExtensionsAreaImpl(null, null, new DefaultPicoContainer());
|
||||
}
|
||||
|
||||
private static MyShootingComponentAdapter stringAdapter() {
|
||||
|
||||
+4
-5
@@ -1,9 +1,7 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.extensions.impl;
|
||||
|
||||
import com.intellij.openapi.extensions.AreaInstance;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.extensions.*;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
@@ -103,14 +101,15 @@ public class ExtensionsComplexTest {
|
||||
final Element element = JDOMUtil.load(data);
|
||||
for (final Object o : element.getChildren()) {
|
||||
Element child = (Element)o;
|
||||
((ExtensionsAreaImpl)Extensions.getArea(instance)).registerExtensionPoint(ExtensionsComplexTest.PLUGIN_NAME, child);
|
||||
Extensions.getArea(instance)
|
||||
.registerExtensionPoint(new DefaultPluginDescriptor(PluginId.getId(PLUGIN_NAME)), child);
|
||||
}
|
||||
}
|
||||
|
||||
private static void initExtensions(@NonNls String data, AreaInstance instance) throws IOException, JDOMException {
|
||||
final Element element = JDOMUtil.load(data);
|
||||
for (final Element child : element.getChildren()) {
|
||||
ExtensionsImplTest.registerExtension(((ExtensionsAreaImpl)Extensions.getArea(instance)), element.getNamespaceURI(), child);
|
||||
ExtensionsImplTest.registerExtension((ExtensionsAreaImpl)Extensions.getArea(instance), element.getNamespaceURI(), child);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -23,7 +23,7 @@ public class ExtensionsImplTest {
|
||||
|
||||
@Test
|
||||
public void testCreateAndAccess() {
|
||||
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(null);
|
||||
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(null, null, null);
|
||||
int numEP = extensionsArea.getExtensionPoints().length;
|
||||
extensionsArea.registerExtensionPoint(EXTENSION_POINT_NAME_1, Integer.class.getName());
|
||||
assertEquals("Additional EP available", numEP + 1, extensionsArea.getExtensionPoints().length);
|
||||
@@ -32,7 +32,7 @@ public class ExtensionsImplTest {
|
||||
|
||||
@Test(expected = Throwable.class)
|
||||
public void testInvalidActions() {
|
||||
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(null);
|
||||
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(null, null, null);
|
||||
extensionsArea.registerExtensionPoint(EXTENSION_POINT_NAME_1, Integer.class.getName());
|
||||
extensionsArea.registerExtensionPoint(EXTENSION_POINT_NAME_1, Boolean.class.getName());
|
||||
fail("Should not allow duplicate registration");
|
||||
@@ -40,7 +40,7 @@ public class ExtensionsImplTest {
|
||||
|
||||
@Test
|
||||
public void testUnregisterEP() {
|
||||
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(null);
|
||||
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(null, null, null);
|
||||
int numEP = extensionsArea.getExtensionPoints().length;
|
||||
extensionsArea.registerExtensionPoint(EXTENSION_POINT_NAME_1, Integer.class.getName());
|
||||
|
||||
@@ -59,7 +59,7 @@ public class ExtensionsImplTest {
|
||||
|
||||
@Test
|
||||
public void testAvailabilityListener() {
|
||||
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(null);
|
||||
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(null, null, null);
|
||||
MyListener.reset();
|
||||
extensionsArea.getExtensionPoint(EPAvailabilityListenerExtension.EXTENSION_POINT_NAME).registerExtension(
|
||||
new EPAvailabilityListenerExtension(EXTENSION_POINT_NAME_1, MyListener.class.getName()));
|
||||
@@ -76,7 +76,7 @@ public class ExtensionsImplTest {
|
||||
|
||||
@Test
|
||||
public void testAvailability2Listeners() {
|
||||
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(null);
|
||||
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(null, null, null);
|
||||
MyListener.reset();
|
||||
extensionsArea.registerExtensionPoint(EXTENSION_POINT_NAME_1, Integer.class.getName());
|
||||
extensionsArea.getExtensionPoint(EPAvailabilityListenerExtension.EXTENSION_POINT_NAME).registerExtension(
|
||||
@@ -93,7 +93,7 @@ public class ExtensionsImplTest {
|
||||
|
||||
@Test
|
||||
public void testAvailabilityListenerAfter() {
|
||||
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(null);
|
||||
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(null, null, null);
|
||||
extensionsArea.registerExtensionPoint(EXTENSION_POINT_NAME_1, Integer.class.getName());
|
||||
MyListener.reset();
|
||||
extensionsArea.getExtensionPoint(EPAvailabilityListenerExtension.EXTENSION_POINT_NAME).registerExtension(
|
||||
@@ -155,7 +155,7 @@ public class ExtensionsImplTest {
|
||||
|
||||
@Test
|
||||
public void testExtensionsNamespaces() throws IOException, JDOMException {
|
||||
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(new DefaultPicoContainer());
|
||||
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(null, null, new DefaultPicoContainer());
|
||||
extensionsArea.registerExtensionPoint("plugin.ep1", TestExtensionClassOne.class.getName(), ExtensionPoint.Kind.BEAN_CLASS);
|
||||
registerExtension(extensionsArea, "plugin", JDOMUtil.load(
|
||||
"<plugin:ep1 xmlns:plugin=\"plugin\" order=\"LAST\"><text>3</text></plugin:ep1>"));
|
||||
@@ -173,7 +173,7 @@ public class ExtensionsImplTest {
|
||||
|
||||
@Test
|
||||
public void testExtensionsWithOrdering() throws IOException, JDOMException {
|
||||
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(new DefaultPicoContainer());
|
||||
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(null, null, new DefaultPicoContainer());
|
||||
extensionsArea.registerExtensionPoint("ep1", TestExtensionClassOne.class.getName(), ExtensionPoint.Kind.BEAN_CLASS);
|
||||
registerExtension(extensionsArea, "", JDOMUtil.load(
|
||||
"<extension point=\"ep1\" order=\"LAST\"><text>3</text></extension>"));
|
||||
@@ -191,7 +191,7 @@ public class ExtensionsImplTest {
|
||||
|
||||
@Test
|
||||
public void testExtensionsWithOrderingUpdate() throws IOException, JDOMException {
|
||||
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(new DefaultPicoContainer());
|
||||
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(null, null, new DefaultPicoContainer());
|
||||
extensionsArea.registerExtensionPoint("ep1", TestExtensionClassOne.class.getName(), ExtensionPoint.Kind.BEAN_CLASS);
|
||||
registerExtension(extensionsArea, "", JDOMUtil.load("<extension point=\"ep1\" id=\"_7\" order=\"LAST\"><text>7</text></extension>"));
|
||||
registerExtension(extensionsArea, "", JDOMUtil.load("<extension point=\"ep1\" id=\"fst\" order=\"FIRST\"><text>1</text></extension>"));
|
||||
|
||||
@@ -75,7 +75,7 @@ public class AutoPopupController implements Disposable {
|
||||
private void setupListeners() {
|
||||
ApplicationManager.getApplication().getMessageBus().connect(this).subscribe(AnActionListener.TOPIC, new AnActionListener() {
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
cancelAllRequests();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class ActionTracker {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
myActionsHappened = true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -543,7 +543,7 @@ public class DaemonListeners implements Disposable {
|
||||
private final AnAction escapeAction = myActionManager.getAction(IdeActions.ACTION_EDITOR_ESCAPE);
|
||||
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
myEscPressed = action == escapeAction;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -208,7 +208,7 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
myActionManager = manager;
|
||||
AnActionListener actionListener = new AnActionListener() {
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
JBPopup hint = getDocInfoHint();
|
||||
if (hint != null) {
|
||||
if (action instanceof HintManagerImpl.ActionToIgnore) return;
|
||||
|
||||
+1
-1
@@ -283,7 +283,7 @@ public class HighlightManagerImpl extends HighlightManager {
|
||||
|
||||
private class MyAnActionListener implements AnActionListener {
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull final DataContext dataContext, AnActionEvent event) {
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull final DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
requestHideHighlights(dataContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ public class SearchReplaceComponent extends EditorHeaderComponent implements Dat
|
||||
private final DefaultActionGroup mySearchFieldActions;
|
||||
private final ActionToolbarImpl mySearchActionsToolbar1;
|
||||
private final ActionToolbarImpl mySearchActionsToolbar2;
|
||||
@NotNull
|
||||
private final ActionToolbarImpl.PopupStateModifier mySearchToolbar1PopupStateModifier;
|
||||
|
||||
private final DefaultActionGroup myReplaceFieldActions;
|
||||
|
||||
@@ -2093,7 +2093,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
|
||||
|
||||
ApplicationManager.getApplication().getMessageBus().connect(myPopup).subscribe(AnActionListener.TOPIC, new AnActionListener() {
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
if (action instanceof TextComponentEditorAction) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ public class NavBarListener
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void afterActionPerformed(AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void afterActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
if (shouldSkipAction(action)) return;
|
||||
|
||||
if (myPanel.isInFloatingMode()) {
|
||||
@@ -379,7 +379,7 @@ public class NavBarListener
|
||||
public void keyReleased(KeyEvent e) {}
|
||||
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {}
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {}
|
||||
|
||||
@Override
|
||||
public void beforeChildAddition(@NotNull PsiTreeChangeEvent event) {}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ActionTracer implements UiDebuggerExtension, AnActionListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterActionPerformed(AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void afterActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
StringBuilder out = new StringBuilder(String.format("%1$tF %1$tT,%1$tL ", System.currentTimeMillis()));
|
||||
final ActionManager actionManager = ActionManager.getInstance();
|
||||
final String id = actionManager.getId(action);
|
||||
|
||||
+5
-11
@@ -4,7 +4,6 @@
|
||||
package com.intellij.openapi.actionSystem.ex;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -20,11 +19,11 @@ public abstract class ActionManagerEx extends ActionManager {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract ActionToolbar createActionToolbar(String place, @NotNull ActionGroup group, boolean horizontal, boolean decorateButtons);
|
||||
public abstract ActionToolbar createActionToolbar(@NotNull String place, @NotNull ActionGroup group, boolean horizontal, boolean decorateButtons);
|
||||
|
||||
public abstract void fireBeforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event);
|
||||
|
||||
public abstract void fireAfterActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, AnActionEvent event);
|
||||
public abstract void fireAfterActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event);
|
||||
|
||||
|
||||
public abstract void fireBeforeEditorTyping(char c, @NotNull DataContext dataContext);
|
||||
@@ -54,7 +53,7 @@ public abstract class ActionManagerEx extends ActionManager {
|
||||
* @return null if string cannot be parsed.
|
||||
*/
|
||||
@Nullable
|
||||
public static KeyStroke getKeyStroke(String s) {
|
||||
public static KeyStroke getKeyStroke(@NotNull String s) {
|
||||
KeyStroke result = null;
|
||||
try {
|
||||
result = KeyStroke.getKeyStroke(s);
|
||||
@@ -62,7 +61,7 @@ public abstract class ActionManagerEx extends ActionManager {
|
||||
catch (Exception ex) {
|
||||
//ok
|
||||
}
|
||||
if (result == null && s != null && s.length() >= 2 && s.charAt(s.length() - 2) == ' ') {
|
||||
if (result == null && s.length() >= 2 && s.charAt(s.length() - 2) == ' ') {
|
||||
try {
|
||||
String s1 = s.substring(0, s.length() - 1) + Character.toUpperCase(s.charAt(s.length() - 1));
|
||||
result = KeyStroke.getKeyStroke(s1);
|
||||
@@ -83,17 +82,12 @@ public abstract class ActionManagerEx extends ActionManager {
|
||||
|
||||
public abstract boolean isTransparentOnlyActionsUpdateNow();
|
||||
|
||||
public void fireBeforeActionPerformed(String actionId, InputEvent event) {
|
||||
public void fireBeforeActionPerformed(@NotNull String actionId, @NotNull InputEvent event) {
|
||||
final AnAction action = getAction(actionId);
|
||||
if (action != null) {
|
||||
AnActionEvent e = AnActionEvent.createFromAnAction(action, event, ActionPlaces.UNKNOWN, DataManager.getInstance().getDataContext());
|
||||
fireBeforeActionPerformed(action, DataManager.getInstance().getDataContext(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to receive notifications when popup menus created from action groups are shown and hidden.
|
||||
*/
|
||||
public abstract void addActionPopupMenuListener(ActionPopupMenuListener listener, Disposable parentDisposable);
|
||||
}
|
||||
|
||||
|
||||
-2
@@ -1,14 +1,12 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.actionSystem.ex;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.ActionPopupMenu;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Allows to receive notifications when popup menus created from action groups are shown and closed.
|
||||
*
|
||||
* @see ActionManagerEx#addActionPopupMenuListener(ActionPopupMenuListener, Disposable)
|
||||
*/
|
||||
public interface ActionPopupMenuListener {
|
||||
default void actionPopupMenuCreated(@NotNull ActionPopupMenu menu) {
|
||||
|
||||
@@ -868,7 +868,7 @@ public class HintManagerImpl extends HintManager {
|
||||
|
||||
private class MyAnActionListener implements AnActionListener {
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
if (action instanceof ActionToIgnore) return;
|
||||
|
||||
AnAction escapeAction = ActionManagerEx.getInstanceEx().getAction(IdeActions.ACTION_EDITOR_ESCAPE);
|
||||
|
||||
@@ -95,7 +95,7 @@ public class IdeTooltipManager implements Disposable, AWTEventListener, BaseComp
|
||||
|
||||
ApplicationManager.getApplication().getMessageBus().connect(ApplicationManager.getApplication()).subscribe(AnActionListener.TOPIC, new AnActionListener() {
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
hideCurrent(null, action, event);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -78,7 +78,7 @@ public class ActionMacroManager implements PersistentStateComponent<Element>, Di
|
||||
myActionManager = actionManager;
|
||||
messageBus.connect(this).subscribe(AnActionListener.TOPIC, new AnActionListener() {
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, final AnActionEvent event) {
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull final AnActionEvent event) {
|
||||
String id = actionManager.getId(action);
|
||||
if (id == null) return;
|
||||
//noinspection HardCodedStringLiteral
|
||||
|
||||
@@ -200,6 +200,7 @@ public class DataManagerImpl extends DataManager {
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DataContext getDataContextTest(Component component) {
|
||||
DataContext dataContext = getDataContext(component);
|
||||
if (myWindowManager == null) {
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public class FileTypeExtensionUsagesCollectorStartupActivity implements StartupA
|
||||
});
|
||||
ApplicationManager.getApplication().getMessageBus().connect(project).subscribe(AnActionListener.TOPIC, new AnActionListener() {
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
if (action instanceof EditorAction && ((EditorAction)action).getHandler() instanceof EditorWriteActionHandler) {
|
||||
onChange(dataContext);
|
||||
}
|
||||
|
||||
+28
-46
@@ -13,6 +13,7 @@ import com.intellij.openapi.actionSystem.ex.CustomComponentAction;
|
||||
import com.intellij.openapi.application.impl.LaterInvocator;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.keymap.impl.IdeMouseEventDispatcher;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupAdapter;
|
||||
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
|
||||
@@ -33,9 +34,6 @@ import java.awt.event.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
import static com.intellij.openapi.keymap.impl.IdeMouseEventDispatcher.requestFocusInNonFocusedWindow;
|
||||
import static java.awt.event.KeyEvent.VK_SPACE;
|
||||
|
||||
public class ActionButton extends JComponent implements ActionButtonComponent, AnActionHolder, Accessible {
|
||||
private JBDimension myMinimumButtonSize;
|
||||
private PropertyChangeListener myPresentationListener;
|
||||
@@ -47,9 +45,9 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
private ActionButtonLook myLook = ActionButtonLook.SYSTEM_LOOK;
|
||||
private boolean myMouseDown;
|
||||
private boolean myRollover;
|
||||
private static boolean ourGlobalMouseDown = false;
|
||||
private static boolean ourGlobalMouseDown;
|
||||
|
||||
private boolean myNoIconsInPopup = false;
|
||||
private boolean myNoIconsInPopup;
|
||||
private Insets myInsets;
|
||||
|
||||
public ActionButton(@NotNull AnAction action,
|
||||
@@ -70,7 +68,7 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getModifiers() == 0 && e.getKeyCode() == VK_SPACE) {
|
||||
if (e.getModifiers() == 0 && e.getKeyCode() == KeyEvent.VK_SPACE) {
|
||||
click();
|
||||
}
|
||||
}
|
||||
@@ -94,7 +92,7 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
myNoIconsInPopup = noIconsInPopup;
|
||||
}
|
||||
|
||||
public void setMinimumButtonSize(@NotNull Dimension size) {
|
||||
void setMinimumButtonSize(@NotNull Dimension size) {
|
||||
myMinimumButtonSize = JBDimension.create(size);
|
||||
}
|
||||
|
||||
@@ -118,7 +116,7 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
return super.isEnabled() && myPresentation.isEnabled();
|
||||
}
|
||||
|
||||
protected boolean isButtonEnabled() {
|
||||
boolean isButtonEnabled() {
|
||||
return isEnabled();
|
||||
}
|
||||
|
||||
@@ -185,7 +183,7 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
}
|
||||
}
|
||||
|
||||
protected void showPopupMenu(AnActionEvent event, ActionGroup actionGroup) {
|
||||
private void showPopupMenu(AnActionEvent event, ActionGroup actionGroup) {
|
||||
final ActionManagerImpl am = (ActionManagerImpl) ActionManager.getInstance();
|
||||
ActionPopupMenuImpl popupMenu = (ActionPopupMenuImpl)am.createActionPopupMenu(event.getPlace(), actionGroup, new MenuItemPresentationFactory() {
|
||||
@Override
|
||||
@@ -196,7 +194,7 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
}
|
||||
}
|
||||
});
|
||||
popupMenu.setDataContextProvider(() -> this.getDataContext());
|
||||
popupMenu.setDataContextProvider(() -> getDataContext());
|
||||
|
||||
if (event.isFromActionToolbar()) {
|
||||
popupMenu.getComponent().show(this, 0, getHeight());
|
||||
@@ -206,7 +204,7 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isPopupMenuAction(AnActionEvent event, AnAction action) {
|
||||
private static boolean isPopupMenuAction(AnActionEvent event, AnAction action) {
|
||||
return action instanceof ActionGroup &&
|
||||
!(action instanceof CustomComponentAction) &&
|
||||
((ActionGroup) action).isPopup() &&
|
||||
@@ -244,7 +242,7 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
public void setToolTipText(String s) {
|
||||
if (!Registry.is("ide.helptooltip.enabled")) {
|
||||
String tooltipText = KeymapUtil.createTooltipText(s, myAction);
|
||||
super.setToolTipText(tooltipText.length() > 0 ? tooltipText : null);
|
||||
super.setToolTipText(tooltipText.isEmpty() ? null : tooltipText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,7 +348,7 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
paintDownArrowIfGroup(g);
|
||||
}
|
||||
|
||||
protected void jComponentPaint(Graphics g) {
|
||||
private void jComponentPaint(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
}
|
||||
|
||||
@@ -378,18 +376,13 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
}
|
||||
|
||||
public void setLook(ActionButtonLook look) {
|
||||
if (look != null) {
|
||||
myLook = look;
|
||||
}
|
||||
else {
|
||||
myLook = ActionButtonLook.SYSTEM_LOOK;
|
||||
}
|
||||
myLook = look == null ? ActionButtonLook.SYSTEM_LOOK : look;
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processMouseEvent(MouseEvent e) {
|
||||
requestFocusInNonFocusedWindow(e);
|
||||
IdeMouseEventDispatcher.requestFocusInNonFocusedWindow(e);
|
||||
super.processMouseEvent(e);
|
||||
if (e.isConsumed()) return;
|
||||
boolean skipPress = checkSkipPressForEvent(e);
|
||||
@@ -398,7 +391,6 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
if (skipPress || !isButtonEnabled()) return;
|
||||
myMouseDown = true;
|
||||
ourGlobalMouseDown = true;
|
||||
onMousePressed(e);
|
||||
repaint();
|
||||
break;
|
||||
|
||||
@@ -406,7 +398,6 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
if (skipPress || !isButtonEnabled()) return;
|
||||
myMouseDown = false;
|
||||
ourGlobalMouseDown = false;
|
||||
onMouseReleased(e);
|
||||
if (myRollover) {
|
||||
performAction(e);
|
||||
}
|
||||
@@ -429,15 +420,7 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
}
|
||||
}
|
||||
|
||||
protected void onMouseReleased(@NotNull MouseEvent e) {
|
||||
// Extension point
|
||||
}
|
||||
|
||||
protected void onMousePressed(@NotNull MouseEvent e) {
|
||||
// Extension point
|
||||
}
|
||||
|
||||
protected boolean checkSkipPressForEvent(@NotNull MouseEvent e) {
|
||||
private static boolean checkSkipPressForEvent(@NotNull MouseEvent e) {
|
||||
return e.isMetaDown() || e.getButton() != MouseEvent.BUTTON1;
|
||||
}
|
||||
|
||||
@@ -482,17 +465,18 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
// Accessibility
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public AccessibleContext getAccessibleContext() {
|
||||
if(this.accessibleContext == null) {
|
||||
this.accessibleContext = new AccessibleActionButton();
|
||||
AccessibleContext context = accessibleContext;
|
||||
if(context == null) {
|
||||
accessibleContext = context = new AccessibleActionButton();
|
||||
}
|
||||
|
||||
return this.accessibleContext;
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
protected class AccessibleActionButton extends JComponent.AccessibleJComponent implements AccessibleAction {
|
||||
public AccessibleActionButton() {
|
||||
AccessibleActionButton() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -504,11 +488,11 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
public String getAccessibleName() {
|
||||
String name = accessibleName;
|
||||
if (name == null) {
|
||||
name = (String)ActionButton.this.getClientProperty(ACCESSIBLE_NAME_PROPERTY);
|
||||
name = (String)getClientProperty(ACCESSIBLE_NAME_PROPERTY);
|
||||
if (name == null) {
|
||||
name = ActionButton.this.getToolTipText();
|
||||
if (name == null) {
|
||||
name = ActionButton.this.myPresentation.getText();
|
||||
name = myPresentation.getText();
|
||||
if (name == null) {
|
||||
name = super.getAccessibleName();
|
||||
}
|
||||
@@ -526,7 +510,7 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
|
||||
@Override
|
||||
public AccessibleIcon[] getAccessibleIcon() {
|
||||
Icon icon = ActionButton.this.getIcon();
|
||||
Icon icon = getIcon();
|
||||
if (icon instanceof Accessible) {
|
||||
AccessibleContext context = ((Accessible)icon).getAccessibleContext();
|
||||
if (context instanceof AccessibleIcon) {
|
||||
@@ -540,7 +524,7 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
@Override
|
||||
public AccessibleStateSet getAccessibleStateSet() {
|
||||
AccessibleStateSet var1 = super.getAccessibleStateSet();
|
||||
int state = ActionButton.this.getPopState();
|
||||
int state = getPopState();
|
||||
|
||||
// TODO: Not sure what the "POPPED" state represents
|
||||
//if (state == POPPED) {
|
||||
@@ -554,7 +538,7 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
var1.add(AccessibleState.CHECKED);
|
||||
}
|
||||
|
||||
if (ActionButton.this.isFocusOwner()) {
|
||||
if (isFocusOwner()) {
|
||||
var1.add(AccessibleState.FOCUSED);
|
||||
}
|
||||
|
||||
@@ -580,13 +564,11 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
|
||||
@Override
|
||||
public boolean doAccessibleAction(int index) {
|
||||
if (index == 0) { //
|
||||
ActionButton.this.click();
|
||||
if (index == 0) {
|
||||
click();
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+93
-129
@@ -15,7 +15,6 @@ import com.intellij.internal.statistic.collectors.fus.actions.persistence.Action
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
|
||||
import com.intellij.openapi.actionSystem.ex.ActionPopupMenuListener;
|
||||
import com.intellij.openapi.actionSystem.ex.ActionUtil;
|
||||
import com.intellij.openapi.actionSystem.ex.AnActionListener;
|
||||
import com.intellij.openapi.application.*;
|
||||
@@ -31,7 +30,6 @@ import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.ProjectType;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -48,7 +46,6 @@ import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.pico.CachingConstructorInjectionComponentAdapter;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TObjectIntHashMap;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -57,49 +54,52 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.Timer;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public final class ActionManagerImpl extends ActionManagerEx implements Disposable {
|
||||
public static final String ACTION_ELEMENT_NAME = "action";
|
||||
public static final String GROUP_ELEMENT_NAME = "group";
|
||||
public static final String CLASS_ATTR_NAME = "class";
|
||||
public static final String ID_ATTR_NAME = "id";
|
||||
public static final String INTERNAL_ATTR_NAME = "internal";
|
||||
public static final String ICON_ATTR_NAME = "icon";
|
||||
public static final String ADD_TO_GROUP_ELEMENT_NAME = "add-to-group";
|
||||
public static final String SHORTCUT_ELEMENT_NAME = "keyboard-shortcut";
|
||||
public static final String MOUSE_SHORTCUT_ELEMENT_NAME = "mouse-shortcut";
|
||||
public static final String DESCRIPTION = "description";
|
||||
public static final String TEXT_ATTR_NAME = "text";
|
||||
public static final String POPUP_ATTR_NAME = "popup";
|
||||
public static final String COMPACT_ATTR_NAME = "compact";
|
||||
public static final String SEPARATOR_ELEMENT_NAME = "separator";
|
||||
public static final String REFERENCE_ELEMENT_NAME = "reference";
|
||||
public static final String ABBREVIATION_ELEMENT_NAME = "abbreviation";
|
||||
public static final String GROUPID_ATTR_NAME = "group-id";
|
||||
public static final String ANCHOR_ELEMENT_NAME = "anchor";
|
||||
public static final String FIRST = "first";
|
||||
public static final String LAST = "last";
|
||||
public static final String BEFORE = "before";
|
||||
public static final String AFTER = "after";
|
||||
public static final String SECONDARY = "secondary";
|
||||
public static final String RELATIVE_TO_ACTION_ATTR_NAME = "relative-to-action";
|
||||
public static final String FIRST_KEYSTROKE_ATTR_NAME = "first-keystroke";
|
||||
public static final String SECOND_KEYSTROKE_ATTR_NAME = "second-keystroke";
|
||||
public static final String REMOVE_SHORTCUT_ATTR_NAME = "remove";
|
||||
public static final String REPLACE_SHORTCUT_ATTR_NAME = "replace-all";
|
||||
public static final String KEYMAP_ATTR_NAME = "keymap";
|
||||
public static final String KEYSTROKE_ATTR_NAME = "keystroke";
|
||||
public static final String REF_ATTR_NAME = "ref";
|
||||
public static final String VALUE_ATTR_NAME = "value";
|
||||
public static final String ACTIONS_BUNDLE = "messages.ActionsBundle";
|
||||
public static final String USE_SHORTCUT_OF_ATTR_NAME = "use-shortcut-of";
|
||||
public static final String OVERRIDES_ATTR_NAME = "overrides";
|
||||
public static final String KEEP_CONTENT_ATTR_NAME = "keep-content";
|
||||
public static final String PROJECT_TYPE = "project-type";
|
||||
public static final String UNREGISTER_ELEMENT_NAME = "unregister";
|
||||
private static final String ACTION_ELEMENT_NAME = "action";
|
||||
private static final String GROUP_ELEMENT_NAME = "group";
|
||||
private static final String CLASS_ATTR_NAME = "class";
|
||||
private static final String ID_ATTR_NAME = "id";
|
||||
private static final String INTERNAL_ATTR_NAME = "internal";
|
||||
private static final String ICON_ATTR_NAME = "icon";
|
||||
private static final String ADD_TO_GROUP_ELEMENT_NAME = "add-to-group";
|
||||
private static final String SHORTCUT_ELEMENT_NAME = "keyboard-shortcut";
|
||||
private static final String MOUSE_SHORTCUT_ELEMENT_NAME = "mouse-shortcut";
|
||||
private static final String DESCRIPTION = "description";
|
||||
private static final String TEXT_ATTR_NAME = "text";
|
||||
private static final String POPUP_ATTR_NAME = "popup";
|
||||
private static final String COMPACT_ATTR_NAME = "compact";
|
||||
private static final String SEPARATOR_ELEMENT_NAME = "separator";
|
||||
private static final String REFERENCE_ELEMENT_NAME = "reference";
|
||||
private static final String ABBREVIATION_ELEMENT_NAME = "abbreviation";
|
||||
private static final String GROUPID_ATTR_NAME = "group-id";
|
||||
private static final String ANCHOR_ELEMENT_NAME = "anchor";
|
||||
private static final String FIRST = "first";
|
||||
private static final String LAST = "last";
|
||||
private static final String BEFORE = "before";
|
||||
private static final String AFTER = "after";
|
||||
private static final String SECONDARY = "secondary";
|
||||
private static final String RELATIVE_TO_ACTION_ATTR_NAME = "relative-to-action";
|
||||
private static final String FIRST_KEYSTROKE_ATTR_NAME = "first-keystroke";
|
||||
private static final String SECOND_KEYSTROKE_ATTR_NAME = "second-keystroke";
|
||||
private static final String REMOVE_SHORTCUT_ATTR_NAME = "remove";
|
||||
private static final String REPLACE_SHORTCUT_ATTR_NAME = "replace-all";
|
||||
private static final String KEYMAP_ATTR_NAME = "keymap";
|
||||
private static final String KEYSTROKE_ATTR_NAME = "keystroke";
|
||||
private static final String REF_ATTR_NAME = "ref";
|
||||
private static final String VALUE_ATTR_NAME = "value";
|
||||
private static final String ACTIONS_BUNDLE = "messages.ActionsBundle";
|
||||
private static final String USE_SHORTCUT_OF_ATTR_NAME = "use-shortcut-of";
|
||||
private static final String OVERRIDES_ATTR_NAME = "overrides";
|
||||
private static final String KEEP_CONTENT_ATTR_NAME = "keep-content";
|
||||
private static final String PROJECT_TYPE = "project-type";
|
||||
private static final String UNREGISTER_ELEMENT_NAME = "unregister";
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.actionSystem.impl.ActionManagerImpl");
|
||||
private static final int DEACTIVATED_TIMER_DELAY = 5000;
|
||||
@@ -108,16 +108,15 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
|
||||
private final Object myLock = new Object();
|
||||
private final Map<String,AnAction> myId2Action = new THashMap<>();
|
||||
private final Map<PluginId, THashSet<String>> myPlugin2Id = new THashMap<>();
|
||||
private final MultiMap<PluginId, String> myPlugin2Id = new MultiMap<>();
|
||||
private final TObjectIntHashMap<String> myId2Index = new TObjectIntHashMap<>();
|
||||
private final Map<Object,String> myAction2Id = new THashMap<>();
|
||||
private final MultiMap<String,String> myId2GroupId = new MultiMap<>();
|
||||
private final List<String> myNotRegisteredInternalActionIds = new ArrayList<>();
|
||||
private final List<AnActionListener> myActionListeners = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
private final List<ActionPopupMenuListener> myActionPopupMenuListeners = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
private final KeymapManagerEx myKeymapManager;
|
||||
private final DataManager myDataManager;
|
||||
private final List<Object> myPopups = new ArrayList<>();
|
||||
private final List<Object/*ActionPopupMenuImpl|JBPopup*/> myPopups = new ArrayList<>();
|
||||
private final Map<AnAction, DataContext> myQueuedNotifications = new LinkedHashMap<>();
|
||||
private final Map<AnAction, AnActionEvent> myQueuedNotificationsEvents = new LinkedHashMap<>();
|
||||
private MyTimer myTimer;
|
||||
@@ -126,9 +125,8 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
private String myPrevPerformedActionId;
|
||||
private long myLastTimeEditorWasTypedIn;
|
||||
private boolean myTransparentOnlyUpdate;
|
||||
private final Map<OverridingAction, AnAction> myBaseActions = new HashMap<>();
|
||||
private final AnActionListener messageBusPublisher;
|
||||
private int myAnonymousGroupIdCounter = 0;
|
||||
private int myAnonymousGroupIdCounter;
|
||||
|
||||
ActionManagerImpl(@NotNull KeymapManager keymapManager, DataManager dataManager, @NotNull MessageBus messageBus) {
|
||||
myKeymapManager = (KeymapManagerEx)keymapManager;
|
||||
@@ -258,10 +256,10 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
return CommonBundle.messageOrDefault(bundle, elementType + "." + id + "." + TEXT_ATTR_NAME, value == null ? "" : value);
|
||||
}
|
||||
|
||||
public static boolean checkRelativeToAction(final String relativeToActionId,
|
||||
@NotNull final Anchor anchor,
|
||||
@NotNull final String actionName,
|
||||
@Nullable final PluginId pluginId) {
|
||||
private static boolean checkRelativeToAction(final String relativeToActionId,
|
||||
@NotNull final Anchor anchor,
|
||||
@NotNull final String actionName,
|
||||
@Nullable final PluginId pluginId) {
|
||||
if ((Anchor.BEFORE == anchor || Anchor.AFTER == anchor) && relativeToActionId == null) {
|
||||
reportActionError(pluginId, actionName + ": \"relative-to-action\" cannot be null if anchor is \"after\" or \"before\"");
|
||||
return false;
|
||||
@@ -270,9 +268,9 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Anchor parseAnchor(final String anchorStr,
|
||||
@Nullable final String actionName,
|
||||
@Nullable final PluginId pluginId) {
|
||||
private static Anchor parseAnchor(final String anchorStr,
|
||||
@Nullable final String actionName,
|
||||
@Nullable final PluginId pluginId) {
|
||||
if (anchorStr == null) {
|
||||
return Anchor.LAST;
|
||||
}
|
||||
@@ -383,22 +381,22 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTimerListener(int delay, final TimerListener listener) {
|
||||
public void addTimerListener(int delay, @NotNull final TimerListener listener) {
|
||||
_addTimerListener(listener, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTimerListener(TimerListener listener) {
|
||||
public void removeTimerListener(@NotNull TimerListener listener) {
|
||||
_removeTimerListener(listener, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTransparentTimerListener(int delay, TimerListener listener) {
|
||||
public void addTransparentTimerListener(int delay, @NotNull TimerListener listener) {
|
||||
_addTimerListener(listener, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTransparentTimerListener(TimerListener listener) {
|
||||
public void removeTransparentTimerListener(@NotNull TimerListener listener) {
|
||||
_removeTimerListener(listener, true);
|
||||
}
|
||||
|
||||
@@ -425,7 +423,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ActionPopupMenu createActionPopupMenu(String place, @NotNull ActionGroup group) {
|
||||
public ActionPopupMenu createActionPopupMenu(@NotNull String place, @NotNull ActionGroup group) {
|
||||
return new ActionPopupMenuImpl(place, group, this, null);
|
||||
}
|
||||
|
||||
@@ -437,7 +435,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ActionToolbar createActionToolbar(final String place, @NotNull final ActionGroup group, final boolean horizontal, final boolean decorateButtons) {
|
||||
public ActionToolbar createActionToolbar(@NotNull final String place, @NotNull final ActionGroup group, final boolean horizontal, final boolean decorateButtons) {
|
||||
return new ActionToolbarImpl(place, group, horizontal, decorateButtons, myDataManager, this, myKeymapManager);
|
||||
}
|
||||
|
||||
@@ -461,7 +459,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private AnAction getActionImpl(String id, boolean canReturnStub) {
|
||||
private AnAction getActionImpl(@NotNull String id, boolean canReturnStub) {
|
||||
AnAction action;
|
||||
synchronized (myLock) {
|
||||
action = myId2Action.get(id);
|
||||
@@ -510,6 +508,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String[] getActionIds(@NotNull String idPrefix) {
|
||||
synchronized (myLock) {
|
||||
@@ -530,12 +529,12 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JComponent createButtonToolbar(final String actionPlace, @NotNull final ActionGroup messageActionGroup) {
|
||||
public JComponent createButtonToolbar(@NotNull final String actionPlace, @NotNull final ActionGroup messageActionGroup) {
|
||||
return new ButtonToolbarImpl(actionPlace, messageActionGroup, myDataManager, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnAction getActionOrStub(String id) {
|
||||
public AnAction getActionOrStub(@NotNull String id) {
|
||||
return getActionImpl(id, true);
|
||||
}
|
||||
|
||||
@@ -632,17 +631,15 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
reportActionError(pluginId, "unexpected name of element \"" + element.getName() + "\"");
|
||||
return null;
|
||||
}
|
||||
boolean customClass = false;
|
||||
String className = element.getAttributeValue(CLASS_ATTR_NAME);
|
||||
if (className == null) { // use default group if class isn't specified
|
||||
if ("true".equals(element.getAttributeValue(COMPACT_ATTR_NAME))) {
|
||||
className = DefaultCompactActionGroup.class.getName();
|
||||
} else {
|
||||
className = DefaultActionGroup.class.getName();
|
||||
}
|
||||
className = "true".equals(element.getAttributeValue(COMPACT_ATTR_NAME))
|
||||
? DefaultCompactActionGroup.class.getName()
|
||||
: DefaultActionGroup.class.getName();
|
||||
}
|
||||
try {
|
||||
ActionGroup group;
|
||||
boolean customClass = false;
|
||||
if (DefaultActionGroup.class.getName().equals(className)) {
|
||||
group = new DefaultActionGroup();
|
||||
} else if (DefaultCompactActionGroup.class.getName().equals(className)) {
|
||||
@@ -677,7 +674,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
}
|
||||
|
||||
if (id == null) {
|
||||
id = "<anonymous-group-" + (myAnonymousGroupIdCounter++) + ">";
|
||||
id = "<anonymous-group-" + myAnonymousGroupIdCounter++ + ">";
|
||||
}
|
||||
|
||||
registerOrReplaceActionInner(element, id, group, pluginId);
|
||||
@@ -991,7 +988,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
myId2Index.put(actionId, myRegisteredActionsCount++);
|
||||
myAction2Id.put(action, actionId);
|
||||
if (pluginId != null && !(action instanceof ActionGroup)){
|
||||
myPlugin2Id.computeIfAbsent(pluginId, k -> new THashSet<>()).add(actionId);
|
||||
myPlugin2Id.putValue(pluginId, actionId);
|
||||
}
|
||||
action.registerCustomShortcutSet(new ProxyShortcutSet(actionId, myKeymapManager), null);
|
||||
}
|
||||
@@ -1056,11 +1053,10 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
AnAction oldValue = myId2Action.remove(actionId);
|
||||
myAction2Id.remove(oldValue);
|
||||
myId2Index.remove(actionId);
|
||||
for (PluginId pluginName : myPlugin2Id.keySet()) {
|
||||
final THashSet<String> pluginActions = myPlugin2Id.get(pluginName);
|
||||
if (pluginActions != null) {
|
||||
pluginActions.remove(actionId);
|
||||
}
|
||||
|
||||
for (final Map.Entry<PluginId, Collection<String>> entry : myPlugin2Id.entrySet()) {
|
||||
Collection<String> pluginActions = entry.getValue();
|
||||
pluginActions.remove(actionId);
|
||||
}
|
||||
if (removeFromGroups) {
|
||||
for (String groupId : myId2GroupId.get(actionId)) {
|
||||
@@ -1086,22 +1082,12 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
return ArrayUtilRt.toStringArray(myPlugin2Id.get(pluginName));
|
||||
}
|
||||
|
||||
public void addActionPopup(final Object menu) {
|
||||
boolean added = myPopups.add(menu);
|
||||
if (added && menu instanceof ActionPopupMenu) {
|
||||
for (ActionPopupMenuListener listener : myActionPopupMenuListeners) {
|
||||
listener.actionPopupMenuCreated((ActionPopupMenu)menu);
|
||||
}
|
||||
}
|
||||
void addActionPopup(@NotNull Object /*ActionPopupMenuImpl|JBPopup*/menu) {
|
||||
myPopups.add(menu);
|
||||
}
|
||||
|
||||
void removeActionPopup(final Object menu) {
|
||||
void removeActionPopup(@NotNull Object /*ActionPopupMenuImpl|JBPopup*/ menu) {
|
||||
final boolean removed = myPopups.remove(menu);
|
||||
if (removed && menu instanceof ActionPopupMenu) {
|
||||
for (ActionPopupMenuListener listener : myActionPopupMenuListeners) {
|
||||
listener.actionPopupMenuReleased((ActionPopupMenu)menu);
|
||||
}
|
||||
}
|
||||
if (removed && myPopups.isEmpty()) {
|
||||
flushActionPerformed();
|
||||
}
|
||||
@@ -1137,17 +1123,6 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
return myTransparentOnlyUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addActionPopupMenuListener(ActionPopupMenuListener listener, Disposable parentDisposable) {
|
||||
myActionPopupMenuListeners.add(listener);
|
||||
Disposer.register(parentDisposable, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
myActionPopupMenuListeners.remove(listener);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replaceAction(@NotNull String actionId, @NotNull AnAction newAction) {
|
||||
Class callerClass = ReflectionUtil.getGrandCallerClass();
|
||||
@@ -1158,9 +1133,6 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
private AnAction replaceAction(@NotNull String actionId, @NotNull AnAction newAction, @Nullable PluginId pluginId) {
|
||||
AnAction oldAction = newAction instanceof OverridingAction ? getAction(actionId) : getActionOrStub(actionId);
|
||||
if (oldAction != null) {
|
||||
if (newAction instanceof OverridingAction) {
|
||||
myBaseActions.put((OverridingAction) newAction, oldAction);
|
||||
}
|
||||
boolean isGroup = oldAction instanceof ActionGroup;
|
||||
if (isGroup != newAction instanceof ActionGroup) {
|
||||
throw new IllegalStateException("cannot replace a group with an action and vice versa: " + actionId);
|
||||
@@ -1178,17 +1150,10 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
return oldAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the action overridden by the specified overriding action (with overrides="true" in plugin.xml).
|
||||
*/
|
||||
public AnAction getBaseAction(OverridingAction overridingAction) {
|
||||
return myBaseActions.get(overridingAction);
|
||||
}
|
||||
|
||||
private void flushActionPerformed() {
|
||||
final Set<AnAction> actions = myQueuedNotifications.keySet();
|
||||
for (final AnAction eachAction : actions) {
|
||||
final DataContext eachContext = myQueuedNotifications.get(eachAction);
|
||||
for (final Map.Entry<AnAction, DataContext> entry : myQueuedNotifications.entrySet()) {
|
||||
AnAction eachAction = entry.getKey();
|
||||
final DataContext eachContext = entry.getValue();
|
||||
fireAfterActionPerformed(eachAction, eachContext, myQueuedNotificationsEvents.get(eachAction));
|
||||
}
|
||||
myQueuedNotifications.clear();
|
||||
@@ -1222,7 +1187,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireAfterActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void fireAfterActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
myPrevPerformedActionId = myLastPreformedActionId;
|
||||
myLastPreformedActionId = getId(action);
|
||||
//noinspection AssignmentToStaticFieldFromInstanceMethod
|
||||
@@ -1297,6 +1262,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ActionCallback tryToExecute(@NotNull final AnAction action, @NotNull final InputEvent inputEvent, @Nullable final Component contextComponent, @Nullable final String place,
|
||||
boolean now) {
|
||||
@@ -1309,7 +1275,8 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
|
||||
if (now) {
|
||||
doRunnable.run();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(doRunnable);
|
||||
}
|
||||
@@ -1351,15 +1318,12 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
|
||||
fireBeforeActionPerformed(action, context, event);
|
||||
|
||||
UIUtil.addAwtListener(new AWTEventListener() {
|
||||
@Override
|
||||
public void eventDispatched(AWTEvent event) {
|
||||
if (event.getID() == WindowEvent.WINDOW_OPENED ||event.getID() == WindowEvent.WINDOW_ACTIVATED) {
|
||||
if (!result.isProcessed()) {
|
||||
final WindowEvent we = (WindowEvent)event;
|
||||
IdeFocusManager.findInstanceByComponent(we.getWindow()).doWhenFocusSettlesDown(result.createSetDoneRunnable(),
|
||||
ModalityState.defaultModalityState());
|
||||
}
|
||||
UIUtil.addAwtListener(event1 -> {
|
||||
if (event1.getID() == WindowEvent.WINDOW_OPENED || event1.getID() == WindowEvent.WINDOW_ACTIVATED) {
|
||||
if (!result.isProcessed()) {
|
||||
final WindowEvent we = (WindowEvent)event1;
|
||||
IdeFocusManager.findInstanceByComponent(we.getWindow()).doWhenFocusSettlesDown(result.createSetDoneRunnable(),
|
||||
ModalityState.defaultModalityState());
|
||||
}
|
||||
}
|
||||
}, AWTEvent.WINDOW_EVENT_MASK, result);
|
||||
@@ -1400,11 +1364,11 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
return "Action manager timer";
|
||||
}
|
||||
|
||||
public void addTimerListener(TimerListener listener, boolean transparent){
|
||||
void addTimerListener(@NotNull TimerListener listener, boolean transparent){
|
||||
(transparent ? myTransparentTimerListeners : myTimerListeners).add(listener);
|
||||
}
|
||||
|
||||
public void removeTimerListener(TimerListener listener, boolean transparent){
|
||||
void removeTimerListener(@NotNull TimerListener listener, boolean transparent){
|
||||
(transparent ? myTransparentTimerListeners : myTimerListeners).remove(listener);
|
||||
}
|
||||
|
||||
@@ -1424,8 +1388,8 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
boolean transparentOnly = myLastTimePerformed == lastEventCount;
|
||||
|
||||
try {
|
||||
Set<TimerListener> notified = new HashSet<>();
|
||||
myTransparentOnlyUpdate = transparentOnly;
|
||||
Set<TimerListener> notified = new HashSet<>();
|
||||
notifyListeners(myTransparentTimerListeners, notified);
|
||||
|
||||
if (transparentOnly) {
|
||||
@@ -1439,7 +1403,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyListeners(final List<TimerListener> timerListeners, final Set<? super TimerListener> notified) {
|
||||
private void notifyListeners(final List<? extends TimerListener> timerListeners, final Set<? super TimerListener> notified) {
|
||||
for (TimerListener listener : timerListeners) {
|
||||
if (notified.add(listener)) {
|
||||
runListenerAction(listener);
|
||||
@@ -1447,7 +1411,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
}
|
||||
}
|
||||
|
||||
private void runListenerAction(final TimerListener listener) {
|
||||
private void runListenerAction(@NotNull TimerListener listener) {
|
||||
ModalityState modalityState = listener.getModalityState();
|
||||
if (modalityState == null) return;
|
||||
LOG.debug("notify ", listener);
|
||||
|
||||
+79
-127
@@ -42,8 +42,6 @@ import org.jetbrains.concurrency.CancellablePromise;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
@@ -57,12 +55,9 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
private static final String RIGHT_ALIGN_KEY = "RIGHT_ALIGN";
|
||||
|
||||
static {
|
||||
JBUI.addPropertyChangeListener(JBUI.USER_SCALE_FACTOR_PROPERTY, new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
((JBDimension)ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE).update();
|
||||
((JBDimension)ActionToolbar.NAVBAR_MINIMUM_BUTTON_SIZE).update();
|
||||
}
|
||||
JBUI.addPropertyChangeListener(JBUI.USER_SCALE_FACTOR_PROPERTY, __ -> {
|
||||
((JBDimension)ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE).update();
|
||||
((JBDimension)ActionToolbar.NAVBAR_MINIMUM_BUTTON_SIZE).update();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -94,8 +89,9 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
private int myLayoutPolicy;
|
||||
private int myOrientation;
|
||||
private final ActionGroup myActionGroup;
|
||||
@NotNull
|
||||
private final String myPlace;
|
||||
protected List<AnAction> myVisibleActions;
|
||||
List<? extends AnAction> myVisibleActions;
|
||||
private final PresentationFactory myPresentationFactory = new PresentationFactory();
|
||||
private final boolean myDecorateButtons;
|
||||
|
||||
@@ -106,7 +102,6 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
*/
|
||||
private boolean myAdjustTheSameSize;
|
||||
|
||||
private final ActionButtonLook myButtonLook = null;
|
||||
private final ActionButtonLook myMinimalButtonLook = ActionButtonLook.INPLACE_LOOK;
|
||||
private final DataManager myDataManager;
|
||||
protected final ActionManagerEx myActionManager;
|
||||
@@ -114,10 +109,10 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
private Rectangle myAutoPopupRec;
|
||||
|
||||
private final DefaultActionGroup mySecondaryActions = new DefaultActionGroup();
|
||||
private PopupStateModifier mySecondaryButtonPopupStateModifier = null;
|
||||
private boolean myForceMinimumSize = false;
|
||||
private boolean myForceShowFirstComponent = false;
|
||||
private boolean mySkipWindowAdjustments = false;
|
||||
private PopupStateModifier mySecondaryButtonPopupStateModifier;
|
||||
private boolean myForceMinimumSize;
|
||||
private boolean myForceShowFirstComponent;
|
||||
private boolean mySkipWindowAdjustments;
|
||||
private boolean myMinimalMode;
|
||||
private boolean myForceUseMacEnhancements;
|
||||
|
||||
@@ -132,10 +127,9 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
|
||||
private JComponent myTargetComponent;
|
||||
private boolean myReservePlaceAutoPopupIcon = true;
|
||||
private boolean myAddSeparatorFirst;
|
||||
private boolean myShowSeparatorTitles = false;
|
||||
private boolean myShowSeparatorTitles;
|
||||
|
||||
public ActionToolbarImpl(String place,
|
||||
public ActionToolbarImpl(@NotNull String place,
|
||||
@NotNull final ActionGroup actionGroup,
|
||||
boolean horizontal,
|
||||
@NotNull DataManager dataManager,
|
||||
@@ -144,7 +138,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
this(place, actionGroup, horizontal, false, dataManager, actionManager, keymapManager, false);
|
||||
}
|
||||
|
||||
public ActionToolbarImpl(String place,
|
||||
public ActionToolbarImpl(@NotNull String place,
|
||||
@NotNull ActionGroup actionGroup,
|
||||
boolean horizontal,
|
||||
boolean decorateButtons,
|
||||
@@ -154,7 +148,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
this(place, actionGroup, horizontal, decorateButtons, dataManager, actionManager, keymapManager, false);
|
||||
}
|
||||
|
||||
public ActionToolbarImpl(String place,
|
||||
public ActionToolbarImpl(@NotNull String place,
|
||||
@NotNull ActionGroup actionGroup,
|
||||
final boolean horizontal,
|
||||
final boolean decorateButtons,
|
||||
@@ -199,6 +193,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getPlace() {
|
||||
return myPlace;
|
||||
}
|
||||
@@ -278,35 +273,30 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
if (doMacEnhancementsForMainToolbar()) {
|
||||
final Rectangle r = getBounds();
|
||||
UIUtil.drawGradientHToolbarBackground(g, r.width, r.height);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
super.paintComponent(g);
|
||||
}
|
||||
|
||||
if (myLayoutPolicy == AUTO_LAYOUT_POLICY) {
|
||||
if (myAutoPopupRec != null) {
|
||||
if (myOrientation == SwingConstants.HORIZONTAL) {
|
||||
final int dy = myAutoPopupRec.height / 2 - AllIcons.Ide.Link.getIconHeight() / 2;
|
||||
AllIcons.Ide.Link.paintIcon(this, g, (int)myAutoPopupRec.getMaxX() - AllIcons.Ide.Link.getIconWidth() - 1, myAutoPopupRec.y + dy);
|
||||
}
|
||||
else {
|
||||
final int dx = myAutoPopupRec.width / 2 - AllIcons.Ide.Link.getIconWidth() / 2;
|
||||
AllIcons.Ide.Link.paintIcon(this, g, myAutoPopupRec.x + dx, (int)myAutoPopupRec.getMaxY() - AllIcons.Ide.Link.getIconWidth() - 1);
|
||||
}
|
||||
if (myLayoutPolicy == AUTO_LAYOUT_POLICY && myAutoPopupRec != null) {
|
||||
if (myOrientation == SwingConstants.HORIZONTAL) {
|
||||
final int dy = myAutoPopupRec.height / 2 - AllIcons.Ide.Link.getIconHeight() / 2;
|
||||
AllIcons.Ide.Link.paintIcon(this, g, (int)myAutoPopupRec.getMaxX() - AllIcons.Ide.Link.getIconWidth() - 1, myAutoPopupRec.y + dy);
|
||||
}
|
||||
else {
|
||||
final int dx = myAutoPopupRec.width / 2 - AllIcons.Ide.Link.getIconWidth() / 2;
|
||||
AllIcons.Ide.Link.paintIcon(this, g, myAutoPopupRec.x + dx, (int)myAutoPopupRec.getMaxY() - AllIcons.Ide.Link.getIconWidth() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setSecondaryButtonPopupStateModifier(PopupStateModifier popupStateModifier) {
|
||||
public void setSecondaryButtonPopupStateModifier(@NotNull PopupStateModifier popupStateModifier) {
|
||||
mySecondaryButtonPopupStateModifier = popupStateModifier;
|
||||
}
|
||||
|
||||
private void fillToolBar(final List<AnAction> actions, boolean layoutSecondaries) {
|
||||
final List<AnAction> rightAligned = new ArrayList<>();
|
||||
private void fillToolBar(@NotNull final List<? extends AnAction> actions, boolean layoutSecondaries) {
|
||||
boolean isLastElementSeparator = false;
|
||||
if (myAddSeparatorFirst) {
|
||||
add(new MySeparator(null));
|
||||
isLastElementSeparator = true;
|
||||
}
|
||||
final List<AnAction> rightAligned = new ArrayList<>();
|
||||
for (int i = 0; i < actions.size(); i++) {
|
||||
final AnAction action = actions.get(i);
|
||||
if (action instanceof RightAlignedToolbarAction) {
|
||||
@@ -359,21 +349,10 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
}
|
||||
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) {
|
||||
@NotNull
|
||||
private JComponent getCustomComponent(@NotNull AnAction action) {
|
||||
Presentation presentation = myPresentationFactory.getPresentation(action);
|
||||
JComponent customComponent = presentation.getClientProperty(CustomComponentAction.COMPONENT_KEY);
|
||||
if (customComponent == null) {
|
||||
@@ -404,11 +383,17 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Dimension getMinimumButtonSize() {
|
||||
return isInsideNavBar() ? NAVBAR_MINIMUM_BUTTON_SIZE : DEFAULT_MINIMUM_BUTTON_SIZE;
|
||||
}
|
||||
|
||||
public ActionButton createToolbarButton(final AnAction action, final ActionButtonLook look, final String place, final Presentation presentation, final Dimension minimumSize) {
|
||||
@NotNull
|
||||
private ActionButton createToolbarButton(@NotNull AnAction action,
|
||||
final ActionButtonLook look,
|
||||
@NotNull String place,
|
||||
@NotNull Presentation presentation,
|
||||
@NotNull Dimension minimumSize) {
|
||||
if (action.displayTextInToolbar()) {
|
||||
int mnemonic = KeyEvent.getExtendedKeyCodeForChar(action.getTemplatePresentation().getMnemonic());
|
||||
|
||||
@@ -419,16 +404,8 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
};
|
||||
|
||||
if (mnemonic != KeyEvent.VK_UNDEFINED) {
|
||||
buttonWithText.registerKeyboardAction(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
buttonWithText.click();
|
||||
}
|
||||
}, KeyStroke.getKeyStroke(mnemonic,
|
||||
/*SystemInfo.isMac
|
||||
? InputEvent.CTRL_DOWN_MASK |
|
||||
InputEvent.ALT_DOWN_MASK
|
||||
:*/ InputEvent.ALT_DOWN_MASK), WHEN_IN_FOCUSED_WINDOW);
|
||||
buttonWithText.registerKeyboardAction(__ -> buttonWithText.click(), KeyStroke.getKeyStroke(mnemonic,
|
||||
InputEvent.ALT_DOWN_MASK), WHEN_IN_FOCUSED_WINDOW);
|
||||
}
|
||||
tweakActionComponentUI(buttonWithText);
|
||||
return buttonWithText;
|
||||
@@ -454,11 +431,13 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
return actionButton;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private HelpTooltip.Alignment tooltipLocation() {
|
||||
return myOrientation == SwingConstants.VERTICAL ? HelpTooltip.Alignment.RIGHT: HelpTooltip.Alignment.BOTTOM;
|
||||
}
|
||||
|
||||
private ActionButton createToolbarButton(final AnAction action) {
|
||||
@NotNull
|
||||
private ActionButton createToolbarButton(@NotNull AnAction action) {
|
||||
return createToolbarButton(
|
||||
action,
|
||||
myMinimalMode ? myMinimalButtonLook : myDecorateButtons ? new ActionButtonLook() {
|
||||
@@ -475,7 +454,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
((Graphics2D)g).fill(g.getClip());
|
||||
}
|
||||
}
|
||||
} : myButtonLook,
|
||||
} : null,
|
||||
myPlace, myPresentationFactory.getPresentation(action),
|
||||
myMinimumButtonSize.size());
|
||||
}
|
||||
@@ -531,7 +510,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
return height;
|
||||
}
|
||||
|
||||
private void calculateBoundsNowrapImpl(List<? extends Rectangle> bounds) {
|
||||
private void calculateBoundsNowrapImpl(@NotNull List<? extends Rectangle> bounds) {
|
||||
final int componentCount = getComponentCount();
|
||||
LOG.assertTrue(componentCount <= bounds.size());
|
||||
|
||||
@@ -585,7 +564,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateBoundsAutoImp(Dimension sizeToFit, List<? extends Rectangle> bounds) {
|
||||
private void calculateBoundsAutoImp(@NotNull Dimension sizeToFit, @NotNull List<? extends Rectangle> bounds) {
|
||||
final int componentCount = getComponentCount();
|
||||
LOG.assertTrue(componentCount <= bounds.size());
|
||||
|
||||
@@ -613,12 +592,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
maxHeight = Math.max(eachBound.height, maxHeight);
|
||||
|
||||
if (!full) {
|
||||
boolean inside;
|
||||
if (isLast) {
|
||||
inside = eachX + eachBound.width <= widthToFit;
|
||||
} else {
|
||||
inside = eachX + eachBound.width + autoButtonSize <= widthToFit;
|
||||
}
|
||||
boolean inside = isLast ? eachX + eachBound.width <= widthToFit : eachX + eachBound.width + autoButtonSize <= widthToFit;
|
||||
|
||||
if (inside) {
|
||||
if (eachComp == mySecondaryActionsButton) {
|
||||
@@ -697,7 +671,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
|
||||
}
|
||||
|
||||
private void calculateBoundsWrapImpl(Dimension sizeToFit, List<? extends Rectangle> bounds) {
|
||||
private void calculateBoundsWrapImpl(@NotNull Dimension sizeToFit, @NotNull List<? extends Rectangle> bounds) {
|
||||
// We have to graceful handle case when toolbar was not laid out yet.
|
||||
// In this case we calculate bounds as it is a NOWRAP toolbar.
|
||||
if (getWidth() == 0 || getHeight() == 0) {
|
||||
@@ -839,7 +813,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
/**
|
||||
* Calculates bounds of all the components in the toolbar
|
||||
*/
|
||||
private void calculateBounds(Dimension size2Fit, List<Rectangle> bounds) {
|
||||
private void calculateBounds(@NotNull Dimension size2Fit, @NotNull List<Rectangle> bounds) {
|
||||
bounds.clear();
|
||||
for (int i = 0; i < getComponentCount(); i++) {
|
||||
bounds.add(new Rectangle());
|
||||
@@ -880,6 +854,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Dimension getPreferredSize() {
|
||||
final ArrayList<Rectangle> bounds = new ArrayList<>();
|
||||
calculateBounds(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE), bounds);//it doesn't take into account wrapping
|
||||
@@ -890,11 +865,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
calculateBounds(new Dimension(getWidth(), Integer.MAX_VALUE), limitedBounds);
|
||||
Rectangle union = null;
|
||||
for (Rectangle bound : limitedBounds) {
|
||||
if (union == null) {
|
||||
union = bound;
|
||||
} else {
|
||||
union = union.union(bound);
|
||||
}
|
||||
union = union == null ? bound : union.union(bound);
|
||||
}
|
||||
forcedHeight = union != null ? union.height : 0;
|
||||
}
|
||||
@@ -927,9 +898,8 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces the minimum size of the toolbar to show all buttons, When set to <code>true</code>. By default (<code>false</code>) the
|
||||
* Forces the minimum size of the toolbar to show all buttons, When set to {@code true}. By default ({@code false}) the
|
||||
* toolbar will shrink further and show the auto popup chevron button.
|
||||
* @param force
|
||||
*/
|
||||
public void setForceMinimumSize(boolean force) {
|
||||
myForceMinimumSize = force;
|
||||
@@ -937,7 +907,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
|
||||
/**
|
||||
* By default minimum size is to show chevron only.
|
||||
* If this option is <code>true</code> toolbar shows at least one (the first) component plus chevron (if need)
|
||||
* If this option is {@code true} toolbar shows at least one (the first) component plus chevron (if need)
|
||||
*/
|
||||
public void setForceShowFirstComponent(boolean showFirstComponent) {
|
||||
myForceShowFirstComponent = showFirstComponent;
|
||||
@@ -947,7 +917,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
* This option makes sense when you use a toolbar inside JBPopup
|
||||
* When some 'actions' are hidden under the chevron the popup with extra components would be shown/hidden
|
||||
* with size adjustments for the main popup (this is default behavior).
|
||||
* If this option is <code>true</code> size adjustments would be omitted
|
||||
* If this option is {@code true} size adjustments would be omitted
|
||||
*/
|
||||
public void setSkipWindowAdjustments(boolean skipWindowAdjustments) {
|
||||
mySkipWindowAdjustments = skipWindowAdjustments;
|
||||
@@ -983,7 +953,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
private static final ReferenceQueue<ActionToolbarImpl> ourQueue = new ReferenceQueue<>();
|
||||
private volatile Disposable myDisposable;
|
||||
|
||||
ToolbarReference(ActionToolbarImpl toolbar) {
|
||||
ToolbarReference(@NotNull ActionToolbarImpl toolbar) {
|
||||
super(toolbar, ourQueue);
|
||||
processQueue();
|
||||
}
|
||||
@@ -1047,7 +1017,8 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
int offset;
|
||||
if (myOrientation == SwingConstants.HORIZONTAL) {
|
||||
offset = ActionToolbarImpl.this.getHeight() - getMaxButtonHeight() - 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
offset = ActionToolbarImpl.this.getWidth() - getMaxButtonWidth() - 1;
|
||||
}
|
||||
|
||||
@@ -1126,7 +1097,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
myUpdater.updateActions(true, false);
|
||||
}
|
||||
|
||||
private boolean myAlreadyUpdated = false;
|
||||
private boolean myAlreadyUpdated;
|
||||
|
||||
private void updateActionsImpl(boolean transparentOnly, boolean forced) {
|
||||
DataContext dataContext = getDataContext();
|
||||
@@ -1139,7 +1110,8 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
|
||||
myLastUpdate = updater.expandActionGroupAsync(myActionGroup, false);
|
||||
myLastUpdate.onSuccess(actions -> actionsUpdated(forced, actions)).onProcessed(__ -> myLastUpdate = null);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
actionsUpdated(forced, updater.expandActionGroupWithTimeout(myActionGroup, false));
|
||||
myAlreadyUpdated = true;
|
||||
}
|
||||
@@ -1147,7 +1119,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
|
||||
private CancellablePromise<List<AnAction>> myLastUpdate;
|
||||
|
||||
private void actionsUpdated(boolean forced, List<AnAction> newVisibleActions) {
|
||||
private void actionsUpdated(boolean forced, @NotNull List<? extends AnAction> newVisibleActions) {
|
||||
if (forced || !newVisibleActions.equals(myVisibleActions)) {
|
||||
boolean shouldRebuildUI = newVisibleActions.isEmpty() || myVisibleActions.isEmpty();
|
||||
myVisibleActions = newVisibleActions;
|
||||
@@ -1194,7 +1166,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateWhenFirstShown(JComponent targetComponent, final ToolbarReference ref) {
|
||||
private static void updateWhenFirstShown(@NotNull JComponent targetComponent, @NotNull ToolbarReference ref) {
|
||||
Activatable activatable = new Activatable.Adapter() {
|
||||
@Override
|
||||
public void showNotify() {
|
||||
@@ -1214,6 +1186,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DataContext getToolbarDataContext() {
|
||||
return getDataContext();
|
||||
@@ -1224,6 +1197,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
myShowSeparatorTitles = showSeparatorTitles;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected DataContext getDataContext() {
|
||||
return myTargetComponent != null ? myDataManager.getDataContext(myTargetComponent) : ((DataManagerImpl)myDataManager).getDataContextTest(this);
|
||||
}
|
||||
@@ -1261,6 +1235,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
hidePopup();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected DataContext getDataContext() {
|
||||
return ActionToolbarImpl.this.getDataContext();
|
||||
@@ -1293,14 +1268,9 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
}
|
||||
return toClose;
|
||||
})
|
||||
.setCancelOnMouseOutCallback(new MouseChecker() {
|
||||
@Override
|
||||
public boolean check(final MouseEvent event) {
|
||||
return myAutoPopupRec != null &&
|
||||
myActionManager.isActionPopupStackEmpty() &&
|
||||
!new RelativeRectangle(ActionToolbarImpl.this, myAutoPopupRec).contains(new RelativePoint(event));
|
||||
}
|
||||
});
|
||||
.setCancelOnMouseOutCallback(event -> myAutoPopupRec != null &&
|
||||
myActionManager.isActionPopupStackEmpty() &&
|
||||
!new RelativeRectangle(this, myAutoPopupRec).contains(new RelativePoint(event)));
|
||||
|
||||
builder.addListener(new JBPopupAdapter() {
|
||||
@Override
|
||||
@@ -1311,7 +1281,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
myPopup = builder.createPopup();
|
||||
ApplicationManager.getApplication().getMessageBus().connect(myPopup).subscribe(AnActionListener.TOPIC, new AnActionListener() {
|
||||
@Override
|
||||
public void afterActionPerformed(AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void afterActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
final JBPopup popup = myPopup;
|
||||
if (popup != null && !popup.isDisposed() && popup.isVisible()) {
|
||||
popup.cancel();
|
||||
@@ -1346,21 +1316,14 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
}
|
||||
};
|
||||
window.addComponentListener(componentAdapter);
|
||||
Disposer.register(popupToolbar, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
window.removeComponentListener(componentAdapter);
|
||||
}
|
||||
});
|
||||
Disposer.register(popupToolbar, () -> window.removeComponentListener(componentAdapter));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isPopupShowing() {
|
||||
if (myPopup != null) {
|
||||
if (myPopup.getContent() != null) {
|
||||
return true;
|
||||
}
|
||||
return myPopup.getContent() != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1384,19 +1347,17 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
abstract static class PopupToolbar extends ActionToolbarImpl implements AnActionListener, Disposable {
|
||||
private final JComponent myParent;
|
||||
|
||||
PopupToolbar(final String place,
|
||||
final ActionGroup actionGroup,
|
||||
final boolean horizontal,
|
||||
final DataManager dataManager,
|
||||
@NotNull ActionManagerEx actionManager,
|
||||
final KeymapManagerEx keymapManager,
|
||||
JComponent parent) {
|
||||
PopupToolbar(@NotNull String place,
|
||||
@NotNull ActionGroup actionGroup,
|
||||
final boolean horizontal,
|
||||
@NotNull DataManager dataManager,
|
||||
@NotNull ActionManagerEx actionManager,
|
||||
@NotNull KeymapManagerEx keymapManager,
|
||||
@NotNull JComponent parent) {
|
||||
super(place, actionGroup, horizontal, false, dataManager, actionManager, keymapManager, true);
|
||||
ApplicationManager.getApplication().getMessageBus().connect(this).subscribe(AnActionListener.TOPIC, this);
|
||||
myParent = parent;
|
||||
if (myParent != null) {
|
||||
setBorder(myParent.getBorder());
|
||||
}
|
||||
setBorder(myParent.getBorder());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1410,11 +1371,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull final AnAction action, @NotNull final DataContext dataContext, AnActionEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterActionPerformed(final AnAction action, @NotNull final DataContext dataContext, AnActionEvent event) {
|
||||
public void afterActionPerformed(@NotNull final AnAction action, @NotNull final DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
if (!myVisibleActions.contains(action)) {
|
||||
onOtherActionPerformed();
|
||||
}
|
||||
@@ -1429,7 +1386,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecondaryActionsTooltip(String secondaryActionsTooltip) {
|
||||
public void setSecondaryActionsTooltip(@NotNull String secondaryActionsTooltip) {
|
||||
mySecondaryActions.getTemplatePresentation().setDescription(secondaryActionsTooltip);
|
||||
}
|
||||
|
||||
@@ -1484,11 +1441,6 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
myUpdater.updateActions(false, true);
|
||||
}
|
||||
|
||||
public void setAddSeparatorFirst(boolean addSeparatorFirst) {
|
||||
myAddSeparatorFirst = addSeparatorFirst;
|
||||
myUpdater.updateActions(false, true);
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public Presentation getPresentation(AnAction action) {
|
||||
return myPresentationFactory.getPresentation(action);
|
||||
|
||||
+11
-16
@@ -13,23 +13,22 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* extended by fabrique
|
||||
*/
|
||||
public class ButtonToolbarImpl extends JPanel {
|
||||
class ButtonToolbarImpl extends JPanel {
|
||||
|
||||
private final DataManager myDataManager;
|
||||
private final String myPlace;
|
||||
private final PresentationFactory myPresentationFactory;
|
||||
private final ArrayList<ActionJButton> myActions = new ArrayList<>();
|
||||
|
||||
public ButtonToolbarImpl(final String place,
|
||||
@NotNull ActionGroup actionGroup,
|
||||
DataManager dataManager,
|
||||
ActionManagerEx actionManager) {
|
||||
ButtonToolbarImpl(@NotNull String place,
|
||||
@NotNull ActionGroup actionGroup,
|
||||
@NotNull DataManager dataManager,
|
||||
@NotNull ActionManagerEx actionManager) {
|
||||
super(new GridBagLayout());
|
||||
myPlace = place;
|
||||
myPresentationFactory = new PresentationFactory();
|
||||
@@ -38,9 +37,8 @@ public class ButtonToolbarImpl extends JPanel {
|
||||
initButtons(actionGroup);
|
||||
|
||||
updateActions();
|
||||
//
|
||||
actionManager.addTimerListener(500, new WeakTimerListener(actionManager, new MyTimerListener()));
|
||||
enableEvents(MouseEvent.MOUSE_MOTION_EVENT_MASK | MouseEvent.MOUSE_EVENT_MASK);
|
||||
enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK);
|
||||
|
||||
}
|
||||
|
||||
@@ -55,15 +53,12 @@ public class ButtonToolbarImpl extends JPanel {
|
||||
Box.createHorizontalGlue(),
|
||||
new GridBagConstraints(gridx++, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
|
||||
new Insets(8, 0, 0, 0), 0, 0));
|
||||
if (actions.length > 0) {
|
||||
JPanel buttonsPanel = createButtons(actions);
|
||||
//noinspection UnusedAssignment
|
||||
add(buttonsPanel,
|
||||
new GridBagConstraints(gridx++, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
|
||||
new Insets(8, 0, 0, 0), 0, 0));
|
||||
}
|
||||
JPanel buttonsPanel = createButtons(actions);
|
||||
//noinspection UnusedAssignment
|
||||
add(buttonsPanel,
|
||||
new GridBagConstraints(gridx++, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
|
||||
new Insets(8, 0, 0, 0), 0, 0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private JPanel createButtons(AnAction[] actions) {
|
||||
|
||||
+2
-2
@@ -61,7 +61,7 @@ public class EditorLastActionTrackerImpl implements AnActionListener, EditorMous
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
myCurrentEditor = CommonDataKeys.EDITOR.getData(dataContext);
|
||||
if (myCurrentEditor != myLastEditor) {
|
||||
resetLastAction();
|
||||
@@ -69,7 +69,7 @@ public class EditorLastActionTrackerImpl implements AnActionListener, EditorMous
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterActionPerformed(AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void afterActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
myLastActionId = getActionId(action);
|
||||
myLastEditor = myCurrentEditor;
|
||||
myCurrentEditor = null;
|
||||
|
||||
+1
-1
@@ -262,7 +262,7 @@ public class ModifierKeyDoubleClickHandler implements Disposable, BaseComponent
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
if (!myIsRunningAction) resetState();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -145,11 +145,11 @@ class ConfigurableEditor extends AbstractEditor implements AnActionListener, AWT
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext context, AnActionEvent event) {
|
||||
public final void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext context, @NotNull AnActionEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void afterActionPerformed(AnAction action, @NotNull DataContext context, AnActionEvent event) {
|
||||
public final void afterActionPerformed(@NotNull AnAction action, @NotNull DataContext context, @NotNull AnActionEvent event) {
|
||||
requestUpdate();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ public class ActionCommand extends TypeCommand {
|
||||
Disposable disposable = Disposer.newDisposable();
|
||||
ApplicationManager.getApplication().getMessageBus().connect(disposable).subscribe(AnActionListener.TOPIC, new AnActionListener() {
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull final AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void beforeActionPerformed(@NotNull final AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
if (context.isDisposed()) {
|
||||
Disposer.dispose(disposable);
|
||||
|
||||
@@ -134,7 +134,7 @@ public class ToolWindowManagerImpl extends ToolWindowManagerEx implements Persis
|
||||
busConnection.subscribe(ToolWindowManagerListener.TOPIC, myDispatcher.getMulticaster());
|
||||
busConnection.subscribe(AnActionListener.TOPIC, new AnActionListener() {
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
if (myCurrentState != KeyState.hold) {
|
||||
resetHoldState();
|
||||
}
|
||||
|
||||
@@ -584,7 +584,7 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
|
||||
if (ApplicationManager.getApplication() != null) {
|
||||
ApplicationManager.getApplication().getMessageBus().connect(this).subscribe(AnActionListener.TOPIC, new AnActionListener() {
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
if (myHideOnAction && !(action instanceof HintManagerImpl.ActionToIgnore)) {
|
||||
hide();
|
||||
}
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ class LogActionsDuringTest : TestWatcher() {
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
private val actionListener = object : AnActionListener {
|
||||
override fun beforeActionPerformed(action: AnAction, dataContext: DataContext, event: AnActionEvent?) {
|
||||
override fun beforeActionPerformed(action: AnAction, dataContext: DataContext, event: AnActionEvent) {
|
||||
LOG.info("Action: $action (actionId: ${ActionManager.getInstance().getId(action)}); DataContext: $dataContext; Event: $event")
|
||||
}
|
||||
}
|
||||
|
||||
+4
-5
@@ -24,8 +24,8 @@ object GlobalActionRecorder {
|
||||
private set
|
||||
|
||||
private val globalActionListener = object : AnActionListener {
|
||||
override fun beforeActionPerformed(action: AnAction, dataContext: DataContext, event: AnActionEvent?) {
|
||||
if (event?.place == GuiScriptEditorPanel.GUI_SCRIPT_EDITOR_PLACE) return //avoid GUI Script Editor Actions
|
||||
override fun beforeActionPerformed(action: AnAction, dataContext: DataContext, event: AnActionEvent) {
|
||||
if (event.place == GuiScriptEditorPanel.GUI_SCRIPT_EDITOR_PLACE) return //avoid GUI Script Editor Actions
|
||||
EventDispatcher.processActionEvent(action, event)
|
||||
LOG.info("IDEA is going to perform action ${action.templatePresentation.text}")
|
||||
}
|
||||
@@ -34,9 +34,8 @@ object GlobalActionRecorder {
|
||||
LOG.info("IDEA typing detected: ${c}")
|
||||
}
|
||||
|
||||
override fun afterActionPerformed(action: AnAction?, dataContext: DataContext, event: AnActionEvent?) {
|
||||
if (event?.place == GuiScriptEditorPanel.GUI_SCRIPT_EDITOR_PLACE) return //avoid GUI Script Editor Actions
|
||||
if (action == null) return
|
||||
override fun afterActionPerformed(action: AnAction, dataContext: DataContext, event: AnActionEvent) {
|
||||
if (event.place == GuiScriptEditorPanel.GUI_SCRIPT_EDITOR_PLACE) return //avoid GUI Script Editor Actions
|
||||
LOG.info("IDEA action performed ${action.templatePresentation.text}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.util.ui;
|
||||
|
||||
import com.intellij.util.ui.JBUI.Scaler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.plaf.UIResource;
|
||||
import java.awt.*;
|
||||
@@ -27,7 +28,7 @@ import static java.lang.Math.ceil;
|
||||
* @author tav
|
||||
*/
|
||||
public class JBDimension extends Dimension {
|
||||
protected Size2D size2D;
|
||||
Size2D size2D;
|
||||
private final MyScaler scaler = new MyScaler();
|
||||
|
||||
private static class Size2D {
|
||||
@@ -75,6 +76,7 @@ public class JBDimension extends Dimension {
|
||||
return Math.max(-1, JBUI.scale((float)size));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JBDimension create(Dimension from, boolean preScaled) {
|
||||
if (from instanceof JBDimension) {
|
||||
return ((JBDimension)from);
|
||||
@@ -82,10 +84,12 @@ public class JBDimension extends Dimension {
|
||||
return new JBDimension(from.width, from.height, preScaled);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JBDimension create(Dimension from) {
|
||||
return create(from, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JBDimensionUIResource asUIResource() {
|
||||
return new JBDimensionUIResource(this);
|
||||
}
|
||||
@@ -99,6 +103,7 @@ public class JBDimension extends Dimension {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JBDimension withWidth(int width) {
|
||||
JBDimension size = new JBDimension(0, 0);
|
||||
size.size2D.set(scale(width), size2D.height);
|
||||
@@ -107,6 +112,7 @@ public class JBDimension extends Dimension {
|
||||
return size;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JBDimension withHeight(int height) {
|
||||
JBDimension size = new JBDimension(0, 0);
|
||||
size.size2D.set(size2D.width, scale(height));
|
||||
@@ -142,6 +148,7 @@ public class JBDimension extends Dimension {
|
||||
/**
|
||||
* @return this JBDimension with updated size
|
||||
*/
|
||||
@NotNull
|
||||
public JBDimension size() {
|
||||
update();
|
||||
return this;
|
||||
@@ -150,6 +157,7 @@ public class JBDimension extends Dimension {
|
||||
/**
|
||||
* @return new JBDimension with updated size
|
||||
*/
|
||||
@NotNull
|
||||
public JBDimension newSize() {
|
||||
update();
|
||||
return new JBDimension(size2D.width, size2D.height, true);
|
||||
@@ -203,7 +211,7 @@ class MyScaler extends Scaler {
|
||||
return JBUI.scale(1f);
|
||||
}
|
||||
|
||||
public boolean needUpdate() {
|
||||
boolean needUpdate() {
|
||||
return initialScale != JBUI.scale(1f);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ public class VcsBackForwardUsageTriggerCollector extends ApplicationUsageTrigger
|
||||
public void componentsInitialized() {
|
||||
ApplicationManager.getApplication().getMessageBus().connect().subscribe(AnActionListener.TOPIC, new AnActionListener() {
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, AnActionEvent e) {
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent e) {
|
||||
if (action instanceof BackAction ||
|
||||
action instanceof ForwardAction) {
|
||||
FUSApplicationUsageTrigger.getInstance().trigger(VcsBackForwardUsageTriggerCollector.class, getContextName(e));
|
||||
|
||||
@@ -85,7 +85,7 @@ public abstract class InstancesViewBase extends JBPanel implements Disposable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, AnActionEvent event) {
|
||||
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
|
||||
if (dataContext.getData(PlatformDataKeys.CONTEXT_COMPONENT) == getInstancesTree() &&
|
||||
(isAddToWatchesAction(action) || isEvaluateExpressionAction(action))) {
|
||||
XValueNodeImpl selectedNode = XDebuggerTreeActionBase.getSelectedNode(dataContext);
|
||||
|
||||
@@ -16,7 +16,7 @@ class LookupActionsListener : AnActionListener {
|
||||
|
||||
var listener: CompletionPopupListener = CompletionPopupListener.Adapter()
|
||||
|
||||
override fun afterActionPerformed(action: AnAction, dataContext: DataContext, event: AnActionEvent?) {
|
||||
override fun afterActionPerformed(action: AnAction, dataContext: DataContext, event: AnActionEvent) {
|
||||
LOG.runAndLogException {
|
||||
when (action) {
|
||||
down -> listener.downPressed()
|
||||
@@ -26,7 +26,7 @@ class LookupActionsListener : AnActionListener {
|
||||
}
|
||||
}
|
||||
|
||||
override fun beforeActionPerformed(action: AnAction, dataContext: DataContext, event: AnActionEvent?) {
|
||||
override fun beforeActionPerformed(action: AnAction, dataContext: DataContext, event: AnActionEvent) {
|
||||
LOG.runAndLogException {
|
||||
when (action) {
|
||||
down -> listener.beforeDownPressed()
|
||||
|
||||
Reference in New Issue
Block a user