use of com.amalto.workbench.models.Line in project tmdm-studio-se by Talend.
the class UserSecurityCellModifier method getValue.
public Object getValue(Object element, String property) {
int columnIndex = Arrays.asList(viewer.getColumnProperties()).indexOf(property);
Line line = (Line) element;
if (isAColumnWithCombo(columnIndex)) {
String value = line.keyValues.get(columnIndex).value;
String[] attrs = conditionColumns[columnIndex].getComboValues();
return Arrays.asList(attrs).indexOf(value);
}
for (KeyValue keyvalue : line.keyValues) {
if (property.equals(keyvalue.key)) {
if (keyvalue.value == null) {
return conditionColumns[columnIndex].getNillDisplay();
}
return keyvalue.value;
}
}
return null;
}
use of com.amalto.workbench.models.Line in project tmdm-studio-se by Talend.
the class FKFilterParserTest method testGetDeParseredFilter.
@Test
public void testGetDeParseredFilter() {
// $NON-NLS-1$
String criteria = "Store/Long$$=$$111$$And#Store/Address$$Contains$$shanghai$$Or#";
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
String[] keyNames = { "XPath", "Operator", "Value", "Predicate" };
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
String[] values1 = { "Store/Long", "=", "111", "And" };
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
String[] values2 = { "Store/Address", "Contains", "shanghai", "Or" };
List<KeyValue> keyValues1 = new ArrayList<KeyValue>();
List<KeyValue> keyValues2 = new ArrayList<KeyValue>();
for (int i = 0; i < keyNames.length && i < values1.length; i++) {
keyValues1.add(new KeyValue(keyNames[i], values1[i]));
keyValues2.add(new KeyValue(keyNames[i], values2[i]));
}
Line line1 = new Line(keyValues1);
Line line2 = new Line(keyValues2);
String deParseredFilter = FKFilterParser.getDeParseredFilter(Arrays.asList(line1, line2));
assertEquals(criteria, deParseredFilter);
deParseredFilter = FKFilterParser.getDeParseredFilter(null);
// $NON-NLS-1$
assertEquals("", deParseredFilter);
}
use of com.amalto.workbench.models.Line in project tmdm-studio-se by Talend.
the class UpdateAutoIncrementDialog method getInput.
private List<Line> getInput() {
List<Line> lines = new ArrayList<Line>();
Iterator<String> iterator = entityValues.keySet().iterator();
while (iterator.hasNext()) {
String entity = iterator.next();
String value = entityValues.get(entity);
List<KeyValue> keyvalues = new ArrayList<KeyValue>();
// $NON-NLS-1$
keyvalues.add(new KeyValue("Entity", entity));
// $NON-NLS-1$
keyvalues.add(new KeyValue("Value", value));
Line line = new Line(keyvalues);
lines.add(line);
}
return lines;
}
use of com.amalto.workbench.models.Line in project tmdm-studio-se by Talend.
the class UpdateAutoIncrementDialog method createTable.
private void createTable(Composite mainComp) {
int style = SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION;
resultsViewer = new TableViewer(mainComp, style);
resultsViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
resultsViewer.getTable().setHeaderVisible(true);
resultsViewer.getTable().setLinesVisible(true);
resultsViewer.setContentProvider(getContentProvider());
TableViewerColumn column = new TableViewerColumn(resultsViewer, SWT.NONE);
column.getColumn().setText(Messages.UpdateAutoIncrementDialog_entity);
column.getColumn().setResizable(true);
column.getColumn().setWidth(300);
column.setLabelProvider(new CustomedLabelProvider(0));
column.setEditingSupport(null);
column = new TableViewerColumn(resultsViewer, SWT.NONE);
column.getColumn().setText(Messages.UpdateAutoIncrementDialog_value);
column.getColumn().setResizable(true);
column.getColumn().setWidth(100);
column.setLabelProvider(new CustomedLabelProvider(1));
column.setEditingSupport(new EditingSupport(resultsViewer) {
@Override
protected CellEditor getCellEditor(Object element) {
return new VerificableTextCellEditor(resultsViewer.getTable());
}
@Override
protected boolean canEdit(Object element) {
return true;
}
@Override
protected Object getValue(Object element) {
Line line = (Line) element;
return line.keyValues.get(1).value;
}
@Override
protected void setValue(Object element, Object value) {
Line line = (Line) element;
line.keyValues.get(1).value = value.toString();
resultsViewer.refresh();
}
});
resultsViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) resultsViewer.getSelection();
resetBtn.setEnabled(!selection.isEmpty());
}
});
List<Line> lines = getInput();
resultsViewer.setInput(lines);
}
use of com.amalto.workbench.models.Line in project tmdm-studio-se by Talend.
the class UpdateAutoIncrementDialog method buttonPressed.
@Override
protected void buttonPressed(int buttonId) {
if (resetAllBtnId == buttonId) {
List<Line> lines = (List<Line>) resultsViewer.getInput();
for (Line line : lines) {
line.keyValues.get(1).value = DEFAULT_VALUE;
}
resultsViewer.refresh();
}
if (resetBtnId == buttonId) {
IStructuredSelection selection = (IStructuredSelection) resultsViewer.getSelection();
for (Object obj : selection.toList()) {
Line line = (Line) obj;
line.keyValues.get(1).value = DEFAULT_VALUE;
}
resultsViewer.refresh();
}
super.buttonPressed(buttonId);
}
Aggregations