IJPL-300 Do not use AllIcons class during ActionManager instantiation

GitOrigin-RevId: 3f6590989a50044398ef0f4414285b20444257f2
This commit is contained in:
Vladimir Krivosheev
2023-10-20 01:08:04 +02:00
committed by intellij-monorepo-bot
parent d49757e59e
commit 7eb33862d7
51 changed files with 303 additions and 273 deletions

View File

@@ -1,26 +1,12 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.packaging.impl.ui.actions;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.compiler.JavaCompilerBundle;
import com.intellij.openapi.compiler.CompilerManager;
import com.intellij.openapi.compiler.JavaCompilerBundle;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex;
@@ -43,13 +29,13 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class PackageFileAction extends AnAction {
public final class PackageFileAction extends AnAction {
private static class Holder {
private static final SyncDateFormat TIME_FORMAT = new SyncDateFormat(new SimpleDateFormat("h:mm:ss a"));
}
public PackageFileAction() {
super(JavaCompilerBundle.messagePointer("action.name.package.file"), JavaCompilerBundle.messagePointer("action.description.package.file"), null);
super(JavaCompilerBundle.messagePointer("action.name.package.file"), JavaCompilerBundle.messagePointer("action.description.package.file"));
}
@Override

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.roots.ui.configuration.actions;
import com.intellij.ide.JavaUiBundle;
@@ -26,7 +26,7 @@ import org.jetbrains.annotations.Nullable;
*/
public class NewModuleAction extends AnAction implements DumbAware, NewProjectOrModuleAction {
public NewModuleAction() {
super(JavaUiBundle.messagePointer("module.new.action", 0, 1), JavaUiBundle.messagePointer("module.new.action.description"), null);
super(JavaUiBundle.messagePointer("module.new.action", 0, 1), JavaUiBundle.messagePointer("module.new.action.description"));
}
@Override

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.roots.ui.configuration.projectRoot
import com.intellij.ide.JavaUiBundle
@@ -22,7 +22,6 @@ import com.intellij.openapi.roots.impl.libraries.LibraryEx
import com.intellij.openapi.roots.libraries.Library
import com.intellij.openapi.roots.libraries.NewLibraryConfiguration
import com.intellij.openapi.roots.libraries.ui.OrderRoot
import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable
import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor
import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditorBase
import com.intellij.openapi.ui.DialogWrapper
@@ -44,7 +43,7 @@ private val LOG = logger<ConvertToRepositoryLibraryActionBase>()
abstract class ConvertToRepositoryLibraryActionBase(protected val context: StructureConfigurableContext) :
DumbAwareAction(JavaUiBundle.messagePointer("action.text.convert.to.repository.library"),
JavaUiBundle.messagePointer("action.description.convert.to.repository.library"), null) {
JavaUiBundle.messagePointer("action.description.convert.to.repository.library")) {
protected val project: Project = context.project

View File

@@ -67,6 +67,12 @@ public abstract class ActionGroup extends AnAction {
super(text, description, icon);
}
public ActionGroup(@NotNull Supplier<@ActionText String> text,
@NotNull Supplier<@ActionDescription String> description,
@Nullable Supplier<? extends @Nullable Icon> icon) {
super(text, description, icon);
}
public ActionGroup(@NotNull Supplier<@ActionText String> dynamicText,
@NotNull Supplier<@ActionDescription String> dynamicDescription,
@Nullable Icon icon) {

View File

@@ -59,7 +59,7 @@ public abstract class AnAction implements PossiblyDumbAware, ActionUpdateThreadA
public static final Key<List<AnAction>> ACTIONS_KEY = Key.create("AnAction.shortcutSet");
public static final AnAction[] EMPTY_ARRAY = new AnAction[0];
private Presentation myTemplatePresentation;
private Presentation templatePresentation;
private @NotNull ShortcutSet myShortcutSet = CustomShortcutSet.EMPTY;
private boolean myEnabledInModalContext;
@@ -104,7 +104,10 @@ public abstract class AnAction implements PossiblyDumbAware, ActionUpdateThreadA
* and the name of the menu item when the presentation is a menu item (with mnemonic)
*/
public AnAction(@NotNull Supplier<@ActionText String> dynamicText) {
this(dynamicText, Presentation.NULL_STRING, null);
Presentation presentation = getTemplatePresentation();
presentation.setText(dynamicText);
presentation.setDescription(Presentation.NULL_STRING);
presentation.setIconSupplier(null);
}
/**
@@ -116,12 +119,27 @@ public abstract class AnAction implements PossiblyDumbAware, ActionUpdateThreadA
* this description will appear on the status bar when the presentation has the focus
* @param icon the action's icon
*/
public AnAction(@Nullable @ActionText String text,
@Nullable @ActionDescription String description,
@Nullable Icon icon) {
public AnAction(@Nullable @ActionText String text, @Nullable @ActionDescription String description, @Nullable Icon icon) {
this(() -> text, () -> description, icon);
}
@ApiStatus.Experimental
public AnAction(@NotNull @ActionText Supplier<String> text,
@NotNull @ActionDescription Supplier<String> description,
@Nullable Supplier<? extends @Nullable Icon> iconSupplier) {
Presentation presentation = getTemplatePresentation();
presentation.setText(text);
presentation.setDescription(description);
presentation.setIconSupplier(iconSupplier);
}
@ApiStatus.Experimental
public AnAction(@NotNull @ActionText Supplier<String> text, @NotNull @ActionDescription Supplier<String> description) {
Presentation presentation = getTemplatePresentation();
presentation.setText(text);
presentation.setDescription(description);
}
/**
* Creates a new action with the given text, description and icon.
* Use this variant if you need to localize the action text.
@@ -131,7 +149,11 @@ public abstract class AnAction implements PossiblyDumbAware, ActionUpdateThreadA
* @param icon the action's icon
*/
public AnAction(@NotNull Supplier<@ActionText String> dynamicText, @Nullable Icon icon) {
this(dynamicText, Presentation.NULL_STRING, icon);
Presentation presentation = getTemplatePresentation();
presentation.setText(dynamicText);
if (icon != null) {
presentation.setIcon(icon);
}
}
/**
@@ -150,7 +172,9 @@ public abstract class AnAction implements PossiblyDumbAware, ActionUpdateThreadA
Presentation presentation = getTemplatePresentation();
presentation.setText(dynamicText);
presentation.setDescription(dynamicDescription);
presentation.setIcon(icon);
if (icon != null) {
presentation.setIcon(icon);
}
}
@Override
@@ -317,16 +341,16 @@ public abstract class AnAction implements PossiblyDumbAware, ActionUpdateThreadA
* a new presentation of the action is needed.
*/
public final @NotNull Presentation getTemplatePresentation() {
Presentation presentation = myTemplatePresentation;
Presentation presentation = templatePresentation;
if (presentation == null) {
presentation = createTemplatePresentation();
LOG.assertTrue(presentation.isTemplate(), "Not a template presentation");
myTemplatePresentation = presentation;
if (this instanceof ActionGroup) {
templatePresentation = presentation;
if (this instanceof ActionGroup group) {
// init group flags from deprecated methods
//myTemplatePresentation.setPopupGroup(((ActionGroup)this).isPopup());
myTemplatePresentation.setHideGroupIfEmpty(((ActionGroup)this).hideIfNoVisibleChildren());
myTemplatePresentation.setDisableGroupIfEmpty(((ActionGroup)this).disableIfNoVisibleChildren());
templatePresentation.setHideGroupIfEmpty(group.hideIfNoVisibleChildren());
templatePresentation.setDisableGroupIfEmpty(group.disableIfNoVisibleChildren());
}
}
return presentation;

View File

@@ -99,16 +99,16 @@ public final class Presentation implements Cloneable {
private static final int IS_TEMPLATE = 0x1000;
private int myFlags = IS_ENABLED | IS_VISIBLE | IS_DISABLE_GROUP_IF_EMPTY;
private @NotNull Supplier<@ActionDescription String> myDescriptionSupplier = () -> null;
private @NotNull Supplier<TextWithMnemonic> myTextWithMnemonicSupplier = () -> null;
private @NotNull Supplier<@ActionDescription String> descriptionSupplier = NULL_STRING;
private @NotNull Supplier<TextWithMnemonic> textWithMnemonicSupplier = () -> null;
private @NotNull SmartFMap<String, Object> myUserMap = SmartFMap.emptyMap();
private Icon myIcon;
private Icon myDisabledIcon;
private Icon myHoveredIcon;
private Icon mySelectedIcon;
private @Nullable Supplier<? extends @Nullable Icon> icon;
private Icon disabledIcon;
private Icon hoveredIcon;
private Icon selectedIcon;
private PropertyChangeSupport myChangeSupport;
private PropertyChangeSupport changeSupport;
private double myWeight = DEFAULT_WEIGHT;
private static final @NotNull NotNullLazyValue<Boolean> removeMnemonics = NotNullLazyValue.createValue(() -> {
@@ -126,23 +126,23 @@ public final class Presentation implements Cloneable {
public Presentation(@NotNull @ActionText String text) {
TextWithMnemonic textWithMnemonic = TextWithMnemonic.fromPlainText(text);
myTextWithMnemonicSupplier = () -> textWithMnemonic;
textWithMnemonicSupplier = () -> textWithMnemonic;
}
public Presentation(@NotNull Supplier<@ActionText String> dynamicText) {
myTextWithMnemonicSupplier = () -> TextWithMnemonic.fromPlainText(dynamicText.get());
textWithMnemonicSupplier = () -> TextWithMnemonic.fromPlainText(dynamicText.get());
}
public void addPropertyChangeListener(@NotNull PropertyChangeListener l) {
PropertyChangeSupport support = myChangeSupport;
PropertyChangeSupport support = changeSupport;
if (support == null) {
myChangeSupport = support = new PropertyChangeSupport(this);
changeSupport = support = new PropertyChangeSupport(this);
}
support.addPropertyChangeListener(l);
}
public void removePropertyChangeListener(@NotNull PropertyChangeListener l) {
PropertyChangeSupport support = myChangeSupport;
PropertyChangeSupport support = changeSupport;
if (support != null) {
support.removePropertyChangeListener(l);
}
@@ -165,13 +165,13 @@ public final class Presentation implements Cloneable {
}
public @ActionText String getText(boolean withSuffix) {
TextWithMnemonic textWithMnemonic = myTextWithMnemonicSupplier.get();
TextWithMnemonic textWithMnemonic = textWithMnemonicSupplier.get();
return textWithMnemonic == null ? null : textWithMnemonic.getText(withSuffix);
}
@ApiStatus.Internal
public boolean hasText() {
return myTextWithMnemonicSupplier.get() != null;
return textWithMnemonicSupplier.get() != null;
}
/**
@@ -224,8 +224,8 @@ public final class Presentation implements Cloneable {
* @param textWithMnemonicSupplier text with mnemonic to set
*/
public void setTextWithMnemonic(@NotNull Supplier<TextWithMnemonic> textWithMnemonicSupplier) {
if (myChangeSupport == null) {
myTextWithMnemonicSupplier = textWithMnemonicSupplier;
if (changeSupport == null) {
this.textWithMnemonicSupplier = textWithMnemonicSupplier;
return;
}
@@ -233,7 +233,7 @@ public final class Presentation implements Cloneable {
String oldTextWithSuffix = getText(true);
int oldMnemonic = getMnemonic();
int oldIndex = getDisplayedMnemonicIndex();
myTextWithMnemonicSupplier = textWithMnemonicSupplier;
this.textWithMnemonicSupplier = textWithMnemonicSupplier;
fireObjectPropertyChange(PROP_TEXT, oldText, getText());
fireObjectPropertyChange(PROP_TEXT_WITH_SUFFIX, oldTextWithSuffix, getText(true));
@@ -259,9 +259,9 @@ public final class Presentation implements Cloneable {
@ApiStatus.Internal
public void setFallbackPresentationText(@NotNull Supplier<String> supplier) {
Supplier<TextWithMnemonic> original = myTextWithMnemonicSupplier;
Supplier<TextWithMnemonic> original = textWithMnemonicSupplier;
Supplier<TextWithMnemonic> fallback = getTextWithMnemonic(supplier, true);
myTextWithMnemonicSupplier = () -> {
textWithMnemonicSupplier = () -> {
TextWithMnemonic result = original.get();
return result == null ? fallback.get() : result;
};
@@ -271,12 +271,12 @@ public final class Presentation implements Cloneable {
* @return the text with mnemonic, properly escaped, so it could be passed to {@link #setText(String)} (e.g. to copy the presentation).
*/
public @ActionText @Nullable String getTextWithMnemonic() {
TextWithMnemonic textWithMnemonic = myTextWithMnemonicSupplier.get();
TextWithMnemonic textWithMnemonic = textWithMnemonicSupplier.get();
return textWithMnemonic == null ? null : textWithMnemonic.toString();
}
public @NotNull Supplier<TextWithMnemonic> getTextWithPossibleMnemonic() {
return myTextWithMnemonicSupplier;
return textWithMnemonicSupplier;
}
public void restoreTextWithMnemonic(Presentation presentation) {
@@ -284,66 +284,87 @@ public final class Presentation implements Cloneable {
}
public @ActionDescription String getDescription() {
return myDescriptionSupplier.get();
return descriptionSupplier.get();
}
public void setDescription(@NotNull Supplier<@ActionDescription String> dynamicDescription) {
Supplier<String> oldDescription = myDescriptionSupplier;
myDescriptionSupplier = dynamicDescription;
fireObjectPropertyChange(PROP_DESCRIPTION, oldDescription.get(), myDescriptionSupplier.get());
Supplier<String> oldDescription = descriptionSupplier;
descriptionSupplier = dynamicDescription;
if (changeSupport != null) {
fireObjectPropertyChange(PROP_DESCRIPTION, oldDescription.get(), descriptionSupplier.get());
}
}
public void setDescription(@ActionDescription String description) {
Supplier<String> oldDescriptionSupplier = myDescriptionSupplier;
myDescriptionSupplier = () -> description;
fireObjectPropertyChange(PROP_DESCRIPTION, oldDescriptionSupplier.get(), description);
Supplier<String> oldDescriptionSupplier = descriptionSupplier;
descriptionSupplier = () -> description;
if (changeSupport != null) {
fireObjectPropertyChange(PROP_DESCRIPTION, oldDescriptionSupplier.get(), description);
}
}
public Icon getIcon() {
return myIcon;
Supplier<? extends Icon> icon = this.icon;
return icon == null ? null : icon.get();
}
public void copyIconIfUnset(@NotNull Presentation other) {
if (icon == null && other.icon != null) {
icon = other.icon;
}
}
public void setIcon(@Nullable Icon icon) {
Icon oldIcon = myIcon;
myIcon = icon;
fireObjectPropertyChange(PROP_ICON, oldIcon, myIcon);
if (changeSupport == null) {
this.icon = icon == null ? null : () -> icon;
return;
}
Icon oldIcon = getIcon();
this.icon = () -> icon;
fireObjectPropertyChange(PROP_ICON, oldIcon, this.icon);
}
// event is not fired - use for init
public void setIconSupplier(@Nullable Supplier<? extends @Nullable Icon> icon) {
this.icon = icon;
}
public Icon getDisabledIcon() {
return myDisabledIcon;
return disabledIcon;
}
public void setDisabledIcon(@Nullable Icon icon) {
Icon oldDisabledIcon = myDisabledIcon;
myDisabledIcon = icon;
fireObjectPropertyChange(PROP_DISABLED_ICON, oldDisabledIcon, myDisabledIcon);
Icon oldDisabledIcon = disabledIcon;
disabledIcon = icon;
fireObjectPropertyChange(PROP_DISABLED_ICON, oldDisabledIcon, disabledIcon);
}
public Icon getHoveredIcon() {
return myHoveredIcon;
return hoveredIcon;
}
public void setHoveredIcon(final @Nullable Icon hoveredIcon) {
Icon old = myHoveredIcon;
myHoveredIcon = hoveredIcon;
fireObjectPropertyChange(PROP_HOVERED_ICON, old, myHoveredIcon);
Icon old = this.hoveredIcon;
this.hoveredIcon = hoveredIcon;
fireObjectPropertyChange(PROP_HOVERED_ICON, old, this.hoveredIcon);
}
public Icon getSelectedIcon() {
return mySelectedIcon;
return selectedIcon;
}
public void setSelectedIcon(Icon selectedIcon) {
Icon old = mySelectedIcon;
mySelectedIcon = selectedIcon;
fireObjectPropertyChange(PROP_SELECTED_ICON, old, mySelectedIcon);
Icon old = this.selectedIcon;
this.selectedIcon = selectedIcon;
fireObjectPropertyChange(PROP_SELECTED_ICON, old, this.selectedIcon);
}
/**
* @return an extended key code for a mnemonic character, or {@code KeyEvent.VK_UNDEFINED} if mnemonic is not set
*/
public int getMnemonic() {
TextWithMnemonic textWithMnemonic = myTextWithMnemonicSupplier.get();
TextWithMnemonic textWithMnemonic = textWithMnemonicSupplier.get();
return textWithMnemonic == null ? 0 : textWithMnemonic.getMnemonicCode();
}
@@ -351,7 +372,7 @@ public final class Presentation implements Cloneable {
* @return a mnemonic index in the whole text, or {@code -1} if mnemonic is not set
*/
public int getDisplayedMnemonicIndex() {
TextWithMnemonic textWithMnemonic = myTextWithMnemonicSupplier.get();
TextWithMnemonic textWithMnemonic = textWithMnemonicSupplier.get();
return textWithMnemonic == null ? -1 : textWithMnemonic.getMnemonicIndex();
}
@@ -457,14 +478,14 @@ public final class Presentation implements Cloneable {
}
private void fireBooleanPropertyChange(String propertyName, boolean oldValue, boolean newValue) {
PropertyChangeSupport support = myChangeSupport;
PropertyChangeSupport support = changeSupport;
if (oldValue != newValue && support != null) {
support.firePropertyChange(propertyName, oldValue, newValue);
}
}
private void fireObjectPropertyChange(String propertyName, Object oldValue, Object newValue) {
PropertyChangeSupport support = myChangeSupport;
PropertyChangeSupport support = changeSupport;
if (support != null && !Objects.equals(oldValue, newValue)) {
support.firePropertyChange(propertyName, oldValue, newValue);
}
@@ -481,7 +502,7 @@ public final class Presentation implements Cloneable {
try {
Presentation clone = (Presentation)super.clone();
clone.myFlags = BitUtil.set(clone.myFlags, IS_TEMPLATE, false);
clone.myChangeSupport = null;
clone.changeSupport = null;
return clone;
}
catch (CloneNotSupportedException e) {
@@ -505,7 +526,10 @@ public final class Presentation implements Cloneable {
@Nullable Component customComponent,
boolean forceNullComponent,
boolean allFlags) {
if (presentation == this) return;
if (presentation == this) {
return;
}
boolean oldEnabled = isEnabled(), oldVisible = isVisible();
if (allFlags) {
myFlags = BitUtil.set(presentation.myFlags, IS_TEMPLATE, isTemplate());
@@ -518,8 +542,10 @@ public final class Presentation implements Cloneable {
fireBooleanPropertyChange(PROP_VISIBLE, oldVisible, isVisible());
setTextWithMnemonic(presentation.getTextWithPossibleMnemonic());
setDescription(presentation.myDescriptionSupplier);
setIcon(presentation.getIcon());
setDescription(presentation.descriptionSupplier);
setIconSupplier(presentation.icon);
setSelectedIcon(presentation.getSelectedIcon());
setDisabledIcon(presentation.getDisabledIcon());
setHoveredIcon(presentation.getHoveredIcon());
@@ -601,6 +627,6 @@ public final class Presentation implements Cloneable {
@Override
public @Nls String toString() {
return getText() + " (" + myDescriptionSupplier.get() + ")";
return getText() + " (" + descriptionSupplier.get() + ")";
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.execution;
import com.intellij.execution.actions.*;
@@ -34,7 +34,6 @@ import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.IPopupChooserBuilder;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
@@ -115,7 +114,7 @@ public final class ExecutorRegistryImpl extends ExecutorRegistry {
if (executor instanceof ExecutorGroup<?> executorGroup) {
ActionGroup toolbarActionGroup = new SplitButtonAction(new ExecutorGroupActionGroup(executorGroup, ExecutorAction::new));
Presentation presentation = toolbarActionGroup.getTemplatePresentation();
presentation.setIcon(executor.getIcon());
presentation.setIconSupplier(executor::getIcon);
presentation.setText(executor.getStartActionText());
presentation.setDescription(executor.getDescription());
toolbarAction = toolbarActionGroup;
@@ -306,7 +305,8 @@ public final class ExecutorRegistryImpl extends ExecutorRegistry {
protected final Executor myExecutor;
protected ExecutorAction(@NotNull Executor executor) {
super(executor.getStartActionText(), executor.getDescription(), IconLoader.createLazy(() -> executor.getIcon()));
super(executor::getStartActionText, executor::getDescription, executor::getIcon);
myExecutor = executor;
}
@@ -797,8 +797,9 @@ public final class ExecutorRegistryImpl extends ExecutorRegistry {
@NotNull Function<? super Executor, ? extends AnAction> childConverter) {
myExecutorGroup = executorGroup;
myChildConverter = childConverter;
getTemplatePresentation().setText(executorGroup.getStartActionText());
getTemplatePresentation().setIcon(executorGroup.getIcon());
Presentation presentation = getTemplatePresentation();
presentation.setText(executorGroup.getStartActionText());
presentation.setIconSupplier(executorGroup::getIcon);
}
@Override

View File

@@ -1,5 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.execution.actions;
import com.intellij.execution.ProgramRunnerUtil;
@@ -40,6 +39,15 @@ public abstract class BaseRunConfigurationAction extends ActionGroup {
setEnabledInModalContext(true);
}
protected BaseRunConfigurationAction(@NotNull Supplier<String> text,
@NotNull Supplier<String> description,
@Nullable Supplier<? extends @Nullable Icon> icon) {
super(text, description, icon);
setPopup(true);
setEnabledInModalContext(true);
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;

View File

@@ -20,7 +20,6 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.Pair;
import com.intellij.util.ThreeState;
import com.intellij.util.concurrency.AppExecutorUtil;
@@ -38,7 +37,8 @@ public class RunContextAction extends BaseRunConfigurationAction {
public RunContextAction(@NotNull Executor executor) {
super(ExecutionBundle.messagePointer("perform.action.with.context.configuration.action.name", executor.getStartActionText()),
Presentation.NULL_STRING, IconLoader.createLazy(() -> executor.getIcon()));
Presentation.NULL_STRING,
executor::getIcon);
myExecutor = executor;
}

View File

@@ -44,10 +44,9 @@ import java.util.List;
import java.util.Set;
final class ShowRunningListAction extends AnAction {
ShowRunningListAction() {
super(ExecutionBundle.messagePointer("show.running.list.action.name"),
ExecutionBundle.messagePointer("show.running.list.action.description"), null);
ExecutionBundle.messagePointer("show.running.list.action.description"));
}
@Override

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.project;
import com.intellij.ide.lightEdit.LightEditCompatible;
@@ -19,28 +19,23 @@ import java.util.function.Supplier;
* @see DumbAware
*/
public abstract class DumbAwareAction extends AnAction implements DumbAware {
@NotNull
public static DumbAwareAction create(@NotNull Consumer<? super AnActionEvent> actionPerformed) {
public static @NotNull DumbAwareAction create(@NotNull Consumer<? super AnActionEvent> actionPerformed) {
return new SimpleDumbAwareAction(actionPerformed);
}
@NotNull
public static DumbAwareAction create(@Nullable @NlsActions.ActionText String text,
@NotNull Consumer<? super AnActionEvent> actionPerformed) {
public static @NotNull DumbAwareAction create(@Nullable @NlsActions.ActionText String text,
@NotNull Consumer<? super AnActionEvent> actionPerformed) {
return new SimpleDumbAwareAction(text, actionPerformed);
}
@NotNull
public static DumbAwareAction create(@Nullable Icon icon,
@NotNull Consumer<? super AnActionEvent> actionPerformed) {
public static @NotNull DumbAwareAction create(@Nullable Icon icon,
@NotNull Consumer<? super AnActionEvent> actionPerformed) {
return new SimpleDumbAwareAction(icon, actionPerformed);
}
@NotNull
public static DumbAwareAction create(@Nullable @NlsActions.ActionText String text,
@Nullable Icon icon,
@NotNull Consumer<? super AnActionEvent> actionPerformed) {
public static @NotNull DumbAwareAction create(@Nullable @NlsActions.ActionText String text,
@Nullable Icon icon,
@NotNull Consumer<? super AnActionEvent> actionPerformed) {
DumbAwareAction action = new SimpleDumbAwareAction(text, actionPerformed);
action.getTemplatePresentation().setIcon(icon);
return action;
@@ -68,12 +63,23 @@ public abstract class DumbAwareAction extends AnAction implements DumbAware {
super(text, description, icon);
}
protected DumbAwareAction(@NotNull Supplier<@NlsActions.ActionText String> text,
@NotNull Supplier<@NlsActions.ActionDescription String> description,
@Nullable Supplier<? extends @Nullable Icon> iconSupplier) {
super(text, description, iconSupplier);
}
protected DumbAwareAction(@NotNull Supplier<@NlsActions.ActionText String> dynamicText,
@NotNull Supplier<@NlsActions.ActionDescription String> dynamicDescription,
@Nullable Icon icon) {
super(dynamicText, dynamicDescription, icon);
}
protected DumbAwareAction(@NotNull Supplier<@NlsActions.ActionText String> dynamicText,
@NotNull Supplier<@NlsActions.ActionDescription String> dynamicDescription) {
super(dynamicText, dynamicDescription);
}
protected DumbAwareAction(@NotNull Supplier<@NlsActions.ActionText String> dynamicText, @Nullable Icon icon) {
super(dynamicText, icon);
}
@@ -103,9 +109,8 @@ public abstract class DumbAwareAction extends AnAction implements DumbAware {
myActionPerformed.consume(e);
}
@NotNull
@Override
public Consumer<? super AnActionEvent> getDelegate() {
public @NotNull Consumer<? super AnActionEvent> getDelegate() {
return myActionPerformed;
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight.documentation;
import com.intellij.codeInsight.CodeInsightBundle;
@@ -232,7 +232,8 @@ public abstract class DockablePopupManager<T extends JComponent & Disposable> {
@NotNull
protected AnAction createRestorePopupAction() {
return new DumbAwareAction(CodeInsightBundle.messagePointer("action.AnActionButton.text.open.as.popup"), () -> getRestorePopupDescription(), null) {
return new DumbAwareAction(CodeInsightBundle.messagePointer("action.AnActionButton.text.open.as.popup"), () -> getRestorePopupDescription(),
(Icon)null) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
restorePopupBehavior();

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight.template.impl;
import com.intellij.codeInsight.CodeInsightBundle;
@@ -761,7 +761,7 @@ public class TemplateListPanel extends JPanel implements Disposable {
final DumbAwareAction revert =
new DumbAwareAction(CodeInsightBundle.messagePointer("action.DumbAware.TemplateListPanel.text.restore.defaults"),
CodeInsightBundle.messagePointer("action.DumbAware.TemplateListPanel.description.restore.default.setting"),
null) {
(Icon)null) {
@Override
public void update(@NotNull AnActionEvent e) {

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.find;
import com.intellij.icons.AllIcons;
@@ -26,7 +26,7 @@ public final class FindAllAction extends AnAction implements ShortcutProvider, D
public FindAllAction() {
super(IdeBundle.messagePointer(ExperimentalUI.isNewUI() ? "show.in.find.window.button.name.newui" : "show.in.find.window.button.name"),
IdeBundle.messagePointer("show.in.find.window.button.description"), null);
IdeBundle.messagePointer("show.in.find.window.button.description"));
}
@Override

View File

@@ -67,7 +67,7 @@ public class CreateDirectoryOrPackageAction extends AnAction implements DumbAwar
public CreateDirectoryOrPackageAction() {
super(IdeBundle.messagePointer("action.create.new.directory.or.package"),
IdeBundle.messagePointer("action.create.new.directory.or.package"), null);
IdeBundle.messagePointer("action.create.new.directory.or.package"));
}
@Override

View File

@@ -7,12 +7,15 @@ import com.intellij.ide.ui.search.OptionDescription
import com.intellij.ide.util.gotoByName.GotoActionModel
import com.intellij.ide.util.gotoByName.GotoActionModel.MatchedValue
import com.intellij.lang.LangBundle
import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.IdeActions
import com.intellij.openapi.keymap.KeymapUtil
import com.intellij.openapi.project.Project
import java.util.function.Supplier
fun createActionExtendedInfo(project: Project?): ExtendedInfo {
internal fun createActionExtendedInfo(project: Project?): ExtendedInfo {
val description = fun(it: Any): String? {
return when (val value = (it as? MatchedValue)?.value ?: return null) {
is GotoActionModel.ActionWrapper -> value.action.templatePresentation.description
@@ -27,14 +30,13 @@ fun createActionExtendedInfo(project: Project?): ExtendedInfo {
return ExtendedInfo(description, shortcut)
}
class AssignShortcutAction(val project: Project?, val value: MatchedValue) :
private class AssignShortcutAction(val project: Project?, val value: MatchedValue) :
AnAction(Supplier { LangBundle.message("label.assign.shortcut") },
Supplier {
LangBundle.message("actions.tab.assign.a.shortcut", KeymapUtil.getFirstKeyboardShortcutText(
KeymapUtil.getActiveKeymapShortcuts(IdeActions.ACTION_SHOW_INTENTION_ACTIONS))
)
},
null) {
}) {
init {
shortcutSet = KeymapUtil.getActiveKeymapShortcuts(IdeActions.ACTION_SHOW_INTENTION_ACTIONS)

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.internal;
@@ -31,8 +31,7 @@ final class LoadAllContentsAction extends AnAction implements DumbAware {
LoadAllContentsAction() {
super(InternalActionsBundle.messagePointer("action.AnAction.text.load.all.files.content"),
InternalActionsBundle.messagePointer("action.AnAction.description.load.all.files.content"),
null);
InternalActionsBundle.messagePointer("action.AnAction.description.load.all.files.content"));
}
@Override

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.internal;
@@ -36,8 +36,7 @@ final class LoadAllVfsStoredContentsAction extends AnAction implements DumbAware
LoadAllVfsStoredContentsAction() {
super(InternalActionsBundle.messagePointer("action.AnAction.text.load.all.virtual.files.content"),
InternalActionsBundle.messagePointer("action.AnAction.description.load.all.virtual.files.content"),
null);
InternalActionsBundle.messagePointer("action.AnAction.description.load.all.virtual.files.content"));
}
@Override

View File

@@ -975,7 +975,7 @@ public final class DependenciesPanel extends JPanel implements Disposable, DataP
private final class SelectInLeftTreeAction extends AnAction {
SelectInLeftTreeAction() {
super(CodeInsightBundle.messagePointer("action.select.in.left.tree"),
CodeInsightBundle.messagePointer("action.select.in.left.tree.description"), null);
CodeInsightBundle.messagePointer("action.select.in.left.tree.description"));
}
@Override

View File

@@ -16,6 +16,8 @@ import com.intellij.refactoring.RefactoringBundle;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
/**
* @author lene
*/
@@ -23,7 +25,7 @@ public final class RenameProjectAction extends DumbAwareAction {
public RenameProjectAction() {
super(RefactoringBundle.messagePointer("rename.project.action.title"),
RefactoringBundle.messagePointer("renames.project"), null);
RefactoringBundle.messagePointer("renames.project"), (Icon)null);
}
private static final Logger LOG = Logger.getInstance(RenameProjectAction.class);

View File

@@ -106,9 +106,7 @@ public final class ActionStub extends AnAction implements ActionStubBase {
}
public static void copyTemplatePresentation(Presentation sourcePresentation, Presentation targetPresentation) {
if (targetPresentation.getIcon() == null && sourcePresentation.getIcon() != null) {
targetPresentation.setIcon(sourcePresentation.getIcon());
}
targetPresentation.copyIconIfUnset(sourcePresentation);
if (Strings.isEmpty(targetPresentation.getText()) && sourcePresentation.getText() != null) {
targetPresentation.setTextWithMnemonic(sourcePresentation.getTextWithPossibleMnemonic());
}

View File

@@ -69,10 +69,10 @@ public abstract class ToggleAction extends AnAction implements Toggleable {
@Override
public void update(final @NotNull AnActionEvent e) {
boolean selected = isSelected(e);
final Presentation presentation = e.getPresentation();
Presentation presentation = e.getPresentation();
Toggleable.setSelected(presentation, selected);
if (e.isFromContextMenu()) {
//force showing check marks instead of toggle icons in the context menu
// force showing check marks instead of toggle icons in the context menu
presentation.setIcon(null);
}
}

View File

@@ -57,8 +57,12 @@ public class ToggleOptionAction extends ToggleAction {
String name = option.getName();
if (name != null) presentation.setText(name);
String description = option.getDescription();
if (description != null) presentation.setDescription(description);
if (ActionPlaces.isPopupPlace(event.getPlace())) presentation.setIcon(null);
if (description != null) {
presentation.setDescription(description);
}
if (ActionPlaces.isPopupPlace(event.getPlace())) {
presentation.setIcon(null);
}
}
}

View File

@@ -1,6 +1,4 @@
/*
* Copyright 2000-2017 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.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.actions;
import com.intellij.ide.IdeBundle;
@@ -11,10 +9,12 @@ import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.ui.AppUIUtil;
import org.jetbrains.annotations.NotNull;
public final class DataSharingOptionsAction extends DumbAwareAction {
public DataSharingOptionsAction() {
import javax.swing.*;
final class DataSharingOptionsAction extends DumbAwareAction {
DataSharingOptionsAction() {
super(IdeBundle.messagePointer("action.DataSharingOptionsAction.text"),
IdeBundle.messagePointer("action.DataSharingOptionsAction.description"), null);
IdeBundle.messagePointer("action.DataSharingOptionsAction.description"), (Icon)null);
}
@Override

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.ui.customization
import com.intellij.icons.AllIcons
@@ -184,7 +184,7 @@ class ActionGroupPanel(
.mapNotNull { (id, group) ->
group ?: return@mapNotNull null
@NlsSafe val name = currentSchema.getDisplayName(id)
ActionsTreeUtil.createGroup(group, name, null, null, false) { true }
ActionsTreeUtil.createGroup(group, name, null, false) { true }
}
}
}

View File

@@ -340,7 +340,7 @@ class CustomActionsSchema(private val coroutineScope: CoroutineScope?) : Persist
for ((key, value) in idToName) {
val actionGroup = (actionManager.getAction(key) as? ActionGroup) ?: continue
//J2EE/Commander plugin was disabled
root.add(ActionsTreeUtil.createNode(ActionsTreeUtil.createGroup(actionGroup, value, null, null, true, null, false)))
root.add(ActionsTreeUtil.createNode(ActionsTreeUtil.createGroup(actionGroup, value, null, true, null, false)))
}
}

View File

@@ -425,7 +425,7 @@ public final class CustomizationUtil {
@NlsSafe
String displayName = schema.getDisplayName(groupId);
return ActionsTreeUtil.createGroup(group, displayName, null, null, false, action -> true);
return ActionsTreeUtil.createGroup(group, displayName, null, false, action -> true);
}
/**

View File

@@ -164,7 +164,7 @@ class CustomizeActionGroupPanel(
private inner class AddAction(
text: Supplier<String>,
val block: (selected: Int, model: CollectionListModel<Any>) -> Unit
) : DumbAwareAction(text, Presentation.NULL_STRING, null) {
) : DumbAwareAction(text) {
override fun actionPerformed(e: AnActionEvent) {
val selected = list.selectedIndices?.lastOrNull() ?: (list.model.size - 1)
val model = (list.model as CollectionListModel)
@@ -177,7 +177,6 @@ class CustomizeActionGroupPanel(
text: Supplier<String>,
icon: Icon
) : DumbAwareAction(text, Presentation.NULL_STRING, icon) {
init {
registerCustomShortcutSet(direction.shortcut, list)
}

View File

@@ -75,7 +75,7 @@ fun groupContainsAction(groupID: String, actionID: String, schema: CustomActions
private fun getGroup(groupID: String, schema: CustomActionsSchema): Group? {
val group = (schema.getCorrectedAction(groupID) as? ActionGroup) ?: return null
@NlsSafe val name = schema.getDisplayName(groupID)
return ActionsTreeUtil.createGroup(group, name, null, null, false, { _: AnAction? -> true }, false)
return ActionsTreeUtil.createGroup(group, name, null, false, { _: AnAction? -> true }, false)
}
private fun getSubGroup(group: Group, path: List<String>): Group? {

View File

@@ -57,10 +57,7 @@ import com.intellij.util.ArrayUtilRt
import com.intellij.util.DefaultBundleService
import com.intellij.util.ReflectionUtil
import com.intellij.util.childScope
import com.intellij.util.concurrency.AppExecutorUtil
import com.intellij.util.concurrency.ChildContext
import com.intellij.util.concurrency.ThreadingAssertions
import com.intellij.util.concurrency.createChildContext
import com.intellij.util.concurrency.*
import com.intellij.util.containers.ContainerUtil
import com.intellij.util.ui.StartupUiUtil.addAwtListener
import com.intellij.util.xml.dom.XmlElement
@@ -97,12 +94,15 @@ private val DEFAULT_ACTION_GROUP_CLASS_NAME = DefaultActionGroup::class.java.nam
open class ActionManagerImpl protected constructor(private val coroutineScope: CoroutineScope) : ActionManagerEx(), Disposable {
private val lock = Any()
@Volatile
private var idToAction = persistentHashMapOf<String, AnAction>()
private val pluginToId = HashMap<PluginId, MutableList<String>>()
private val idToIndex = Object2IntOpenHashMap<String>()
@Volatile
private var prohibitedActionIds = persistentHashSetOf<String>()
@Suppress("SSBasedInspection")
private val actionToId = Object2ObjectOpenHashMap<Any, String>()
private val idToGroupId = HashMap<String, MutableList<String>>()
@@ -175,7 +175,9 @@ open class ActionManagerImpl protected constructor(private val coroutineScope: C
if (timer == null) {
timer = MyTimer(coroutineScope.childScope())
}
val wrappedListener = if (AppExecutorUtil.propagateContextOrCancellation() && listener !is CapturingListener) CapturingListener(listener) else listener
val wrappedListener = if (AppExecutorUtil.propagateContextOrCancellation() && listener !is CapturingListener) CapturingListener(
listener)
else listener
timer!!.listeners.add(wrappedListener)
}
@@ -403,6 +405,7 @@ open class ActionManagerImpl protected constructor(private val coroutineScope: C
val iconPath = element.attributes.get(ICON_ATTR_NAME)
val projectType = element.attributes.get(PROJECT_TYPE)
val textValue = element.attributes.get(TEXT_ATTR_NAME)
@Suppress("HardCodedStringLiteral")
val descriptionValue = element.attributes.get(DESCRIPTION)
val stub = ActionStub(className, id, module, iconPath, ProjectType.create(projectType)) {
@@ -1049,7 +1052,7 @@ open class ActionManagerImpl protected constructor(private val coroutineScope: C
@TestOnly
fun resetProhibitedActions() {
synchronized(lock) {
prohibitedActionIds = prohibitedActionIds.clear()
prohibitedActionIds = prohibitedActionIds.clear()
}
}
@@ -1422,8 +1425,11 @@ private fun <T> instantiate(stubClassName: String,
private fun updateIconFromStub(stub: ActionStubBase, anAction: AnAction, componentManager: ComponentManager) {
val iconPath = stub.iconPath
if (iconPath != null) {
val icon = loadIcon(module = stub.plugin, iconPath = iconPath, requestor = anAction.javaClass.name)
anAction.templatePresentation.icon = icon
val module = stub.plugin
val requestor = anAction.javaClass.name
anAction.templatePresentation.setIconSupplier(SynchronizedClearableLazy {
loadIcon(module = module, iconPath = iconPath, requestor = requestor)
})
}
val customActionsSchema = componentManager.serviceIfCreated<CustomActionsSchema>()
@@ -1771,6 +1777,8 @@ private fun configureGroupDescriptionAndIcon(presentation: Presentation,
}
if (iconPath != null && group !is ActionGroupStub) {
presentation.icon = loadIcon(module = module, iconPath = iconPath, requestor = className)
presentation.setIconSupplier(SynchronizedClearableLazy {
loadIcon(module = module, iconPath = iconPath, requestor = className)
})
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.actionSystem.impl
import com.intellij.icons.AllIcons
@@ -8,10 +8,12 @@ import com.intellij.openapi.actionSystem.DefaultActionGroup
open class MoreActionGroup @JvmOverloads constructor(
horizontal: Boolean = true
) : DefaultActionGroup({ ActionsBundle.groupText("MoreActionGroup") }, true) {
init {
templatePresentation.icon = if (horizontal) AllIcons.Actions.More else AllIcons.Actions.MoreHorizontal
templatePresentation.putClientProperty(ActionButton.HIDE_DROPDOWN_ICON, true)
templatePresentation.isHideGroupIfEmpty = true
val presentation = templatePresentation
presentation.setIconSupplier {
if (horizontal) AllIcons.Actions.More else AllIcons.Actions.MoreHorizontal
}
presentation.putClientProperty(ActionButton.HIDE_DROPDOWN_ICON, true)
presentation.isHideGroupIfEmpty = true
}
}

View File

@@ -31,6 +31,7 @@ import com.intellij.openapi.util.NlsActions;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.util.text.Strings;
import com.intellij.util.containers.CollectionFactory;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.JBIterable;
@@ -43,6 +44,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import java.util.*;
import java.util.function.Predicate;
import java.util.function.Supplier;
import static com.intellij.codeInsight.intention.IntentionShortcuts.WRAPPER_PREFIX;
@@ -183,7 +185,7 @@ public final class ActionsTreeUtil {
}
public static Group createGroup(ActionGroup actionGroup, boolean forceAsPopup, Condition<? super AnAction> filtered) {
return createGroup(actionGroup, getName(actionGroup), actionGroup.getTemplatePresentation().getIcon(), null, forceAsPopup, filtered);
return createGroup(actionGroup, getName(actionGroup), actionGroup.getTemplatePresentation().getIcon(), forceAsPopup, filtered);
}
public static @NlsActions.ActionText String getName(AnAction action) {
@@ -213,33 +215,29 @@ public final class ActionsTreeUtil {
public static Group createGroup(ActionGroup actionGroup,
@NlsActions.ActionText String groupName,
Icon icon,
Icon openIcon,
boolean forceAsPopup,
Condition<? super AnAction> filtered) {
return createGroup(actionGroup, groupName, icon, openIcon, forceAsPopup, filtered, true);
return createGroup(actionGroup, groupName, icon, forceAsPopup, filtered, true);
}
public static Group createGroup(ActionGroup actionGroup,
@NlsActions.ActionText String groupName,
Icon icon,
Icon openIcon,
boolean forceAsPopup,
Condition<? super AnAction> filtered,
Predicate<? super AnAction> filtered,
boolean normalizeSeparators) {
ActionManager actionManager = ActionManager.getInstance();
Group group = new Group(groupName, actionManager.getId(actionGroup), icon);
AnAction[] children = getActions(actionGroup, actionManager);
for (AnAction action : children) {
if (action == null) {
LOG.error(groupName + " contains null actions");
continue;
}
if (action instanceof ActionGroup childGroup) {
Group subGroup = createGroup(childGroup, getName(action), null, null, forceAsPopup, filtered, normalizeSeparators);
if (forceAsPopup || childGroup.isPopup() || StringUtil.isNotEmpty(childGroup.getTemplateText())) {
if (subGroup.getSize() > 0 ||
filtered == null || filtered.value(childGroup)) {
Group subGroup = createGroup(childGroup, getName(action), null, forceAsPopup, filtered, normalizeSeparators);
if (forceAsPopup || childGroup.isPopup() || !Strings.isEmpty(childGroup.getTemplateText())) {
if (subGroup.getSize() > 0 || filtered == null || filtered.test(childGroup)) {
group.addGroup(subGroup);
}
}
@@ -248,14 +246,14 @@ public final class ActionsTreeUtil {
}
}
else if (action instanceof Separator) {
if (filtered == null || filtered.value(action)) {
if (filtered == null || filtered.test(action)) {
group.addSeparator();
}
}
else {
String id = actionManager.getId(action);
if (id != null) {
if (filtered == null || filtered.value(action)) {
if (filtered == null || filtered.test(action)) {
group.addActionId(id);
}
}
@@ -337,7 +335,7 @@ public final class ActionsTreeUtil {
return true;
}
private static Group createEditorActionsGroup(Condition<? super AnAction> filtered) {
private static Group createEditorActionsGroup(Predicate<? super AnAction> filtered) {
ActionManager actionManager = ActionManager.getInstance();
DefaultActionGroup editorGroup = (DefaultActionGroup)actionManager.getActionOrStub(IdeActions.GROUP_EDITOR);
if (editorGroup == null) throw new AssertionError(IdeActions.GROUP_EDITOR + " group not found");
@@ -354,7 +352,7 @@ public final class ActionsTreeUtil {
return group;
}
private static void addEditorActions(final Condition<? super AnAction> filtered,
private static void addEditorActions(Predicate<? super AnAction> filtered,
final DefaultActionGroup editorGroup,
final ArrayList<? super String> ids) {
AnAction[] editorActions = editorGroup.getChildActionsOrStubs();
@@ -365,8 +363,10 @@ public final class ActionsTreeUtil {
}
else {
String actionId = actionManager.getId(editorAction);
if (actionId == null) continue;
if (filtered == null || filtered.value(editorAction)) {
if (actionId == null) {
continue;
}
if (filtered == null || filtered.test(editorAction)) {
ids.add(actionId);
}
}

View File

@@ -738,15 +738,12 @@ internal class ToolWindowImpl(val toolWindowManager: ToolWindowManagerImpl,
private inner class RemoveStripeButtonAction :
AnAction(ActionsBundle.messagePointer("action.RemoveStripeButton.text"),
ActionsBundle.messagePointer("action.RemoveStripeButton.description"),
null), DumbAware, FusAwareAction {
ActionsBundle.messagePointer("action.RemoveStripeButton.description")), DumbAware, FusAwareAction {
override fun update(e: AnActionEvent) {
e.presentation.isEnabledAndVisible = isShowStripeButton
}
override fun getActionUpdateThread(): ActionUpdateThread {
return ActionUpdateThread.EDT
}
override fun getActionUpdateThread() = ActionUpdateThread.EDT
override fun actionPerformed(e: AnActionEvent) {
toolWindowManager.hideToolWindow(id, removeFromStripe = true, source = ToolWindowEventSource.RemoveStripeButtonAction)

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.toolWindow
import com.intellij.icons.AllIcons
@@ -17,6 +17,7 @@ import com.intellij.openapi.wm.impl.AbstractSquareStripeButton
import com.intellij.ui.UIBundle
import com.intellij.ui.awt.RelativePoint
import com.intellij.ui.icons.loadIconCustomVersionOrScale
import com.intellij.util.concurrency.SynchronizedClearableLazy
import com.intellij.util.ui.JBUI
import com.intellij.util.ui.accessibility.AccessibleContextUtil
import org.jetbrains.annotations.ApiStatus
@@ -75,7 +76,7 @@ internal class MoreSquareStripeButton(toolWindowToolbar: ToolWindowToolbar,
private fun createPresentation(): Presentation {
val presentation = Presentation()
presentation.icon = scaleIcon()
presentation.setIconSupplier(SynchronizedClearableLazy(::scaleIcon))
presentation.isEnabledAndVisible = true
return presentation
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.tasks.context;
import com.intellij.notification.*;
@@ -79,7 +79,7 @@ public class BranchContextTracker implements BranchChangeListener {
new ConfigureBranchContextDialog(myProject).show();
}
}).setContextHelpAction(new AnAction(TaskBundle.messagePointer("action.BranchContextTracker.Anonymous.text.what.is.a.workspace"),
TaskBundle.messagePointer("action.BranchContextTracker.Anonymous.description"), null) {
TaskBundle.messagePointer("action.BranchContextTracker.Anonymous.description")) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.vcs.changes.actions;
import com.intellij.openapi.actionSystem.*;
@@ -16,10 +16,9 @@ import com.intellij.pom.Navigatable;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
public class OpenRepositoryVersionAction extends AnAction implements DumbAware {
public final class OpenRepositoryVersionAction extends AnAction implements DumbAware {
public OpenRepositoryVersionAction() {
super(VcsBundle.messagePointer("open.repository.version.text"), VcsBundle.messagePointer("open.repository.version.description"), null);
super(VcsBundle.messagePointer("open.repository.version.text"), VcsBundle.messagePointer("open.repository.version.description"));
}
@Override

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.vcs.changes.savedPatches
import com.intellij.openapi.actionSystem.ActionUpdateThread
@@ -16,7 +16,7 @@ import java.util.function.Supplier
abstract class ShelfAction(
dynamicText: Supplier<@NlsActions.ActionText String>,
dynamicDescription: Supplier<@NlsActions.ActionDescription String>)
: DumbAwareAction(dynamicText, dynamicDescription, null) {
: DumbAwareAction(dynamicText, dynamicDescription) {
abstract fun perform(project: Project, shelves: List<ShelvedChangeList>)

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.vcs.changes.shelf;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
@@ -34,10 +20,10 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class ImportIntoShelfAction extends DumbAwareAction {
public final class ImportIntoShelfAction extends DumbAwareAction {
public ImportIntoShelfAction() {
super(VcsBundle.messagePointer("action.ImportIntoShelfAction.text"),
VcsBundle.messagePointer("action.ImportIntoShelfAction.description"), null);
VcsBundle.messagePointer("action.ImportIntoShelfAction.description"));
}
@Override

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.vcs.changes.ui.browser
import com.intellij.diff.DiffContentFactory
@@ -297,7 +297,7 @@ class ChangesFilterer(val project: Project?, val listener: Listener) : Disposabl
init {
isPopup = false
templatePresentation.text = VcsBundle.message("action.filter.filter.by.text")
templatePresentation.icon = AllIcons.General.Filter
templatePresentation.setIconSupplier { AllIcons.General.Filter }
templatePresentation.isDisableGroupIfEmpty = false
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.vcs.log.ui.actions;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
@@ -32,7 +32,7 @@ abstract class CollapseOrExpandGraphAction extends DumbAwareAction {
@NotNull Supplier<String> linearBranchesDescription,
@NotNull Supplier<String> mergesAction,
@NotNull Supplier<String> mergesDescription) {
super(linearBranchesAction, linearBranchesDescription, null);
super(linearBranchesAction, linearBranchesDescription);
myLinearBranchesAction = linearBranchesAction;
myLinearBranchesDescription = linearBranchesDescription;
myMergesAction = mergesAction;

View File

@@ -13,10 +13,10 @@ import com.intellij.vcs.log.statistics.VcsLogUsageTriggerCollector;
import com.intellij.vcs.log.ui.MainVcsLogUi;
import org.jetbrains.annotations.NotNull;
public class FocusTextFilterAction extends DumbAwareAction {
public final class FocusTextFilterAction extends DumbAwareAction {
public FocusTextFilterAction() {
super(VcsLogBundle.messagePointer("action.FocusTextFilterAction.text"),
VcsLogBundle.messagePointer("action.FocusTextFilterAction.description"), null);
VcsLogBundle.messagePointer("action.FocusTextFilterAction.description"));
}
@Override

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.vcs.log.ui.actions;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
@@ -14,10 +14,10 @@ import com.intellij.vcs.log.ui.table.VcsLogGraphTable;
import com.intellij.vcs.log.ui.table.column.Commit;
import org.jetbrains.annotations.NotNull;
public class ShowCommitTooltipAction extends DumbAwareAction {
public final class ShowCommitTooltipAction extends DumbAwareAction {
public ShowCommitTooltipAction() {
super(VcsLogBundle.messagePointer("action.ShowCommitTooltipAction.text"),
VcsLogBundle.messagePointer("action.ShowCommitTooltipAction.description"), null);
VcsLogBundle.messagePointer("action.ShowCommitTooltipAction.description"));
}
@Override

View File

@@ -74,7 +74,7 @@ import java.io.File;
import java.util.List;
import java.util.*;
public class AntExplorer extends SimpleToolWindowPanel implements DataProvider, Disposable {
public final class AntExplorer extends SimpleToolWindowPanel implements DataProvider, Disposable {
private Project myProject;
private Tree myTree;
private final AntBuildFilePropertiesAction myAntBuildFilePropertiesAction;
@@ -847,10 +847,9 @@ public class AntExplorer extends SimpleToolWindowPanel implements DataProvider,
}
private final class CreateMetaTargetAction extends AnAction {
CreateMetaTargetAction() {
super(AntBundle.messagePointer("ant.create.meta.target.action.name"),
AntBundle.messagePointer("ant.create.meta.target.action.description"), null);
AntBundle.messagePointer("ant.create.meta.target.action.description"));
}
@Override

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package git4idea.merge
import com.intellij.openapi.actionSystem.ActionUpdateThread
@@ -21,11 +21,11 @@ import git4idea.repo.GitRepositoryManager
import org.jetbrains.annotations.Nls
import java.util.function.Supplier
class GitAcceptTheirsAction : GitAcceptConflictSideAction(GitBundle.messagePointer("conflicts.accept.theirs.action.text"), true)
class GitAcceptYoursAction : GitAcceptConflictSideAction(GitBundle.messagePointer("conflicts.accept.yours.action.text"), false)
private class GitAcceptTheirsAction : GitAcceptConflictSideAction(GitBundle.messagePointer("conflicts.accept.theirs.action.text"), true)
private class GitAcceptYoursAction : GitAcceptConflictSideAction(GitBundle.messagePointer("conflicts.accept.yours.action.text"), false)
abstract class GitConflictAction(text: Supplier<@Nls String>) :
DumbAwareAction(text, Presentation.NULL_STRING, null) {
DumbAwareAction(text, Presentation.NULL_STRING) {
override fun update(e: AnActionEvent) {
val project = e.project

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.plugins.github.pullrequest.action
import com.intellij.openapi.actionSystem.ActionUpdateThread
@@ -6,9 +6,8 @@ import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.DumbAwareAction
import org.jetbrains.plugins.github.i18n.GithubBundle
class GHPROpenPullRequestAction : DumbAwareAction(GithubBundle.messagePointer("pull.request.open.action"),
GithubBundle.messagePointer("pull.request.open.action.description"),
null) {
private class GHPROpenPullRequestAction : DumbAwareAction(GithubBundle.messagePointer("pull.request.open.action"),
GithubBundle.messagePointer("pull.request.open.action.description")) {
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
override fun update(e: AnActionEvent) {

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.plugins.github.pullrequest.action
import com.intellij.collaboration.messages.CollaborationToolsBundle
@@ -7,10 +7,9 @@ import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.DumbAwareAction
import org.jetbrains.plugins.github.i18n.GithubBundle
class GHPROpenPullRequestTimelineAction
private class GHPROpenPullRequestTimelineAction
: DumbAwareAction(CollaborationToolsBundle.messagePointer("review.details.view.timeline.action"),
GithubBundle.messagePointer("pull.request.view.conversations.action.description"),
null) {
GithubBundle.messagePointer("pull.request.view.conversations.action.description")) {
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

View File

@@ -6,13 +6,12 @@ import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.DumbAwareAction
import org.jetbrains.plugins.gitlab.mergerequest.data.GitLabMergeRequestDetails
import org.jetbrains.plugins.gitlab.mergerequest.ui.toolwindow.model.GitLabToolWindowProjectViewModel
import org.jetbrains.plugins.gitlab.mergerequest.ui.toolwindow.GitLabReviewTab
import org.jetbrains.plugins.gitlab.mergerequest.ui.toolwindow.model.GitLabToolWindowProjectViewModel
import org.jetbrains.plugins.gitlab.util.GitLabBundle
class GitLabShowMergeRequestAction : DumbAwareAction(GitLabBundle.messagePointer("merge.request.show.action"),
GitLabBundle.messagePointer("merge.request.show.action.description"),
null) {
private class GitLabShowMergeRequestAction : DumbAwareAction(GitLabBundle.messagePointer("merge.request.show.action"),
GitLabBundle.messagePointer("merge.request.show.action.description")) {
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
override fun update(e: AnActionEvent) {

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.idea.svn.actions;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
@@ -36,11 +36,10 @@ import static org.jetbrains.idea.svn.SvnBundle.messagePointer;
import static org.jetbrains.idea.svn.commandLine.CommandUtil.escape;
import static org.jetbrains.idea.svn.properties.ExternalsDefinitionParser.parseExternalsProperty;
public class CreateExternalAction extends DumbAwareAction {
public final class CreateExternalAction extends DumbAwareAction {
public CreateExternalAction() {
super(messagePointer("svn.create.external.below.action"),
messagePointer("svn.create.external.below.description"),
null);
messagePointer("svn.create.external.below.description"));
}
@Override

View File

@@ -320,8 +320,7 @@ public class RepositoryBrowserDialog extends DialogWrapper {
public HistoryAction() {
super(
messagePointer("action.repository.browser.history.text"),
messagePointer("action.repository.browser.history.description"),
null
messagePointer("action.repository.browser.history.description")
);
}
@@ -1005,8 +1004,7 @@ public class RepositoryBrowserDialog extends DialogWrapper {
public BrowseCommittedChangesAction() {
super(
messagePointer("repository.browser.browse.changes.action"),
messagePointer("repository.browser.browse.changes.description"),
null
messagePointer("repository.browser.browse.changes.description")
);
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.plugins.terminal.action
import com.intellij.icons.AllIcons
@@ -13,7 +13,7 @@ import org.jetbrains.plugins.terminal.TerminalToolWindowManager
open class TerminalNewTabAction : DumbAwareAction(
TerminalBundle.messagePointer("action.Terminal.NewTab.text"),
TerminalBundle.messagePointer("action.Terminal.NewTab.description"),
AllIcons.General.Add), ActionRemoteBehaviorSpecification.Frontend {
{ AllIcons.General.Add }), ActionRemoteBehaviorSpecification.Frontend {
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
@@ -28,6 +28,6 @@ open class TerminalNewTabAction : DumbAwareAction(
}
companion object {
const val ACTION_ID = "Terminal.NewTab"
const val ACTION_ID: String = "Terminal.NewTab"
}
}

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.designer.actions;
import com.intellij.designer.DesignerBundle;
@@ -105,7 +91,7 @@ public class DesignerActionPanel implements DataProvider {
final DefaultActionGroup group = DefaultActionGroup.createPopupGroup(() -> DesignerBundle.message("action.select.text"));
AnAction selectParent = new AnAction(UIBundle.messagePointer("action.DesignerActionPanel.Anonymous.text.select.parent"),
UIBundle.messagePointer("action.DesignerActionPanel.Anonymous.description.select.parent"), null) {
UIBundle.messagePointer("action.DesignerActionPanel.Anonymous.description.select.parent")) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
myDesigner.getToolProvider().processKeyEvent(new KeyEvent(myDesigner.getSurfaceArea().getNativeComponent(),