diff options
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; }); } |