localize AnActionButton(String, String, Icon)

GitOrigin-RevId: eab24c5ee719c41860b1bc564d0f67ed7f46b1b3
This commit is contained in:
Dmitry.Krasilschikov
2020-01-26 17:45:32 +02:00
committed by intellij-monorepo-bot
parent 3cc5c57c23
commit 236eb26697
6 changed files with 86 additions and 13 deletions

View File

@@ -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()

View File

@@ -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<ActionButtonListener> myListeners = new ArrayList<>();
public AnActionButton(@Nls(capitalization = Nls.Capitalization.Title) String text) {
super(text);
super(() -> text);
}
public AnActionButton(@NotNull Supplier<String> 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<String> dynamicText,
@NotNull Supplier<String> 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<String> dynamicText, Icon icon) {
this(dynamicText, Presentation.NULL_STRING, icon);
}
public AnActionButton() {
}

View File

@@ -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<String> dynamicText,
@NotNull Supplier<String> 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<String> dynamicText, Icon icon) {
this(dynamicText, Presentation.NULL_STRING, icon);
}
public DumbAwareActionButton() {
}
}

View File

@@ -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
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

View File

@@ -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) {

View File

@@ -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