use of com.centurylink.mdw.model.value.attribute.AssetVersionSpec in project mdw-designer by CenturyLinkCloud.
the class WorkflowAssetEditor method render.
@Override
public void render(Composite parent) {
label = new Label(parent, SWT.NONE);
label.setText(attributeLabel + ":");
treeCombo = new CTreeCombo(parent, SWT.BORDER | SWT.FULL_SELECTION);
GridData gd = new GridData(GridData.BEGINNING);
gd.widthHint = comboWidth;
gd.heightHint = 16;
treeCombo.setLayoutData(gd);
fillTreeCombo();
treeCombo.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
CTreeComboItem[] selItems = treeCombo.getSelection();
if (selItems.length == 1) {
CTreeComboItem selItem = selItems[0];
if (selItem.getParentItem() == null) {
// ignore package selection
treeCombo.setSelection(new CTreeComboItem[0]);
} else {
try {
Thread.sleep(200);
} catch (InterruptedException ex) {
}
// ** set asset
WorkflowPackage pkg = getProject().getPackage(selItem.getParentItem().getText());
if (pkg == null) {
workflowAsset = null;
} else {
AssetLocator assetLocator = new AssetLocator(getElement(), getLocatorType());
workflowAsset = assetLocator.getAssetVersion(selItem.getText(), pkg);
}
link.setText(getLinkLabel());
fireValueChanged(new AssetLocator(getElement(), getLocatorType()).attrFromAsset(workflowAsset));
// selecting the asset also selects the version
updateVersionAttribute(workflowAsset);
treeCombo.dropDown(false);
}
}
}
});
treeCombo.addListener(SWT.Modify, new Listener() {
public void handleEvent(Event event) {
if (treeCombo.getSelection().length == 0 && !suppressFire) {
// triggered when something was typed in the combo
// instead of selecting -- use it verbatim
// note: also triggered on selection, but immediately
// followed by SWT.Selection event, so no harm done
// ** set asset
workflowAsset = null;
link.setText("");
AssetVersionSpec versionSpec = AssetVersionSpec.parse(treeCombo.getText().trim());
String oldName = getElement().getAttribute(attributeName);
String newName = versionSpec.getName();
boolean nameChanged = oldName == null ? newName != null && newName.length() > 0 : !oldName.equals(newName);
if (nameChanged)
fireValueChanged(newName);
String oldVer = readVersionAttribute();
String newVer = "".equals(newName) ? "" : versionSpec.getVersion();
boolean verChanged = oldVer == null ? newVer != null && newVer.length() > 0 : !oldVer.equals(newVer);
if (verChanged)
updateVersionAttribute(newVer);
}
}
});
link = new Link(parent, SWT.SINGLE);
gd = new GridData(GridData.BEGINNING);
gd.widthHint = 75;
link.setLayoutData(gd);
link.setText(getLinkLabel());
link.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (workflowAsset == null) {
workflowAsset = createWorkflowAsset();
fillTreeCombo();
if (workflowAsset != null) {
treeCombo.setText(workflowAsset.getName());
fireValueChanged(new AssetLocator(getElement(), getLocatorType()).attrFromAsset(workflowAsset));
updateVersionAttribute(workflowAsset);
}
} else {
openWorkflowAsset();
}
}
});
spacer = new Label(parent, SWT.NONE);
}
use of com.centurylink.mdw.model.value.attribute.AssetVersionSpec in project mdw-designer by CenturyLinkCloud.
the class WorkflowAssetEditor method updateVersionAttribute.
private void updateVersionAttribute(WorkflowElement workflowAsset) {
AssetVersionSpec versionSpec = AssetVersionSpec.parse(workflowAsset.getLabel());
String versionAttr = null;
if (isProcess()) {
if (getProject().checkRequiredVersion(5, 5) && !(getElement() instanceof Activity && ((Activity) getElement()).isOldMultipleSubProcInvoke())) {
if (MdwPlugin.getSettings().isInferSmartSubprocVersionSpec())
versionAttr = AssetVersionSpec.getDefaultSmartVersionSpec(versionSpec.getVersion());
else
versionAttr = versionSpec.getVersion();
} else {
// pre-5.5
versionAttr = String.valueOf(((WorkflowProcess) workflowAsset).getVersion());
// compatibility
}
getElement().setAttribute(WorkAttributeConstant.PROCESS_VERSION, versionAttr);
} else if (// assets only save
getProject().checkRequiredVersion(5, 5)) // version for 5.5
{
if (MdwPlugin.getSettings().isInferSmartSubprocVersionSpec())
versionAttr = AssetVersionSpec.getDefaultSmartVersionSpec(versionSpec.getVersion());
else
versionAttr = versionSpec.getVersion();
getElement().setAttribute(getAssetVersionAttributeName(), versionAttr);
}
}
use of com.centurylink.mdw.model.value.attribute.AssetVersionSpec in project mdw-designer by CenturyLinkCloud.
the class AssetLocator method getWorkflowAssetVersion.
private WorkflowAsset getWorkflowAssetVersion(String versionSpec, List<WorkflowAsset> assets) {
AssetVersionSpec spec = AssetVersionSpec.parse(versionSpec);
boolean isDefaultSmart = isDefaultSmartFormat(spec.getVersion());
WorkflowAsset match = null;
for (WorkflowAsset asset : assets) {
if (asset.getName().matches(spec.getName())) {
if (asset.getVersionString().equals(spec.getVersion())) {
match = asset;
break;
} else if ((AssetVersionSpec.VERSION_LATEST.equals(spec.getVersion()) || (isDefaultSmart && asset.meetsVersionSpec(spec.getVersion()))) && (match == null || asset.getVersion() > match.getVersion())) {
match = asset;
}
}
}
return match;
}
use of com.centurylink.mdw.model.value.attribute.AssetVersionSpec in project mdw-designer by CenturyLinkCloud.
the class AssetLocator method getTaskTemplateVersion.
private TaskTemplate getTaskTemplateVersion(String versionSpec, List<TaskTemplate> taskTemplates) {
AssetVersionSpec spec = AssetVersionSpec.parse(versionSpec);
boolean isDefaultSmart = isDefaultSmartFormat(spec.getVersion());
TaskTemplate match = null;
for (TaskTemplate taskTemplate : taskTemplates) {
if (taskTemplate.getName().matches(spec.getName())) {
if (taskTemplate.getVersionString().equals(spec.getVersion())) {
match = taskTemplate;
break;
} else if ((AssetVersionSpec.VERSION_LATEST.equals(spec.getVersion()) || (isDefaultSmart && taskTemplate.meetsVersionSpec(spec.getVersion()))) && (match == null || taskTemplate.getVersion() > match.getVersion())) {
match = taskTemplate;
}
}
}
return match;
}
use of com.centurylink.mdw.model.value.attribute.AssetVersionSpec in project mdw-designer by CenturyLinkCloud.
the class AssetLocator method getProcessVersion.
private WorkflowProcess getProcessVersion(String versionSpec, List<WorkflowProcess> processes) {
AssetVersionSpec spec = AssetVersionSpec.parse(versionSpec);
boolean isDefaultSmart = isDefaultSmartFormat(spec.getVersion());
WorkflowProcess match = null;
for (WorkflowProcess process : processes) {
if (process.getName().equals(spec.getName())) {
if (process.getVersionString().equals(spec.getVersion())) {
match = process;
break;
} else if ((AssetVersionSpec.VERSION_LATEST.equals(spec.getVersion()) || (isDefaultSmart && process.meetsVersionSpec(spec.getVersion()))) && (match == null || process.getVersion() > match.getVersion())) {
match = process;
}
}
}
return match;
}
Aggregations