Search in sources :

Example 1 with IEndpointDescriptionLocator

use of org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionLocator in project ecf by eclipse.

the class EndpointDiscoveryView method makeActions.

protected void makeActions() {
    copyValueAction = new Action() {

        public void run() {
            Object o = ((ITreeSelection) viewer.getSelection()).getFirstElement();
            String data = ((EndpointPropertyNode) o).getPropertyValue().toString();
            if (data != null && data.length() > 0) {
                clipboard.setContents(new Object[] { data }, new Transfer[] { TextTransfer.getInstance() });
            }
        }
    };
    copyValueAction.setText(Messages.EndpointDiscoveryView_COPY_PROPERTY_VALUE);
    copyValueAction.setToolTipText(Messages.EndpointDiscoveryView_COPY_PROPERTY_VALUE);
    copyValueAction.setImageDescriptor(RSAImageRegistry.DESC_PROPERTY_OBJ);
    copyNameAction = new Action() {

        public void run() {
            Object o = ((ITreeSelection) viewer.getSelection()).getFirstElement();
            String data = ((EndpointPropertyNode) o).getPropertyName();
            if (data != null && data.length() > 0) {
                clipboard.setContents(new Object[] { data }, new Transfer[] { TextTransfer.getInstance() });
            }
        }
    };
    copyNameAction.setText(Messages.EndpointDiscoveryView_COPY_PROPERTY_NAME);
    copyNameAction.setToolTipText(Messages.EndpointDiscoveryView_COPY_PROPERTY_NAME);
    copyNameAction.setImageDescriptor(RSAImageRegistry.DESC_PROPERTY_OBJ);
    importAction = new Action() {

        public void run() {
            EndpointNode edNode = getEDNodeSelected();
            if (edNode != null) {
                RemoteServiceAdmin rsa = discovery.getRSA();
                if (rsa == null)
                    showMessage(Messages.EndpointDiscoveryView_ERROR_MSG_RSA_IS_NULL);
                else {
                    // Do import
                    EndpointDescription ed = edNode.getEndpointDescription();
                    ImportRegistration reg = (ImportRegistration) rsa.importService(ed);
                    if (reg == null) {
                        logError(Messages.EndpointDiscoveryView_ERROR_MSG_RSA_IMPORTSERVICE_FAILED, // $NON-NLS-1$
                        new Exception("Import Registration Is Null"));
                        showMessage(Messages.EndpointDiscoveryView_ERROR_MSG_RSA_IMPORTSERVICE_FAILED_PREFIX + // $NON-NLS-1$
                        "Import Registration Is Null" + Messages.EndpointDiscoveryView_ERROR_MSG_SUFFIX);
                        return;
                    }
                    // Check if import exception in returned registration
                    Throwable exception = reg.getException();
                    if (exception != null) {
                        logError(Messages.EndpointDiscoveryView_ERROR_MSG_RSA_IMPORTSERVICE_FAILED, exception);
                        showMessage(Messages.EndpointDiscoveryView_ERROR_MSG_RSA_IMPORTSERVICE_FAILED_PREFIX + exception.getMessage() + Messages.EndpointDiscoveryView_ERROR_MSG_SUFFIX);
                    } else {
                        // Success! Set registration
                        // and refresh
                        edNode.setImportReference((ImportReference) reg.getImportReference());
                        viewer.refresh();
                    }
                }
            }
        }
    };
    importAction.setText(Messages.EndpointDiscoveryView_IMPORT_REMOTE_SERVICE);
    importAction.setToolTipText(Messages.EndpointDiscoveryView_IMPORT_REMOTE_SERVICE_TT);
    importAction.setImageDescriptor(RSAImageRegistry.DESC_RSPROXY_CO);
    edefDiscoverAction = new Action() {

        public void run() {
            IEndpointDescriptionLocator locator = discovery.getEndpointDescriptionLocator();
            if (locator != null) {
                FileDialog dialog = new FileDialog(viewer.getControl().getShell(), SWT.OPEN);
                // $NON-NLS-1$
                dialog.setFilterExtensions(new String[] { "*.xml" });
                dialog.setText(Messages.EndpointDiscoveryView_OPEN_EDEF_FILE);
                dialog.setFilterPath(null);
                String result = dialog.open();
                if (result != null)
                    try {
                        EndpointDescription[] eds = (EndpointDescription[]) new EndpointDescriptionReader().readEndpointDescriptions(new FileInputStream(result));
                        if (eds != null) {
                            for (int i = 0; i < eds.length; i++) locator.discoverEndpoint(eds[i]);
                        }
                    } catch (IOException e) {
                        logError(Messages.EndpointDiscoveryView_ERROR_MSG_ENDPOINT_PARSING_FAILED, e);
                        showMessage(Messages.EndpointDiscoveryView_ERROR_MSG_ENDPOINT_PARSING_FAILED_PREFIX + e.getMessage() + Messages.EndpointDiscoveryView_ERROR_MSG_SUFFIX);
                    }
            }
        }
    };
    edefDiscoverAction.setText(Messages.EndpointDiscoveryView_OPEN_EDEF_FILE_DIALOG);
    edefDiscoverAction.setToolTipText(Messages.EndpointDiscoveryView_OPEN_EDEF_FILE_DIALOG_TT);
    edefDiscoverAction.setEnabled(discovery.getRSA() != null);
    edefDiscoverAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FILE));
    undiscoverAction = new Action() {

        public void run() {
            EndpointNode endpoint = getEDNodeSelected();
            if (endpoint != null && endpoint.getImportReference() == null) {
                IEndpointDescriptionLocator l = discovery.getEndpointDescriptionLocator();
                if (l != null && MessageDialog.openQuestion(viewer.getControl().getShell(), Messages.EndpointDiscoveryView_REMOVE_ENDPOINT_QUESTION_TITLE, Messages.EndpointDiscoveryView_REMOVE_ENDPOINT_QUESTION))
                    l.undiscoverEndpoint(endpoint.getEndpointDescription());
            }
        }
    };
    undiscoverAction.setText(Messages.EndpointDiscoveryView_REMOVE_ENDPOINT);
    undiscoverAction.setToolTipText(Messages.EndpointDiscoveryView_REMOVE_ENDPOINT_TT);
}
Also used : EndpointPropertyNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointPropertyNode) Action(org.eclipse.jface.action.Action) RemoteServiceAdmin(org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin) EndpointNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointNode) AbstractEndpointNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.AbstractEndpointNode) ImportReference(org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportReference) EndpointDescriptionReader(org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescriptionReader) EndpointDescription(org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription) IOException(java.io.IOException) ImportRegistration(org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportRegistration) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) IEndpointDescriptionLocator(org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionLocator) Transfer(org.eclipse.swt.dnd.Transfer) TextTransfer(org.eclipse.swt.dnd.TextTransfer) FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 2 with IEndpointDescriptionLocator

