diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-08-04 13:00:18 +0200 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-08-04 13:00:18 +0200 |
commit | 035886dcc2c8c80944f4e7dda06b4581ff4423a1 (patch) | |
tree | 61dff6dfce7e3a86a4e5a345998e7d7a4601feb7 /pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils | |
parent | f31b6bca11145073a76432125863da6b1d3c5723 (diff) | |
download | pdf-over-035886dcc2c8c80944f4e7dda06b4581ff4423a1.tar.gz pdf-over-035886dcc2c8c80944f4e7dda06b4581ff4423a1.tar.bz2 pdf-over-035886dcc2c8c80944f4e7dda06b4581ff4423a1.zip |
add setLocalizedToolTipText + batch replace
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils')
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTUtils.java | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTUtils.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTUtils.java index 45558121..c89f12b8 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTUtils.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTUtils.java @@ -39,10 +39,21 @@ public final class SWTUtils { log.error("Failed to re-layout {}", swtObj.getClass().getSimpleName(), e); } } - public static void setLocalizedText(Object o, String messageKey) { genericSetText(o, Messages.getString(messageKey)); } public static void setLocalizedText(Object o, String formatMessageKey, Object... formatArgs) { genericSetText(o, String.format(Messages.getString(formatMessageKey), formatArgs)); } + private static void genericSetToolTipText(Object swtObj, String text) { + try { + Method m = swtObj.getClass().getMethod("setToolTipText", String.class); + m.invoke(swtObj, text); + } catch (NoSuchMethodException | IllegalAccessException e) { + log.error("Attempted to setLocalizedToolTipText on object of type {}, which does not have an accessible setToolTipText method", swtObj.getClass().getSimpleName(), e); + } catch (InvocationTargetException e) { + log.error("Failed to setLocalizedToolTipText on object of type {}", swtObj.getClass().getSimpleName(), e); + } + } + public static void setLocalizedToolTipText(Object o, String messageKey) { genericSetToolTipText(o, Messages.getString(messageKey));} + public static void disableEventDefault(Control c, int event) { c.addListener(event, (Event e) -> { e.doit = false; }); } |