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());
}
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;
}
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;
}
}
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;
}
}
Aggregations