Search in sources :

Example 1 with ImportReference

use of org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportReference 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 ImportReference

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

the class EndpointDiscoveryView method fillContextMenu.

protected void fillContextMenu(IMenuManager manager) {
    ITreeSelection selection = (ITreeSelection) viewer.getSelection();
    if (selection != null) {
        Object e = selection.getFirstElement();
        if (e instanceof EndpointPropertyNode) {
            manager.add(copyNameAction);
            manager.add(copyValueAction);
        } else if (e instanceof EndpointNode) {
            EndpointNode edNode = (EndpointNode) e;
            ImportReference ir = edNode.getImportReference();
            if (ir == null) {
                manager.add(importAction);
                manager.add(undiscoverAction);
            }
        }
    }
}
Also used : EndpointPropertyNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointPropertyNode) ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) 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)

Example 3 with ImportReference

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

the class RemoteServiceAdminView method updateImports.

private void updateImports(ImportedEndpointsRootNode importedRoot) {
    RemoteServiceAdmin rsa = getLocalRSA();
    if (rsa != null && importedRoot != null) {
        importedRoot.clearChildren();
        List<ImportRegistration> importRegistrations = rsa.getImportedRegistrations();
        for (ImportRegistration ir : importRegistrations) {
            ImportRegistrationNode importRegistrationNode = new ImportRegistrationNode(ir);
            ImportReference iRef = (ImportReference) ir.getImportReference();
            if (iRef != null) {
                importRegistrationNode.addChild(new ServiceIdNode(iRef.getImportedService(), Messages.RSAView_PROXY_SERVICE_ID_LABEL));
                EndpointDescription ed = (EndpointDescription) iRef.getImportedEndpoint();
                if (ed != null)
                    importRegistrationNode.addChild(new EndpointDescriptionRSANode(ed, ir));
            }
            importedRoot.addChild(importRegistrationNode);
        }
    }
}
Also used : RemoteServiceAdmin(org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin) ImportReference(org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportReference) ServiceIdNode(org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.ServiceIdNode) ImportRegistrationNode(org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.ImportRegistrationNode) EndpointDescriptionRSANode(org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.EndpointDescriptionRSANode) EndpointDescription(org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription) ImportRegistration(org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportRegistration)

Example 4 with ImportReference

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

the class DebugRemoteServiceAdminListener method printEvent.

protected void printEvent(RemoteServiceAdmin.RemoteServiceAdminEvent event) {
    ID cID = event.getContainerID();
    StringBuffer buf = // $NON-NLS-1$
    new StringBuffer(sdf.format(new Date())).append(";").append(eventTypeToString(event.getType()));
    switch(event.getType()) {
        case RemoteServiceAdminEvent.EXPORT_REGISTRATION:
        case RemoteServiceAdminEvent.EXPORT_UNREGISTRATION:
        case RemoteServiceAdminEvent.EXPORT_UPDATE:
        case RemoteServiceAdminEvent.EXPORT_WARNING:
            ExportReference exRef = (RemoteServiceAdmin.ExportReference) event.getExportReference();
            if (exRef != null) {
                writeRemoteReference(buf.append(";exportedSR="), exRef.getExportedService(), cID, // $NON-NLS-1$
                exRef.getRemoteServiceId());
                if (this.writeEndpoint)
                    writeEndpoint(exRef.getEndpointDescription());
            }
            break;
        case RemoteServiceAdminEvent.IMPORT_REGISTRATION:
        case RemoteServiceAdminEvent.IMPORT_UNREGISTRATION:
        case RemoteServiceAdminEvent.IMPORT_UPDATE:
        case RemoteServiceAdminEvent.IMPORT_WARNING:
            ImportReference imRef = (RemoteServiceAdmin.ImportReference) event.getImportReference();
            if (imRef != null) {
                writeRemoteReference(buf.append(";importedSR="), imRef.getImportedService(), cID, // $NON-NLS-1$
                imRef.getRemoteServiceId());
                if (this.writeEndpoint)
                    writeEndpoint(imRef.getEndpointDescription());
            }
            break;
        case RemoteServiceAdminEvent.EXPORT_ERROR:
        case RemoteServiceAdminEvent.IMPORT_ERROR:
            writer.println(buf.toString());
            Throwable t = event.getException();
            if (t != null)
                t.printStackTrace(this.writer);
            break;
    }
    writer.flush();
}
Also used : ImportReference(org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportReference) ExportReference(org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ExportReference) ID(org.eclipse.ecf.core.identity.ID) Date(java.util.Date)

Example 5 with ImportReference

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

the class EndpointDiscoveryView method findImportReference.

protected ImportReference findImportReference(EndpointDescription ed) {
    RemoteServiceAdmin rsa = discovery.getRSA();
    if (rsa == null)
        return null;
    List<ImportRegistration> iRegs = rsa.getImportedRegistrations();
    for (ImportRegistration ir : iRegs) {
        ImportReference importRef = (ImportReference) ir.getImportReference();
        if (importRef != null && ed.equals(importRef.getImportedEndpoint()))
            return importRef;
    }
    return null;
}
Also used : RemoteServiceAdmin(org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin) ImportReference(org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportReference) ImportRegistration(org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportRegistration)

Aggregations

ImportReference (org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportReference)7 AbstractEndpointNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.AbstractEndpointNode)4 EndpointNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointNode)4 RemoteServiceAdmin (org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin)3 ImportRegistration (org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportRegistration)3 EndpointDescription (org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription)2 EndpointGroupNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointGroupNode)2 EndpointPropertyNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointPropertyNode)2 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 Date (java.util.Date)1 ID (org.eclipse.ecf.core.identity.ID)1 EndpointDescriptionReader (org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescriptionReader)1 IEndpointDescriptionLocator (org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionLocator)1 ExportReference (org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ExportReference)1 EndpointDescriptionRSANode (org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.EndpointDescriptionRSANode)1 ImportRegistrationNode (org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.ImportRegistrationNode)1 ServiceIdNode (org.eclipse.ecf.remoteserviceadmin.ui.rsa.model.ServiceIdNode)1 Action (org.eclipse.jface.action.Action)1 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)1