use of com.twinsoft.convertigo.eclipse.dialogs.WsReferenceImportDialog in project convertigo by convertigo.
the class ProjectImportWsReference method run.
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
try {
ProjectExplorerView explorerView = getProjectExplorerView();
if (explorerView != null) {
TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
if (treeObject != null) {
ProjectTreeObject projectTreeObject = null;
RemoteFileReference reference = null;
HttpConnector httpConnector = null;
// Create a new WS reference
if (treeObject instanceof ProjectTreeObject) {
projectTreeObject = (ProjectTreeObject) treeObject;
if (wsType == TYPE_SOAP) {
reference = new WebServiceReference();
reference.bNew = true;
}
if (wsType == TYPE_REST) {
reference = new RestServiceReference();
reference.bNew = true;
}
} else // Update an existing WS reference
if (treeObject instanceof ReferenceTreeObject) {
/* For further use
ReferenceTreeObject referenceTreeObject = (ReferenceTreeObject)treeObject;
webServiceReference = (WebServiceReference) referenceTreeObject.getObject();
projectTreeObject = referenceTreeObject.getProjectTreeObject();*/
}
if (reference != null) {
WsReferenceImportDialog wsReferenceImportDialog = null;
if (wsType == TYPE_SOAP) {
wsReferenceImportDialog = new WsReferenceImportDialog(shell, WsSoapReferenceImportDialogComposite.class, "SOAP Web Service reference");
}
if (wsType == TYPE_REST) {
wsReferenceImportDialog = new WsReferenceImportDialog(shell, WsRestReferenceImportDialogComposite.class, "REST Web Service reference");
}
wsReferenceImportDialog.setProject(projectTreeObject.getObject());
wsReferenceImportDialog.setReference(reference);
wsReferenceImportDialog.open();
if (wsReferenceImportDialog.getReturnCode() != Window.CANCEL) {
httpConnector = wsReferenceImportDialog.getHttpConnector();
}
Project project = projectTreeObject.getObject();
Engine.theApp.schemaManager.clearCache(project.getName());
// Reload project in tree
explorerView.reloadTreeObject(projectTreeObject);
if (httpConnector != null && httpConnector.getParent() != null) {
explorerView.objectSelected(new CompositeEvent(httpConnector));
} else if (reference != null && reference.getParent() != null) {
if (reference.hasChanged)
projectTreeObject.hasBeenModified(true);
explorerView.objectSelected(new CompositeEvent(reference));
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to " + (updateMode ? "update" : "import") + " from remote WS definition!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
Aggregations