Search in sources :

Example 16 with DesignerProxy

use of com.centurylink.mdw.plugin.designer.DesignerProxy in project mdw-designer by CenturyLinkCloud.

the class ImportProcessWizard method performImportExport.

void performImportExport(ProgressMonitor progressMonitor) throws IOException, XmlException, DataAccessException, ValidationException, ActionCancelledException {
    DesignerProxy designerProxy = getProject().getDesignerProxy();
    Importer importer = new Importer(designerProxy.getPluginDataAccess(), getShell());
    progressMonitor.progress(10);
    progressMonitor.subTask("Reading XML file");
    byte[] bytes = readFile(getPage().getFilePath());
    progressMonitor.progress(20);
    if (progressMonitor.isCanceled())
        throw new ActionCancelledException();
    progressMonitor.subTask("Performing Import");
    WorkflowProcess newProc = importer.importProcess(getPackage(), getProcess(), new String(bytes));
    setElement(newProc);
    progressMonitor.progress(30);
    designerProxy.toggleProcessLock(newProc, true);
    designerProxy.savePackage(newProc.getPackage());
}
Also used : DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) ActionCancelledException(com.centurylink.mdw.common.utilities.timer.ActionCancelledException) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) Importer(com.centurylink.mdw.plugin.designer.Importer)

Example 17 with DesignerProxy

use of com.centurylink.mdw.plugin.designer.DesignerProxy in project mdw-designer by CenturyLinkCloud.

the class NewPackageWizard method performFinish.

@Override
public boolean performFinish() {
    DesignerProxy designerProxy = newPackage.getProject().getDesignerProxy();
    designerProxy.createNewPackage(newPackage, isJson());
    newPackage.addElementChangeListener(newPackage.getProject());
    newPackage.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, newPackage);
    DesignerPerspective.promptForShowPerspective(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), newPackage);
    return true;
}
Also used : DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy)

Example 18 with DesignerProxy

use of com.centurylink.mdw.plugin.designer.DesignerProxy in project mdw-designer by CenturyLinkCloud.

the class NewTaskTemplateWizard method performFinish.

@Override
public boolean performFinish() {
    TaskTemplate taskTemplate = (TaskTemplate) getWorkflowAsset();
    try {
        TaskTemplateDocument doc;
        if (isImportFile()) {
            // load from selected file
            doc = TaskTemplateDocument.Factory.parse(new File(getImportFilePath()));
            com.centurylink.mdw.task.TaskTemplate template = doc.getTaskTemplate();
            // selection)
            if (template.getLogicalId() == null)
                throw new XmlException("Task template missing logicalId");
            else if (template.getCategory() == null)
                throw new XmlException("Task template missing category");
            else if (template.getName() == null || template.getName().isEmpty())
                throw new XmlException("Task template missing name");
        } else {
            doc = TaskTemplateDocument.Factory.newInstance();
            com.centurylink.mdw.task.TaskTemplate template = doc.addNewTaskTemplate();
            String taskName = taskTemplate.getName().substring(0, taskTemplate.getName().length() - 5);
            template.setLogicalId(taskName.replace(' ', '_'));
            template.setCategory("GEN");
            template.setName(taskName);
            if ("AUTOFORM".equals(taskTemplate.getLanguage())) {
                Attribute form = template.addNewAttribute();
                form.setName("FormName");
                form.setStringValue("Autoform");
            }
        }
        XmlOptions xmlOptions = new XmlOptions().setSaveAggressiveNamespaces();
        xmlOptions.setSavePrettyPrint().setSavePrettyPrintIndent(2);
        taskTemplate.setContent(doc.xmlText(xmlOptions));
        String templateName = taskTemplate.getName();
        taskTemplate.setTaskVO(new TaskVO(doc.getTaskTemplate()));
        taskTemplate.setName(templateName);
        taskTemplate.getTaskVO().setPackageName(taskTemplate.getPackage().getName());
        DesignerProxy designerProxy = taskTemplate.getProject().getDesignerProxy();
        designerProxy.createNewTaskTemplate(taskTemplate);
        if (designerProxy.getRunnerStatus().equals(RunnerStatus.SUCCESS)) {
            taskTemplate.openFile(new NullProgressMonitor());
            taskTemplate.addElementChangeListener(taskTemplate.getProject());
            taskTemplate.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, taskTemplate);
            taskTemplate.setVersion(1);
            taskTemplate.fireElementChangeEvent(ChangeType.VERSION_CHANGE, taskTemplate);
            DesignerPerspective.promptForShowPerspective(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), taskTemplate);
            return true;
        } else {
            return false;
        }
    } catch (Exception ex) {
        PluginMessages.uiError(getShell(), ex, "Create " + taskTemplate.getTitle(), taskTemplate.getProject());
        return false;
    }
}
Also used : TaskTemplate(com.centurylink.mdw.plugin.designer.model.TaskTemplate) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) TaskTemplateDocument(com.centurylink.mdw.task.TaskTemplateDocument) Attribute(com.centurylink.mdw.task.Attribute) XmlOptions(org.apache.xmlbeans.XmlOptions) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) XmlException(org.apache.xmlbeans.XmlException) XmlException(org.apache.xmlbeans.XmlException) File(java.io.File) TaskVO(com.centurylink.mdw.model.value.task.TaskVO)

