Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2015-11-25 22:13:40 +0000
committerslewis2015-11-25 22:13:40 +0000
commit04ea3540bba192cbbc3431681a7264477d402eb6 (patch)
tree0628f90ae8cc5399cf8a4d27d31918341d31da46 /framework
parent4147cc8a8c1edfc0da70d4ae34eb65b2bcff041c (diff)
downloadorg.eclipse.ecf-04ea3540bba192cbbc3431681a7264477d402eb6.tar.gz
org.eclipse.ecf-04ea3540bba192cbbc3431681a7264477d402eb6.tar.xz
org.eclipse.ecf-04ea3540bba192cbbc3431681a7264477d402eb6.zip
Added servicesview extension point to support future support of
https://bugs.eclipse.org/bugs/show_bug.cgi?id=483025 Change-Id: I42917201cbe317dfaa9a7b753ab2116e25189c6f
Diffstat (limited to 'framework')
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice.ui/META-INF/MANIFEST.MF4
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice.ui/build.properties6
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice.ui/plugin.xml2
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice.ui/schema/org.eclipse.ecf.remoteservice.ui.servicesview.exsd113
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/Activator.java81
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/RemoteServicePerspective.java14
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/ServicesViewExtension.java41
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteservice/ui/services/IServicesView.java19
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/EndpointDiscoveryView.java31
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/AbstractRemoteServiceAdminView.java69
10 files changed, 360 insertions, 20 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 a680f9b83..13994acd8 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
@@ -13,7 +13,9 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ecf.discovery.ui;bundle-version="3.0.0",
org.eclipse.ecf.discovery.ui.model;bundle-version="3.0.0",
org.eclipse.pde.runtime
-Export-Package: org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model;version="1.0.0",
+Export-Package: org.eclipse.ecf.remoteservice.ui.services,
+ org.eclipse.ecf.remoteserviceadmin.ui.endpoint,
+ 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",
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/build.properties b/framework/bundles/org.eclipse.ecf.remoteservice.ui/build.properties
index 5c555cc28..e8555af3f 100644
--- a/framework/bundles/org.eclipse.ecf.remoteservice.ui/build.properties
+++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/build.properties
@@ -6,6 +6,8 @@ bin.includes = META-INF/,\
plugin.properties,\
plugin.xml,\
OSGI-INF/,\
- icons/
+ icons/,\
+ schema/
src.includes = about.html,\
- icons/
+ icons/,\
+ schema/
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/plugin.xml b/framework/bundles/org.eclipse.ecf.remoteservice.ui/plugin.xml
index 7d01bb9e5..5ceeddea8 100644
--- a/framework/bundles/org.eclipse.ecf.remoteservice.ui/plugin.xml
+++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/plugin.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
+ <extension-point id="org.eclipse.ecf.remoteservice.ui.servicesview" name="Services View Extension Point" schema="schema/org.eclipse.ecf.remoteservice.ui.servicesview.exsd"/>
<extension
point="org.eclipse.ui.commands">
<command
@@ -302,5 +303,6 @@
</factory>
</extension>
+
</plugin>
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/schema/org.eclipse.ecf.remoteservice.ui.servicesview.exsd b/framework/bundles/org.eclipse.ecf.remoteservice.ui/schema/org.eclipse.ecf.remoteservice.ui.servicesview.exsd
new file mode 100644
index 000000000..db258501a
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/schema/org.eclipse.ecf.remoteservice.ui.servicesview.exsd
@@ -0,0 +1,113 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.ecf.remoteservice.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.ecf.remoteservice.ui" id="org.eclipse.ecf.remoteservice.ui.servicesview" name="Services View Extension Point"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="servicesview" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="servicesview">
+ <complexType>
+ <attribute name="viewid" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="local" type="boolean">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="priority" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/Activator.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/Activator.java
index e16d01636..c212eaf87 100644
--- a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/Activator.java
+++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/Activator.java
@@ -12,6 +12,14 @@
package org.eclipse.ecf.internal.remoteservices.ui;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.ecf.core.IContainerManager;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -25,6 +33,19 @@ public class Activator extends AbstractUIPlugin {
// The shared instance
private volatile static Activator plugin;
+ private BundleContext context;
+ private IExtensionRegistry extensionRegistry;
+
+ private String servicesViewId;
+
+ public String getLocalServicesViewId() {
+ return servicesViewId;
+ }
+
+ public void setLocalServicesViewId(String viewId) {
+ this.servicesViewId = viewId;
+ }
+
/**
* The constructor
*/
@@ -32,6 +53,65 @@ public class Activator extends AbstractUIPlugin {
plugin = this;
}
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ this.context = context;
+ ServiceTracker<IExtensionRegistry, IExtensionRegistry> st = new ServiceTracker(this.context,
+ IExtensionRegistry.class, null);
+ st.open();
+ this.extensionRegistry = st.getService();
+ st.close();
+ }
+
+ public List<ServicesViewExtension> getLocalServicesViewExtensions() {
+ return getServicesViewExtensions(Boolean.TRUE);
+ }
+
+ public List<ServicesViewExtension> getRemoteServicesViewExtensions() {
+ return getServicesViewExtensions(Boolean.FALSE);
+ }
+
+ public List<ServicesViewExtension> getServicesViewExtensions() {
+ return getServicesViewExtensions(null);
+ }
+
+ public List<ServicesViewExtension> getServicesViewExtensions(Boolean localOnly) {
+ List<ServicesViewExtension> results = new ArrayList<ServicesViewExtension>();
+ if (this.extensionRegistry != null) {
+ IExtensionPoint epoint = this.extensionRegistry
+ .getExtensionPoint("org.eclipse.ecf.remoteservice.ui.servicesview");
+ if (epoint != null) {
+ IConfigurationElement[] elements = epoint.getConfigurationElements();
+ for (IConfigurationElement element : elements) {
+ try {
+ ServicesViewExtension sve = new ServicesViewExtension(element);
+ if (localOnly != null) {
+ if (localOnly.booleanValue()) {
+ if (!sve.isLocal())
+ sve = null;
+ } else {
+ if (sve.isLocal())
+ sve = null;
+ }
+ }
+ if (sve != null)
+ results.add(sve);
+ } catch (Exception e) {
+ e.printStackTrace(System.err);
+ }
+ }
+ }
+ }
+ Collections.sort(results, new Comparator<ServicesViewExtension>() {
+ @Override
+ public int compare(ServicesViewExtension o1, ServicesViewExtension o2) {
+ return o2.getPriority() - o1.getPriority();
+ }
+ });
+ return results;
+ }
+
/*
* (non-Javadoc)
*
@@ -44,6 +124,7 @@ public class Activator extends AbstractUIPlugin {
containerManagerTracker.close();
containerManagerTracker = null;
}
+ this.extensionRegistry = null;
super.stop(context);
}
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 b64680d39..e7735d479 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 java.util.List;
+
import org.eclipse.ecf.remoteserviceadmin.ui.endpoint.EndpointDiscoveryView;
import org.eclipse.ecf.remoteserviceadmin.ui.rsa.RemoteServiceAdminView;
import org.eclipse.ui.IFolderLayout;
@@ -55,8 +57,16 @@ public class RemoteServicePerspective implements IPerspectiveFactory {
// Create folder for right 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"); //$NON-NLS-1$
+
+ List<ServicesViewExtension> sves = Activator.getDefault().getLocalServicesViewExtensions();
+
+ String viewId = "org.eclipse.pde.runtime.RegistryBrowser"; //$NON-NLS-1$
+ if (sves.size() > 0) {
+ viewId = sves.get(0).getViewId();
+ Activator.getDefault().setLocalServicesViewId(viewId);
+ }
+ rightBottom.addView(viewId);
+
// Add properties view in the middle
bottom.addView(IPageLayout.ID_PROP_SHEET);
// Create folder for left side above Endpoint Discover/Service Discovery
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/ServicesViewExtension.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/ServicesViewExtension.java
new file mode 100644
index 000000000..df876fa7c
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/internal/remoteservices/ui/ServicesViewExtension.java
@@ -0,0 +1,41 @@
+package org.eclipse.ecf.internal.remoteservices.ui;
+
+import java.io.InvalidObjectException;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+
+public class ServicesViewExtension {
+
+ private final String viewId;
+ private final boolean local;
+ private int priority = 0;
+
+ public ServicesViewExtension(IConfigurationElement ce) throws InvalidObjectException {
+ this.viewId = ce.getAttribute("viewid");
+ if (this.viewId == null) throw new InvalidObjectException("viewId must be set for services view extension");
+ this.local = Boolean.parseBoolean(ce.getAttribute("local"));
+ String priorityStr = ce.getAttribute("priority");
+ try {
+ this.priority = Integer.parseInt(priorityStr);
+ } catch (NumberFormatException e) {
+ // ignore
+ }
+ }
+
+ public String getViewId() {
+ return this.viewId;
+ }
+
+ public boolean isLocal() {
+ return this.local;
+ }
+
+ public int getPriority() {
+ return this.priority;
+ }
+
+ @Override
+ public String toString() {
+ return "ServicesViewExtension [viewId=" + viewId + ", local=" + local + ", priority=" + priority + "]";
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteservice/ui/services/IServicesView.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteservice/ui/services/IServicesView.java
new file mode 100644
index 000000000..cced2c2cf
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteservice/ui/services/IServicesView.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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.remoteservice.ui.services;
+
+/**
+ * @since 3.3
+ */
+public interface IServicesView {
+
+ public String getRemoteId();
+
+ public void selectService(long serviceId);
+}
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/EndpointDiscoveryView.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/EndpointDiscoveryView.java
index 461eb5b8f..cc7e64dc9 100644
--- a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/EndpointDiscoveryView.java
+++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/endpoint/EndpointDiscoveryView.java
@@ -10,7 +10,6 @@ package org.eclipse.ecf.remoteserviceadmin.ui.endpoint;
import java.io.FileInputStream;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
@@ -73,6 +72,9 @@ import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.part.ViewPart;
import org.osgi.service.remoteserviceadmin.EndpointEvent;
+/**
+ * @since 3.3
+ */
public class EndpointDiscoveryView extends ViewPart {
public static final String ID_VIEW = "org.eclipse.ecf.remoteserviceadmin.ui.views.EndpointDiscoveryView"; //$NON-NLS-1$
@@ -130,7 +132,6 @@ public class EndpointDiscoveryView extends ViewPart {
});
showServicesInRegistryBrowser();
-
}
protected EndpointContentProvider createContentProvider(IViewSite viewSite) {
@@ -139,23 +140,24 @@ public class EndpointDiscoveryView extends ViewPart {
private int previousRegistryBrowserGroupBy;
- private int invokeShowGroupBy(RegistryBrowser registryBrowser, int groupBy) throws NoSuchMethodException,
- SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- return (int) registryBrowser.getClass().getDeclaredMethod("showGroupBy", int.class) //$NON-NLS-1$
- .invoke(registryBrowser, groupBy);
+ private IViewPart findView(String viewId) {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window != null) {
+ IWorkbenchPage page = window.getActivePage();
+ if (page != null)
+ return page.findView(viewId); // $NON-NLS-1$
+ }
+ return null;
}
protected int showInRegistryBrowser(int groupBy) {
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=270684#c33
try {
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- IViewPart view = page.findView("org.eclipse.pde.runtime.RegistryBrowser"); //$NON-NLS-1$
- if (view != null)
- return invokeShowGroupBy((RegistryBrowser) view, RegistryBrowser.SERVICES);
- }
+ IViewPart view = findView("org.eclipse.pde.runtime.RegistryBrowser"); //$NON-NLS-1$
+ if (view != null) {
+ RegistryBrowser registryBrowser = (RegistryBrowser) view;
+ return (int) registryBrowser.getClass().getDeclaredMethod("showGroupBy", int.class) //$NON-NLS-1$
+ .invoke(registryBrowser, RegistryBrowser.SERVICES);
}
} catch (Exception e) {
logWarning("Could not show services in PDE Plugin view", e); //$NON-NLS-1$
@@ -163,6 +165,7 @@ public class EndpointDiscoveryView extends ViewPart {
return RegistryBrowser.BUNDLES;
}
+ @Deprecated
protected void showServicesInRegistryBrowser() {
this.previousRegistryBrowserGroupBy = showInRegistryBrowser(RegistryBrowser.SERVICES);
}
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/AbstractRemoteServiceAdminView.java b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/AbstractRemoteServiceAdminView.java
index eb3ee4c92..43914dd45 100644
--- a/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/AbstractRemoteServiceAdminView.java
+++ b/framework/bundles/org.eclipse.ecf.remoteservice.ui/src/org/eclipse/ecf/remoteserviceadmin/ui/rsa/AbstractRemoteServiceAdminView.java
@@ -13,19 +13,32 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.ecf.internal.remoteservices.ui.Activator;
import org.eclipse.ecf.internal.remoteservices.ui.DiscoveryComponent;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin;
+import org.eclipse.ecf.remoteservice.ui.services.IServicesView;
import org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.AbstractRSAContentProvider;
import org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.AbstractRSANode;
+import org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.ExportRegistrationNode;
+import org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.ImportRegistrationNode;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
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.IViewPart;
import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPage;
+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.Constants;
+import org.osgi.framework.ServiceReference;
/**
* @since 3.3
@@ -81,7 +94,48 @@ public abstract class AbstractRemoteServiceAdminView extends ViewPart {
protected void updateModel() {
}
- protected abstract void setupListeners();
+ protected void setupListeners() {
+
+ }
+
+ protected void setupSelectionListeners() {
+ final String servicesViewId = Activator.getDefault().getLocalServicesViewId();
+ if (servicesViewId != null) {
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection sel = event.getSelection();
+ Object selection = null;
+ if (sel instanceof IStructuredSelection)
+ selection = ((IStructuredSelection) sel).getFirstElement();
+ ServiceReference sr = null;
+ if (selection instanceof ExportRegistrationNode) {
+ sr = ((ExportRegistrationNode) selection).getServiceReference();
+ } else if (selection instanceof ImportRegistrationNode) {
+ sr = ((ImportRegistrationNode) selection).getServiceReference();
+ }
+ if (sr != null)
+ selectServiceInServicesView(servicesViewId, (Long) sr.getProperty(Constants.SERVICE_ID));
+ }
+ });
+ }
+ }
+
+ protected void selectServiceInServicesView(String servicesViewId, final long serviceId) {
+ try {
+ IViewPart view = findView(servicesViewId);
+ if (view != null) {
+ if (view instanceof IServicesView) {
+ IServicesView sv = (IServicesView) view;
+ sv.selectService(serviceId);
+ } else {
+ logWarning("Could not select services on viewId="+servicesViewId, null);
+ }
+ }
+ } catch (Exception e) {
+ logWarning("Could not show services in PDE Plugin view", e); //$NON-NLS-1$
+ }
+ }
protected void log(int level, String message, Throwable e) {
Activator.getDefault().getLog().log(new Status(level, Activator.PLUGIN_ID, message, e));
@@ -115,11 +169,24 @@ public abstract class AbstractRemoteServiceAdminView extends ViewPart {
setupListeners();
+ setupSelectionListeners();
+
RemoteServiceAdmin rsa = getLocalRSA();
if (rsa != null)
updateModel();
}
+ protected IViewPart findView(String viewId) {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window != null) {
+ IWorkbenchPage page = window.getActivePage();
+ if (page != null)
+ return page.findView(viewId); // $NON-NLS-1$
+ }
+ return null;
+ }
+
+
@Override
public void setFocus() {
}

Back to the top