From 7eb33862d7dcf2ca0018a01f50dfc4db5bc6000a Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 20 Oct 2023 01:08:04 +0200 Subject: [PATCH] IJPL-300 Do not use AllIcons class during ActionManager instantiation GitOrigin-RevId: 3f6590989a50044398ef0f4414285b20444257f2 --- .../impl/ui/actions/PackageFileAction.java | 22 +-- .../actions/NewModuleAction.java | 4 +- .../ConvertToRepositoryLibraryActionBase.kt | 5 +- .../openapi/actionSystem/ActionGroup.java | 6 + .../openapi/actionSystem/AnAction.java | 48 +++++-- .../openapi/actionSystem/Presentation.java | 132 +++++++++++------- .../execution/ExecutorRegistryImpl.java | 13 +- .../actions/BaseRunConfigurationAction.java | 12 +- .../execution/actions/RunContextAction.java | 4 +- .../actions/ShowRunningListAction.java | 3 +- .../openapi/project/DumbAwareAction.java | 37 ++--- .../documentation/DockablePopupManager.java | 5 +- .../template/impl/TemplateListPanel.java | 4 +- .../src/com/intellij/find/FindAllAction.java | 4 +- .../CreateDirectoryOrPackageAction.java | 2 +- .../footer/ActionExtendedInfo.kt | 12 +- .../internal/LoadAllContentsAction.java | 5 +- .../LoadAllVfsStoredContentsAction.java | 5 +- .../ui/DependenciesPanel.java | 2 +- .../renameProject/RenameProjectAction.java | 4 +- .../openapi/actionSystem/ActionStub.java | 4 +- .../openapi/actionSystem/ToggleAction.java | 4 +- .../actionSystem/ToggleOptionAction.java | 8 +- .../ide/actions/DataSharingOptionsAction.java | 12 +- .../ide/ui/customization/ActionGroupPanel.kt | 4 +- .../ui/customization/CustomActionsSchema.kt | 2 +- .../ui/customization/CustomizationUtil.java | 2 +- .../CustomizeActionGroupPanel.kt | 3 +- .../ToolbarQuickActionInsertStrategies.kt | 2 +- .../actionSystem/impl/ActionManagerImpl.kt | 26 ++-- .../actionSystem/impl/MoreActionGroup.kt | 12 +- .../keymap/impl/ui/ActionsTreeUtil.java | 32 ++--- .../openapi/wm/impl/ToolWindowImpl.kt | 7 +- .../toolWindow/MoreSquareStripeButton.kt | 5 +- .../tasks/context/BranchContextTracker.java | 4 +- .../actions/OpenRepositoryVersionAction.java | 7 +- .../vcs/changes/savedPatches/ShelfActions.kt | 4 +- .../changes/shelf/ImportIntoShelfAction.java | 20 +-- .../vcs/changes/ui/browser/ChangesFilterer.kt | 4 +- .../actions/CollapseOrExpandGraphAction.java | 4 +- .../log/ui/actions/FocusTextFilterAction.java | 4 +- .../ui/actions/ShowCommitTooltipAction.java | 6 +- .../lang/ant/config/explorer/AntExplorer.java | 5 +- .../src/git4idea/merge/GitConflictActions.kt | 8 +- .../action/GHPROpenPullRequestAction.kt | 7 +- .../GHPROpenPullRequestTimelineAction.kt | 7 +- .../action/GitLabShowMergeRequestAction.kt | 7 +- .../svn/actions/CreateExternalAction.java | 7 +- .../svn/dialogs/RepositoryBrowserDialog.java | 6 +- .../terminal/action/TerminalNewTabAction.kt | 6 +- .../designer/actions/DesignerActionPanel.java | 18 +-- 51 files changed, 303 insertions(+), 273 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/ui/actions/PackageFileAction.java b/java/compiler/impl/src/com/intellij/packaging/impl/ui/actions/PackageFileAction.java index fa883723250e..4a955cac63fc 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/ui/actions/PackageFileAction.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/ui/actions/PackageFileAction.java @@ -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 diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/actions/NewModuleAction.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/actions/NewModuleAction.java index 9d9dfec1bfd9..fa4a77286525 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/actions/NewModuleAction.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/actions/NewModuleAction.java @@ -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 diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ConvertToRepositoryLibraryActionBase.kt b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ConvertToRepositoryLibraryActionBase.kt index f7cd16c751fb..46967105a51b 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ConvertToRepositoryLibraryActionBase.kt +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ConvertToRepositoryLibraryActionBase.kt @@ -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() 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 diff --git a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionGroup.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionGroup.java index 4f52b3352a51..33ff26330e5a 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionGroup.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionGroup.java @@ -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 icon) { + super(text, description, icon); + } + public ActionGroup(@NotNull Supplier<@ActionText String> dynamicText, @NotNull Supplier<@ActionDescription String> dynamicDescription, @Nullable Icon icon) { diff --git a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnAction.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnAction.java index ce604ebb5bf9..4f1a417178ce 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnAction.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnAction.java @@ -59,7 +59,7 @@ public abstract class AnAction implements PossiblyDumbAware, ActionUpdateThreadA public static final Key> 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 text, + @NotNull @ActionDescription Supplier description, + @Nullable Supplier iconSupplier) { + Presentation presentation = getTemplatePresentation(); + presentation.setText(text); + presentation.setDescription(description); + presentation.setIconSupplier(iconSupplier); + } + + @ApiStatus.Experimental + public AnAction(@NotNull @ActionText Supplier text, @NotNull @ActionDescription Supplier 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; diff --git a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/Presentation.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/Presentation.java index 244b62008a0b..c38fdc3bff49 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/Presentation.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/Presentation.java @@ -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 myTextWithMnemonicSupplier = () -> null; + private @NotNull Supplier<@ActionDescription String> descriptionSupplier = NULL_STRING; + private @NotNull Supplier textWithMnemonicSupplier = () -> null; private @NotNull SmartFMap myUserMap = SmartFMap.emptyMap(); - private Icon myIcon; - private Icon myDisabledIcon; - private Icon myHoveredIcon; - private Icon mySelectedIcon; + private @Nullable Supplier 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 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 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 supplier) { - Supplier original = myTextWithMnemonicSupplier; + Supplier original = textWithMnemonicSupplier; Supplier 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 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 oldDescription = myDescriptionSupplier; - myDescriptionSupplier = dynamicDescription; - fireObjectPropertyChange(PROP_DESCRIPTION, oldDescription.get(), myDescriptionSupplier.get()); + Supplier oldDescription = descriptionSupplier; + descriptionSupplier = dynamicDescription; + if (changeSupport != null) { + fireObjectPropertyChange(PROP_DESCRIPTION, oldDescription.get(), descriptionSupplier.get()); + } } public void setDescription(@ActionDescription String description) { - Supplier oldDescriptionSupplier = myDescriptionSupplier; - myDescriptionSupplier = () -> description; - fireObjectPropertyChange(PROP_DESCRIPTION, oldDescriptionSupplier.get(), description); + Supplier oldDescriptionSupplier = descriptionSupplier; + descriptionSupplier = () -> description; + if (changeSupport != null) { + fireObjectPropertyChange(PROP_DESCRIPTION, oldDescriptionSupplier.get(), description); + } } public Icon getIcon() { - return myIcon; + Supplier 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 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() + ")"; } } diff --git a/platform/execution-impl/src/com/intellij/execution/ExecutorRegistryImpl.java b/platform/execution-impl/src/com/intellij/execution/ExecutorRegistryImpl.java index 77d99a24e275..7d8bc74b6a6f 100644 --- a/platform/execution-impl/src/com/intellij/execution/ExecutorRegistryImpl.java +++ b/platform/execution-impl/src/com/intellij/execution/ExecutorRegistryImpl.java @@ -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 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 diff --git a/platform/execution-impl/src/com/intellij/execution/actions/BaseRunConfigurationAction.java b/platform/execution-impl/src/com/intellij/execution/actions/BaseRunConfigurationAction.java index 797ac5bb02e1..7165d80fde34 100644 --- a/platform/execution-impl/src/com/intellij/execution/actions/BaseRunConfigurationAction.java +++ b/platform/execution-impl/src/com/intellij/execution/actions/BaseRunConfigurationAction.java @@ -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 text, + @NotNull Supplier description, + @Nullable Supplier icon) { + super(text, description, icon); + + setPopup(true); + setEnabledInModalContext(true); + } + @Override public @NotNull ActionUpdateThread getActionUpdateThread() { return ActionUpdateThread.BGT; diff --git a/platform/execution-impl/src/com/intellij/execution/actions/RunContextAction.java b/platform/execution-impl/src/com/intellij/execution/actions/RunContextAction.java index 37da333bf847..db4f6d10dd5d 100644 --- a/platform/execution-impl/src/com/intellij/execution/actions/RunContextAction.java +++ b/platform/execution-impl/src/com/intellij/execution/actions/RunContextAction.java @@ -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; } diff --git a/platform/execution-impl/src/com/intellij/execution/actions/ShowRunningListAction.java b/platform/execution-impl/src/com/intellij/execution/actions/ShowRunningListAction.java index 6f7c4fc1c5a0..37310560d2f7 100644 --- a/platform/execution-impl/src/com/intellij/execution/actions/ShowRunningListAction.java +++ b/platform/execution-impl/src/com/intellij/execution/actions/ShowRunningListAction.java @@ -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 diff --git a/platform/ide-core/src/com/intellij/openapi/project/DumbAwareAction.java b/platform/ide-core/src/com/intellij/openapi/project/DumbAwareAction.java index 2b056863aea0..419802701722 100644 --- a/platform/ide-core/src/com/intellij/openapi/project/DumbAwareAction.java +++ b/platform/ide-core/src/com/intellij/openapi/project/DumbAwareAction.java @@ -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 actionPerformed) { + public static @NotNull DumbAwareAction create(@NotNull Consumer actionPerformed) { return new SimpleDumbAwareAction(actionPerformed); } - @NotNull - public static DumbAwareAction create(@Nullable @NlsActions.ActionText String text, - @NotNull Consumer actionPerformed) { + public static @NotNull DumbAwareAction create(@Nullable @NlsActions.ActionText String text, + @NotNull Consumer actionPerformed) { return new SimpleDumbAwareAction(text, actionPerformed); } - @NotNull - public static DumbAwareAction create(@Nullable Icon icon, - @NotNull Consumer actionPerformed) { + public static @NotNull DumbAwareAction create(@Nullable Icon icon, + @NotNull Consumer actionPerformed) { return new SimpleDumbAwareAction(icon, actionPerformed); } - @NotNull - public static DumbAwareAction create(@Nullable @NlsActions.ActionText String text, - @Nullable Icon icon, - @NotNull Consumer actionPerformed) { + public static @NotNull DumbAwareAction create(@Nullable @NlsActions.ActionText String text, + @Nullable Icon icon, + @NotNull Consumer 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 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 getDelegate() { + public @NotNull Consumer getDelegate() { return myActionPerformed; } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DockablePopupManager.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DockablePopupManager.java index b7310d21110e..098fe3bf2859 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DockablePopupManager.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DockablePopupManager.java @@ -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 { @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(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java index 6a08055b56ac..e76602dfa741 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java @@ -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) { diff --git a/platform/lang-impl/src/com/intellij/find/FindAllAction.java b/platform/lang-impl/src/com/intellij/find/FindAllAction.java index 53f9fb1e787b..2a2ebc65e79b 100644 --- a/platform/lang-impl/src/com/intellij/find/FindAllAction.java +++ b/platform/lang-impl/src/com/intellij/find/FindAllAction.java @@ -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 diff --git a/platform/lang-impl/src/com/intellij/ide/actions/CreateDirectoryOrPackageAction.java b/platform/lang-impl/src/com/intellij/ide/actions/CreateDirectoryOrPackageAction.java index 176ba71abe4b..7e795ef1b9d2 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/CreateDirectoryOrPackageAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/CreateDirectoryOrPackageAction.java @@ -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 diff --git a/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/footer/ActionExtendedInfo.kt b/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/footer/ActionExtendedInfo.kt index 595002770534..eb9b394f6da0 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/footer/ActionExtendedInfo.kt +++ b/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/footer/ActionExtendedInfo.kt @@ -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) diff --git a/platform/lang-impl/src/com/intellij/internal/LoadAllContentsAction.java b/platform/lang-impl/src/com/intellij/internal/LoadAllContentsAction.java index 7a31205706cf..c85d65025b16 100644 --- a/platform/lang-impl/src/com/intellij/internal/LoadAllContentsAction.java +++ b/platform/lang-impl/src/com/intellij/internal/LoadAllContentsAction.java @@ -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 diff --git a/platform/lang-impl/src/com/intellij/internal/LoadAllVfsStoredContentsAction.java b/platform/lang-impl/src/com/intellij/internal/LoadAllVfsStoredContentsAction.java index cc9c23426955..21deae70aa58 100644 --- a/platform/lang-impl/src/com/intellij/internal/LoadAllVfsStoredContentsAction.java +++ b/platform/lang-impl/src/com/intellij/internal/LoadAllVfsStoredContentsAction.java @@ -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 diff --git a/platform/lang-impl/src/com/intellij/packageDependencies/ui/DependenciesPanel.java b/platform/lang-impl/src/com/intellij/packageDependencies/ui/DependenciesPanel.java index 449c96eddf0d..91f8e6837137 100644 --- a/platform/lang-impl/src/com/intellij/packageDependencies/ui/DependenciesPanel.java +++ b/platform/lang-impl/src/com/intellij/packageDependencies/ui/DependenciesPanel.java @@ -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 diff --git a/platform/lang-impl/src/com/intellij/platform/renameProject/RenameProjectAction.java b/platform/lang-impl/src/com/intellij/platform/renameProject/RenameProjectAction.java index 3a0b2d8983a7..657a3186007f 100644 --- a/platform/lang-impl/src/com/intellij/platform/renameProject/RenameProjectAction.java +++ b/platform/lang-impl/src/com/intellij/platform/renameProject/RenameProjectAction.java @@ -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); diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionStub.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionStub.java index e068cca54b40..8cc92aa092cb 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionStub.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionStub.java @@ -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()); } diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ToggleAction.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ToggleAction.java index f3640c0fc033..ab6fe5c27982 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ToggleAction.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ToggleAction.java @@ -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); } } diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ToggleOptionAction.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ToggleOptionAction.java index bc37a7f5112f..01acae660a8a 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ToggleOptionAction.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ToggleOptionAction.java @@ -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); + } } } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/DataSharingOptionsAction.java b/platform/platform-impl/src/com/intellij/ide/actions/DataSharingOptionsAction.java index 7fa8899453b9..97e7478917f3 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/DataSharingOptionsAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/DataSharingOptionsAction.java @@ -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 diff --git a/platform/platform-impl/src/com/intellij/ide/ui/customization/ActionGroupPanel.kt b/platform/platform-impl/src/com/intellij/ide/ui/customization/ActionGroupPanel.kt index 1c9e35fe8c66..0514fac796a6 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/customization/ActionGroupPanel.kt +++ b/platform/platform-impl/src/com/intellij/ide/ui/customization/ActionGroupPanel.kt @@ -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 } } } } diff --git a/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomActionsSchema.kt b/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomActionsSchema.kt index 6fb25d3a5f17..2394a3cddded 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomActionsSchema.kt +++ b/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomActionsSchema.kt @@ -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))) } } diff --git a/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomizationUtil.java b/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomizationUtil.java index 1ab06bcb6459..ac1175cef072 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomizationUtil.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomizationUtil.java @@ -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); } /** diff --git a/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomizeActionGroupPanel.kt b/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomizeActionGroupPanel.kt index 48ed4a117c6a..bc9fed5d70ec 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomizeActionGroupPanel.kt +++ b/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomizeActionGroupPanel.kt @@ -164,7 +164,7 @@ class CustomizeActionGroupPanel( private inner class AddAction( text: Supplier, val block: (selected: Int, model: CollectionListModel) -> 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, icon: Icon ) : DumbAwareAction(text, Presentation.NULL_STRING, icon) { - init { registerCustomShortcutSet(direction.shortcut, list) } diff --git a/platform/platform-impl/src/com/intellij/ide/ui/customization/ToolbarQuickActionInsertStrategies.kt b/platform/platform-impl/src/com/intellij/ide/ui/customization/ToolbarQuickActionInsertStrategies.kt index 76e2795f5222..63dbb45af3e9 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/customization/ToolbarQuickActionInsertStrategies.kt +++ b/platform/platform-impl/src/com/intellij/ide/ui/customization/ToolbarQuickActionInsertStrategies.kt @@ -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): Group? { diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.kt b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.kt index 639aea670e7c..a6dc46ff6f99 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.kt +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.kt @@ -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() private val pluginToId = HashMap>() private val idToIndex = Object2IntOpenHashMap() + @Volatile private var prohibitedActionIds = persistentHashSetOf() + @Suppress("SSBasedInspection") private val actionToId = Object2ObjectOpenHashMap() private val idToGroupId = HashMap>() @@ -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 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() @@ -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) + }) } } diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/MoreActionGroup.kt b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/MoreActionGroup.kt index aa2555c03c50..0402e15a07ff 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/MoreActionGroup.kt +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/MoreActionGroup.kt @@ -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 } } \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTreeUtil.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTreeUtil.java index 1f7d96307231..82a45e9ef0c3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTreeUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTreeUtil.java @@ -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 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 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 filtered, + Predicate 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 filtered) { + private static Group createEditorActionsGroup(Predicate 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 filtered, + private static void addEditorActions(Predicate filtered, final DefaultActionGroup editorGroup, final ArrayList 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); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.kt b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.kt index f1d00c0968b9..0652a7d78371 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.kt +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.kt @@ -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) diff --git a/platform/platform-impl/src/com/intellij/toolWindow/MoreSquareStripeButton.kt b/platform/platform-impl/src/com/intellij/toolWindow/MoreSquareStripeButton.kt index 75e954be1501..b8aba49b8661 100644 --- a/platform/platform-impl/src/com/intellij/toolWindow/MoreSquareStripeButton.kt +++ b/platform/platform-impl/src/com/intellij/toolWindow/MoreSquareStripeButton.kt @@ -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 } diff --git a/platform/tasks-platform-impl/src/com/intellij/tasks/context/BranchContextTracker.java b/platform/tasks-platform-impl/src/com/intellij/tasks/context/BranchContextTracker.java index bd187e7df012..ff7d61d3b1dd 100644 --- a/platform/tasks-platform-impl/src/com/intellij/tasks/context/BranchContextTracker.java +++ b/platform/tasks-platform-impl/src/com/intellij/tasks/context/BranchContextTracker.java @@ -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) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/OpenRepositoryVersionAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/OpenRepositoryVersionAction.java index ea4230c27703..ef242fbfe6ff 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/OpenRepositoryVersionAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/OpenRepositoryVersionAction.java @@ -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 diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/savedPatches/ShelfActions.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/savedPatches/ShelfActions.kt index f8c55cc02497..f580a89b4b5d 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/savedPatches/ShelfActions.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/savedPatches/ShelfActions.kt @@ -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) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ImportIntoShelfAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ImportIntoShelfAction.java index 07124bf2df16..a10cbb6c195b 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ImportIntoShelfAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ImportIntoShelfAction.java @@ -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 diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/browser/ChangesFilterer.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/browser/ChangesFilterer.kt index d747b97aa946..fd2d3f9660f3 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/browser/ChangesFilterer.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/browser/ChangesFilterer.kt @@ -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 } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/CollapseOrExpandGraphAction.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/CollapseOrExpandGraphAction.java index 7f597a346a18..53c3d2e6540a 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/CollapseOrExpandGraphAction.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/CollapseOrExpandGraphAction.java @@ -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 linearBranchesDescription, @NotNull Supplier mergesAction, @NotNull Supplier mergesDescription) { - super(linearBranchesAction, linearBranchesDescription, null); + super(linearBranchesAction, linearBranchesDescription); myLinearBranchesAction = linearBranchesAction; myLinearBranchesDescription = linearBranchesDescription; myMergesAction = mergesAction; diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/FocusTextFilterAction.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/FocusTextFilterAction.java index dcd76ca0b8b5..4ce6fea89ec4 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/FocusTextFilterAction.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/FocusTextFilterAction.java @@ -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 diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/ShowCommitTooltipAction.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/ShowCommitTooltipAction.java index 85f4bd13a8ff..d6adaca7fb7a 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/ShowCommitTooltipAction.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/ShowCommitTooltipAction.java @@ -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 diff --git a/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntExplorer.java b/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntExplorer.java index f18e85fb2681..78efd00b1bb5 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntExplorer.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntExplorer.java @@ -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 diff --git a/plugins/git4idea/src/git4idea/merge/GitConflictActions.kt b/plugins/git4idea/src/git4idea/merge/GitConflictActions.kt index 9fc206650abe..260a0044b1b1 100644 --- a/plugins/git4idea/src/git4idea/merge/GitConflictActions.kt +++ b/plugins/git4idea/src/git4idea/merge/GitConflictActions.kt @@ -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 diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/action/GHPROpenPullRequestAction.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/action/GHPROpenPullRequestAction.kt index b6fc45309df9..d39b6b74487f 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/action/GHPROpenPullRequestAction.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/action/GHPROpenPullRequestAction.kt @@ -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) { diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/action/GHPROpenPullRequestTimelineAction.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/action/GHPROpenPullRequestTimelineAction.kt index 07360093843e..5caf4c0c95fc 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/action/GHPROpenPullRequestTimelineAction.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/action/GHPROpenPullRequestTimelineAction.kt @@ -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 diff --git a/plugins/gitlab/src/org/jetbrains/plugins/gitlab/mergerequest/action/GitLabShowMergeRequestAction.kt b/plugins/gitlab/src/org/jetbrains/plugins/gitlab/mergerequest/action/GitLabShowMergeRequestAction.kt index d1110b53ebb4..dac3009b20f2 100644 --- a/plugins/gitlab/src/org/jetbrains/plugins/gitlab/mergerequest/action/GitLabShowMergeRequestAction.kt +++ b/plugins/gitlab/src/org/jetbrains/plugins/gitlab/mergerequest/action/GitLabShowMergeRequestAction.kt @@ -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) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateExternalAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateExternalAction.java index 4d87a1a6008a..b4ac50bbd4ac 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateExternalAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateExternalAction.java @@ -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 diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java index 53916f75e396..f8965c7ba8e6 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java @@ -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") ); } diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/action/TerminalNewTabAction.kt b/plugins/terminal/src/org/jetbrains/plugins/terminal/action/TerminalNewTabAction.kt index f3a6d1ed93c6..a471e956d650 100644 --- a/plugins/terminal/src/org/jetbrains/plugins/terminal/action/TerminalNewTabAction.kt +++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/action/TerminalNewTabAction.kt @@ -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" } } \ No newline at end of file diff --git a/plugins/ui-designer-core/src/com/intellij/designer/actions/DesignerActionPanel.java b/plugins/ui-designer-core/src/com/intellij/designer/actions/DesignerActionPanel.java index b94f175d5fff..785973483ea8 100644 --- a/plugins/ui-designer-core/src/com/intellij/designer/actions/DesignerActionPanel.java +++ b/plugins/ui-designer-core/src/com/intellij/designer/actions/DesignerActionPanel.java @@ -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(),