Example 19 with DesignerProxy

use of com.centurylink.mdw.plugin.designer.DesignerProxy in project mdw-designer by CenturyLinkCloud.

the class WorkflowAssetWizard method performFinish.

@Override
public boolean performFinish() {
    if (!workflowAsset.getProject().checkRequiredVersion(5, 0))
        workflowAsset.setPackage(workflowAsset.getProject().getDefaultPackage());
    if (isImportFile()) {
        try {
            // load from selected file
            File file = new File(importFilePath);
            byte[] fileBytes = PluginUtil.readFile(file);
            if (workflowAsset.isBinary())
                workflowAsset.encodeAndSetContent(fileBytes);
            else
                workflowAsset.setContent(new String(fileBytes));
        } catch (IOException ex) {
            PluginMessages.uiError(getShell(), ex, "Create " + workflowAsset.getTitle(), workflowAsset.getProject());
        }
    } else {
        try {
            DocumentTemplate docTemplate = getNewDocTemplate();
            if (docTemplate != null) {
                byte[] templateContents = docTemplate.getContent();
                if (workflowAsset.isBinary())
                    workflowAsset.encodeAndSetContent(templateContents);
                else if (workflowAsset.getLanguage().equals(RuleSetVO.FACELET) || workflowAsset.getLanguage().equals(RuleSetVO.HTML))
                    workflowAsset.setContent(new String(templateContents));
                else
                    workflowAsset.substituteAndSetContent(new String(templateContents));
            }
        } catch (Exception ex) {
            PluginMessages.uiError(getShell(), ex, "Create " + workflowAsset.getTitle(), workflowAsset.getProject());
        }
    }
    DesignerProxy designerProxy = workflowAsset.getProject().getDesignerProxy();
    try {
        designerProxy.createNewWorkflowAsset(workflowAsset, true);
    } catch (Exception ex) {
        PluginMessages.uiError(getShell(), ex, "New " + workflowAsset.getTitle(), workflowAsset.getProject());
        return false;
    }
    if (designerProxy.getRunnerStatus().equals(RunnerStatus.SUCCESS)) {
        if (!workflowAsset.isBinary() || getNewDocTemplate() != null)
            workflowAsset.openFile(new NullProgressMonitor());
        workflowAsset.addElementChangeListener(workflowAsset.getProject());
        workflowAsset.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, workflowAsset);
        WorkflowAssetFactory.registerAsset(workflowAsset);
        DesignerPerspective.promptForShowPerspective(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), workflowAsset);
        return true;
    } else {
        return false;
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) DocumentTemplate(com.centurylink.mdw.plugin.designer.model.DocumentTemplate) IOException(java.io.IOException) File(java.io.File) IOException(java.io.IOException)

Aggregations

DesignerProxy (com.centurylink.mdw.plugin.designer.DesignerProxy)19 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)8 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)8 CoreException (org.eclipse.core.runtime.CoreException)6 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)5 File (java.io.File)5 IOException (java.io.IOException)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)5 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)4 ArrayList (java.util.ArrayList)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 ActionCancelledException (com.centurylink.mdw.common.utilities.timer.ActionCancelledException)3 CopyDialog (com.centurylink.mdw.plugin.designer.dialogs.CopyDialog)3 ConnectException (java.net.ConnectException)3 IFile (org.eclipse.core.resources.IFile)3 TreeViewer (org.eclipse.jface.viewers.TreeViewer)3 VariableTypeVO (com.centurylink.mdw.model.value.variable.VariableTypeVO)2 Importer (com.centurylink.mdw.plugin.designer.Importer)2 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)2