use of org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionLocator in project ecf by eclipse.

the class EndpointDiscoveryView method createPartControl.

public void createPartControl(Composite parent) {
    this.discovery = DiscoveryComponent.getDefault();
    this.discovery.setView(this);
    IViewSite viewSite = getViewSite();
    this.contentProvider = createContentProvider(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();
    contributeToActionBars();
    // setup clipboard
    clipboard = new Clipboard(viewer.getControl().getDisplay());
    getSite().setSelectionProvider(viewer);
    // Add any previously discovered endpoints
    viewer.getControl().getDisplay().asyncExec(new Runnable() {

        @Override
        public void run() {
            IEndpointDescriptionLocator locator = discovery.getEndpointDescriptionLocator();
            if (locator != null) {
                EndpointDescription[] eds = locator.getDiscoveredEndpoints();
                for (EndpointDescription ed : eds) handleEndpointDescription(EndpointEvent.ADDED, ed);
            }
        }
    });
    showServicesInRegistryBrowser();
}
Also used : IViewSite(org.eclipse.ui.IViewSite) IEndpointDescriptionLocator(org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionLocator) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Clipboard(org.eclipse.swt.dnd.Clipboard) EndpointDescription(org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription)

Example 3 with IEndpointDescriptionLocator

use of org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionLocator in project ecf by eclipse.

the class EndpointDiscoveryView method createEndpointDescriptionNode.

protected EndpointNode createEndpointDescriptionNode(EndpointDescription ed) {
    EndpointNode edo = new EndpointNode(ed, findImportReference(ed));
    // Interfaces
    EndpointInterfacesNode ein = new EndpointInterfacesNode();
    for (String intf : ed.getInterfaces()) ein.addChild(new EndpointPackageVersionNode(EndpointNode.getPackageName(intf)));
    edo.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)));
        edo.addChild(ain);
    }
    // ID
    edo.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());
    edo.addChild(idp);
    IEndpointDescriptionLocator locator = discovery.getEndpointDescriptionLocator();
    IServiceID serviceID = (locator == null) ? null : locator.getNetworkDiscoveredServiceID(ed);
    if (serviceID != null)
        edo.addChild(new EndpointDiscoveryGroupNode(Messages.EndpointDiscoveryView_DISCOVERY_GROUP_NAME, serviceID));
    return edo;
}
Also used : EndpointIntentsNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointIntentsNode) EndpointNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointNode) AbstractEndpointNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.AbstractEndpointNode) EndpointDiscoveryGroupNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointDiscoveryGroupNode) EndpointServiceIDNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointServiceIDNode) EndpointConfigTypesNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointConfigTypesNode) EndpointInterfacesNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointInterfacesNode) EndpointIDNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointIDNode) EndpointTimestampNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointTimestampNode) EndpointRemoteServiceFilterNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointRemoteServiceFilterNode) IEndpointDescriptionLocator(org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionLocator) EndpointHostGroupNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointHostGroupNode) EndpointRemoteServiceIDNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointRemoteServiceIDNode) EndpointPackageVersionNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointPackageVersionNode) EndpointConnectTargetIDNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointConnectTargetIDNode) EndpointNamespaceNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointNamespaceNode) IServiceID(org.eclipse.ecf.discovery.identity.IServiceID) EndpointAsyncInterfacesNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointAsyncInterfacesNode) EndpointFrameworkIDNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointFrameworkIDNode)

Aggregations

IEndpointDescriptionLocator (org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionLocator)3 EndpointDescription (org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription)2 AbstractEndpointNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.AbstractEndpointNode)2 EndpointNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointNode)2 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 IServiceID (org.eclipse.ecf.discovery.identity.IServiceID)1 EndpointDescriptionReader (org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescriptionReader)1 RemoteServiceAdmin (org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin)1 ImportReference (org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportReference)1 ImportRegistration (org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportRegistration)1 EndpointAsyncInterfacesNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointAsyncInterfacesNode)1 EndpointConfigTypesNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointConfigTypesNode)1 EndpointConnectTargetIDNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointConnectTargetIDNode)1 EndpointDiscoveryGroupNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointDiscoveryGroupNode)1 EndpointFrameworkIDNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointFrameworkIDNode)1 EndpointHostGroupNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointHostGroupNode)1 EndpointIDNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointIDNode)1 EndpointIntentsNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointIntentsNode)1 EndpointInterfacesNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointInterfacesNode)1