Search in sources :

Example 1 with MethodInvocationDialog

use of org.eclipse.ecf.remoteservices.ui.MethodInvocationDialog in project ecf by eclipse.

the class ReflectiveRemoteServiceHandler method executeMethodInvocationDialog.

protected void executeMethodInvocationDialog(final Class cls, final IRemoteService remoteService) {
    final MethodInvocationDialog mid = new MethodInvocationDialog((Shell) null, cls);
    if (mid.open() == Window.OK) {
        final int timeout = (mid.getTimeout() > 0) ? mid.getTimeout() : 30000;
        final String methodName = mid.getMethod().getName();
        final Object[] methodArgs = mid.getMethodArguments();
        final IRemoteCall remoteCall = new IRemoteCall() {

            public String getMethod() {
                return methodName;
            }

            public Object[] getParameters() {
                return methodArgs;
            }

            public long getTimeout() {
                return timeout;
            }
        };
        final int invokeType = mid.getInvocationType();
        try {
            switch(invokeType) {
                case MethodInvocationDialog.ASYNC_FIRE_AND_GO:
                    remoteService.callAsync(remoteCall);
                    break;
                case MethodInvocationDialog.ASYNC_FUTURE_RESULT:
                    invokeFuture(cls, remoteService, remoteCall);
                    break;
                case MethodInvocationDialog.ASYNC_LISTENER:
                    invokeAsyncListener(cls, remoteService, remoteCall);
                    break;
                case MethodInvocationDialog.OSGI_SERVICE_PROXY:
                    throw new UnsupportedOperationException();
                // break;
                case MethodInvocationDialog.REMOTE_SERVICE_PROXY:
                    throw new UnsupportedOperationException();
                // break;
                case MethodInvocationDialog.SYNCHRONOUS:
                    invokeSync(cls, remoteService, remoteCall);
                    break;
                default:
                    break;
            }
        } catch (final Exception e) {
            showException(e);
        }
    }
}
Also used : MethodInvocationDialog(org.eclipse.ecf.remoteservices.ui.MethodInvocationDialog) ECFException(org.eclipse.ecf.core.util.ECFException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ExecutionException(org.eclipse.core.commands.ExecutionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRemoteCall(org.eclipse.ecf.remoteservice.IRemoteCall)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 ECFException (org.eclipse.ecf.core.util.ECFException)1 IRemoteCall (org.eclipse.ecf.remoteservice.IRemoteCall)1 MethodInvocationDialog (org.eclipse.ecf.remoteservices.ui.MethodInvocationDialog)1