diff options
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java | 15 | ||||
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java | 2 |
2 files changed, 8 insertions, 9 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java index 118f0b35..3db26635 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java @@ -299,19 +299,20 @@ public class PositioningComposite extends StateComposite { int numPages = this.numPages; if ((previousPage > numPages) && (currentPage <= numPages)) { // Was on new page - this.btnNewPage.setText(Messages.getString("positioning.newPage")); + StateComposite.setLocalizedText(btnNewPage, "positioning.newPage"); this.btnNewPage.setSelection(false); this.bottomBar.layout(); this.scrollbar.setMaximum(numPages + 1); } else if ((previousPage <= numPages) && (currentPage > numPages)) { // Go to new page + StateComposite.setLocalizedText(btnNewPage, "positioning.removeNewPage"); this.btnNewPage.setText(Messages.getString("positioning.removeNewPage")); this.btnNewPage.setSelection(true); this.bottomBar.layout(); this.scrollbar.setMaximum(numPages + 2); } this.scrollbar.setSelection(currentPage); - this.lblPage.setText(String.format(Messages.getString("positioning.page"), currentPage, numPages)); + StateComposite.setLocalizedText(lblPage, "positioning.page", currentPage, numPages); }); EventQueue.invokeLater(() -> { PositioningComposite.this.viewer.showPage(page); @@ -394,12 +395,8 @@ public class PositioningComposite extends StateComposite { */ @Override public void reloadResources() { - if (this.currentPage <= this.numPages) - this.btnNewPage.setText(Messages.getString("positioning.newPage")); - else - this.btnNewPage.setText(Messages.getString("positioning.removeNewPage")); - this.btnSign.setText(Messages.getString("positioning.sign")); - this.lblPage.setText(String.format(Messages.getString("positioning.page"), - this.currentPage, this.numPages)); + StateComposite.setLocalizedText(btnNewPage, (this.currentPage <= this.numPages) ? "positioning.newPage" : "positioning.removeNewPage"); + StateComposite.setLocalizedText(btnSign, "positioning.sign"); + StateComposite.setLocalizedText(lblPage, "positioning.page", this.currentPage, this.numPages); } } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java index a5ea4e4d..421e52d3 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java @@ -68,7 +68,9 @@ public abstract class StateComposite extends Composite { } public static void setLocalizedText(Label l, String messageKey) { l.setText(Messages.getString(messageKey)); l.requestLayout(); } + public static void setLocalizedText(Label l, String formatMessageKey, Object... formatArgs) { l.setText(String.format(Messages.getString(formatMessageKey), formatArgs)); l.requestLayout(); } public static void setLocalizedText(Button b, String messageKey) { b.setText(Messages.getString(messageKey)); b.requestLayout(); } + public static void setLocalizedText(Button b, String formatMessageKey, Object... formatArgs) { b.setText(String.format(Messages.getString(formatMessageKey), formatArgs)); b.requestLayout(); } public static void setFontHeight(Control c, int height) { |