use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.
the class ExportPackageWizard method performImportExport.
void performImportExport(ProgressMonitor progressMonitor) throws IOException, JSONException, XmlException, DataAccessException, ActionCancelledException {
Exporter exporter = new Exporter(getProject().getDesignerDataAccess());
boolean exportJson = false;
boolean includeTaskTemplates = false;
boolean inferReferencedImpls = false;
boolean exportZip = false;
IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
if (getProject().isFilePersist()) {
exportJson = prefsStore.getBoolean(PreferenceConstants.PREFS_EXPORT_JSON_FORMAT);
includeTaskTemplates = !prefsStore.getBoolean(PreferenceConstants.PREFS_SUPPRESS_TASK_TEMPLATES_IN_PKG_EXPORT);
exportZip = prefsStore.getBoolean(PreferenceConstants.PREFS_EXPORT_ZIP_FORMAT);
} else {
inferReferencedImpls = !prefsStore.getBoolean(PreferenceConstants.PREFS_SUPPRESS_INFER_REFERENCED_IMPLS_DURING_EXPORT);
}
List<WorkflowPackage> packages = getPackages();
String export = null;
if (exportZip) {
File assetDir = getProject().getAssetDir();
List<File> includes = new ArrayList<>();
for (WorkflowPackage pkg : packages) includes.add(new File(assetDir + "/" + pkg.getName().replace('.', '/')));
ZipHelper.zipWith(assetDir, new File(getPage().getFilePath()), includes);
} else if (packages.size() == 1 && !exportJson)
export = exporter.exportPackage(packages.get(0), includeTaskTemplates, inferReferencedImpls, progressMonitor);
else
export = exporter.exportPackages(packages, exportJson, includeTaskTemplates, progressMonitor);
progressMonitor.progress(10);
progressMonitor.subTask("Writing " + (exportJson ? "JSON" : "XML") + " file");
if (export != null)
writeFile(getPage().getFilePath(), export.getBytes());
progressMonitor.progress(5);
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.
the class TestResultsFormatter method getXslFile.
private File getXslFile(String filename) throws IOException {
File stylesheet = null;
if (project.isFilePersist()) {
// prefer override (non-MDW testing package); fall back to MDW
// testing package
WorkflowPackage mdwTestingPackage = null;
WorkflowPackage otherTestingPackage = null;
for (WorkflowPackage pkg : project.getTopLevelPackages()) {
if (pkg.getName().equals("com.centurylink.mdw.testing"))
mdwTestingPackage = pkg;
else if (pkg.getName().endsWith(".testing"))
otherTestingPackage = pkg;
}
if (otherTestingPackage != null) {
WorkflowAsset asset = otherTestingPackage.getAsset(filename);
if (asset != null)
stylesheet = asset.getRawFile();
}
if (stylesheet == null && mdwTestingPackage != null) {
WorkflowAsset asset = mdwTestingPackage.getAsset(filename);
if (asset != null)
stylesheet = asset.getRawFile();
}
}
if (stylesheet == null) {
// fall back to template version in designer
URL localUrl = PluginUtil.getLocalResourceUrl("templates/xsl/" + filename);
try {
stylesheet = new File(new URI(localUrl.toString()));
} catch (URISyntaxException ex) {
throw new IOException(ex.getMessage(), ex);
}
}
return stylesheet;
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.
the class CodeGenWizardPage method createWorkflowPackageControls.
@Override
protected void createWorkflowPackageControls(Composite parent, int ncol) {
new Label(parent, SWT.NONE).setText("Workflow Package:");
workflowPackageCombo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
GridData gd = new GridData(GridData.BEGINNING);
gd.horizontalSpan = ncol - 1;
gd.widthHint = 250;
workflowPackageCombo.setLayoutData(gd);
workflowPackageCombo.removeAll();
if (getCodeElement().getProject() != null) {
for (WorkflowPackage packageVersion : getCodeElement().getProject().getTopLevelUserVisiblePackages()) workflowPackageCombo.add(packageVersion.getName());
}
workflowPackageCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String packageName = workflowPackageCombo.getText().trim();
getCodeElement().setPackage(getCodeElement().getProject().getPackage(packageName));
handleFieldChanged();
}
});
if (getCodeElement().getPackage() != null)
workflowPackageCombo.setText(getCodeElement().getPackage().getName());
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.
the class ImportTaskTemplatesWizard method postRunUpdates.
@Override
protected void postRunUpdates() {
WorkflowPackage pkg = getPackage();
if (pkg != null) {
pkg.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, pkg);
pkg.refreshFolder();
}
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.
the class ImportTaskTemplatesWizard method performImportExport.
void performImportExport(ProgressMonitor progressMonitor) throws IOException, XmlException, DataAccessException, ValidationException, ActionCancelledException {
Importer importer = new Importer(getProject().getDataAccess(), getShell());
progressMonitor.progress(10);
progressMonitor.subTask("Reading XML file");
byte[] bytes = readFile(getPage().getFilePath());
if (progressMonitor.isCanceled())
throw new ActionCancelledException();
progressMonitor.subTask("Performing Import");
WorkflowPackage pkg = getPackage();
if (pkg == null)
throw new ValidationException("No package found.");
importer.importTaskTemplates(pkg, new String(bytes), progressMonitor);
progressMonitor.progress(30);
}
Aggregations