Search in sources :

Example 1 with WsReferenceImportDialog

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();
    }
}
Also used : RestServiceReference(com.twinsoft.convertigo.beans.references.RestServiceReference) HttpConnector(com.twinsoft.convertigo.beans.connectors.HttpConnector) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) WsReferenceImportDialog(com.twinsoft.convertigo.eclipse.dialogs.WsReferenceImportDialog) WsRestReferenceImportDialogComposite(com.twinsoft.convertigo.eclipse.dialogs.WsRestReferenceImportDialogComposite) Cursor(org.eclipse.swt.graphics.Cursor) WsSoapReferenceImportDialogComposite(com.twinsoft.convertigo.eclipse.dialogs.WsSoapReferenceImportDialogComposite) Project(com.twinsoft.convertigo.beans.core.Project) Shell(org.eclipse.swt.widgets.Shell) ReferenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ReferenceTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) ReferenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ReferenceTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) RemoteFileReference(com.twinsoft.convertigo.beans.references.RemoteFileReference) WebServiceReference(com.twinsoft.convertigo.beans.references.WebServiceReference) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) Display(org.eclipse.swt.widgets.Display)

Aggregations

HttpConnector (com.twinsoft.convertigo.beans.connectors.HttpConnector)1 Project (com.twinsoft.convertigo.beans.core.Project)1 RemoteFileReference (com.twinsoft.convertigo.beans.references.RemoteFileReference)1 RestServiceReference (com.twinsoft.convertigo.beans.references.RestServiceReference)1 WebServiceReference (com.twinsoft.convertigo.beans.references.WebServiceReference)1 WsReferenceImportDialog (com.twinsoft.convertigo.eclipse.dialogs.WsReferenceImportDialog)1 WsRestReferenceImportDialogComposite (com.twinsoft.convertigo.eclipse.dialogs.WsRestReferenceImportDialogComposite)1 WsSoapReferenceImportDialogComposite (com.twinsoft.convertigo.eclipse.dialogs.WsSoapReferenceImportDialogComposite)1 CompositeEvent (com.twinsoft.convertigo.eclipse.editors.CompositeEvent)1 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)1 ProjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject)1 ReferenceTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ReferenceTreeObject)1 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)1 Cursor (org.eclipse.swt.graphics.Cursor)1 Display (org.eclipse.swt.widgets.Display)1 Shell (org.eclipse.swt.widgets.Shell)1