1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-13 03:55:22 +02:00

Bug 323141 - [context-menu] Cleanup introspection code for command contribution items

This commit is contained in:
Martin Oberhuber 2010-11-09 12:48:20 +00:00
parent 8be1c639c9
commit 210b711353

View file

@ -14,6 +14,7 @@
* Contributors: * Contributors:
* David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
* Uwe Stieber (Wind River) - [319618] [context-menu] Tool tip not shown in status bar for command contributions items * Uwe Stieber (Wind River) - [319618] [context-menu] Tool tip not shown in status bar for command contributions items
* Martin Oberhuber (Wind River) - [323141] [context-menu] Cleanup introspection code for command contribution items
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.ui.view; package org.eclipse.rse.internal.ui.view;
@ -167,13 +168,18 @@ implements ISystemViewMenuListener
tip = ((ActionContributionItem)data).getAction().getToolTipText(); tip = ((ActionContributionItem)data).getAction().getToolTipText();
else if (data instanceof CommandContributionItem) { else if (data instanceof CommandContributionItem) {
try { try {
Field f = data.getClass().getDeclaredField("widget"); //$NON-NLS-1$ tip = ((CommandContributionItem) data).getData().tooltip;
f.setAccessible(true); } catch (Exception apiNotYetAvailable) {
Widget widget = (Widget)f.get(data); //API was introduced with Eclipse 3.7m3 -- use introspection on older Eclipse
Method m = data.getClass().getDeclaredMethod("getToolTipText", new Class[] { String.class }); //$NON-NLS-1$ try {
m.setAccessible(true); Field f = data.getClass().getDeclaredField("widget"); //$NON-NLS-1$
tip = (String)m.invoke(data, new Object[] { widget instanceof Item ? ((Item)widget).getText() : (String)null }); f.setAccessible(true);
} catch (Exception e) { /* ignored on purpose */ } Widget widget = (Widget)f.get(data);
Method m = data.getClass().getDeclaredMethod("getToolTipText", new Class[] { String.class }); //$NON-NLS-1$
m.setAccessible(true);
tip = (String)m.invoke(data, new Object[] { widget instanceof Item ? ((Item)widget).getText() : (String)null });
} catch (Exception e) { /* ignored on purpose */ }
}
} }
else if (data instanceof SystemSubMenuManager) else if (data instanceof SystemSubMenuManager)
tip = ((SystemSubMenuManager)data).getToolTipText(); tip = ((SystemSubMenuManager)data).getToolTipText();