diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java b/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java index d66ae14f7743..3ccee12bd782 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java @@ -138,7 +138,9 @@ public class CaptureConfigurable implements SearchableConfigurable, NoScroll { } }); - decorator.addExtraAction(new DumbAwareActionButton("Duplicate", "Duplicate", PlatformIcons.COPY_ICON) { + decorator.addExtraAction(new DumbAwareActionButton(() -> DebuggerBundle.message("action.AnActionButton.text.duplicate"), + () -> DebuggerBundle.message("action.AnActionButton.description.duplicate"), + PlatformIcons.COPY_ICON) { @Override public boolean isEnabled() { return table.getSelectedRowCount() == 1; @@ -158,7 +160,9 @@ public class CaptureConfigurable implements SearchableConfigurable, NoScroll { } }); - decorator.addExtraAction(new DumbAwareActionButton("Enable Selected", "Enable Selected", PlatformIcons.SELECT_ALL_ICON) { + decorator.addExtraAction(new DumbAwareActionButton(() -> DebuggerBundle.message("action.AnActionButton.text.enable.selected"), + () -> DebuggerBundle.message("action.AnActionButton.description.enable.selected"), + PlatformIcons.SELECT_ALL_ICON) { @Override public boolean isEnabled() { return table.getSelectedRowCount() > 0; @@ -170,7 +174,9 @@ public class CaptureConfigurable implements SearchableConfigurable, NoScroll { table.repaint(); } }); - decorator.addExtraAction(new DumbAwareActionButton("Disable Selected", "Disable Selected", PlatformIcons.UNSELECT_ALL_ICON) { + decorator.addExtraAction(new DumbAwareActionButton(() -> DebuggerBundle.message("action.AnActionButton.text.disable.selected"), + () -> DebuggerBundle.message("action.AnActionButton.description.disable.selected"), + PlatformIcons.UNSELECT_ALL_ICON) { @Override public boolean isEnabled() { return table.getSelectedRowCount() > 0; @@ -196,7 +202,9 @@ public class CaptureConfigurable implements SearchableConfigurable, NoScroll { } }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0)), table); - decorator.addExtraAction(new DumbAwareActionButton("Import", "Import", AllIcons.Actions.Install) { + decorator.addExtraAction(new DumbAwareActionButton(() -> DebuggerBundle.message("action.AnActionButton.text.import"), + () -> DebuggerBundle.message("action.AnActionButton.description.import"), + AllIcons.Actions.Install) { @Override public void actionPerformed(@NotNull final AnActionEvent e) { FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, true, false, true, true) { @@ -233,7 +241,9 @@ public class CaptureConfigurable implements SearchableConfigurable, NoScroll { } } }); - decorator.addExtraAction(new DumbAwareActionButton("Export", "Export", AllIcons.ToolbarDecorator.Export) { + decorator.addExtraAction(new DumbAwareActionButton(() -> DebuggerBundle.message("action.AnActionButton.text.export"), + () -> DebuggerBundle.message("action.AnActionButton.description.export"), + AllIcons.ToolbarDecorator.Export) { @Override public void actionPerformed(@NotNull final AnActionEvent e) { VirtualFileWrapper wrapper = FileChooserFactory.getInstance() diff --git a/platform/platform-api/src/com/intellij/ui/AnActionButton.java b/platform/platform-api/src/com/intellij/ui/AnActionButton.java index 26046b84a4da..9e93c363201c 100644 --- a/platform/platform-api/src/com/intellij/ui/AnActionButton.java +++ b/platform/platform-api/src/com/intellij/ui/AnActionButton.java @@ -17,6 +17,7 @@ import java.awt.*; import java.util.ArrayList; import java.util.List; import java.util.Set; +import java.util.function.Supplier; /** * @author Konstantin Bulenkov @@ -30,7 +31,11 @@ public abstract class AnActionButton extends AnAction implements ShortcutProvide private final List myListeners = new ArrayList<>(); public AnActionButton(@Nls(capitalization = Nls.Capitalization.Title) String text) { - super(text); + super(() -> text); + } + + public AnActionButton(@NotNull Supplier dynamicText) { + super(dynamicText); } public AnActionButton(@Nls(capitalization = Nls.Capitalization.Title) String text, @@ -39,10 +44,20 @@ public abstract class AnActionButton extends AnAction implements ShortcutProvide super(text, description, icon); } + public AnActionButton(@NotNull Supplier dynamicText, + @NotNull Supplier dynamicDescription, + @Nullable Icon icon) { + super(dynamicText, dynamicDescription, icon); + } + public AnActionButton(@Nls(capitalization = Nls.Capitalization.Title) String text, Icon icon) { this(text, null, icon); } + public AnActionButton(@NotNull Supplier dynamicText, Icon icon) { + this(dynamicText, Presentation.NULL_STRING, icon); + } + public AnActionButton() { } diff --git a/platform/platform-api/src/com/intellij/ui/DumbAwareActionButton.java b/platform/platform-api/src/com/intellij/ui/DumbAwareActionButton.java index 2b9d4d42210a..cee6405e2b4b 100644 --- a/platform/platform-api/src/com/intellij/ui/DumbAwareActionButton.java +++ b/platform/platform-api/src/com/intellij/ui/DumbAwareActionButton.java @@ -15,11 +15,14 @@ */ package com.intellij.ui; +import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.project.DumbAware; import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import java.util.function.Supplier; /** * @author gregsh @@ -36,11 +39,21 @@ public abstract class DumbAwareActionButton extends AnActionButton implements Du super(text, description, icon); } + public DumbAwareActionButton(@NotNull Supplier dynamicText, + @NotNull Supplier dynamicDescription, + @Nullable Icon icon) { + super(dynamicText, dynamicDescription, icon); + } + public DumbAwareActionButton(@Nls(capitalization = Nls.Capitalization.Title) String text, Icon icon) { super(text, icon); } + public DumbAwareActionButton(@NotNull Supplier dynamicText, Icon icon) { + this(dynamicText, Presentation.NULL_STRING, icon); + } + public DumbAwareActionButton() { } } diff --git a/plugins/IntelliLang/src/messages/IntelliLangBundle.properties b/plugins/IntelliLang/src/messages/IntelliLangBundle.properties index 6b4682c06915..64803b5e65df 100644 --- a/plugins/IntelliLang/src/messages/IntelliLangBundle.properties +++ b/plugins/IntelliLang/src/messages/IntelliLangBundle.properties @@ -21,4 +21,15 @@ settings.use.dataflow.analysis=&Use dataflow analysis (slow) settings.convert.undefined.operands.to.text=Convert undefined operands to &text in concatenations settings.add.language.annotation.or.comment=Add @Language annotation or comment if needed action.XmlLanguageInjectionSupport.Anonymous.xml.tag.injection=XML Tag Injection -action.XmlLanguageInjectionSupport.Anonymous.xml.attribute.injection=XML Attribute Injection \ No newline at end of file +action.XmlLanguageInjectionSupport.Anonymous.xml.attribute.injection=XML Attribute Injection +action.AnActionButton.text.duplicate=Duplicate +action.AnActionButton.description.duplicate=Duplicate +action.AnActionButton.text.enable.selected.injections=Enable Selected Injections +action.AnActionButton.description.enable.selected.injections=Enable Selected Injections +action.AnActionButton.text.disable.selected.injections=Disable Selected Injections +action.AnActionButton.description.disable.selected.injections=Disable Selected Injections +action.AnActionButton.text.move.to.ide.scope=Move to IDE Scope +action.AnActionButton.text.import=Import +action.AnActionButton.description.import=Import +action.AnActionButton.text.export=Export +action.AnActionButton.description.export=Export \ No newline at end of file diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java index 580c2bcacbcf..05ebab46de32 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java @@ -138,7 +138,9 @@ public final class InjectionsSettingsUI extends SearchableConfigurable.Parent.Ab return edit != null && edit.getTemplatePresentation().isEnabled(); }); decorator.setEditAction(button -> performEditAction()); - decorator.addExtraAction(new DumbAwareActionButton("Duplicate", "Duplicate", PlatformIcons.COPY_ICON) { + decorator.addExtraAction(new DumbAwareActionButton(() -> IntelliLangBundle.message("action.AnActionButton.text.duplicate"), + () -> IntelliLangBundle.message("action.AnActionButton.description.duplicate"), + PlatformIcons.COPY_ICON) { @Override public boolean isEnabled() { @@ -155,14 +157,20 @@ public final class InjectionsSettingsUI extends SearchableConfigurable.Parent.Ab } }); - decorator.addExtraAction(new DumbAwareActionButton("Enable Selected Injections", "Enable Selected Injections", PlatformIcons.SELECT_ALL_ICON) { + decorator.addExtraAction( + new DumbAwareActionButton(() -> IntelliLangBundle.message("action.AnActionButton.text.enable.selected.injections"), + () -> IntelliLangBundle.message("action.AnActionButton.description.enable.selected.injections"), + PlatformIcons.SELECT_ALL_ICON) { @Override public void actionPerformed(@NotNull final AnActionEvent e) { performSelectedInjectionsEnabled(true); } }); - decorator.addExtraAction(new DumbAwareActionButton("Disable Selected Injections", "Disable Selected Injections", PlatformIcons.UNSELECT_ALL_ICON) { + decorator.addExtraAction( + new DumbAwareActionButton(() -> IntelliLangBundle.message("action.AnActionButton.text.disable.selected.injections"), + () -> IntelliLangBundle.message("action.AnActionButton.description.disable.selected.injections"), + PlatformIcons.UNSELECT_ALL_ICON) { @Override public void actionPerformed(@NotNull final AnActionEvent e) { @@ -184,7 +192,9 @@ public final class InjectionsSettingsUI extends SearchableConfigurable.Parent.Ab }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0)), myInjectionsTable); if (myInfos.length > 1) { - AnActionButton shareAction = new DumbAwareActionButton("Move to IDE Scope", null, PlatformIcons.IMPORT_ICON) { + AnActionButton shareAction = + new DumbAwareActionButton(() -> IntelliLangBundle.message("action.AnActionButton.text.move.to.ide.scope"), + PlatformIcons.IMPORT_ICON) { { addCustomUpdater(e -> { CfgInfo cfg = getTargetCfgInfo(getSelectedInjections()); @@ -229,7 +239,9 @@ public final class InjectionsSettingsUI extends SearchableConfigurable.Parent.Ab shareAction.setShortcut(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.SHIFT_DOWN_MASK))); decorator.addExtraAction(shareAction); } - decorator.addExtraAction(new DumbAwareActionButton("Import", "Import", AllIcons.Actions.Install) { + decorator.addExtraAction(new DumbAwareActionButton(() -> IntelliLangBundle.message("action.AnActionButton.text.import"), + () -> IntelliLangBundle.message("action.AnActionButton.description.import"), + AllIcons.Actions.Install) { @Override public void actionPerformed(@NotNull final AnActionEvent e) { @@ -237,7 +249,9 @@ public final class InjectionsSettingsUI extends SearchableConfigurable.Parent.Ab updateCountLabel(); } }); - decorator.addExtraAction(new DumbAwareActionButton("Export", "Export", AllIcons.ToolbarDecorator.Export) { + decorator.addExtraAction(new DumbAwareActionButton(() -> IntelliLangBundle.message("action.AnActionButton.text.export"), + () -> IntelliLangBundle.message("action.AnActionButton.description.export"), + AllIcons.ToolbarDecorator.Export) { @Override public void actionPerformed(@NotNull final AnActionEvent e) { diff --git a/resources-en/src/messages/DebuggerBundle.properties b/resources-en/src/messages/DebuggerBundle.properties index 160b46ed61c1..9d725ea5ed4d 100644 --- a/resources-en/src/messages/DebuggerBundle.properties +++ b/resources-en/src/messages/DebuggerBundle.properties @@ -526,3 +526,13 @@ settings.capture.column.insert.key.expression=Insert key expression settings.async.schedule=Async Schedule settings.async.execute=Async Execute settings.async.annotations.configuration=Async Annotations Configuration +action.AnActionButton.text.duplicate=Duplicate +action.AnActionButton.description.duplicate=Duplicate +action.AnActionButton.text.enable.selected=Enable Selected +action.AnActionButton.description.enable.selected=Enable Selected +action.AnActionButton.text.disable.selected=Disable Selected +action.AnActionButton.description.disable.selected=Disable Selected +action.AnActionButton.text.import=Import +action.AnActionButton.description.import=Import +action.AnActionButton.text.export=Export +action.AnActionButton.description.export=Export