diff options
author | slewis | 2015-11-05 22:32:42 +0000 |
---|---|---|
committer | slewis | 2015-11-05 22:32:42 +0000 |
commit | 57a5c936bcc002b36b4afbe29548bfec2d1dface (patch) | |
tree | 2d3a75128cc5b9937e833ad787d215f61f76b2a5 /framework | |
parent | 3a4e16b5e3b182a9810b433594b7979c2c8b6868 (diff) | |
download | org.eclipse.ecf-57a5c936bcc002b36b4afbe29548bfec2d1dface.tar.gz org.eclipse.ecf-57a5c936bcc002b36b4afbe29548bfec2d1dface.tar.xz org.eclipse.ecf-57a5c936bcc002b36b4afbe29548bfec2d1dface.zip |
Commits for enhancement
https://bugs.eclipse.org/bugs/show_bug.cgi?id=454610
Change-Id: I374a73992c845c9c938d786655cf97a5932553a7
Diffstat (limited to 'framework')
35 files changed, 1290 insertions, 91 deletions
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/META-INF/MANIFEST.MF b/framework/bundles/org.eclipse.ecf.remoteservice.ui/META-INF/MANIFEST.MF index 014213fae..5b8f4a272 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.ui/META-INF/MANIFEST.MF +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %plugin.name Bundle-SymbolicName: org.eclipse.ecf.remoteservice.ui;singleton:=true -Bundle-Version: 3.2.100.qualifier +Bundle-Version: 3.3.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Require-Bundle: org.eclipse.core.runtime, org.eclipse.ui, @@ -14,6 +14,8 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.ecf.discovery.ui.model;bundle-version="3.0.0", org.eclipse.pde.runtime;bundle-version="3.4.400" Export-Package: org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model;version="1.0.0", + org.eclipse.ecf.remoteserviceadmin.ui.rsa, + org.eclipse.ecf.remoteserviceadmin.ui.rsa.model, org.eclipse.ecf.remoteservices.ui;version="3.0.0" Bundle-ActivationPolicy: lazy Bundle-Vendor: %plugin.provider @@ -23,6 +25,7 @@ Import-Package: org.eclipse.ecf.osgi.services.remoteserviceadmin;version="1.2.0" org.eclipse.ecf.remoteservice.asyncproxy;version="1.0.0", org.eclipse.equinox.concurrent.future;version="1.0.0", org.eclipse.ui.views.properties, + org.osgi.framework, org.osgi.service.remoteserviceadmin;version="1.1.0" Service-Component: OSGI-INF/discovery.xml diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/OSGI-INF/discovery.xml b/framework/bundles/org.eclipse.ecf.remoteservice.ui/OSGI-INF/discovery.xml index 7b3ccbc3c..459748841 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.ui/OSGI-INF/discovery.xml +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/OSGI-INF/discovery.xml @@ -5,6 +5,7 @@ <reference bind="bindRemoteServiceAdmin" cardinality="0..1" interface="org.osgi.service.remoteserviceadmin.RemoteServiceAdmin" name="RemoteServiceAdmin" policy="dynamic" unbind="unbindRemoteServiceAdmin"/> <service> <provide interface="org.osgi.service.remoteserviceadmin.EndpointEventListener"/> + <provide interface="org.osgi.service.remoteserviceadmin.RemoteServiceAdminListener"/> </service> <reference bind="bindEndpointDescriptionLocator" cardinality="0..1" interface="org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionLocator" name="IEndpointDescriptionLocator" policy="dynamic" unbind="unbindEndpointDescriptionLocator"/> </scr:component> diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/icons/obj16/rsa_obj.gif b/framework/bundles/org.eclipse.ecf.remoteservice.ui/icons/obj16/rsa_obj.gif Binary files differnew file mode 100644 index 000000000..922e11caa --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/icons/obj16/rsa_obj.gif diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/icons/obj16/rsvc_obj.gif b/framework/bundles/org.eclipse.ecf.remoteservice.ui/icons/obj16/rsvc_obj.gif Binary files differnew file mode 100644 index 000000000..e118fd999 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/icons/obj16/rsvc_obj.gif diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/icons/obj16/rsvc_obj_tbg.gif b/framework/bundles/org.eclipse.ecf.remoteservice.ui/icons/obj16/rsvc_obj_tbg.gif Binary files differnew file mode 100644 index 000000000..f4706abfd --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/icons/obj16/rsvc_obj_tbg.gif diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/plugin.properties b/framework/bundles/org.eclipse.ecf.remoteservice.ui/plugin.properties index 07e7abb49..c3e9ee1f8 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.ui/plugin.properties +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/plugin.properties @@ -12,3 +12,4 @@ perspective.name = Remote Services remote.services.category.name=Remote Services remote.services.discovery.view.name=Endpoint Discovery +remote.services.rsa.view.name=Remote Service Admin
\ No newline at end of file diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/plugin.xml b/framework/bundles/org.eclipse.ecf.remoteservice.ui/plugin.xml index 280bfd363..3696c6ac1 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.ui/plugin.xml +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/plugin.xml @@ -108,9 +108,16 @@ name="%remote.services.discovery.view.name" icon="icons/obj16/endpoint_obj.gif" category="org.eclipse.ecf.remoteservice.ui.rsgroup" - class="org.eclipse.ecf.internal.remoteservices.ui.EndpointDiscoveryView" + class="org.eclipse.ecf.remoteserviceadmin.ui.endpoint.EndpointDiscoveryView" id="org.eclipse.ecf.remoteserviceadmin.ui.views.EndpointDiscoveryView"> </view> + <view + name="%remote.services.rsa.view.name" + icon="icons/obj16/rsa_obj.gif" + category="org.eclipse.ecf.remoteservice.ui.rsgroup" + class="org.eclipse.ecf.remoteserviceadmin.ui.rsa.RemoteServiceAdminView" + id="org.eclipse.ecf.remoteserviceadmin.ui.views.RSAView"> + </view> </extension> <extension @@ -205,7 +212,94 @@ <adapter type="org.eclipse.ui.model.IWorkbenchAdapter3"> </adapter> + + </factory> + + + <factory + adaptableType="org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.ExportedServicesRootNode" + class="org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.RSAAdapterFactory"> + <adapter + type="org.eclipse.ui.model.IWorkbenchAdapter"> + </adapter> + <adapter + type="org.eclipse.ui.model.IWorkbenchAdapter2"> + </adapter> + <adapter + type="org.eclipse.ui.model.IWorkbenchAdapter3"> + </adapter> + </factory> + + <factory + adaptableType="org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.ImportedEndpointsRootNode" + class="org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.RSAAdapterFactory"> + <adapter + type="org.eclipse.ui.model.IWorkbenchAdapter"> + </adapter> + <adapter + type="org.eclipse.ui.model.IWorkbenchAdapter2"> + </adapter> + <adapter + type="org.eclipse.ui.model.IWorkbenchAdapter3"> + </adapter> + </factory> + + <factory + adaptableType="org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.ExportRegistrationNode" + class="org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.RSAAdapterFactory"> + <adapter + type="org.eclipse.ui.model.IWorkbenchAdapter"> + </adapter> + <adapter + type="org.eclipse.ui.model.IWorkbenchAdapter2"> + </adapter> + <adapter + type="org.eclipse.ui.model.IWorkbenchAdapter3"> + </adapter> + </factory> + + <factory + adaptableType="org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.ImportRegistrationNode" + class="org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.RSAAdapterFactory"> + <adapter + type="org.eclipse.ui.model.IWorkbenchAdapter"> + </adapter> + <adapter + type="org.eclipse.ui.model.IWorkbenchAdapter2"> + </adapter> + <adapter + type="org.eclipse.ui.model.IWorkbenchAdapter3"> + </adapter> + </factory> + + <factory + adaptableType="org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.NameValuePropertyNode" + class="org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.RSAAdapterFactory"> + <adapter + type="org.eclipse.ui.model.IWorkbenchAdapter"> + </adapter> + <adapter + type="org.eclipse.ui.model.IWorkbenchAdapter2"> + </adapter> + <adapter + type="org.eclipse.ui.model.IWorkbenchAdapter3"> + </adapter> + </factory> + + <factory + adaptableType="org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.EndpointDescriptionRSANode" + class="org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.RSAAdapterFactory"> + <adapter + type="org.eclipse.ui.model.IWorkbenchAdapter"> + </adapter> + <adapter + type="org.eclipse.ui.model.IWorkbenchAdapter2"> + </adapter> + <adapter + type="org.eclipse.ui.model.IWorkbenchAdapter3"> + </adapter> </factory> + </extension> </plugin> diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/DiscoveryComponent.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/DiscoveryComponent.java index bb28aa7b9..4ad281e1e 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/DiscoveryComponent.java +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/DiscoveryComponent.java @@ -13,13 +13,17 @@ import java.util.List; import org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionLocator; import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.EndpointDiscoveryView; +import org.eclipse.ecf.remoteserviceadmin.ui.rsa.RemoteServiceAdminView; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; import org.osgi.service.remoteserviceadmin.EndpointEvent; import org.osgi.service.remoteserviceadmin.EndpointEventListener; +import org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent; +import org.osgi.service.remoteserviceadmin.RemoteServiceAdminListener; -public class DiscoveryComponent implements EndpointEventListener { +public class DiscoveryComponent implements EndpointEventListener, RemoteServiceAdminListener { private static final String RSA_SYMBOLICNAME = "org.eclipse.ecf.osgi.services.remoteserviceadmin"; //$NON-NLS-1$ @@ -37,7 +41,8 @@ public class DiscoveryComponent implements EndpointEventListener { } private EndpointDiscoveryView discoveryView; - + private RemoteServiceAdminView rsaView; + private IEndpointDescriptionLocator edLocator; void bindEndpointDescriptionLocator(IEndpointDescriptionLocator locator) { @@ -56,13 +61,13 @@ public class DiscoveryComponent implements EndpointEventListener { return instance; } - void setView(EndpointDiscoveryView edv) { + public void setView(EndpointDiscoveryView edv) { synchronized (this) { discoveryView = edv; } } - RemoteServiceAdmin getRSA() { + public RemoteServiceAdmin getRSA() { return rsa; } @@ -87,7 +92,7 @@ public class DiscoveryComponent implements EndpointEventListener { } } - void startRSA() throws BundleException { + public void startRSA() throws BundleException { Bundle rsaBundle = null; BundleContext ctxt = null; synchronized (this) { @@ -126,4 +131,14 @@ public class DiscoveryComponent implements EndpointEventListener { h.add(event); } + @Override + public void remoteAdminEvent(RemoteServiceAdminEvent event) { + if (rsaView != null) + rsaView.handleRSAEvent(event); + } + + public void setRSAView(RemoteServiceAdminView rsaView) { + this.rsaView = rsaView; + } + } diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/Messages.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/Messages.java index 42b06e78d..cf9cc2481 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/Messages.java +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/Messages.java @@ -16,6 +16,10 @@ public final class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.ecf.internal.remoteservices.ui.messages"; //$NON-NLS-1$ + public static String AbstractRegistrationNode_ErrorName; + + public static String AbstractRSANode_NodeClosed; + public static String DiscoveryComponent_ERROR_MSG_CANNOT_FIND_RSA_BUNDLE; public static String EndpointConfigTypesNode_0; @@ -122,6 +126,14 @@ public final class Messages extends NLS { public static String MethodInvocationDialog_InvocationTypeRemoteServiceProxy; public static String MethodInvocationDialog_InvocationTypeSynchronous; + public static String RSAContentProvider_ExportedServicesNodeName; + + public static String RSAContentProvider_ImportedEndpointsNodeName; + + public static String RSAView_PROXY_SERVICE_ID_LABEL; + + public static String RSAView_SERVICE_ID_LABEL; + static { NLS.initializeMessages(BUNDLE_NAME, Messages.class); } diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/RSAImageRegistry.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/RSAImageRegistry.java index 5c607e0fc..2a3bfcb30 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/RSAImageRegistry.java +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/RSAImageRegistry.java @@ -30,45 +30,34 @@ public class RSAImageRegistry { public static final String IMG_INTERFACE_OBJ = "int_obj.gif"; //$NON-NLS-1$ public static final String IMG_PROPERTY_OBJ = "property_obj.gif"; //$NON-NLS-1$ - public static final String IMG_RSPROXY_OBJ = "rsvcproxy_obj_transparent.gif"; //$NON-NLS-1$ + public static final String IMG_RSPROXY_OBJ = "rsvcproxy_obj_tbg.gif"; //$NON-NLS-1$ + public static final String IMG_RS_OBJ = "rsvc_obj_tbg.gif"; //$NON-NLS-1$ public static final String IMG_ENDPOINTDESCRIPTION_OBJ = "endpoint_obj.gif"; //$NON-NLS-1$ - public static final ImageDescriptor INTERFACE_OBJ = create(PATH_OBJ, - IMG_INTERFACE_OBJ); - public static final ImageDescriptor RSPROXY_OBJ = create(PATH_OBJ, - IMG_RSPROXY_OBJ); - public static final ImageDescriptor ENDPOINTDESCRIPTION_OBJ = create( - PATH_OBJ, IMG_ENDPOINTDESCRIPTION_OBJ); + public static final ImageDescriptor INTERFACE_OBJ = create(PATH_OBJ, IMG_INTERFACE_OBJ); + public static final ImageDescriptor RSPROXY_OBJ = create(PATH_OBJ, IMG_RSPROXY_OBJ); + public static final ImageDescriptor RS_OBJ = create(PATH_OBJ, IMG_RS_OBJ); + public static final ImageDescriptor ENDPOINTDESCRIPTION_OBJ = create(PATH_OBJ, IMG_ENDPOINTDESCRIPTION_OBJ); - public static final ImageDescriptor DESC_ERROR_ST_OBJ = create(PATH_OBJ, - "error_st_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_ERROR_ST_OBJ = create(PATH_OBJ, "error_st_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WARNING_ST_OBJ = create(PATH_OBJ, - "warning_st_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_WARNING_ST_OBJ = create(PATH_OBJ, "warning_st_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_LOCATION = create(PATH_OBJ, - "location_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_LOCATION = create(PATH_OBJ, "location_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_SERVICE_OBJ = create(PATH_OBJ, - "int_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_SERVICE_OBJ = create(PATH_OBJ, "int_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_ASYNC_SERVICE_OBJ = create( - PATH_OBJ, "async_int_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_ASYNC_SERVICE_OBJ = create(PATH_OBJ, "async_int_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_PROPERTY_OBJ = create(PATH_OBJ, - "property_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_PROPERTY_OBJ = create(PATH_OBJ, "property_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_PACKAGE_OBJ = create(PATH_OBJ, - "package_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_PACKAGE_OBJ = create(PATH_OBJ, "package_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_RSPROXY_CO = create(PATH_OVR, - "rsvcproxy_co_alpha.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_RSPROXY_CO = create(PATH_OVR, "rsvcproxy_co_alpha.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_HOST_OBJ = create(PATH_OBJ, - "IHost.gif"); + public static final ImageDescriptor DESC_HOST_OBJ = create(PATH_OBJ, "IHost.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_SERVICEID_OBJ = create(PATH_OBJ, - "IServiceID.gif"); + public static final ImageDescriptor DESC_SERVICEID_OBJ = create(PATH_OBJ, "IServiceID.gif"); //$NON-NLS-1$ private static final void initialize() { PLUGIN_REGISTRY = Activator.getDefault().getImageRegistry(); @@ -89,8 +78,7 @@ public class RSAImageRegistry { private static URL makeIconURL(String prefix, String name) { String path = "$nl$/" + prefix + name; //$NON-NLS-1$ - return FileLocator.find(Activator.getDefault().getBundle(), new Path( - path), null); + return FileLocator.find(Activator.getDefault().getBundle(), new Path(path), null); } public static Image manage(String key, ImageDescriptor desc) { diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/RemoteServicePerspective.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/RemoteServicePerspective.java index e6108b419..82ad1d27c 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/RemoteServicePerspective.java +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/RemoteServicePerspective.java @@ -10,6 +10,8 @@ ******************************************************************************/ package org.eclipse.ecf.internal.remoteservices.ui; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.EndpointDiscoveryView; +import org.eclipse.ecf.remoteserviceadmin.ui.rsa.RemoteServiceAdminView; import org.eclipse.ui.IFolderLayout; import org.eclipse.ui.IPageLayout; import org.eclipse.ui.IPerspectiveFactory; @@ -32,6 +34,7 @@ public class RemoteServicePerspective implements IPerspectiveFactory { // to be replaced by IPageLayout.ID_PROJECT_EXPLORER layout.addShowViewShortcut("org.eclipse.ui.navigator.ProjectExplorer"); //$NON-NLS-1$ layout.addShowViewShortcut(EndpointDiscoveryView.ID_VIEW); + layout.addShowViewShortcut(RemoteServiceAdminView.ID_VIEW); layout.addShowViewShortcut(IPageLayout.ID_OUTLINE); layout.addShowViewShortcut(IPageLayout.ID_PROP_SHEET); layout.addShowViewShortcut(IPageLayout.ID_PROGRESS_VIEW); @@ -49,24 +52,26 @@ public class RemoteServicePerspective implements IPerspectiveFactory { // The ECF Endpoint Discovery view leftBottom.addView(EndpointDiscoveryView.ID_VIEW); // The ECF Service Discovery view - leftBottom.addView("org.eclipse.ecf.discovery.ui.DiscoveryView"); + leftBottom.addView("org.eclipse.ecf.discovery.ui.DiscoveryView"); //$NON-NLS-1$ // Create folder for right bottom - IFolderLayout rightBottom = layout.createFolder("rightBottom", - IPageLayout.RIGHT, 0.5f, "bottom"); + IFolderLayout rightBottom = layout.createFolder("rightBottom", //$NON-NLS-1$ + IPageLayout.RIGHT, 0.5f, "bottom"); //$NON-NLS-1$ // Add the registry browser on right bottom - rightBottom.addView("org.eclipse.pde.runtime.RegistryBrowser"); + rightBottom.addView("org.eclipse.pde.runtime.RegistryBrowser"); //$NON-NLS-1$ // Add properties view in the middle bottom.addView(IPageLayout.ID_PROP_SHEET); // Create folder for left side above Endpoint Discover/Service Discovery // views IFolderLayout left = layout.createFolder( "left", IPageLayout.LEFT, 0.30f, editorArea); //$NON-NLS-1$ - // Add Project Explorer view - left.addView("org.eclipse.ui.navigator.ProjectExplorer"); //$NON-NLS-1$ + left.addView(RemoteServiceAdminView.ID_VIEW); // Top right. IFolderLayout topRight = layout.createFolder( "topRight", IPageLayout.RIGHT, 0.70f, editorArea); //$NON-NLS-1$ + // Add Project Explorer view + topRight.addView("org.eclipse.ui.navigator.ProjectExplorer"); //$NON-NLS-1$ // Add Outline view topRight.addView(IPageLayout.ID_OUTLINE); + } } diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/messages.properties b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/messages.properties index c8b4eee3b..046d75bd2 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/messages.properties +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/messages.properties @@ -8,6 +8,8 @@ # Contributors: # Remy Chi Jian Suen <remy.suen@gmail.com> - initial API and implementation ################################################################################ +AbstractRegistrationNode_ErrorName=Error +AbstractRSANode_NodeClosed=closed DiscoveryComponent_ERROR_MSG_CANNOT_FIND_RSA_BUNDLE=Cannot find ECF RSA bundle to start EndpointConfigTypesNode_0=Supported Configs EndpointConnectTargetIDNode_CONNECT_TARGET_ID_PROP_NAME=Connect Target ID @@ -67,3 +69,7 @@ MethodInvocationDialog_InvocationTypeAsyncFireAndGo = Async Fire-and-Go MethodInvocationDialog_InvocationTypeOSGiServiceProxy = OSGi Service Proxy MethodInvocationDialog_InvocationTypeRemoteServiceProxy = Remote Service Proxy MethodInvocationDialog_InvocationTypeSynchronous = Synchronous +RSAContentProvider_ExportedServicesNodeName=Exported Services +RSAContentProvider_ImportedEndpointsNodeName=Imported Endpoints +RSAView_PROXY_SERVICE_ID_LABEL=OSGi Proxy Service Id +RSAView_SERVICE_ID_LABEL=OSGi Service Id diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/EndpointDiscoveryView.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/EndpointDiscoveryView.java index 101a7df44..26966de86 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/EndpointDiscoveryView.java +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/EndpointDiscoveryView.java @@ -6,7 +6,7 @@ * * Contributors: Scott Lewis - initial API and implementation ******************************************************************************/ -package org.eclipse.ecf.internal.remoteservices.ui; +package org.eclipse.ecf.remoteserviceadmin.ui.endpoint; import java.io.FileInputStream; import java.io.IOException; @@ -17,6 +17,10 @@ import java.util.List; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.ecf.discovery.identity.IServiceID; +import org.eclipse.ecf.internal.remoteservices.ui.Activator; +import org.eclipse.ecf.internal.remoteservices.ui.DiscoveryComponent; +import org.eclipse.ecf.internal.remoteservices.ui.Messages; +import org.eclipse.ecf.internal.remoteservices.ui.RSAImageRegistry; import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription; import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescriptionReader; import org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionLocator; @@ -67,7 +71,6 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.model.WorkbenchLabelProvider; import org.eclipse.ui.part.ViewPart; -import org.osgi.framework.BundleException; import org.osgi.service.remoteserviceadmin.EndpointEvent; public class EndpointDiscoveryView extends ViewPart { @@ -75,7 +78,6 @@ public class EndpointDiscoveryView extends ViewPart { public static final String ID_VIEW = "org.eclipse.ecf.remoteserviceadmin.ui.views.EndpointDiscoveryView"; //$NON-NLS-1$ private TreeViewer viewer; - private Action startRSAAction; private Action copyValueAction; private Action copyNameAction; private Action importAction; @@ -138,11 +140,11 @@ public class EndpointDiscoveryView extends ViewPart { IllegalAccessException, IllegalArgumentException, InvocationTargetException { return (int) registryBrowser.getClass() - .getDeclaredMethod("showGroupBy", int.class) + .getDeclaredMethod("showGroupBy", int.class) //$NON-NLS-1$ .invoke(registryBrowser, groupBy); } - private int showInRegistryBrowser(int groupBy) { + protected int showInRegistryBrowser(int groupBy) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=270684#c33 try { IWorkbenchWindow window = PlatformUI.getWorkbench() @@ -151,19 +153,19 @@ public class EndpointDiscoveryView extends ViewPart { IWorkbenchPage page = window.getActivePage(); if (page != null) { IViewPart view = page - .findView("org.eclipse.pde.runtime.RegistryBrowser"); + .findView("org.eclipse.pde.runtime.RegistryBrowser"); //$NON-NLS-1$ if (view != null) return invokeShowGroupBy((RegistryBrowser) view, RegistryBrowser.SERVICES); } } } catch (Exception e) { - logWarning("Could not show services in PDE Plugin view", e); + logWarning("Could not show services in PDE Plugin view", e); //$NON-NLS-1$ } return RegistryBrowser.BUNDLES; } - private void showServicesInRegistryBrowser() { + protected void showServicesInRegistryBrowser() { this.previousRegistryBrowserGroupBy = showInRegistryBrowser(RegistryBrowser.SERVICES); } @@ -180,7 +182,7 @@ public class EndpointDiscoveryView extends ViewPart { discoveredEndpointIds.clear(); } - private void hookContextMenu() { + protected void hookContextMenu() { MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { @@ -193,15 +195,13 @@ public class EndpointDiscoveryView extends ViewPart { getSite().registerContextMenu(menuMgr, viewer); } - private void contributeToActionBars() { + protected void contributeToActionBars() { IActionBars bars = getViewSite().getActionBars(); - bars.getMenuManager().add(startRSAAction); bars.getMenuManager().add(edefDiscoverAction); - bars.getToolBarManager().add(startRSAAction); bars.getToolBarManager().add(edefDiscoverAction); } - private void fillContextMenu(IMenuManager manager) { + protected void fillContextMenu(IMenuManager manager) { ITreeSelection selection = (ITreeSelection) viewer.getSelection(); if (selection != null) { Object e = selection.getFirstElement(); @@ -220,7 +220,7 @@ public class EndpointDiscoveryView extends ViewPart { } } - private void log(int level, String message, Throwable e) { + protected void log(int level, String message, Throwable e) { Activator .getDefault() .getLog() @@ -235,28 +235,7 @@ public class EndpointDiscoveryView extends ViewPart { log(IStatus.ERROR, message, e); } - private void makeActions() { - startRSAAction = new Action() { - public void run() { - if (discovery != null) - try { - discovery.startRSA(); - startRSAAction.setEnabled(false); - } catch (BundleException e) { - logError( - Messages.EndpointDiscoveryView_ERROR_RSA_START_FAILED, - e); - showMessage(Messages.EndpointDiscoveryView_ERROR_MSG_RSA_START_PREFIX - + e.getMessage() - + Messages.EndpointDiscoveryView_ERROR_MSG_SUFFIX); - } - } - }; - startRSAAction.setText(Messages.EndpointDiscoveryView_START_RSA); - startRSAAction - .setToolTipText(Messages.EndpointDiscoveryView_START_RSA_SERVICE); - startRSAAction.setEnabled(discovery.getRSA() == null); - + protected void makeActions() { copyValueAction = new Action() { public void run() { Object o = ((ITreeSelection) viewer.getSelection()) @@ -308,9 +287,9 @@ public class EndpointDiscoveryView extends ViewPart { if (reg == null) { logError( Messages.EndpointDiscoveryView_ERROR_MSG_RSA_IMPORTSERVICE_FAILED, - new Exception("Import Registration Is Null")); + new Exception("Import Registration Is Null")); //$NON-NLS-1$ showMessage(Messages.EndpointDiscoveryView_ERROR_MSG_RSA_IMPORTSERVICE_FAILED_PREFIX - + "Import Registration Is Null" + + "Import Registration Is Null" //$NON-NLS-1$ + Messages.EndpointDiscoveryView_ERROR_MSG_SUFFIX); return; } @@ -444,7 +423,7 @@ public class EndpointDiscoveryView extends ViewPart { .getFirstElement()); } - void showMessage(String message) { + protected void showMessage(String message) { MessageDialog.openInformation(viewer.getControl().getShell(), Messages.EndpointDiscoveryView_ENDPOINT_MSGBOX_TITLE, message); } @@ -456,7 +435,7 @@ public class EndpointDiscoveryView extends ViewPart { viewer.getControl().setFocus(); } - void handleEndpointDescription(final int type, final EndpointDescription ed) { + protected void handleEndpointDescription(final int type, final EndpointDescription ed) { if (ed == null || viewer == null) return; viewer.getControl().getDisplay().asyncExec(new Runnable() { @Override @@ -475,13 +454,13 @@ public class EndpointDiscoveryView extends ViewPart { }); } - void handleEndpointChanged(final EndpointEvent event) { + public void handleEndpointChanged(final EndpointEvent event) { handleEndpointDescription(event.getType(),(EndpointDescription) event.getEndpoint()); } private List<String> discoveredEndpointIds = new ArrayList<String>(); - void addEndpoint(EndpointDescription ed) { + protected void addEndpoint(EndpointDescription ed) { if (EndpointDiscoveryView.this.previousRegistryBrowserGroupBy != RegistryBrowser.SERVICES) showServicesInRegistryBrowser(); String edId = ed.getId(); @@ -491,12 +470,12 @@ public class EndpointDiscoveryView extends ViewPart { } } - void removeEndpoint(EndpointDescription ed) { + protected void removeEndpoint(EndpointDescription ed) { if (discoveredEndpointIds.remove(ed.getId())) contentProvider.getRootNode().removeChild(new EndpointNode(ed)); } - ImportRegistration findImportRegistration(EndpointDescription ed) { + protected ImportRegistration findImportRegistration(EndpointDescription ed) { RemoteServiceAdmin rsa = discovery.getRSA(); if (rsa == null) return null; @@ -510,7 +489,7 @@ public class EndpointDiscoveryView extends ViewPart { return null; } - EndpointNode createEndpointDescriptionNode(EndpointDescription ed) { + protected EndpointNode createEndpointDescriptionNode(EndpointDescription ed) { EndpointNode edo = new EndpointNode( ed, new org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.ImportRegistrationNode( diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/model/EndpointNodeWorkbenchAdapter.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/model/EndpointNodeWorkbenchAdapter.java index 45f2d6aad..c6781785e 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/model/EndpointNodeWorkbenchAdapter.java +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/model/EndpointNodeWorkbenchAdapter.java @@ -19,8 +19,14 @@ import org.eclipse.jface.resource.ImageDescriptor; public class EndpointNodeWorkbenchAdapter extends AbstractEndpointNodeWorkbenchAdapter { - private ImageDescriptor edImageDesc; - private ImageDescriptor importedEndpointDesc; + /** + * @since 3.3 + */ + protected ImageDescriptor edImageDesc; + /** + * @since 3.3 + */ + protected ImageDescriptor importedEndpointDesc; public EndpointNodeWorkbenchAdapter() { edImageDesc = RSAImageRegistry.ENDPOINTDESCRIPTION_OBJ; diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/model/EndpointPropertyNode.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/model/EndpointPropertyNode.java index a32407112..dc9e424ac 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/model/EndpointPropertyNode.java +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/model/EndpointPropertyNode.java @@ -1,5 +1,3 @@ -package org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model; - /******************************************************************************* * Copyright (c) 2015 Composent, Inc. All rights reserved. This program and the * accompanying materials are made available under the terms of the Eclipse @@ -10,6 +8,8 @@ package org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model; * * @since 3.2 ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model; + public class EndpointPropertyNode extends AbstractEndpointNode { private final String propertyName; diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/model/EndpointPropertySource.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/model/EndpointPropertySource.java index f3bcb42e2..457564a76 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/model/EndpointPropertySource.java +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/model/EndpointPropertySource.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + * + * @since 3.2 + ******************************************************************************/ package org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model; import java.util.ArrayList; diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/RemoteServiceAdminView.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/RemoteServiceAdminView.java new file mode 100644 index 000000000..658a01e5c --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/RemoteServiceAdminView.java @@ -0,0 +1,259 @@ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa; + +import java.util.List; + +import org.eclipse.ecf.internal.remoteservices.ui.DiscoveryComponent; +import org.eclipse.ecf.internal.remoteservices.ui.Messages; +import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription; +import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin; +import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ExportReference; +import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ExportRegistration; +import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportReference; +import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportRegistration; +import org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.AbstractRSANode; +import org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.AbstractRegistrationNode; +import org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.EndpointDescriptionRSANode; +import org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.ExportRegistrationNode; +import org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.ExportedServicesRootNode; +import org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.ImportRegistrationNode; +import org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.ImportedEndpointsRootNode; +import org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.RSAContentProvider; +import org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.ServiceIdNode; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IMenuListener; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.viewers.ITreeSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.ui.IViewSite; +import org.eclipse.ui.model.WorkbenchLabelProvider; +import org.eclipse.ui.part.ViewPart; +import org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent; + +/** + * @since 3.3 + */ +public class RemoteServiceAdminView extends ViewPart { + + public static final String ID_VIEW = "org.eclipse.ecf.remoteserviceadmin.ui.views.RSAView"; //$NON-NLS-1$ + + private DiscoveryComponent discovery; + private TreeViewer viewer; + + private RSAContentProvider contentProvider; + private Action closeExportAction; + private Action closeImportAction; + + public RemoteServiceAdminView() { + } + + @Override + public void dispose() { + super.dispose(); + viewer = null; + contentProvider = null; + if (discovery != null) { + discovery.setRSAView(null); + discovery = null; + } + } + + @Override + public void createPartControl(Composite parent) { + + this.discovery = DiscoveryComponent.getDefault(); + this.discovery.setRSAView(this); + + IViewSite viewSite = getViewSite(); + + this.contentProvider = new RSAContentProvider(viewSite); + + viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); + viewer.setContentProvider(this.contentProvider); + viewer.setLabelProvider(new WorkbenchLabelProvider()); + viewer.setAutoExpandLevel(TreeViewer.ALL_LEVELS); + viewer.setInput(viewSite); + + makeActions(); + hookContextMenu(); + + viewSite.setSelectionProvider(viewer); + + RemoteServiceAdmin rsa = this.discovery.getRSA(); + if (rsa != null) update(rsa, 0); + } + + protected void fillContextMenu(IMenuManager manager) { + ITreeSelection selection = (ITreeSelection) viewer.getSelection(); + if (selection != null) { + Object e = selection.getFirstElement(); + if (e instanceof ImportRegistrationNode) { + manager.add(closeImportAction); + } else if (e instanceof ExportRegistrationNode) { + manager.add(closeExportAction); + } + } + } + + protected void hookContextMenu() { + MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$ + menuMgr.setRemoveAllWhenShown(true); + menuMgr.addMenuListener(new IMenuListener() { + public void menuAboutToShow(IMenuManager manager) { + RemoteServiceAdminView.this.fillContextMenu(manager); + } + }); + Menu menu = menuMgr.createContextMenu(viewer.getControl()); + viewer.getControl().setMenu(menu); + getSite().registerContextMenu(menuMgr, viewer); + } + + protected void makeActions() { + RemoteServiceAdmin rsa = discovery.getRSA(); + + closeExportAction = createCloseAction(); + closeExportAction.setText("Unexport Service"); + closeExportAction.setEnabled(rsa != null); + + closeImportAction = createCloseAction(); + closeImportAction.setText("Unimport Service"); + closeImportAction.setEnabled(rsa != null); + + } + + Action createCloseAction() { + return new Action() { + public void run() { + AbstractRegistrationNode n = getRegistrationNodeSelected(); + if (n != null) + n.close(); + } + }; + } + + AbstractRSANode getNodeSelected() { + return ((AbstractRSANode) ((ITreeSelection) viewer.getSelection()) + .getFirstElement()); + } + + + AbstractRegistrationNode getRegistrationNodeSelected() { + AbstractRSANode aen = getNodeSelected(); + return (aen instanceof AbstractRegistrationNode) ? (AbstractRegistrationNode) aen : null; + } + + @Override + public void setFocus() { + } + + public void handleRSAEvent(final RemoteServiceAdminEvent event) { + if (viewer == null) + return; + viewer.getControl().getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + RemoteServiceAdmin rsa = getRSA(); + if (rsa != null) { + switch (event.getType()) { + case RemoteServiceAdminEvent.EXPORT_REGISTRATION: + case RemoteServiceAdminEvent.EXPORT_UNREGISTRATION: + case RemoteServiceAdminEvent.EXPORT_ERROR: + case RemoteServiceAdminEvent.EXPORT_UPDATE: + case RemoteServiceAdminEvent.EXPORT_WARNING: + update(rsa, 1); + break; + case RemoteServiceAdminEvent.IMPORT_REGISTRATION: + case RemoteServiceAdminEvent.IMPORT_UNREGISTRATION: + case RemoteServiceAdminEvent.IMPORT_ERROR: + case RemoteServiceAdminEvent.IMPORT_UPDATE: + case RemoteServiceAdminEvent.IMPORT_WARNING: + update(rsa, 2); + break; + } + } + } + }); + } + + RemoteServiceAdmin getRSA() { + return (discovery == null) ? null : discovery.getRSA(); + } + + void updateExports(RemoteServiceAdmin rsa) { + ExportedServicesRootNode exportedRoot = contentProvider.getExportedServicesRoot(); + exportedRoot.clearChildren(); + if (rsa != null && exportedRoot != null) { + List<ExportRegistration> exportRegistrations = rsa.getExportedRegistrations(); + for (ExportRegistration er : exportRegistrations) + exportedRoot.addChild(createExportRegistrationNode(er)); + } + } + + void updateImports(RemoteServiceAdmin rsa) { + ImportedEndpointsRootNode importedRoot = contentProvider.getImportedEndpointsRoot(); + importedRoot.clearChildren(); + if (rsa != null && importedRoot != null) { + List<ImportRegistration> importRegistrations = rsa.getImportedRegistrations(); + for (ImportRegistration ir : importRegistrations) + importedRoot.addChild(createImportRegistrationNode(ir)); + } + } + + protected AbstractRSANode createExportRegistrationNode(ExportRegistration er) { + ExportRegistrationNode result = new ExportRegistrationNode(er); + ExportReference eRef = (ExportReference) er.getExportReference(); + if (eRef != null) { + result.addChild(new ServiceIdNode(eRef.getExportedService(), Messages.RSAView_SERVICE_ID_LABEL)); + EndpointDescription ed = (EndpointDescription) eRef.getExportedEndpoint(); + if (ed != null) + result.addChild(new EndpointDescriptionRSANode(ed)); + } + return result; + } + + protected AbstractRSANode createImportRegistrationNode(ImportRegistration ir) { + ImportRegistrationNode result = new ImportRegistrationNode(ir); + ImportReference iRef = (ImportReference) ir.getImportReference(); + if (iRef != null) { + result.addChild(new ServiceIdNode(iRef.getImportedService(), Messages.RSAView_PROXY_SERVICE_ID_LABEL)); + EndpointDescription ed = (EndpointDescription) iRef.getImportedEndpoint(); + if (ed != null) + result.addChild(new EndpointDescriptionRSANode(ed, ir)); + } + return result; + } + + protected + void update(final RemoteServiceAdmin rsa, final int type) { + if (viewer == null) + return; + viewer.getControl().getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + switch (type) { + // both + case 0: + updateExports(rsa); + updateImports(rsa); + break; + // exports + case 1: + updateExports(rsa); + break; + // imports + case 2: + updateImports(rsa); + break; + } + viewer.setExpandedState(contentProvider.getExportedServicesRoot(), true); + viewer.setExpandedState(contentProvider.getImportedEndpointsRoot(), true); + viewer.refresh(); + } + }); + + } + +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/AbstractRSANode.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/AbstractRSANode.java new file mode 100644 index 000000000..d60b4ffa3 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/AbstractRSANode.java @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa.model; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.ecf.internal.remoteservices.ui.Activator; +import org.eclipse.ecf.internal.remoteservices.ui.DiscoveryComponent; +import org.eclipse.ecf.internal.remoteservices.ui.Messages; +import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin; +import org.osgi.framework.Constants; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceReference; + +/** + * @since 3.3 + */ +public class AbstractRSANode implements IAdaptable { + + public static final String CLOSED = Messages.AbstractRSANode_NodeClosed; + + private AbstractRSANode parent; + private final List<AbstractRSANode> children = new ArrayList<AbstractRSANode>(); + + public AbstractRSANode() { + } + + protected RemoteServiceAdmin getRSA() { + return DiscoveryComponent.getDefault().getRSA(); + } + + public AbstractRSANode getParent() { + return this.parent; + } + + protected void setParent(AbstractRSANode p) { + this.parent = p; + } + + public void addChild(AbstractRSANode child) { + children.add(child); + child.setParent(this); + } + + public void addChildAtIndex(int index, AbstractRSANode child) { + children.add(index, child); + child.setParent(this); + } + + public void removeChild(AbstractRSANode child) { + children.remove(child); + child.setParent(null); + } + + public AbstractRSANode[] getChildren() { + return (AbstractRSANode[]) children.toArray(new AbstractRSANode[children.size()]); + } + + public boolean hasChildren() { + return children.size() > 0; + } + + public void clearChildren() { + children.clear(); + } + + protected String convertStringArrayToString(String[] strings) { + StringBuffer buf = new StringBuffer("["); + for (int i = 0; i < strings.length; i++) { + buf.append(strings[i]); + if (i < strings.length - 1) + buf.append(", "); + } + return buf.append("]").toString(); + } + + protected String convertObjectClassToString(ServiceReference sr) { + return convertStringArrayToString((String[]) sr.getProperty(Constants.OBJECTCLASS)); + } + + protected ServiceReference<org.osgi.service.remoteserviceadmin.RemoteServiceAdmin> getRSARef() { + Activator a = Activator.getDefault(); + if (a != null) { + Collection<ServiceReference<org.osgi.service.remoteserviceadmin.RemoteServiceAdmin>> rsaRefs = null; + try { + rsaRefs = a.getBundle().getBundleContext() + .getServiceReferences(org.osgi.service.remoteserviceadmin.RemoteServiceAdmin.class, null); + } catch (InvalidSyntaxException e) { + // will not happen + } + return (rsaRefs != null && rsaRefs.size() > 0) ? rsaRefs.iterator().next() : null; + } else + return null; + } + + @Override + public Object getAdapter(Class adapter) { + return null; + } +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/AbstractRSAWorkbenchAdapter.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/AbstractRSAWorkbenchAdapter.java new file mode 100644 index 000000000..2c3f05c5d --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/AbstractRSAWorkbenchAdapter.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa.model; + +import org.eclipse.ui.model.WorkbenchAdapter; + +/** + * @since 3.3 + */ +public class AbstractRSAWorkbenchAdapter extends WorkbenchAdapter { + + @Override + public Object getParent(Object object) { + return ((AbstractRSANode) object).getParent(); + } + + @Override + public Object[] getChildren(Object object) { + return ((AbstractRSANode) object).getChildren(); + } + +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/AbstractRegistrationNode.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/AbstractRegistrationNode.java new file mode 100644 index 000000000..5a32632bd --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/AbstractRegistrationNode.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa.model; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.ecf.internal.remoteservices.ui.Messages; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointPropertySource; +import org.eclipse.ui.views.properties.IPropertySource; +import org.osgi.framework.ServiceReference; + +/** + * @since 3.3 + */ +public abstract class AbstractRegistrationNode extends AbstractRSANode { + + public static final String ERROR = Messages.AbstractRegistrationNode_ErrorName; + + private final boolean error; + + public AbstractRegistrationNode(Throwable t) { + this.error = t != null; + } + + protected boolean hasError() { + return error; + } + + public abstract boolean isClosed(); + + protected abstract String getValidName(); + + public abstract ServiceReference getServiceReference(); + + public String getName() { + return hasError() ? ERROR : (isClosed() ? CLOSED : getValidName()); + } + + protected Map<String, Object> convertServicePropsToMap(ServiceReference sr) { + String[] keys = sr.getPropertyKeys(); + Map<String, Object> result = new HashMap<String, Object>(); + for (String key : keys) + result.put(key, sr.getProperty(key)); + return result; + } + + @Override + public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { + if (adapter == IPropertySource.class) { + ServiceReference sr = getServiceReference(); + if (sr != null) + return new EndpointPropertySource(convertServicePropsToMap(sr)); + } + return Platform.getAdapterManager().getAdapter(this, adapter); + } + + public abstract void close(); + +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/EndpointDescriptionRSANode.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/EndpointDescriptionRSANode.java new file mode 100644 index 000000000..a596ead19 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/EndpointDescriptionRSANode.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa.model; + +import java.util.List; + +import org.eclipse.ecf.internal.remoteservices.ui.Messages; +import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription; +import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportRegistration; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointAsyncInterfacesNode; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointConfigTypesNode; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointConnectTargetIDNode; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointFrameworkIDNode; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointHostGroupNode; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointIDNode; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointIntentsNode; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointInterfacesNode; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointNamespaceNode; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointNode; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointPackageVersionNode; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointRemoteServiceFilterNode; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointRemoteServiceIDNode; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointServiceIDNode; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointTimestampNode; + +/** + * @since 3.3 + */ +public class EndpointDescriptionRSANode extends AbstractRSANode { + + private final EndpointNode endpointNode; + + public EndpointDescriptionRSANode(EndpointDescription ed) { + this(ed, null); + } + + public EndpointDescriptionRSANode(EndpointDescription ed, ImportRegistration ir) { + this.endpointNode = (ir == null)?new EndpointNode(ed):new EndpointNode(ed,new org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.ImportRegistrationNode(ir)); + // Interfaces + EndpointInterfacesNode ein = new EndpointInterfacesNode(); + for (String intf : ed.getInterfaces()) + ein.addChild(new EndpointPackageVersionNode(EndpointNode.getPackageName(intf))); + this.endpointNode.addChild(ein); + // Async Interfaces (if present) + List<String> aintfs = ed.getAsyncInterfaces(); + if (aintfs.size() > 0) { + EndpointAsyncInterfacesNode ain = new EndpointAsyncInterfacesNode(); + for (String intf : ed.getAsyncInterfaces()) + ain.addChild(new EndpointPackageVersionNode(EndpointNode.getPackageName(intf))); + this.endpointNode.addChild(ain); + } + // ID + this.endpointNode.addChild(new EndpointIDNode()); + // Remote Service Host + EndpointHostGroupNode idp = new EndpointHostGroupNode(Messages.EndpointDiscoveryView_REMOTE_HOST_NAME); + // Host children + idp.addChild(new EndpointNamespaceNode()); + idp.addChild(new EndpointRemoteServiceIDNode()); + org.eclipse.ecf.core.identity.ID connectTarget = ed.getConnectTargetID(); + if (connectTarget != null) + idp.addChild(new EndpointConnectTargetIDNode()); + idp.addChild(new EndpointServiceIDNode()); + idp.addChild(new EndpointIntentsNode()); + idp.addChild(new EndpointConfigTypesNode()); + idp.addChild(new EndpointFrameworkIDNode()); + idp.addChild(new EndpointTimestampNode()); + String filter = ed.getRemoteServiceFilter(); + if (filter != null) + idp.addChild(new EndpointRemoteServiceFilterNode()); + this.endpointNode.addChild(idp); + } + + public EndpointNode getEndpointNode() { + return this.endpointNode; + } + +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/EndpointDescriptionRSANodeWorkbenchAdapter.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/EndpointDescriptionRSANodeWorkbenchAdapter.java new file mode 100644 index 000000000..c998c94fd --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/EndpointDescriptionRSANodeWorkbenchAdapter.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa.model; + +import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription; +import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointNodeWorkbenchAdapter; +import org.eclipse.jface.resource.ImageDescriptor; + +/** + * @since 3.3 + */ +public class EndpointDescriptionRSANodeWorkbenchAdapter extends EndpointNodeWorkbenchAdapter { + + @Override + public String getLabel(Object object) { + EndpointDescription ed = ((EndpointDescriptionRSANode) object).getEndpointNode().getEndpointDescription(); + return ed.getContainerID().getName() + ":" + ed.getRemoteServiceId(); //$NON-NLS-1$ + } + + @Override + public ImageDescriptor getImageDescriptor(Object object) { + return ((EndpointDescriptionRSANode) object).getEndpointNode().isImported() ? importedEndpointDesc + : edImageDesc; + } + + @Override + public Object getParent(Object object) { + return ((AbstractRSANode) object).getParent(); + } + + @Override + public Object[] getChildren(Object object) { + return ((EndpointDescriptionRSANode) object).getEndpointNode().getChildren(); + } + +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ExportRegistrationNode.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ExportRegistrationNode.java new file mode 100644 index 000000000..91881e32d --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ExportRegistrationNode.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa.model; + +import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ExportReference; +import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ExportRegistration; +import org.osgi.framework.ServiceReference; + +/** + * @since 3.3 + */ +public class ExportRegistrationNode extends AbstractRegistrationNode { + + private final ExportRegistration exportRegistration; + + public ExportRegistrationNode(ExportRegistration eReg) { + super(eReg.getException()); + this.exportRegistration = eReg; + } + + ExportReference getExportReference() { + return (ExportReference) this.exportRegistration.getExportReference(); + } + + public String getValidName() { + return convertObjectClassToString(getExportReference().getExportedService()); + } + + @Override + public boolean isClosed() { + return getExportReference() == null; + } + + @Override + public ServiceReference getServiceReference() { + ExportReference exportRef = getExportReference(); + return exportRef == null ? null : exportRef.getExportedService(); + } + + @Override + public void close() { + exportRegistration.close(); + } +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ExportRegistrationNodeWorkbenchAdapter.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ExportRegistrationNodeWorkbenchAdapter.java new file mode 100644 index 000000000..f63a6f2b8 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ExportRegistrationNodeWorkbenchAdapter.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa.model; + +import org.eclipse.ecf.internal.remoteservices.ui.RSAImageRegistry; +import org.eclipse.jface.resource.ImageDescriptor; + +/** + * @since 3.3 + */ +public class ExportRegistrationNodeWorkbenchAdapter extends AbstractRSAWorkbenchAdapter { + + @Override + public String getLabel(Object object) { + return ((ExportRegistrationNode) object).getName(); + } + + @Override + public ImageDescriptor getImageDescriptor(Object object) { + return RSAImageRegistry.RS_OBJ; + } +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ExportedServicesRootNode.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ExportedServicesRootNode.java new file mode 100644 index 000000000..6ddc487bc --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ExportedServicesRootNode.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa.model; + +/** + * @since 3.3 + */ +public class ExportedServicesRootNode extends AbstractRSANode { + + private final String groupName; + + public ExportedServicesRootNode(String groupName) { + super(); + this.groupName = groupName; + } + + public String getGroupName() { + return groupName; + } + +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ExportedServicesRootNodeWorkbenchAdapter.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ExportedServicesRootNodeWorkbenchAdapter.java new file mode 100644 index 000000000..a487d9f54 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ExportedServicesRootNodeWorkbenchAdapter.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa.model; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; + +/** + * @since 3.3 + */ +public class ExportedServicesRootNodeWorkbenchAdapter extends AbstractRSAWorkbenchAdapter { + + @Override + public String getLabel(Object object) { + return ((ExportedServicesRootNode) object).getGroupName(); + } + + @Override + public ImageDescriptor getImageDescriptor(Object object) { + return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER); + } +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ImportRegistrationNode.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ImportRegistrationNode.java new file mode 100644 index 000000000..2dd233bb7 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ImportRegistrationNode.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa.model; + +import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportReference; +import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportRegistration; +import org.osgi.framework.ServiceReference; + +/** + * @since 3.3 + */ +public class ImportRegistrationNode extends AbstractRegistrationNode { + + private final ImportRegistration importRegistration; + + public ImportRegistrationNode(ImportRegistration iReg) { + super(iReg.getException()); + this.importRegistration = iReg; + } + + ImportReference getImportReference() { + return (ImportReference) this.importRegistration.getImportReference(); + } + + public String getValidName() { + return convertObjectClassToString(getImportReference().getImportedService()); + } + + @Override + public boolean isClosed() { + return getImportReference() == null; + } + + @Override + public ServiceReference getServiceReference() { + ImportReference importRef = getImportReference(); + return importRef == null ? null : importRef.getImportedService(); + } + + @Override + public void close() { + importRegistration.close(); + } + +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ImportRegistrationNodeWorkbenchAdapter.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ImportRegistrationNodeWorkbenchAdapter.java new file mode 100644 index 000000000..47eecc24a --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ImportRegistrationNodeWorkbenchAdapter.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa.model; + +import org.eclipse.ecf.internal.remoteservices.ui.RSAImageRegistry; +import org.eclipse.jface.resource.ImageDescriptor; + +/** + * @since 3.3 + */ +public class ImportRegistrationNodeWorkbenchAdapter extends AbstractRSAWorkbenchAdapter { + + @Override + public String getLabel(Object object) { + return ((ImportRegistrationNode) object).getName(); + } + + @Override + public ImageDescriptor getImageDescriptor(Object object) { + return RSAImageRegistry.RSPROXY_OBJ; + } +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ImportedEndpointsRootNode.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ImportedEndpointsRootNode.java new file mode 100644 index 000000000..2c98a931d --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ImportedEndpointsRootNode.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa.model; + +/** + * @since 3.3 + */ +public class ImportedEndpointsRootNode extends AbstractRSANode { + + private final String groupName; + + public ImportedEndpointsRootNode(String groupName) { + super(); + this.groupName = groupName; + } + + public String getGroupName() { + return groupName; + } + +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ImportedEndpointsRootNodeWorkbenchAdapter.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ImportedEndpointsRootNodeWorkbenchAdapter.java new file mode 100644 index 000000000..36b7b3c29 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ImportedEndpointsRootNodeWorkbenchAdapter.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa.model; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; + +/** + * @since 3.3 + */ +public class ImportedEndpointsRootNodeWorkbenchAdapter extends AbstractRSAWorkbenchAdapter { + + @Override + public String getLabel(Object object) { + return ((ImportedEndpointsRootNode) object).getGroupName(); + } + + @Override + public ImageDescriptor getImageDescriptor(Object object) { + return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER); + } +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/NameValuePropertyNode.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/NameValuePropertyNode.java new file mode 100644 index 000000000..4c7a169db --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/NameValuePropertyNode.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa.model; + +/** + * @since 3.3 + */ +public class NameValuePropertyNode extends AbstractRSANode { + + private final String propertyName; + private String propertyAlias; + private String nameValueSeparator = ": "; //$NON-NLS-1$ + private Object propertyValue; + + public NameValuePropertyNode(String propertyName, Object propertyValue) { + this.propertyName = propertyName; + this.propertyValue = propertyValue; + } + + public String getPropertyAlias() { + return this.propertyAlias; + } + + public void setPropertyAlias(String propertyAlias) { + this.propertyAlias = propertyAlias; + } + + public String getNameValueSeparator() { + return nameValueSeparator; + } + + public void setNameValueSeparator(String nameValueSeparator) { + this.nameValueSeparator = nameValueSeparator; + } + + public String getPropertyName() { + return propertyName; + } + + public Object getPropertyValue() { + return propertyValue; + } + +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/NameValuePropertyNodeWorkbenchAdapter.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/NameValuePropertyNodeWorkbenchAdapter.java new file mode 100644 index 000000000..eb6eb51f7 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/NameValuePropertyNodeWorkbenchAdapter.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa.model; + +import org.eclipse.ecf.internal.remoteservices.ui.RSAImageRegistry; +import org.eclipse.jface.resource.ImageDescriptor; + +/** + * @since 3.3 + */ +public class NameValuePropertyNodeWorkbenchAdapter extends AbstractRSAWorkbenchAdapter { + + @Override + public String getLabel(Object object) { + NameValuePropertyNode nvpn = (NameValuePropertyNode) object; + String propertyName = nvpn.getPropertyAlias(); + if (propertyName == null) + propertyName = nvpn.getPropertyName(); + return propertyName + nvpn.getNameValueSeparator() + nvpn.getPropertyValue(); + } + + @Override + public ImageDescriptor getImageDescriptor(Object object) { + return RSAImageRegistry.DESC_PROPERTY_OBJ; + } +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/RSAAdapterFactory.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/RSAAdapterFactory.java new file mode 100644 index 000000000..53b2284f1 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/RSAAdapterFactory.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa.model; + +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.ui.model.IWorkbenchAdapter; +import org.eclipse.ui.model.IWorkbenchAdapter2; +import org.eclipse.ui.model.IWorkbenchAdapter3; + +/** + * @since 3.3 + */ +public class RSAAdapterFactory implements IAdapterFactory { + + private ExportedServicesRootNodeWorkbenchAdapter exportedServicesRootAdapter = new ExportedServicesRootNodeWorkbenchAdapter(); + private ImportedEndpointsRootNodeWorkbenchAdapter importedEndpointsRootAdapter = new ImportedEndpointsRootNodeWorkbenchAdapter(); + private ExportRegistrationNodeWorkbenchAdapter exportRegistrationAdapter = new ExportRegistrationNodeWorkbenchAdapter(); + private ImportRegistrationNodeWorkbenchAdapter importRegistrationAdapter = new ImportRegistrationNodeWorkbenchAdapter(); + private NameValuePropertyNodeWorkbenchAdapter nameValuePropertyAdapter = new NameValuePropertyNodeWorkbenchAdapter(); + private EndpointDescriptionRSANodeWorkbenchAdapter edAdapter = new EndpointDescriptionRSANodeWorkbenchAdapter(); + + @Override + public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes") Class adapterType) { + if (adapterType.isInstance(adaptableObject)) { + return adaptableObject; + } + if (adapterType == IWorkbenchAdapter.class || adapterType == IWorkbenchAdapter2.class + || adapterType == IWorkbenchAdapter3.class) { + return getWorkbenchElement(adaptableObject); + } + return null; + } + + protected Object getWorkbenchElement(Object adaptableObject) { + if (adaptableObject instanceof ExportedServicesRootNode) + return exportedServicesRootAdapter; + if (adaptableObject instanceof ImportedEndpointsRootNode) + return importedEndpointsRootAdapter; + if (adaptableObject instanceof ExportRegistrationNode) + return exportRegistrationAdapter; + if (adaptableObject instanceof ImportRegistrationNode) + return importRegistrationAdapter; + if (adaptableObject instanceof NameValuePropertyNode) + return nameValuePropertyAdapter; + if (adaptableObject instanceof EndpointDescriptionRSANode) + return edAdapter; + return null; + } + + @SuppressWarnings("rawtypes") + @Override + public Class[] getAdapterList() { + return new Class[] { IWorkbenchAdapter.class, IWorkbenchAdapter2.class, IWorkbenchAdapter3.class }; + } + +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/RSAContentProvider.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/RSAContentProvider.java new file mode 100644 index 000000000..f0579dd3a --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/RSAContentProvider.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa.model; + +import org.eclipse.ecf.internal.remoteservices.ui.Messages; +import org.eclipse.ui.IViewSite; +import org.eclipse.ui.model.BaseWorkbenchContentProvider; + +/** + * @since 3.3 + */ +public class RSAContentProvider extends BaseWorkbenchContentProvider { + + private IViewSite viewSite; + + private ExportedServicesRootNode invisibleRoot; + private ExportedServicesRootNode exportedServicesRoot; + private ImportedEndpointsRootNode importedEndpointsRoot; + + public RSAContentProvider(IViewSite viewSite) { + this.viewSite = viewSite; + } + + public ExportedServicesRootNode getExportedServicesRoot() { + return exportedServicesRoot; + } + + public ImportedEndpointsRootNode getImportedEndpointsRoot() { + return importedEndpointsRoot; + } + + public Object[] getElements(Object parent) { + if (parent.equals(viewSite)) { + if (invisibleRoot == null) { + invisibleRoot = new ExportedServicesRootNode(""); //$NON-NLS-1$ + exportedServicesRoot = new ExportedServicesRootNode( + Messages.RSAContentProvider_ExportedServicesNodeName); + invisibleRoot.addChild(exportedServicesRoot); + importedEndpointsRoot = new ImportedEndpointsRootNode( + Messages.RSAContentProvider_ImportedEndpointsNodeName); + invisibleRoot.addChild(importedEndpointsRoot); + } + return getChildren(invisibleRoot); + } + return getChildren(parent); + } + +} diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ServiceIdNode.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ServiceIdNode.java new file mode 100644 index 000000000..da101945b --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/model/ServiceIdNode.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2015 Composent, Inc. 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: Scott Lewis - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.remoteserviceadmin.ui.rsa.model; + +import org.osgi.framework.Constants; +import org.osgi.framework.ServiceReference; + +/** + * @since 3.3 + */ +public class ServiceIdNode extends NameValuePropertyNode { + + public ServiceIdNode(ServiceReference sr, String labelPrefix) { + super(Constants.SERVICE_ID, sr.getProperty(Constants.SERVICE_ID)); + setPropertyAlias(labelPrefix); + } + +} |