protected Variant invoke(int dispId, int flags, Variant[] params)
throws HResultException, InvocationTargetException {
if (dispId == 0 && (flags & COM.DISPATCH_PROPERTYGET) != 0) {
// MAGIC: this is the default property, let's just do toString()
return new Variant(toString());
} else if (dispId == 1) {
if ((flags & COM.DISPATCH_METHOD) != 0) {
try {
IDispatch frameWnd = (params[0].getType() == COM.VT_DISPATCH)
? params[0].getDispatch() : null;
String moduleName = (params[1].getType() == COM.VT_BSTR)
? params[1].getString() : null;
boolean success = gwtOnLoad(frameWnd, moduleName);
// boolean return type
return new Variant(success);
} catch (SWTException e) {
throw new HResultException(COM.E_INVALIDARG);
}
} else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
// property get on the method itself
try {
Method gwtOnLoadMethod = getClass().getMethod("gwtOnLoad",
new Class[] {IDispatch.class, String.class});
IDispatchImpl funcObj = new MethodDispatch(null, gwtOnLoadMethod);
IDispatch disp = new IDispatch(funcObj.getAddress());
disp.AddRef();
return new Variant(disp);
} catch (Exception e) {
// just return VT_EMPTY
return new Variant();
}
}
throw new HResultException(COM.E_NOTSUPPORTED);
}