| <?xml version='1.0' encoding='UTF-8'?> |
| <!-- Schema file written by PDE --> |
| <schema targetNamespace="org.eclipse.ecf.discovery.ui"> |
| <annotation> |
| <appInfo> |
| <meta.schema plugin="org.eclipse.ecf.discovery.ui" id="serviceAccessHandler" name="ECF Service Access Handler"/> |
| </appInfo> |
| <documentation> |
| This extension point allows plugins to add menu items to the |
| discovery view's context menu for accessing/invoking a remote service. |
| </documentation> |
| </annotation> |
| |
| <element name="extension"> |
| <complexType> |
| <sequence minOccurs="1" maxOccurs="unbounded"> |
| <element ref="serviceAccessHandler"/> |
| </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="serviceAccessHandler"> |
| <complexType> |
| <attribute name="class" type="string" use="required"> |
| <annotation> |
| <documentation> |
| Required service access handler class. Note this class must implement the <b>org.eclipse.ecf.discovery.ui.views.IServiceAccessHandler</b> interface. |
| </documentation> |
| <appInfo> |
| <meta.attribute kind="java" basedOn=":org.eclipse.ecf.discovery.ui.views.IServiceAccessHandler"/> |
| </appInfo> |
| </annotation> |
| </attribute> |
| </complexType> |
| </element> |
| |
| <annotation> |
| <appInfo> |
| <meta.section type="since"/> |
| </appInfo> |
| <documentation> |
| 2.0.0M5 |
| </documentation> |
| </annotation> |
| |
| <annotation> |
| <appInfo> |
| <meta.section type="examples"/> |
| </appInfo> |
| <documentation> |
| Here is example usage of the serviceAccessHandler extension point. In this example, a http/http service handler is declared: |
| |
| <pre> |
| <extension |
| point="org.eclipse.ecf.discovery.ui.serviceAccessHandler"> |
| <serviceAccessHandler |
| class="org.eclipse.ecf.discovery.ui.UrlServiceAccessHandler"> |
| </serviceAccessHandler> |
| </extension> |
| </pre> |
| |
| Here's is implementation of the HttpServiceAccessHandler: |
| |
| <pre> |
| public class HttpServiceAccessHandler implements IServiceAccessHandler { |
| |
| private static final String RFC2782_PATH = "path"; //$NON-NLS-1$ |
| //private static final String RFC2782_USERNAME = "u"; //$NON-NLS-1$ |
| //private static final String RFC2782_PASSWORD = "p"; //$NON-NLS-1$ |
| static final IContributionItem[] EMPTY_CONTRIBUTION = {}; |
| |
| public HttpServiceAccessHandler() { |
| // nothing to do |
| } |
| |
| public IContributionItem[] getContributionsForService(IServiceInfo serviceInfo) { |
| IServiceID serviceID = serviceInfo.getServiceID(); |
| List serviceTypes = Arrays.asList(serviceID.getServiceTypeID().getProtocols()); |
| String protocol = null; |
| if (serviceTypes.contains("http")) //$NON-NLS-1$ |
| protocol = "http"; //$NON-NLS-1$ |
| else if (serviceTypes.contains("https")) //$NON-NLS-1$ |
| protocol = "https"; //$NON-NLS-1$ |
| if (protocol == null) |
| return EMPTY_CONTRIBUTION; |
| URI location = serviceInfo.getLocation(); |
| StringBuffer buf = new StringBuffer(protocol); |
| buf.append("://").append(location.getHost()); //$NON-NLS-1$ |
| if (location.getPort() != -1) |
| buf.append(":").append(location.getPort()).append("/"); //$NON-NLS-1$ //$NON-NLS-2$ |
| IServiceProperties svcProps = serviceInfo.getServiceProperties(); |
| final String path = svcProps.getPropertyString(RFC2782_PATH); |
| if (path != null) |
| buf.append(path); |
| final String urlString = buf.toString(); |
| //final String username = svcProps.getPropertyString(RFC2782_USERNAME); |
| //final String password = svcProps.getPropertyString(RFC2782_PASSWORD); |
| Action action = new Action() { |
| public void run() { |
| openBrowser(urlString); |
| } |
| }; |
| action.setText(Messages.HttpServiceAccessHandler_MENU_TEXT + urlString); |
| return new IContributionItem[] {new ActionContributionItem(action)}; |
| } |
| |
| protected void openBrowser(String urlString) { |
| final IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport(); |
| try { |
| support.createBrowser(null).openURL(new URL(urlString)); |
| } catch (final Exception e) { |
| logError(Messages.HttpServiceAccessHandler_EXCEPTION_CREATEBROWSER, e); |
| } |
| |
| } |
| |
| protected void logError(String exceptionString, Throwable e) { |
| Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, exceptionString, e)); |
| |
| } |
| |
| } |
| |
| </pre> |
| |
| </documentation> |
| </annotation> |
| |
| <annotation> |
| <appInfo> |
| <meta.section type="apiInfo"/> |
| </appInfo> |
| <documentation> |
| The IServiceAccessHandler interface must be implemented by the class defined in the extension: |
| |
| <pre> |
| public interface IServiceAccessHandler { |
| |
| /** |
| * Get the menu items to contribute for the given IServiceInfo. Implementers should return |
| * a non-null array of IContributionItem instances (menus or menu items). These will |
| * be added to the context menu of the service entry identified by the given service info. |
| * |
| * @param serviceInfo the IServiceInfo for the contributions. Will not be <code>null</code>. |
| * @return IContributionItem [] any contribution to the context menu for the given service info. If <code>null</code>, |
| * then no items will be added to the context menu. |
| */ |
| public IContributionItem[] getContributionsForService(IServiceInfo serviceInfo); |
| |
| } |
| </pre> |
| </documentation> |
| </annotation> |
| |
| <annotation> |
| <appInfo> |
| <meta.section type="implementation"/> |
| </appInfo> |
| <documentation> |
| None. |
| </documentation> |
| </annotation> |
| |
| <annotation> |
| <appInfo> |
| <meta.section type="copyright"/> |
| </appInfo> |
| <documentation> |
| /**************************************************************************** |
| * Copyright (c) 2008 Composent, Inc. and others. |
| * 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: |
| * Composent, Inc. - initial API and implementation |
| *****************************************************************************/ |
| |
| </documentation> |
| </annotation> |
| |
| </schema> |