use of com.centurylink.mdw.plugin.designer.properties.editor.TableEditor in project mdw-designer by CenturyLinkCloud.
the class SearchResultsPage method createTableEditor.
private TableEditor createTableEditor() {
TableEditor editor = new TableEditor(null, TableEditor.TYPE_TABLE);
List<ColumnSpec> columnSpecs = new ArrayList<ColumnSpec>();
ColumnSpec nameColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Name", "name");
nameColSpec.width = 225;
columnSpecs.add(nameColSpec);
ColumnSpec versionColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Version", "version");
versionColSpec.width = 60;
columnSpecs.add(versionColSpec);
ColumnSpec idColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "ID", "id");
idColSpec.width = 80;
columnSpecs.add(idColSpec);
ColumnSpec projectColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Project", "workflowProject");
projectColSpec.width = 175;
columnSpecs.add(projectColSpec);
ColumnSpec packageColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Package", "package");
packageColSpec.width = 175;
columnSpecs.add(packageColSpec);
if (searchQuery != null && searchQuery.isInstanceQuery()) {
ColumnSpec instanceColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Instance ID", "instanceId");
instanceColSpec.width = 85;
columnSpecs.add(instanceColSpec);
ColumnSpec statusColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Status", "status");
instanceColSpec.width = 75;
columnSpecs.add(statusColSpec);
ColumnSpec startDateColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Start", "instanceStartDate");
startDateColSpec.width = 100;
columnSpecs.add(startDateColSpec);
ColumnSpec endDateColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "End", "instanceEndDate");
endDateColSpec.width = 100;
columnSpecs.add(endDateColSpec);
}
if (searchQuery instanceof AssetSearchQuery) {
ColumnSpec lastModColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Last Modified", "modifyDate");
lastModColSpec.width = 100;
columnSpecs.add(lastModColSpec);
}
editor.setColumnSpecs(columnSpecs);
editor.setReadOnly(true);
editor.setContentProvider(new ResultElementContentProvider());
editor.setLabelProvider(new ResultElementLabelProvider());
return editor;
}
use of com.centurylink.mdw.plugin.designer.properties.editor.TableEditor in project mdw-designer by CenturyLinkCloud.
the class TaskTemplateEditor method addPage.
private void addPage(String section) {
ScrolledComposite scrolledComposite = new ScrolledComposite(getContainer(), SWT.V_SCROLL);
scrolledComposite.setLayout(new GridLayout());
scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
scrolledComposite.setAlwaysShowScrollBars(true);
Composite composite = new Composite(scrolledComposite, SWT.NONE);
composite.setLayout(new FillLayout());
// create the grid layout
GridLayout gl = new GridLayout();
gl.numColumns = PropertyEditor.COLUMNS;
gl.marginTop = 6;
gl.marginLeft = 3;
composite.setLayout(gl);
for (PropertyEditor propertyEditor : propertyEditors) {
boolean belongs;
if (section == null)
belongs = propertyEditor.getSection() == null;
else
belongs = section.equals(propertyEditor.getSection());
if (belongs) {
if ("Notices".equals(propertyEditor.getName())) {
// special handling for notices
String attrVal = taskTemplate.getAttribute(TaskAttributeConstant.NOTICES);
if (StringHelper.isEmpty(attrVal) || attrVal.equals("$DefaultNotices"))
taskTemplate.setAttribute(TaskAttributeConstant.NOTICES, TaskVO.getDefaultNotices());
if (noticesValueChangeListener != null)
taskTemplate.removeAttributeValueChangeListener(noticesValueChangeListener);
noticesValueChangeListener = new NoticesValueChangeListener(propertyEditor);
taskTemplate.addAttributeValueChangeListener(noticesValueChangeListener);
propertyEditor.render(composite);
} else if ("Variables".equals(propertyEditor.getName())) {
// special handling for variables
TableEditor tableEditor = (TableEditor) propertyEditor;
// support for value expressions
tableEditor.setCellModifier(tableEditor.new DefaultCellModifier() {
@Override
public boolean canModify(Object element, String property) {
boolean editable = super.canModify(element, property);
if (editable && getColumnIndex(property) == 1) {
for (VariableVO var : getProcessVariables()) {
if (var.getName().equals(getValue(element, property)))
// can't edit process var rows
return false;
}
}
return editable;
}
});
tableEditor.setHorizontalSpan(4);
propertyEditor.render(composite);
tableEditor.getAddButton().setText("Expression");
GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gridData.widthHint = 80;
tableEditor.getAddButton().setLayoutData(gridData);
final Button deleteBtn = tableEditor.getDeleteButton();
tableEditor.getTableViewer().addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
if (sel.getFirstElement() instanceof DefaultRowImpl) {
DefaultRowImpl row = (DefaultRowImpl) sel.getFirstElement();
for (VariableVO var : getProcessVariables()) {
if (var.getName().equals(row.getColumnValue(1))) {
deleteBtn.setEnabled(false);
return;
}
}
deleteBtn.setEnabled(true);
} else {
deleteBtn.setEnabled(false);
}
}
});
} else {
propertyEditor.render(composite);
}
propertyEditor.setValue(taskTemplate);
if (!propertyEditor.getType().equals(PropertyEditor.TYPE_LINK)) {
propertyEditor.setEditable(!(propertyEditor.isReadOnly() || taskTemplate.isReadOnly()));
}
}
}
scrolledComposite.setContent(composite);
scrolledComposite.setExpandVertical(true);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
String pageName = section == null ? "General" : section;
setPageText(addPage(scrolledComposite), pageName);
pages.put(pageName, scrolledComposite);
}
use of com.centurylink.mdw.plugin.designer.properties.editor.TableEditor in project mdw-designer by CenturyLinkCloud.
the class SubProcessInstancesSection method drawWidgets.
public void drawWidgets(Composite composite, WorkflowElement selection) {
this.element = selection;
tableEditor = new TableEditor(element, TableEditor.TYPE_TABLE);
tableEditor.setReadOnly(true);
if (columnSpecs == null)
columnSpecs = createColumnSpecs();
tableEditor.setColumnSpecs(columnSpecs);
if (contentProvider == null)
contentProvider = new SubProcessInstanceContentProvider();
tableEditor.setContentProvider(contentProvider);
if (labelProvider == null)
labelProvider = new SubProcessInstanceLabelProvider();
tableEditor.setLabelProvider(labelProvider);
tableEditor.render(composite);
// double-click
tableEditor.addValueChangeListener(new ValueChangeListener() {
public void propertyValueChanged(Object newValue) {
if (!(element instanceof EmbeddedSubProcess))
openSubProcessInstance((ProcessInstanceVO) newValue);
}
});
// right-click menu
tableEditor.getTable().addListener(SWT.MenuDetect, new Listener() {
public void handleEvent(Event event) {
tableEditor.getTable().setMenu(element instanceof EmbeddedSubProcess ? null : createContextMenu(getShell()));
}
});
}
use of com.centurylink.mdw.plugin.designer.properties.editor.TableEditor in project mdw-designer by CenturyLinkCloud.
the class TaskInstancesSection method drawWidgets.
public void drawWidgets(Composite composite, WorkflowElement selection) {
activity = (Activity) selection;
tableEditor = new TableEditor(activity, TableEditor.TYPE_TABLE);
tableEditor.setReadOnly(true);
tableEditor.setColumnSpecs(getColumnSpecs());
if (contentProvider == null)
contentProvider = getContentProvider();
tableEditor.setContentProvider(contentProvider);
if (labelProvider == null)
labelProvider = getLabelProvider();
tableEditor.setLabelProvider(labelProvider);
tableEditor.render(composite);
// double-click
tableEditor.addValueChangeListener(new ValueChangeListener() {
public void propertyValueChanged(Object newValue) {
openTaskInstance((TaskInstanceVO) newValue);
}
});
// right-click menu
tableEditor.getTable().addListener(SWT.MenuDetect, new Listener() {
public void handleEvent(Event event) {
tableEditor.getTable().setMenu(createContextMenu(getShell()));
}
});
}
use of com.centurylink.mdw.plugin.designer.properties.editor.TableEditor in project mdw-designer by CenturyLinkCloud.
the class VariableValueDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
composite.getShell().setText("Variable Value");
Label nameLabel = new Label(composite, SWT.NONE);
nameLabel.setFont(new Font(nameLabel.getDisplay(), new FontData("Tahoma", 8, SWT.BOLD)));
nameLabel.setText(variableValue.getName());
final String type = variableValue.getType() == null ? "Unknown" : variableValue.getType().getVariableType();
new Label(composite, SWT.NONE).setText("(" + type + ")");
if (type.equals("java.lang.Boolean")) {
valueEditor = new PropertyEditor(null, PropertyEditor.TYPE_CHECKBOX);
} else if (type.equals("java.util.Date")) {
valueEditor = new PropertyEditor(null, PropertyEditor.TYPE_DATE_PICKER);
valueEditor.setWidth(100);
} else if (type.equals("java.lang.Integer") || type.equals("java.lang.Long")) {
valueEditor = new PropertyEditor(null, PropertyEditor.TYPE_TEXT);
valueEditor.setWidth(250);
valueEditor.addValueChangeListener(new ValueChangeListener() {
public void propertyValueChanged(Object newValue) {
String stringValue = (String) newValue;
try {
long val = type.equals("java.lang.Long") ? Long.parseLong(stringValue) : Integer.parseInt(stringValue);
variableValue.setValue(String.valueOf(val));
} catch (NumberFormatException ex) {
String oldValue = variableValue.getValue();
valueEditor.setValue(oldValue);
}
}
});
} else if (type.equals("java.net.URI")) {
valueEditor = new PropertyEditor(null, PropertyEditor.TYPE_TEXT);
valueEditor.setWidth(450);
valueEditor.addValueChangeListener(new ValueChangeListener() {
public void propertyValueChanged(Object newValue) {
try {
new URI((String) newValue);
valueEditor.setLabel("");
} catch (URISyntaxException ex) {
valueEditor.setLabel(ex.getMessage());
}
}
});
} else if (type.equals("java.lang.Integer[]") || type.equals("java.lang.Long[]") || type.equals("java.lang.String[]")) {
valueEditor = new TableEditor(null, TableEditor.TYPE_TABLE);
TableEditor tableEditor = (TableEditor) valueEditor;
List<ColumnSpec> columnSpecs = new ArrayList<ColumnSpec>();
ColumnSpec valueColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, type.substring(type.lastIndexOf('.') + 1, type.length() - 2) + " Values", type);
columnSpecs.add(valueColSpec);
tableEditor.setColumnSpecs(columnSpecs);
tableEditor.setFillWidth(true);
tableEditor.setRowDelimiter(ROW_DELIMITER);
tableEditor.setModelUpdater(new CollectionModelUpdater(tableEditor));
} else if (type.equals("java.util.Map")) {
valueEditor = new MappingEditor(null);
MappingEditor mappingEditor = (MappingEditor) valueEditor;
List<ColumnSpec> columnSpecs = new ArrayList<ColumnSpec>();
ColumnSpec keyColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Key", "key");
keyColSpec.width = 150;
columnSpecs.add(keyColSpec);
ColumnSpec valColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Value", "value");
valColSpec.width = 150;
columnSpecs.add(valColSpec);
mappingEditor.setColumnSpecs(columnSpecs);
mappingEditor.setHeight(150);
mappingEditor.setFillWidth(true);
mappingEditor.setRowDelimiter(ROW_DELIMITER);
mappingEditor.setColumnDelimiter(COLUMN_DELIMITER);
mappingEditor.setContentProvider(mappingEditor.new DefaultContentProvider());
mappingEditor.setLabelProvider(((TableEditor) mappingEditor).new DefaultLabelProvider());
mappingEditor.setCellModifier(((TableEditor) mappingEditor).new DefaultCellModifier());
mappingEditor.setModelUpdater(new CollectionModelUpdater(mappingEditor));
} else {
valueEditor = new PropertyEditor(null, PropertyEditor.TYPE_TEXT);
valueEditor.setMultiLine(true);
valueEditor.setWidth(500);
valueEditor.setHeight(500);
}
valueEditor.setReadOnly(variableValue.isReadOnly());
valueEditor.render(composite);
valueEditor.setValue(variableValue.getValue());
if (!variableValue.isReadOnly()) {
valueEditor.addValueChangeListener(new ValueChangeListener() {
public void propertyValueChanged(Object newValue) {
Button okButton = getButton(Dialog.OK);
if (// else not editable
okButton != null)
okButton.setEnabled(true);
}
});
}
if (isCollectionType(type))
tentativeValueForCollection = variableValue.getValue();
if (type.equals("java.lang.Boolean"))
((Button) valueEditor.getWidget()).setText("(checked = true)");
else if (type.equals("java.lang.Object"))
valueEditor.setValue(variableValue.getValue() == null ? null : variableValue.getValue().toString());
else if (type.equals("java.lang.Integer[]") || type.equals("java.lang.Long[]")) {
if (!variableValue.isReadOnly()) {
TableEditor tableEditor = (TableEditor) valueEditor;
final CellEditor cellEditor = tableEditor.getTableViewer().getCellEditors()[0];
cellEditor.setValidator(new ICellEditorValidator() {
private String oldValue = "";
public String isValid(Object value) {
String message = validateValue((String) value, variableValue.getType().getVariableType());
if (message != null)
cellEditor.setValue(oldValue);
else
oldValue = (String) value;
return null;
}
});
}
} else if (type.equals("java.util.Map")) {
if (!variableValue.isReadOnly()) {
MappingEditor mappingEditor = (MappingEditor) valueEditor;
final CellEditor valueCellEditor = mappingEditor.getTableViewer().getCellEditors()[1];
valueCellEditor.setValidator(new ICellEditorValidator() {
public String isValid(Object value) {
String message = validateValue((String) value, variableValue.getType().getVariableType());
if (message != null)
getButton(Dialog.OK).setEnabled(false);
return null;
}
});
}
}
return composite;
}
Aggregations