use of org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin 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);
}
use of org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin in project ecf by eclipse.
the class AbstractRemoteServiceAdminView method createPartControl.
@Override
public void createPartControl(Composite parent) {
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();
viewSite.setSelectionProvider(viewer);
setupListeners();
setupSelectionListeners();
RemoteServiceAdmin rsa = getLocalRSA();
if (rsa != null)
updateModel();
}
use of org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin in project ecf by eclipse.
the class RemoteServiceAdminView method updateExports.
private void updateExports(ExportedServicesRootNode exportedRoot) {
RemoteServiceAdmin rsa = getLocalRSA();
if (rsa != null && exportedRoot != null) {
exportedRoot.clearChildren();
List<ExportRegistration> exportRegistrations = rsa.getExportedRegistrations();
for (ExportRegistration er : exportRegistrations) {
ExportRegistrationNode exportRegistrationNode = new ExportRegistrationNode(er);
ExportReference eRef = (ExportReference) er.getExportReference();
if (eRef != null) {
exportRegistrationNode.addChild(new ServiceIdNode(eRef.getExportedService(), Messages.RSAView_SERVICE_ID_LABEL));
EndpointDescription ed = (EndpointDescription) eRef.getExportedEndpoint();
if (ed != null)
exportRegistrationNode.addChild(new EndpointDescriptionRSANode(ed));
}
exportedRoot.addChild(exportRegistrationNode);
}
}
}
use of org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin in project ecf by eclipse.
the class RemoteServiceAdminView method makeActions.
@Override
protected void makeActions() {
RemoteServiceAdmin rsa = getLocalRSA();
closeExportAction = createCloseAction();
closeExportAction.setText(Messages.RemoteServiceAdminView_0);
closeExportAction.setEnabled(rsa != null);
closeImportAction = createCloseAction();
closeImportAction.setText(Messages.RemoteServiceAdminView_1);
closeImportAction.setEnabled(rsa != null);
}
use of org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin 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);
}
}
}
Aggregations