Search in sources :

Example 11 with Line

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;
}
Also used : Line(com.amalto.workbench.models.Line) KeyValue(com.amalto.workbench.models.KeyValue)

Example 12 with Line

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);
}
Also used : Line(com.amalto.workbench.models.Line) KeyValue(com.amalto.workbench.models.KeyValue) ArrayList(java.util.ArrayList) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 13 with Line

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;
}
Also used : Line(com.amalto.workbench.models.Line) KeyValue(com.amalto.workbench.models.KeyValue) ArrayList(java.util.ArrayList)

Example 14 with Line

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);
}
Also used : CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) EditingSupport(org.eclipse.jface.viewers.EditingSupport) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Point(org.eclipse.swt.graphics.Point) Line(com.amalto.workbench.models.Line) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 15 with Line

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);
}
Also used : Line(com.amalto.workbench.models.Line) ArrayList(java.util.ArrayList) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

Line (com.amalto.workbench.models.Line)25 ArrayList (java.util.ArrayList)19 KeyValue (com.amalto.workbench.models.KeyValue)10 List (java.util.List)7 XtentisException (com.amalto.workbench.utils.XtentisException)6 GridData (org.eclipse.swt.layout.GridData)5 TableItem (org.eclipse.swt.widgets.TableItem)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 SelectionListener (org.eclipse.swt.events.SelectionListener)4 CellEditor (org.eclipse.jface.viewers.CellEditor)3 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 EImage (com.amalto.workbench.image.EImage)2 WSBoolean (com.amalto.workbench.webservices.WSBoolean)2 WSGetServicesList (com.amalto.workbench.webservices.WSGetServicesList)2 WSRoutingRule (com.amalto.workbench.webservices.WSRoutingRule)2 WSRoutingRuleExpression (com.amalto.workbench.webservices.WSRoutingRuleExpression)2 WSServicesList (com.amalto.workbench.webservices.WSServicesList)2