From b50ca187b451e5dce18d60a11d338817f58b65fe Mon Sep 17 00:00:00 2001 From: weisj Date: Wed, 17 Jun 2020 20:04:47 +0200 Subject: [PATCH] Added option to close all other tabs in ClosableTabbedPane. --- .../components/ClosableTabComponent.java | 22 ++++++++++++++++--- .../weisj/darklaf/bundles/actions.properties | 7 +++--- .../darklaf/bundles/actions_ar.properties | 8 ++++--- .../darklaf/bundles/actions_da.properties | 7 +++--- .../darklaf/bundles/actions_de.properties | 7 +++--- .../darklaf/bundles/actions_en.properties | 7 +++--- .../darklaf/bundles/actions_es.properties | 7 +++--- .../darklaf/bundles/actions_fr.properties | 7 +++--- .../darklaf/bundles/actions_it.properties | 7 +++--- .../darklaf/bundles/actions_ja.properties | 7 +++--- .../darklaf/bundles/actions_nl.properties | 7 +++--- .../darklaf/bundles/actions_no.properties | 7 +++--- .../darklaf/bundles/actions_pl.properties | 7 +++--- .../darklaf/bundles/actions_ru.properties | 7 +++--- .../darklaf/bundles/actions_sv.properties | 7 +++--- .../darklaf/bundles/actions_zh.properties | 7 +++--- 16 files changed, 80 insertions(+), 48 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/components/ClosableTabComponent.java b/core/src/main/java/com/github/weisj/darklaf/components/ClosableTabComponent.java index 049d840f..4d6ff3f9 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/ClosableTabComponent.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/ClosableTabComponent.java @@ -32,6 +32,7 @@ import javax.swing.*; import javax.swing.plaf.ComponentUI; import com.github.weisj.darklaf.ui.tabbedpane.DarkTabbedPaneUI; +import com.github.weisj.darklaf.util.ResourceUtil; /** * @author Jannis Weis @@ -161,13 +162,28 @@ public class ClosableTabComponent extends JPanel { } }; addMouseListener(mouseListener); + setToolTipText(ResourceUtil.getResourceBundle("actions", tabComponent.pane) + .getString("Actions.closableTabbedPane.close")); } @Override public void actionPerformed(final ActionEvent e) { - int i = tabComponent.pane.indexOfTabComponent(tabComponent); - if (i != -1) { - tabComponent.pane.remove(i); + if ((e.getModifiers() & ActionEvent.ALT_MASK) != 0) { + // Close all other tabs. + int tabCount = tabComponent.pane.getTabCount(); + for (int i = tabCount - 1; i >= 0; i--) { + Component tabComp = tabComponent.pane.getTabComponentAt(i); + if (tabComp == tabComponent) continue; + if (tabComp instanceof ClosableTabComponent + && ((ClosableTabComponent) tabComp).isClosable()) { + tabComponent.pane.removeTabAt(i); + } + } + } else { + int i = tabComponent.pane.indexOfTabComponent(tabComponent); + if (i != -1) { + tabComponent.pane.remove(i); + } } } } diff --git a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions.properties b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions.properties index edc7ce3b..55b7f995 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions.properties @@ -24,6 +24,7 @@ # # suppress inspection "UnusedProperty" for whole file # -Actions.cut = Cut -Actions.copy = Copy -Actions.paste = Paste +Actions.cut = Cut +Actions.copy = Copy +Actions.paste = Paste +Actions.closableTabbedPane.close = Close. Alt-Click to close others diff --git a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_ar.properties b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_ar.properties index d4792c36..7fe286b3 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_ar.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_ar.properties @@ -24,6 +24,8 @@ # # suppress inspection "UnusedProperty" for whole file # -Actions.cut = يقطع -Actions.copy = نسخ -Actions.paste = لصق +Actions.cut = يقطع +Actions.copy = نسخ +Actions.paste = لصق +Actions.closableTabbedPane.close = قريب. Alt انقر لإغلاق الآخرين + diff --git a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_da.properties b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_da.properties index dbd721c2..41e1b4d7 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_da.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_da.properties @@ -24,6 +24,7 @@ # # suppress inspection "UnusedProperty" for whole file # -Actions.cut = Skære -Actions.copy = Kopi -Actions.paste = Sæt ind +Actions.cut = Skære +Actions.copy = Kopi +Actions.paste = Sæt ind +Actions.closableTabbedPane.close = Tæt. Alt-Klik for at lukke andre diff --git a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_de.properties b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_de.properties index 8db989d4..f7ccca4b 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_de.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_de.properties @@ -24,6 +24,7 @@ # # suppress inspection "UnusedProperty" for whole file # -Actions.cut = Ausschneiden -Actions.copy = Kopieren -Actions.paste = Einfügen +Actions.cut = Ausschneiden +Actions.copy = Kopieren +Actions.paste = Einfügen +Actions.closableTabbedPane.close = Schließen. Alt-Klicken, um andere zu schließen diff --git a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_en.properties b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_en.properties index edc7ce3b..55b7f995 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_en.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_en.properties @@ -24,6 +24,7 @@ # # suppress inspection "UnusedProperty" for whole file # -Actions.cut = Cut -Actions.copy = Copy -Actions.paste = Paste +Actions.cut = Cut +Actions.copy = Copy +Actions.paste = Paste +Actions.closableTabbedPane.close = Close. Alt-Click to close others diff --git a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_es.properties b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_es.properties index 0970d834..ed1499d8 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_es.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_es.properties @@ -24,6 +24,7 @@ # # suppress inspection "UnusedProperty" for whole file # -Actions.cut = Cortar -Actions.copy = Copiar -Actions.paste = Pegar +Actions.cut = Cortar +Actions.copy = Copiar +Actions.paste = Pegar +Actions.closableTabbedPane.close = Cerca. Alt-Click para cerrar otros diff --git a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_fr.properties b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_fr.properties index cdc6730f..7f63b93a 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_fr.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_fr.properties @@ -24,6 +24,7 @@ # # suppress inspection "UnusedProperty" for whole file # -Actions.cut = Couper -Actions.copy = Copie -Actions.paste = Pâte +Actions.cut = Couper +Actions.copy = Copie +Actions.paste = Pâte +Actions.closableTabbedPane.close = Proche. Alt-Cliquez pour fermer les autres diff --git a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_it.properties b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_it.properties index c8886074..194672fc 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_it.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_it.properties @@ -24,6 +24,7 @@ # # suppress inspection "UnusedProperty" for whole file # -Actions.cut = Taglio -Actions.copy = Copia -Actions.paste = Incolla +Actions.cut = Taglio +Actions.copy = Copia +Actions.paste = Incolla +Actions.closableTabbedPane.close = Vicino. Alt-clic per chiudere gli altri diff --git a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_ja.properties b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_ja.properties index 5bf0d4af..7b39567a 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_ja.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_ja.properties @@ -24,6 +24,7 @@ # # suppress inspection "UnusedProperty" for whole file # -Actions.cut = 切る -Actions.copy = 写し -Actions.paste = 貼付 +Actions.cut = 切る +Actions.copy = 写し +Actions.paste = 貼付 +Actions.closableTabbedPane.close = 閉じる。 Alt-クリックして他を閉じる diff --git a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_nl.properties b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_nl.properties index 9fffce9d..15ae4391 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_nl.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_nl.properties @@ -24,6 +24,7 @@ # # suppress inspection "UnusedProperty" for whole file # -Actions.cut = Knippen -Actions.copy = Kopiëren -Actions.paste = Plakken +Actions.cut = Knippen +Actions.copy = Kopiëren +Actions.paste = Plakken +Actions.closableTabbedPane.close = Dichtbij. Alt-klik om anderen te sluiten diff --git a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_no.properties b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_no.properties index 3cf5aa28..d19891d8 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_no.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_no.properties @@ -24,6 +24,7 @@ # # suppress inspection "UnusedProperty" for whole file # -Actions.cut = Klipp -Actions.copy = Kopi -Actions.paste = Pasta +Actions.cut = Klipp +Actions.copy = Kopi +Actions.paste = Pasta +Actions.closableTabbedPane.close = Lukk. Alt-klikk for å lukke andre diff --git a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_pl.properties b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_pl.properties index 7fc982ae..5c9e1497 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_pl.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_pl.properties @@ -24,6 +24,7 @@ # # suppress inspection "UnusedProperty" for whole file # -Actions.cut = Wytnij -Actions.copy = Kopię -Actions.paste = Wklej +Actions.cut = Wytnij +Actions.copy = Kopię +Actions.paste = Wklej +Actions.closableTabbedPane.close = Blisko. Alt-Kliknij, aby zamknąć inne diff --git a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_ru.properties b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_ru.properties index 5b61d567..e8cf24d7 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_ru.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_ru.properties @@ -24,6 +24,7 @@ # # suppress inspection "UnusedProperty" for whole file # -Actions.cut = Резать -Actions.copy = Копия -Actions.paste = Вставить +Actions.cut = Резать +Actions.copy = Копия +Actions.paste = Вставить +Actions.closableTabbedPane.close = Близко. Alt-Click, чтобы закрыть другие diff --git a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_sv.properties b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_sv.properties index 26fd6903..d3e6c634 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_sv.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_sv.properties @@ -24,6 +24,7 @@ # # suppress inspection "UnusedProperty" for whole file # -Actions.cut = Skära -Actions.copy = Kopia -Actions.paste = Klistra +Actions.cut = Skära +Actions.copy = Kopia +Actions.paste = Klistra +Actions.closableTabbedPane.close = Stänga. Alt-Klicka för att stänga andra diff --git a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_zh.properties b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_zh.properties index 85ffa7b7..f28cec38 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_zh.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/bundles/actions_zh.properties @@ -24,6 +24,7 @@ # # suppress inspection "UnusedProperty" for whole file # -Actions.cut = 切 -Actions.copy = 复制 -Actions.paste = 糊 +Actions.cut = 切 +Actions.copy = 复制 +Actions.paste = 糊 +Actions.closableTabbedPane.close = 关。 Alt单击以关闭其他人