use of com.centurylink.swt.widgets.CTreeComboItem in project mdw-designer by CenturyLinkCloud.
the class ParameterizedCombo method setParamValue.
public void setParamValue(String value) {
if (paramText != null && !paramText.isDisposed()) {
paramText.setText(value);
}
if (paramCombo != null && !paramCombo.isDisposed()) {
paramAsset = assetFromAttr(value);
if (paramAsset != null) {
CTreeComboItem selItem = null;
for (CTreeComboItem pkgItem : paramCombo.getItems()) {
if (pkgItem.getText().equals(paramAsset.getPackage().getName())) {
for (CTreeComboItem assetItem : pkgItem.getItems()) {
if (assetItem.getText().equals(paramAsset.getName())) {
selItem = assetItem;
break;
}
}
break;
}
}
paramCombo.setSelection(selItem == null ? new CTreeComboItem[0] : new CTreeComboItem[] { selItem });
} else {
paramCombo.setText(value == null ? "" : value);
}
paramLink.setText(getParamLinkLabel());
paramLink.setVisible(paramAsset != null || !workflowElement.isReadOnly());
}
}
use of com.centurylink.swt.widgets.CTreeComboItem in project mdw-designer by CenturyLinkCloud.
the class WorkflowAssetEditor method setValue.
@Override
public void setValue(String value) {
String attrVal = value;
String versionAttr = readVersionAttribute();
if (!this.isProcess())
// currently version not supported for assets
versionAttr = null;
if (versionAttr != null && attrVal != null && !attrVal.isEmpty()) {
if (// special
!versionAttr.equals(AssetVersionSpec.VERSION_LATEST)) // case
{
try {
// old style
versionAttr = RuleSetVO.formatVersion(Integer.parseInt(versionAttr));
} catch (NumberFormatException ex) {
// new style -- no formatting needed
}
}
attrVal += " v" + versionAttr;
}
// ** display asset
AssetLocator assetLocator = new AssetLocator(getElement(), getLocatorType());
workflowAsset = assetLocator.assetFromAttr(attrVal);
// AssetDrivenActivityCustomSection.determineCustomAttr()
if (treeCombo != null) {
if (workflowAsset != null) {
CTreeComboItem selItem = null;
for (CTreeComboItem pkgItem : treeCombo.getItems()) {
if (((pkgItem.getText().isEmpty() || pkgItem.getText().equals(PackageVO.DEFAULT_PACKAGE_NAME)) && workflowAsset.getPackage() == null) || pkgItem.getText().equals(workflowAsset.getPackage().getName())) {
for (CTreeComboItem assetItem : pkgItem.getItems()) {
if (assetItem.getText().equals(workflowAsset.getName()) || assetItem.getText().equals(workflowAsset.getLabel())) {
selItem = assetItem;
break;
}
}
break;
}
}
// suppress attribute update
suppressFire = true;
treeCombo.setSelection(selItem == null ? new CTreeComboItem[0] : new CTreeComboItem[] { selItem });
suppressFire = false;
} else {
treeCombo.setText(attrVal == null ? "" : attrVal);
}
}
if (link != null) {
link.setText(getLinkLabel());
link.setVisible(workflowAsset != null || link.getText().equals("<A>New...</A>"));
}
}
use of com.centurylink.swt.widgets.CTreeComboItem in project mdw-designer by CenturyLinkCloud.
the class TableEditor method createTableViewer.
private TableViewer createTableViewer(Table table) {
TableViewer lTableViewer = new TableViewer(table);
lTableViewer.setUseHashlookup(true);
lTableViewer.setColumnProperties(columnProps);
if (!isReadOnly()) {
CellEditor[] cellEditors = new CellEditor[columnSpecs.size()];
for (int i = 0; i < columnSpecs.size(); i++) {
ColumnSpec colSpec = columnSpecs.get(i);
CellEditor cellEditor = null;
if (!colSpec.hidden) {
if (colSpec.type.equals(TYPE_TEXT)) {
if (colSpec.style != 0)
cellEditor = new TextCellEditor(table, colSpec.style);
else
cellEditor = new TextCellEditor(table);
} else if (colSpec.type.equals(TYPE_CHECKBOX)) {
cellEditor = new CheckboxCellEditor(table);
} else if (colSpec.type.equals(TYPE_COMBO)) {
int style = SWT.None;
if (colSpec.readOnly)
style = style | SWT.READ_ONLY;
cellEditor = new ComboBoxCellEditor(table, colSpec.options, style);
if (!colSpec.readOnly)
cellEditor.addListener(new EditableComboCellEditorListener((ComboBoxCellEditor) cellEditor, i));
} else if (colSpec.type.equals(WorkflowAssetEditor.TYPE_ASSET)) {
int style = SWT.None;
if (colSpec.readOnly)
style = style | SWT.READ_ONLY;
cellEditor = new TreeComboCellEditor(table, style) {
@Override
protected void doSetValue(Object value) {
Object val = getValue();
if (val instanceof CTreeComboItem) {
CTreeComboItem selItem = (CTreeComboItem) getValue();
if (selItem != null) {
super.doSetValue(selItem.getText());
return;
}
}
if (value instanceof String) {
String strVal = (String) value;
if (strVal.indexOf('/') > -1) {
super.doSetValue(strVal.substring(strVal.indexOf('/') + 1));
return;
}
}
super.doSetValue(value);
}
};
((TreeComboCellEditor) cellEditor).setSelectionModifier(new SelectionModifier() {
public String modify(CTreeComboItem selection) {
if (selection.getParentItem() != null) {
WorkflowPackage pkg = getProject().getPackage(selection.getParentItem().getText());
if (pkg == null || pkg.isDefaultPackage())
return selection.getText();
else
return pkg.getName() + "/" + selection.getText();
} else {
// ignore packages
return null;
}
}
});
// populate the treecombo
if (colSpec.source.equals(PROCESS)) {
List<WorkflowPackage> packages = getProject().getTopLevelUserVisiblePackages();
for (WorkflowPackage pkg : packages) {
CTreeComboItem packageItem = ((TreeComboCellEditor) cellEditor).addItem(pkg.getName());
packageItem.setText(pkg.getName());
packageItem.setImage(pkg.getIconImage());
for (WorkflowProcess process : pkg.getProcesses()) {
CTreeComboItem processItem = new CTreeComboItem(packageItem, SWT.NONE);
processItem.setText(process.getLabel());
processItem.setImage(process.getIconImage());
}
}
} else {
List<WorkflowAsset> assets = getProject().getAssetList(Arrays.asList(colSpec.assetTypes));
Map<String, CTreeComboItem> packageItems = new HashMap<>();
for (WorkflowAsset asset : assets) {
String pkgName = asset.getPackage().getName();
CTreeComboItem packageItem = packageItems.get(pkgName);
if (packageItem == null) {
packageItem = ((TreeComboCellEditor) cellEditor).addItem(pkgName);
packageItem.setImage(asset.getPackage().getIconImage());
packageItems.put(pkgName, packageItem);
}
CTreeComboItem assetItem = new CTreeComboItem(packageItem, SWT.NONE);
assetItem.setText(asset.getLabel());
assetItem.setImage(asset.getIconImage());
}
}
}
if (colSpec.listener != null && cellEditor != null)
cellEditor.addListener(colSpec.listener);
cellEditors[i] = cellEditor;
}
}
lTableViewer.setCellEditors(cellEditors);
lTableViewer.setCellModifier(cellModifier);
}
return lTableViewer;
}
use of com.centurylink.swt.widgets.CTreeComboItem in project mdw-designer by CenturyLinkCloud.
the class ViewLayoutEditAttributeDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
Composite dialogArea = baseCreateDialogArea(parent);
PlatformUI.getWorkbench().getHelpSystem().setHelp(dialogArea, XMLCommonUIContextIds.XCUI_ATTRIBUTE_DIALOG);
Composite composite = new Composite(dialogArea, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
Label attributeNameLabel = new Label(composite, SWT.NONE);
attributeNameLabel.setText(XMLUIMessages._UI_LABEL_NAME_COLON);
attributeNameField = new Text(composite, SWT.SINGLE | SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = 300;
attributeNameField.setLayoutData(gd);
attributeNameField.setText(getDisplayValue(attribute != null ? attribute.getName() : ""));
attributeNameField.addModifyListener(this);
Label attributeValueLabel = new Label(composite, SWT.NONE);
attributeValueLabel.setText(XMLUIMessages._UI_LABEL_VALUE_COLON);
String value = attribute != null ? attribute.getValue() : "";
int style = SWT.SINGLE | SWT.BORDER;
if (value.indexOf("\n") != -1) {
style = SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL;
}
String[] attrOptions = viewLayout.getAttributeOptions(attribute);
if (attrOptions != null) {
attributeValueCombo = new CTreeCombo(composite, style);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = 300;
gd.heightHint = 16;
attributeValueCombo.setLayoutData(gd);
for (String option : attrOptions) {
CTreeComboItem item = new CTreeComboItem(attributeValueCombo);
item.setText(option);
if (option.equals(ViewLayout.VARIABLES_ATTRIBUTE_OPTION)) {
Map<String, List<String>> vars = viewLayout.getVariables(attribute, option);
for (String task : vars.keySet()) {
CTreeComboItem taskItem = new CTreeComboItem(item);
taskItem.setText(task);
for (String var : vars.get(task)) {
CTreeComboItem varItem = new CTreeComboItem(taskItem);
varItem.setText(var);
}
}
}
}
attributeValueCombo.setText(getDisplayValue(attribute != null ? attribute.getValue() : ""));
attributeValueCombo.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
CTreeComboItem[] selItems = attributeValueCombo.getSelection();
if (selItems.length == 1) {
CTreeComboItem selItem = selItems[0];
if (selItem.getItemCount() != 0) {
// ignore non-node selection
attributeValueCombo.setSelection(new CTreeComboItem[0]);
} else {
if (hasVariablesParent(selItem))
attributeValueCombo.setText("$" + selItem.getText());
try {
Thread.sleep(200);
} catch (InterruptedException ex) {
}
attributeValueCombo.dropDown(false);
}
}
}
});
} else {
attributeValueField = new Text(composite, style);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = 300;
attributeValueField.setLayoutData(gd);
attributeValueField.setText(getDisplayValue(attribute != null ? attribute.getValue() : ""));
}
// error message
Composite message = new Composite(composite, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
message.setLayout(layout);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
message.setLayoutData(gd);
errorMessageIcon = new Label(message, SWT.NONE);
gd = new GridData();
gd.horizontalSpan = 1;
gd.verticalAlignment = SWT.TOP;
errorMessageIcon.setLayoutData(gd);
errorMessageIcon.setImage(null);
errorMessageLabel = new Label(message, SWT.WRAP);
errorMessageLabel.setText(XMLUIMessages.error_message_goes_here);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = 200;
gd.heightHint = Math.max(30, errorMessageLabel.computeSize(0, 0, false).y * 2);
gd.horizontalSpan = 1;
gd.verticalAlignment = SWT.TOP;
errorMessageLabel.setLayoutData(gd);
return dialogArea;
}
use of com.centurylink.swt.widgets.CTreeComboItem in project mdw-designer by CenturyLinkCloud.
the class EventHandlerPage method fillProcessTreeCombo.
private void fillProcessTreeCombo() {
processTreeCombo.removeAll();
List<WorkflowPackage> packages = getProject().getTopLevelUserVisiblePackages();
for (WorkflowPackage pkg : packages) {
CTreeComboItem packageItem = new CTreeComboItem(processTreeCombo, SWT.NONE);
packageItem.setText(pkg.getName());
packageItem.setImage(pkg.getIconImage());
for (WorkflowProcess process : pkg.getProcesses()) {
CTreeComboItem processItem = new CTreeComboItem(packageItem, SWT.NONE);
processItem.setText(process.getName());
processItem.setImage(process.getIconImage());
}
}
}
Aggregations