new Runnable() {
public void run() {
ExceptionHandler
.getInstance()
.handleException(
new ExecutionException(
"An exception occurred while executing " //$NON-NLS-1$
+ methodToExecute
.getName(),
e
.getTargetException()));
}
});
}
}
};
swingInvokeLater(methodRunnable);
}
} catch (final ClassNotFoundException e) {
// There is no Swing support, so do nothing.
} catch (final NoSuchMethodException e) {
// The API has changed, which seems amazingly unlikely.
throw new Error("Something is seriously wrong here"); //$NON-NLS-1$
}
} else if (numParams == 0) {
// This is a no-argument selectAll method.
methodToExecute.invoke(focusControl, null);
focusControl.notifyListeners(SWT.Selection, null);
} else if (numParams == 1) {
// This is a single-point selection method.
final Method textLimitAccessor = focusControl.getClass()
.getMethod("getTextLimit", NO_PARAMETERS); //$NON-NLS-1$
final Integer textLimit = (Integer) textLimitAccessor
.invoke(focusControl, null);
final Object[] parameters = { new Point(0, textLimit
.intValue()) };
methodToExecute.invoke(focusControl, parameters);
focusControl.notifyListeners(SWT.Selection, null);
} else {
/*
* This means that getMethodToExecute() has been changed,
* while this method hasn't.
*/
throw new ExecutionException(
"Too many parameters on select all", new Exception()); //$NON-NLS-1$
}
} catch (IllegalAccessException e) {
// The method is protected, so do nothing.
} catch (InvocationTargetException e) {
throw new ExecutionException(
"An exception occurred while executing " //$NON-NLS-1$
+ getMethodToExecute(), e.getTargetException());
} catch (NoSuchMethodException e) {
// I can't get the text limit. Do nothing.