Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 119599 Details for
Bug 256603
[Discovery][Remotesvcs] Replace org.eclipse.ecf.discovery.ui with EMF based ui (CQ 2038)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
updated patch
clipboard.txt (text/plain), 28.78 KB, created by
Markus Kuppe
on 2008-12-05 04:49:49 EST
(
hide
)
Description:
updated patch
Filename:
MIME Type:
Creator:
Markus Kuppe
Created:
2008-12-05 04:49:49 EST
Size:
28.78 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ecf.remoteservice.ui >Index: .classpath >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/framework/bundles/org.eclipse.ecf.remoteservice.ui/.classpath,v >retrieving revision 1.1 >diff -u -r1.1 .classpath >--- .classpath 2 Mar 2008 01:43:46 -0000 1.1 >+++ .classpath 5 Dec 2008 09:48:28 -0000 >@@ -1,7 +1,7 @@ > <?xml version="1.0" encoding="UTF-8"?> > <classpath> >- <classpathentry kind="src" path="src"/> > <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/> > <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> >+ <classpathentry kind="src" path="src"/> > <classpathentry kind="output" path="bin"/> > </classpath> >Index: build.properties >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/framework/bundles/org.eclipse.ecf.remoteservice.ui/build.properties,v >retrieving revision 1.2 >diff -u -r1.2 build.properties >--- build.properties 2 Mar 2008 16:47:21 -0000 1.2 >+++ build.properties 5 Dec 2008 09:48:28 -0000 >@@ -3,7 +3,8 @@ > bin.includes = META-INF/,\ > .,\ > about.html,\ >- plugin.properties >+ plugin.properties,\ >+ plugin.xml > src.includes = about.html,\ > META-INF/,\ > plugin.properties >Index: src/org/eclipse/ecf/internal/remoteservices/ui/Messages.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/Messages.java,v >retrieving revision 1.2 >diff -u -r1.2 Messages.java >--- src/org/eclipse/ecf/internal/remoteservices/ui/Messages.java 2 Mar 2008 20:51:00 -0000 1.2 >+++ src/org/eclipse/ecf/internal/remoteservices/ui/Messages.java 5 Dec 2008 09:48:28 -0000 >@@ -32,6 +32,13 @@ > public static String MethodInvocationDialog_InvocationTypeRemoteServiceProxy; > public static String MethodInvocationDialog_InvocationTypeSynchronous; > >+ public static String AbstractRemoteServiceAccessHandler_DISCONNECT_MENU_TEXT; >+ public static String AbstractRemoteServiceAccessHandler_MSG_BOX_RECEIVED_EXCEPTION_TEXT; >+ public static String AbstractRemoteServiceAccessHandler_MSG_BOX_RECEIVED_EXCEPTION_TITLE; >+ public static String AbstractRemoteServiceAccessHandler_MSG_BOX_RECEIVED_RESP_TEXT; >+ public static String AbstractRemoteServiceAccessHandler_MSG_BOX_RECEIVED_RESP_TITLE; >+ public static String AbstractRemoteServiceAccessHandler_NOT_AVAILABLE_MENU_TEXT; >+ > static { > NLS.initializeMessages(BUNDLE_NAME, Messages.class); > } >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/framework/bundles/org.eclipse.ecf.remoteservice.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.4 >diff -u -r1.4 MANIFEST.MF >--- META-INF/MANIFEST.MF 6 Apr 2008 22:58:34 -0000 1.4 >+++ META-INF/MANIFEST.MF 5 Dec 2008 09:48:28 -0000 >@@ -2,12 +2,17 @@ > Bundle-ManifestVersion: 2 > Bundle-Name: %plugin.name > Bundle-SymbolicName: org.eclipse.ecf.remoteservice.ui;singleton:=true >-Bundle-Version: 2.0.0.qualifier >+Bundle-Version: 3.0.0.qualifier > Bundle-RequiredExecutionEnvironment: J2SE-1.4 > Require-Bundle: org.eclipse.core.runtime, >- org.eclipse.ui >-Export-Package: org.eclipse.ecf.internal.remoteservices.ui;x-internal:=true, >- org.eclipse.ecf.remoteservices.ui >+ org.eclipse.ui, >+ org.eclipse.core.expressions;bundle-version="3.4.0", >+ org.eclipse.ecf;bundle-version="2.0.1", >+ org.eclipse.ecf.remoteservice;bundle-version="2.0.0", >+ org.eclipse.ecf.discovery;bundle-version="2.1.0", >+ org.eclipse.ecf.discovery.ui;bundle-version="3.0.0" >+Export-Package: org.eclipse.ecf.remoteservices.ui;version="3.0.0" > Bundle-ActivationPolicy: lazy > Bundle-Vendor: %plugin.provider > Bundle-Localization: plugin >+Bundle-Activator: org.eclipse.ecf.internal.remoteservices.ui.Activator >Index: src/org/eclipse/ecf/internal/remoteservices/ui/handlers/ConnectRemoteServicehandler.java >=================================================================== >RCS file: src/org/eclipse/ecf/internal/remoteservices/ui/handlers/ConnectRemoteServicehandler.java >diff -N src/org/eclipse/ecf/internal/remoteservices/ui/handlers/ConnectRemoteServicehandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/internal/remoteservices/ui/handlers/ConnectRemoteServicehandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,64 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Versant Corp. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Markus Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.ecf.internal.remoteservices.ui.handlers; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.ecf.core.ContainerConnectException; >+import org.eclipse.ecf.core.IContainer; >+import org.eclipse.ecf.core.identity.ID; >+import org.eclipse.ecf.internal.remoteservices.ui.RemoteServiceHandlerUtil; >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.swt.widgets.Display; >+ >+public class ConnectRemoteServicehandler extends AbstractHandler { >+ >+ public Object execute(final ExecutionEvent event) throws ExecutionException { >+ final ID createConnectId = RemoteServiceHandlerUtil.getActiveConnectIDChecked(event); >+ // decouple the long running connect call from the ui thread >+ Job job = new Job(NLS.bind("Connecting {0}", createConnectId.getName())) { >+ protected IStatus run(IProgressMonitor monitor) { >+ try { >+ final IContainer container = RemoteServiceHandlerUtil.getActiveIRemoteServiceContainerChecked(event); >+ container.connect(createConnectId, null); >+ } catch (ContainerConnectException e) { >+ showException(e); >+ return Status.CANCEL_STATUS; >+ } catch (ExecutionException e) { >+ showException(e); >+ return Status.CANCEL_STATUS; >+ } >+ return Status.OK_STATUS; >+ } >+ }; >+ job.setUser(true); >+ job.schedule(); >+ return null; >+ } >+ >+ private void showException(final Throwable t) { >+ Display.getDefault().asyncExec(new Runnable() { >+ public void run() { >+ String msg = t.toString(); >+ if (t.getCause() != null) { >+ msg += t.getCause().toString(); >+ } >+ MessageDialog.openError(null, t.getLocalizedMessage(), NLS.bind("Exception: {0}", msg)); >+ } >+ }); >+ } >+} >Index: src/org/eclipse/ecf/internal/remoteservices/ui/property/ConnectedTester.java >=================================================================== >RCS file: src/org/eclipse/ecf/internal/remoteservices/ui/property/ConnectedTester.java >diff -N src/org/eclipse/ecf/internal/remoteservices/ui/property/ConnectedTester.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/internal/remoteservices/ui/property/ConnectedTester.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,70 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Versant Corp. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Markus Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.ecf.internal.remoteservices.ui.property; >+ >+ >+import org.eclipse.core.expressions.PropertyTester; >+import org.eclipse.ecf.core.IContainer; >+import org.eclipse.ecf.core.IContainerManager; >+import org.eclipse.ecf.core.identity.ID; >+import org.eclipse.ecf.core.identity.IDCreateException; >+import org.eclipse.ecf.core.identity.IDFactory; >+import org.eclipse.ecf.discovery.IServiceInfo; >+import org.eclipse.ecf.discovery.ui.DiscoveryPropertyTesterUtil; >+import org.eclipse.ecf.internal.remoteservices.ui.Activator; >+import org.eclipse.ecf.remoteservice.Constants; >+ >+public class ConnectedTester extends PropertyTester { >+ >+ private IContainerManager containerManager; >+ >+ public ConnectedTester() { >+ containerManager = Activator.getDefault().getContainerManager(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) >+ */ >+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { >+ // consumers expect connected or disconnected >+ if(!(expectedValue instanceof Boolean)) { >+ return false; >+ } >+ boolean expected = ((Boolean) expectedValue).booleanValue(); >+ >+ // get the container instance >+ IServiceInfo serviceInfo = DiscoveryPropertyTesterUtil.getIServiceInfoReceiver(receiver); >+ final String connectNamespace = getConnectNamespace(serviceInfo); >+ final String connectId = getConnectID(serviceInfo); >+ try { >+ ID createConnectId = IDFactory.getDefault().createID(connectNamespace, connectId); >+ IContainer container = containerManager.getContainer(createConnectId); >+ if(container == null) { >+ //Trace.trace(...); >+ return expected == false; >+ } >+ ID connectedId = container.getConnectedID(); >+ boolean isConnected = connectedId == null ? false : true; >+ return expected == isConnected; >+ } catch (IDCreateException e) { >+ //Trace.trace(...); >+ return expected == false; >+ } >+ } >+ >+ private String getConnectNamespace(IServiceInfo serviceInfo) { >+ return serviceInfo.getServiceProperties().getPropertyString(Constants.DISCOVERY_CONNECT_ID_NAMESPACE_PROPERTY); >+ } >+ >+ private String getConnectID(IServiceInfo serviceInfo) { >+ return serviceInfo.getServiceProperties().getPropertyString(Constants.DISCOVERY_CONNECT_ID_PROPERTY); >+ } >+} >Index: src/org/eclipse/ecf/internal/remoteservices/ui/handlers/ReflectiveRemoteServiceHandler.java >=================================================================== >RCS file: src/org/eclipse/ecf/internal/remoteservices/ui/handlers/ReflectiveRemoteServiceHandler.java >diff -N src/org/eclipse/ecf/internal/remoteservices/ui/handlers/ReflectiveRemoteServiceHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/internal/remoteservices/ui/handlers/ReflectiveRemoteServiceHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,189 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Versant Corp. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Markus Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.ecf.internal.remoteservices.ui.handlers; >+ >+import java.lang.reflect.InvocationTargetException; >+import java.util.Arrays; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.commands.IHandler; >+import org.eclipse.ecf.core.IContainer; >+import org.eclipse.ecf.core.identity.ID; >+import org.eclipse.ecf.core.util.IAsyncResult; >+import org.eclipse.ecf.internal.remoteservices.ui.RemoteServiceHandlerUtil; >+import org.eclipse.ecf.remoteservice.IRemoteCall; >+import org.eclipse.ecf.remoteservice.IRemoteCallListener; >+import org.eclipse.ecf.remoteservice.IRemoteService; >+import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter; >+import org.eclipse.ecf.remoteservice.IRemoteServiceReference; >+import org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent; >+import org.eclipse.ecf.remoteservice.events.IRemoteCallEvent; >+import org.eclipse.ecf.remoteservices.ui.MethodInvocationDialog; >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.window.Window; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Shell; >+ >+public class ReflectiveRemoteServiceHandler extends AbstractHandler implements >+ IHandler { >+ >+ /* >+ * (non-Javadoc) >+ * @see >+ * org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands >+ * .ExecutionEvent) >+ */ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ final String clazz = event.getParameter("org.eclipse.ecf.remoteservices.ui.commands.reflectiveMethodDialogParameter"); >+ final IRemoteServiceContainerAdapter adapter = RemoteServiceHandlerUtil.getActiveIRemoteServiceContainerAdapterChecked(event); >+ final IRemoteServiceReference[] references = RemoteServiceHandlerUtil.getActiveIRemoteServiceReferencesChecked(event); >+ final IRemoteService remoteService = adapter.getRemoteService(references[0]); >+ try { >+ executeMethodInvocationDialog(Class.forName(clazz), remoteService); >+ } catch (ClassNotFoundException e) { >+ throw new ExecutionException(e.getMessage(), e); >+ } >+ return null; >+ } >+ >+ private 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.callAsynch(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(); >+ // invokeOSGiProxy(interfaceClass, remoteCall); >+ // break; >+ case MethodInvocationDialog.REMOTE_SERVICE_PROXY: >+ throw new UnsupportedOperationException(); >+ // invokeProxy(interfaceClass, remoteService, remoteCall); >+ // break; >+ case MethodInvocationDialog.SYNCHRONOUS: >+ throw new UnsupportedOperationException(); >+ // invokeSync(cls, remoteService, remoteCall); >+ // break; >+ default: >+ break; >+ } >+ } catch (final Exception e) { >+ showException(e); >+ } >+ } >+ } >+ >+ protected void showException(final Throwable t, final IContainer container, >+ ID targetID) { >+ Display.getDefault().asyncExec(new Runnable() { >+ public void run() { >+ String msg = t.toString(); >+ if (t.getCause() != null) { >+ msg += t.getCause().toString(); >+ } >+ MessageDialog.openInformation(null, "Received Exception", NLS >+ .bind("Exception: {0}", msg)); >+ container.disconnect(); >+ } >+ }); >+ } >+ >+ protected void invokeFuture(Class cls, IRemoteService remoteService, >+ IRemoteCall remoteCall) throws InterruptedException, >+ InvocationTargetException { >+ // Make async call with future result >+ final IAsyncResult asyncResult = remoteService.callAsynch(remoteCall); >+ // Call blocking get and show result >+ showResult(cls.getName(), remoteCall, asyncResult.get()); >+ } >+ >+ private void invokeAsyncListener(final Class interfaceClass, >+ final IRemoteService remoteService, final IRemoteCall remoteCall) { >+ // Make async call >+ remoteService.callAsynch(remoteCall, new IRemoteCallListener() { >+ public void handleEvent(IRemoteCallEvent event) { >+ if (event instanceof IRemoteCallCompleteEvent) { >+ final IRemoteCallCompleteEvent complete = (IRemoteCallCompleteEvent) event; >+ if (complete.hadException()) { >+ showException(complete.getException()); >+ } else >+ showResult(interfaceClass.getName(), remoteCall, >+ complete.getResponse()); >+ } >+ } >+ }); >+ } >+ >+ protected void showException(final Throwable t) { >+ Display.getDefault().asyncExec(new Runnable() { >+ public void run() { >+ String msg = t.toString(); >+ if (t.getCause() != null) { >+ msg += t.getCause().toString(); >+ } >+ MessageDialog.openInformation(null, "Received Exception", NLS >+ .bind("Exception: {0}", msg)); >+ } >+ }); >+ } >+ >+ protected void showResult(final String serviceInterface, >+ final IRemoteCall remoteCall, final Object result) { >+ final Object display = (result != null && result.getClass().isArray()) ? Arrays >+ .asList((Object[]) result) >+ : result; >+ final Object[] bindings = new Object[] { serviceInterface, >+ remoteCall.getMethod(), >+ Arrays.asList(remoteCall.getParameters()), display }; >+ Display.getDefault().asyncExec(new Runnable() { >+ public void run() { >+ MessageDialog >+ .openInformation( >+ null, >+ "Received Response", >+ NLS >+ .bind( >+ "Service Interface:\n{0}\n\nMethod: {1}\nParameters: {2}\n\nResult: {3}", >+ bindings)); >+ } >+ }); >+ } >+} >Index: src/org/eclipse/ecf/internal/remoteservices/ui/Activator.java >=================================================================== >RCS file: src/org/eclipse/ecf/internal/remoteservices/ui/Activator.java >diff -N src/org/eclipse/ecf/internal/remoteservices/ui/Activator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/internal/remoteservices/ui/Activator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,61 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Versant Corp. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Markus Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ecf.internal.remoteservices.ui; >+ >+import org.eclipse.ecf.core.IContainerManager; >+import org.eclipse.ui.plugin.AbstractUIPlugin; >+import org.osgi.framework.BundleContext; >+import org.osgi.util.tracker.ServiceTracker; >+ >+public class Activator extends AbstractUIPlugin { >+ >+ private volatile ServiceTracker containerManagerTracker; >+ // The shared instance >+ private volatile static Activator plugin; >+ >+ /** >+ * The constructor >+ */ >+ public Activator() { >+ plugin = this; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) >+ */ >+ public void stop(BundleContext context) throws Exception { >+ plugin = null; >+ if(containerManagerTracker != null) { >+ containerManagerTracker.close(); >+ containerManagerTracker = null; >+ } >+ super.stop(context); >+ } >+ >+ /** >+ * Returns the shared instance >+ * >+ * @return the shared instance >+ */ >+ public static Activator getDefault() { >+ return plugin; >+ } >+ >+ public IContainerManager getContainerManager() { >+ BundleContext context = getBundle().getBundleContext(); >+ if (containerManagerTracker == null) { >+ containerManagerTracker = new ServiceTracker(context, IContainerManager.class.getName(), null); >+ containerManagerTracker.open(); >+ } >+ return (IContainerManager) containerManagerTracker.getService(); >+ } >+} >Index: src/org/eclipse/ecf/internal/remoteservices/ui/RemoteServiceHandlerUtil.java >=================================================================== >RCS file: src/org/eclipse/ecf/internal/remoteservices/ui/RemoteServiceHandlerUtil.java >diff -N src/org/eclipse/ecf/internal/remoteservices/ui/RemoteServiceHandlerUtil.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/internal/remoteservices/ui/RemoteServiceHandlerUtil.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,107 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Versant Corp. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Markus Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ecf.internal.remoteservices.ui; >+ >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.ecf.core.ContainerCreateException; >+import org.eclipse.ecf.core.ContainerFactory; >+import org.eclipse.ecf.core.IContainer; >+import org.eclipse.ecf.core.IContainerManager; >+import org.eclipse.ecf.core.identity.ID; >+import org.eclipse.ecf.core.identity.IDCreateException; >+import org.eclipse.ecf.core.identity.IDFactory; >+import org.eclipse.ecf.discovery.IServiceInfo; >+import org.eclipse.ecf.discovery.ui.DiscoveryHandlerUtil; >+import org.eclipse.ecf.remoteservice.Constants; >+import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter; >+import org.eclipse.ecf.remoteservice.IRemoteServiceReference; >+import org.osgi.framework.InvalidSyntaxException; >+ >+public class RemoteServiceHandlerUtil { >+ >+ public static IRemoteServiceContainerAdapter getActiveIRemoteServiceContainerAdapterChecked(ExecutionEvent event) throws ExecutionException { >+ final ID activeConnectId = getActiveConnectIDChecked(event); >+ final IContainerManager containerManager = Activator.getDefault().getContainerManager(); >+ final IContainer container = containerManager.getContainer(activeConnectId); >+ final IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter) container.getAdapter(IRemoteServiceContainerAdapter.class); >+ return adapter; >+ } >+ >+ public static IRemoteServiceReference[] getActiveIRemoteServiceReferencesChecked(ExecutionEvent event) throws ExecutionException { >+ IServiceInfo serviceInfo = DiscoveryHandlerUtil.getActiveIServiceInfoChecked(event); >+ IRemoteServiceContainerAdapter adapter = getActiveIRemoteServiceContainerAdapterChecked(event); >+ try { >+ return getRemoteServiceReferencesForRemoteServiceAdapter(adapter, serviceInfo); >+ } catch (IDCreateException e) { >+ throw new ExecutionException(e.getMessage(), e); >+ } catch (InvalidSyntaxException e) { >+ throw new ExecutionException(e.getMessage(), e); >+ } >+ } >+ >+ public static ID getActiveConnectIDChecked(ExecutionEvent event) throws ExecutionException { >+ IServiceInfo serviceInfo = DiscoveryHandlerUtil.getActiveIServiceInfoChecked(event); >+ final String connectNamespace = getConnectNamespace(serviceInfo); >+ final String connectId = getConnectID(serviceInfo); >+ try { >+ return IDFactory.getDefault().createID(connectNamespace, connectId); >+ } catch (IDCreateException e) { >+ throw new ExecutionException(e.getMessage(), e); >+ } >+ } >+ >+ public static IContainer getActiveIRemoteServiceContainerChecked(ExecutionEvent event) throws ExecutionException { >+ final IServiceInfo serviceInfo = DiscoveryHandlerUtil.getActiveIServiceInfoChecked(event); >+ final ID createConnectId = getActiveConnectIDChecked(event); >+ //TODO remove parameters once https://bugs.eclipse.org/bugs/show_bug.cgi?id=256586 is fixed >+ final Object[] parameters = new Object[]{createConnectId}; >+ try { >+ return ContainerFactory.getDefault().createContainer(getContainerFactory(serviceInfo), parameters); >+ } catch (ContainerCreateException e) { >+ throw new ExecutionException(e.getMessage(), e); >+ } >+ } >+ >+ private static IRemoteServiceReference[] getRemoteServiceReferencesForRemoteServiceAdapter(IRemoteServiceContainerAdapter adapter, IServiceInfo serviceInfo) throws InvalidSyntaxException, IDCreateException { >+ ID serviceID = null; >+ String serviceNamespace = getServiceNamespace(serviceInfo); >+ String serviceid = getServiceID(serviceInfo); >+ if (serviceNamespace != null && serviceid != null) { >+ serviceID = IDFactory.getDefault().createID(serviceNamespace, serviceid); >+ } >+ ID[] targets = (serviceID == null) ? null : new ID[] {serviceID}; >+ return adapter.getRemoteServiceReferences(targets, getRemoteServiceClass(serviceInfo), getFilter(serviceInfo)); >+ } >+ >+ private static String getServiceNamespace(IServiceInfo serviceInfo) { >+ return serviceInfo.getServiceProperties().getPropertyString(Constants.DISCOVERY_SERVICE_ID_NAMESPACE_PROPERTY); >+ } >+ private static String getServiceID(IServiceInfo serviceInfo) { >+ return serviceInfo.getServiceProperties().getPropertyString(Constants.DISCOVERY_SERVICE_ID_PROPERTY); >+ } >+ private static String getRemoteServiceClass(IServiceInfo serviceInfo) { >+ return serviceInfo.getServiceProperties().getPropertyString(Constants.DISCOVERY_OBJECTCLASS_PROPERTY); >+ } >+ private static String getFilter(IServiceInfo serviceInfo) { >+ return serviceInfo.getServiceProperties().getPropertyString(Constants.DISCOVERY_FILTER_PROPERTY); >+ } >+ private static String getConnectNamespace(IServiceInfo serviceInfo) { >+ return serviceInfo.getServiceProperties().getPropertyString(Constants.DISCOVERY_CONNECT_ID_NAMESPACE_PROPERTY); >+ } >+ private static String getConnectID(IServiceInfo serviceInfo) { >+ return serviceInfo.getServiceProperties().getPropertyString(Constants.DISCOVERY_CONNECT_ID_PROPERTY); >+ } >+ private static String getContainerFactory(IServiceInfo serviceInfo) { >+ return serviceInfo.getServiceProperties().getPropertyString(Constants.DISCOVERY_CONTAINER_FACTORY_PROPERTY); >+ } >+} >Index: plugin.xml >=================================================================== >RCS file: plugin.xml >diff -N plugin.xml >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ plugin.xml 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,63 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<?eclipse version="3.2"?> >+<plugin> >+ <extension >+ point="org.eclipse.ui.commands"> >+ <command >+ defaultHandler="org.eclipse.ecf.internal.remoteservices.ui.handlers.ConnectRemoteServicehandler" >+ id="org.eclipse.ecf.remoteservices.ui.commands.connectCommand" >+ name="Connect Command"> >+ </command> >+ <command >+ defaultHandler="org.eclipse.ecf.internal.remoteservices.ui.handlers.ReflectiveRemoteServiceHandler" >+ id="org.eclipse.ecf.remoteservices.ui.commands.reflectiveMethodDialogHandler" >+ name="Reflective Method Invocation Command"> >+ <commandParameter >+ id="org.eclipse.ecf.remoteservices.ui.commands.reflectiveMethodDialogParameter" >+ name="name" >+ optional="true"> >+ </commandParameter> >+ </command> >+ </extension> >+ <extension >+ point="org.eclipse.ui.menus"> >+ <menuContribution >+ locationURI="popup:org.eclipse.ecf.discovery.ui.DiscoveryView?after=additions"> >+ <command >+ commandId="org.eclipse.ecf.remoteservices.ui.commands.connectCommand" >+ id="org.eclipse.ecf.remoteservices.ui.menus.connectCommand" >+ mnemonic="S"> >+ <visibleWhen> >+ <with >+ variable="activeMenuSelection"> >+ <iterate >+ ifEmpty="false" >+ operator="and"> >+ <test >+ args="remotesvcs" >+ property="org.eclipse.ecf.discovery.isServiceType" >+ value="true"> >+ </test> >+ <test >+ property="org.eclipse.ecf.remoteservices.isConnected" >+ value="false"> >+ </test> >+ </iterate> >+ </with> >+ </visibleWhen> >+ </command> >+ </menuContribution> >+ </extension> >+ >+ <extension >+ point="org.eclipse.core.expressions.propertyTesters"> >+ <propertyTester >+ class="org.eclipse.ecf.internal.remoteservices.ui.property.ConnectedTester" >+ id="org.eclipse.ecf.remoteservices.ui.property.ConnectedPropertyTester" >+ namespace="org.eclipse.ecf.remoteservices" >+ properties="isConnected" >+ type="org.eclipse.ecf.discovery.model.IServiceInfo"> >+ </propertyTester> >+ </extension> >+ >+</plugin>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 256603
:
118782
| 119599 |
119600