Browse Source

Provide localisation for window buttons.

pull/188/head
weisj 5 years ago
parent
commit
093eaf82bb
  1. 48
      core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameTitlePane.java
  2. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/actions.properties
  3. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/actions_ar.properties
  4. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/actions_da.properties
  5. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/actions_de.properties
  6. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/actions_en.properties
  7. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/actions_es.properties
  8. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/actions_fr.properties
  9. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/actions_it.properties
  10. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/actions_ja.properties
  11. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/actions_nl.properties
  12. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/actions_no.properties
  13. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/actions_pl.properties
  14. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/actions_ru.properties
  15. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/actions_sv.properties
  16. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/actions_zh.properties
  17. 35
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java

48
core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameTitlePane.java

@ -27,6 +27,7 @@ package com.github.weisj.darklaf.ui.internalframe;
import java.awt.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ResourceBundle;
import javax.accessibility.AccessibleContext;
import javax.swing.*;
@ -34,10 +35,13 @@ import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import sun.swing.SwingUtilities2;
import com.github.weisj.darklaf.components.tooltip.ToolTipStyle;
import com.github.weisj.darklaf.components.uiresource.JButtonUIResource;
import com.github.weisj.darklaf.icons.EmptyIcon;
import com.github.weisj.darklaf.icons.ToggleIcon;
import com.github.weisj.darklaf.ui.button.DarkButtonUI;
import com.github.weisj.darklaf.ui.tooltip.DarkToolTipUI;
import com.github.weisj.darklaf.util.ResourceUtil;
/**
* @author Jannis Weis
@ -65,6 +69,7 @@ public class DarkInternalFrameTitlePane extends BasicInternalFrameTitlePane impl
private int buttonMarginPad;
private boolean useExternalMenuBar;
private ResourceBundle bundle;
public DarkInternalFrameTitlePane(final JInternalFrame f) {
super(f);
@ -109,6 +114,8 @@ public class DarkInternalFrameTitlePane extends BasicInternalFrameTitlePane impl
protected void installDefaults() {
super.installDefaults();
bundle = ResourceUtil.getResourceBundle("actions", frame);
closeIcon = UIManager.getIcon("InternalFrameTitlePane.close.icon");
minimizeIcon = new ToggleIcon(UIManager.getIcon("InternalFrameTitlePane.minimize.icon"),
EmptyIcon.create(16));
@ -140,18 +147,22 @@ public class DarkInternalFrameTitlePane extends BasicInternalFrameTitlePane impl
@Override
protected void createButtons() {
iconButton = createButton(UIManager.getString("InternalFrameTitlePane.iconifyButtonAccessibleName"));
iconButton.addActionListener(iconifyAction);
maxButton = createButton(UIManager.getString("InternalFrameTitlePane.maximizeButtonAccessibleName"));
iconButton = createButton(iconifyAction);
maxButton = createButton(maximizeAction);
maxButton.addActionListener(e -> {
if (maximizeAction.isEnabled()) {
maximizeAction.actionPerformed(e);
restoreAction.setEnabled(true);
maxButton.setAction(restoreAction);
maximizeAction.setEnabled(false);
} else {
restoreAction.actionPerformed(e);
maximizeAction.setEnabled(true);
maxButton.setAction(restoreAction);
restoreAction.setEnabled(false);
}
maxButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, maxButton.getText());
maxButton.setText(null);
});
closeButton = createButton(UIManager.getString("InternalFrameTitlePane.closeButtonAccessibleName"));
closeButton.addActionListener(closeAction);
closeButton = createButton(closeAction);
setButtonIcons();
}
@ -177,6 +188,15 @@ public class DarkInternalFrameTitlePane extends BasicInternalFrameTitlePane impl
mi.setIcon(closeIcon);
}
@Override
protected void createActions() {
super.createActions();
maximizeAction.putValue(Action.NAME, bundle.getString("Actions.maximize"));
closeAction.putValue(Action.NAME, bundle.getString("Actions.close"));
iconifyAction.putValue(Action.NAME, bundle.getString("Actions.minimize"));
restoreAction.putValue(Action.NAME, bundle.getString("Actions.restore"));
}
private static int getButtonMnemonic(final String button) {
try {
return Integer.parseInt(UIManager.getString("InternalFrameTitlePane." + button + "Button.mnemonic"));
@ -208,20 +228,28 @@ public class DarkInternalFrameTitlePane extends BasicInternalFrameTitlePane impl
return frame.isSelected() ? selectedTitleColor : notSelectedTitleColor;
}
private JButton createButton(final String accessibleName) {
JButton button = new JButtonUIResource() {
private JButton createButton(final Action action) {
JButton button = new JButtonUIResource(action) {
@Override
public boolean isRolloverEnabled() {
return true;
}
@Override
public String getToolTipText() {
Object tipText = getAction().getValue(Action.NAME);
return tipText != null ? tipText.toString() : null;
}
};
ToolTipManager.sharedInstance().registerComponent(button);
button.setFocusable(false);
button.setOpaque(true);
button.putClientProperty(DarkButtonUI.KEY_VARIANT, DarkButtonUI.VARIANT_BORDERLESS);
button.putClientProperty(DarkButtonUI.KEY_SQUARE, true);
button.putClientProperty(DarkButtonUI.KEY_THIN, true);
button.putClientProperty(DarkToolTipUI.KEY_STYLE, ToolTipStyle.PLAIN);
button.setMargin(new Insets(buttonMarginPad, buttonMarginPad, buttonMarginPad, buttonMarginPad));
button.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, accessibleName);
button.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, button.getText());
button.setText(null);
return button;
}

4
core/src/main/resources/com/github/weisj/darklaf/bundles/actions.properties

@ -27,4 +27,8 @@
Actions.cut = Cut
Actions.copy = Copy
Actions.paste = Paste
Actions.close = Close
Actions.maximize = Maximize
Actions.minimize = Minimize
Actions.restore = Restore
Actions.closableTabbedPane.close = Close. Alt-Click to close others

4
core/src/main/resources/com/github/weisj/darklaf/bundles/actions_ar.properties

@ -27,5 +27,9 @@
Actions.cut = يقطع
Actions.copy = نسخ
Actions.paste = لصق
Actions.close = قريب
Actions.maximize = تحقيق أقصى قدر
Actions.minimize = التقليل
Actions.restore = استعادة
Actions.closableTabbedPane.close = قريب. Alt انقر لإغلاق الآخرين

4
core/src/main/resources/com/github/weisj/darklaf/bundles/actions_da.properties

@ -27,4 +27,8 @@
Actions.cut = Skære
Actions.copy = Kopi
Actions.paste = Sæt ind
Actions.close = Tæt
Actions.maximize = Minimer
Actions.minimize = Maksimer
Actions.restore = Gendan
Actions.closableTabbedPane.close = Tæt. Alt-Klik for at lukke andre

4
core/src/main/resources/com/github/weisj/darklaf/bundles/actions_de.properties

@ -27,4 +27,8 @@
Actions.cut = Ausschneiden
Actions.copy = Kopieren
Actions.paste = Einfügen
Actions.close = Schließen
Actions.maximize = Minimieren
Actions.minimize = Maximieren
Actions.restore = Wiederherstellen
Actions.closableTabbedPane.close = Schließen. Alt-Klicken, um andere zu schließen

4
core/src/main/resources/com/github/weisj/darklaf/bundles/actions_en.properties

@ -27,4 +27,8 @@
Actions.cut = Cut
Actions.copy = Copy
Actions.paste = Paste
Actions.close = Close
Actions.maximize = Maximize
Actions.minimize = Minimize
Actions.restore = Restore
Actions.closableTabbedPane.close = Close. Alt-Click to close others

4
core/src/main/resources/com/github/weisj/darklaf/bundles/actions_es.properties

@ -27,4 +27,8 @@
Actions.cut = Cortar
Actions.copy = Copiar
Actions.paste = Pegar
Actions.close = Cerca
Actions.maximize = Maximizar
Actions.minimize = Minimizar
Actions.restore = Restaurar
Actions.closableTabbedPane.close = Cerca. Alt-Click para cerrar otros

4
core/src/main/resources/com/github/weisj/darklaf/bundles/actions_fr.properties

@ -27,4 +27,8 @@
Actions.cut = Couper
Actions.copy = Copie
Actions.paste = Pâte
Actions.close = Proche
Actions.maximize = Maximiser
Actions.minimize = Minimiser
Actions.restore = Restaurer
Actions.closableTabbedPane.close = Proche. Alt-Cliquez pour fermer les autres

4
core/src/main/resources/com/github/weisj/darklaf/bundles/actions_it.properties

@ -27,4 +27,8 @@
Actions.cut = Taglio
Actions.copy = Copia
Actions.paste = Incolla
Actions.close = Vicino
Actions.maximize = Ingrandire a pieno schermo
Actions.minimize = Ridurre
Actions.restore = Ristabilire
Actions.closableTabbedPane.close = Vicino. Alt-clic per chiudere gli altri

4
core/src/main/resources/com/github/weisj/darklaf/bundles/actions_ja.properties

@ -27,4 +27,8 @@
Actions.cut = 切る
Actions.copy = 写し
Actions.paste = 貼付
Actions.close = 閉じる
Actions.maximize = 最大化
Actions.minimize = 最小化
Actions.restore = 戻す
Actions.closableTabbedPane.close = 閉じる。 Alt-クリックして他を閉じる

4
core/src/main/resources/com/github/weisj/darklaf/bundles/actions_nl.properties

@ -27,4 +27,8 @@
Actions.cut = Knippen
Actions.copy = Kopiëren
Actions.paste = Plakken
Actions.close = Dichtbij
Actions.maximize = Maximaliseren
Actions.minimize = Minimaliseren
Actions.restore = Herstellen
Actions.closableTabbedPane.close = Dichtbij. Alt-klik om anderen te sluiten

4
core/src/main/resources/com/github/weisj/darklaf/bundles/actions_no.properties

@ -27,4 +27,8 @@
Actions.cut = Klipp
Actions.copy = Kopi
Actions.paste = Pasta
Actions.close = Lukk
Actions.maximize = Minimere
Actions.minimize = Maksimer
Actions.restore = Restaurere
Actions.closableTabbedPane.close = Lukk. Alt-klikk for å lukke andre

4
core/src/main/resources/com/github/weisj/darklaf/bundles/actions_pl.properties

@ -27,4 +27,8 @@
Actions.cut = Wytnij
Actions.copy = Kopię
Actions.paste = Wklej
Actions.close = Blisko
Actions.maximize = Wyolbrzymiać
Actions.minimize = Zminimalizować
Actions.restore = Przywracać
Actions.closableTabbedPane.close = Blisko. Alt-Kliknij, aby zamknąć inne

4
core/src/main/resources/com/github/weisj/darklaf/bundles/actions_ru.properties

@ -27,4 +27,8 @@
Actions.cut = Резать
Actions.copy = Копия
Actions.paste = Вставить
Actions.close = Близко
Actions.maximize = Максимизация
Actions.minimize = Минимизировать
Actions.restore = Восстановить
Actions.closableTabbedPane.close = Близко. Alt-Click, чтобы закрыть другие

4
core/src/main/resources/com/github/weisj/darklaf/bundles/actions_sv.properties

@ -27,4 +27,8 @@
Actions.cut = Skära
Actions.copy = Kopia
Actions.paste = Klistra
Actions.close = Stänga
Actions.maximize = Maximera
Actions.minimize = Minimera
Actions.restore = Återställ
Actions.closableTabbedPane.close = Stänga. Alt-Klicka för att stänga andra

4
core/src/main/resources/com/github/weisj/darklaf/bundles/actions_zh.properties

@ -27,4 +27,8 @@
Actions.cut = 切
Actions.copy = 复制
Actions.paste = 糊
Actions.close = 关
Actions.maximize = 最大化
Actions.minimize = 最小化
Actions.restore = 恢复
Actions.closableTabbedPane.close = 关。 Alt单击以关闭其他人

35
windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java

@ -29,6 +29,7 @@ import java.awt.event.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.List;
import java.util.ResourceBundle;
import javax.accessibility.AccessibleContext;
import javax.swing.*;
@ -121,11 +122,14 @@ public class WindowsTitlePane extends CustomTitlePane {
private int right;
private int height;
private final ResourceBundle bundle;
private GraphicsConfiguration gc;
public WindowsTitlePane(final JRootPane root, final int decorationStyle, final Window window) {
this.rootPane = root;
this.window = window;
bundle = ResourceBundle.getBundle("com.github.weisj.darklaf.bundles.actions", getLocale());
setDecorationsStyle(decorationStyle);
rootPane.addContainerListener(rootPaneContainerListener);
rootPane.getLayeredPane().addContainerListener(layeredPaneContainerListener);
@ -136,13 +140,13 @@ public class WindowsTitlePane extends CustomTitlePane {
setLayout(createLayout());
}
private static JButton createButton(final String accessibleName, final Icon icon, final Action action) {
return createButton(accessibleName, icon, action, false);
private static JButton createButton(final Icon icon, final Action action) {
return createButton(icon, action, false);
}
private static JButton createButton(final String accessibleName, final Icon icon, final Action action,
private static JButton createButton(final Icon icon, final Action action,
final boolean close) {
JButton button = new JButton() {
JButton button = new JButton(action) {
@Override
public boolean isRolloverEnabled() {
return true;
@ -160,8 +164,9 @@ public class WindowsTitlePane extends CustomTitlePane {
button.setRolloverEnabled(true);
button.putClientProperty("JButton.variant", "borderlessRectangular");
button.putClientProperty("paintActive", Boolean.TRUE);
button.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, accessibleName);
button.setAction(action);
button.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, button.getText());
button.putClientProperty("JToolTip.style", "plain");
button.setToolTipText(button.getText());
button.setIcon(icon);
button.setText(null);
return button;
@ -416,13 +421,13 @@ public class WindowsTitlePane extends CustomTitlePane {
}
private void createButtons() {
closeButton = createButton("Close", closeIcon, closeAction, true);
closeButton = createButton(closeIcon, closeAction, true);
Icon closePressed = UIManager.getIcon("Windows.TitlePane.closeHover.icon");
closeButton.setRolloverIcon(closePressed);
closeButton.setPressedIcon(closePressed);
minimizeButton = createButton("Iconify", minimizeIcon, minimizeAction);
maximizeToggleButton = createButton("Maximize", maximizeIcon, restoreAction);
minimizeButton = createButton(minimizeIcon, minimizeAction);
maximizeToggleButton = createButton(maximizeIcon, restoreAction);
windowIconButton = createWindowIcon();
}
@ -571,6 +576,9 @@ public class WindowsTitlePane extends CustomTitlePane {
private void updateToggleButton(final Action action, final Icon icon) {
maximizeToggleButton.setAction(action);
maximizeToggleButton.setIcon(icon);
maximizeToggleButton.setToolTipText(maximizeToggleButton.getText());
maximizeToggleButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
maximizeToggleButton.getText());
maximizeToggleButton.setText(null);
}
@ -612,7 +620,7 @@ public class WindowsTitlePane extends CustomTitlePane {
private class CloseAction extends AbstractAction {
public CloseAction() {
super("Close", closeIcon);
super(bundle.getString("Actions.close"), closeIcon);
}
public void actionPerformed(final ActionEvent e) {
@ -622,8 +630,7 @@ public class WindowsTitlePane extends CustomTitlePane {
private class MinimizeAction extends AbstractAction {
public MinimizeAction() {
// UIManager.getString("Minimize", getLocale())
super("Minimize", minimizeIcon);
super(bundle.getString("Actions.minimize"), minimizeIcon);
}
public void actionPerformed(final ActionEvent e) {
@ -633,7 +640,7 @@ public class WindowsTitlePane extends CustomTitlePane {
private class MaximizeAction extends AbstractAction {
public MaximizeAction() {
super("Maximize", maximizeIcon);
super(bundle.getString("Actions.maximize"), maximizeIcon);
}
public void actionPerformed(final ActionEvent e) {
@ -643,7 +650,7 @@ public class WindowsTitlePane extends CustomTitlePane {
private class RestoreAction extends AbstractAction {
public RestoreAction() {
super("Restore", restoreIcon);
super(bundle.getString("Actions.restore"), restoreIcon);
}
public void actionPerformed(final ActionEvent e) {

Loading…
Cancel
Save