Search in sources :

Example 11 with MultiMetadataColumn

use of org.talend.designer.filemultischemas.data.MultiMetadataColumn in project tdi-studio-se by Talend.

the class UIManager method refreshSchemasDetailView.

public void refreshSchemasDetailView(TreeViewer schemaTreeViewer, TreeViewer schemaDetailsViewer, boolean model) {
    if (schemaTreeViewer == null || schemaTreeViewer.getTree().isDisposed() || schemaDetailsViewer == null || schemaDetailsViewer.getTree().isDisposed()) {
        return;
    }
    IStructuredSelection selection = (IStructuredSelection) schemaTreeViewer.getSelection();
    Object element = selection.getFirstElement();
    if (element == null || !(element instanceof SchemasKeyData)) {
        return;
    }
    final Tree tree = schemaDetailsViewer.getTree();
    tree.setRedraw(false);
    SchemasKeyData schemasData = (SchemasKeyData) element;
    final List<MultiMetadataColumn> metadataColumns = schemasData.getMetadataColumnsInModel();
    if (model) {
        schemaDetailsViewer.setInput(metadataColumns);
        //
        tree.setRedraw(true);
        // type
        final TreeColumn typeColumn = tree.getColumns()[EPropertyName.indexOf(EPropertyName.TYPE)];
        typeColumn.pack();
    } else {
        final int colSize = metadataColumns.size();
        if (colSize > 0) {
            //
            List<String> columnProperties = new ArrayList<String>();
            // first column
            columnProperties.add(new Integer(-1).toString());
            final int columnNum = tree.getColumnCount() - 1;
            for (int i = 0; i < colSize; i++) {
                TreeColumn dataColumn = null;
                if (i < columnNum) {
                    // existed column, only update data.
                    dataColumn = tree.getColumns()[i + 1];
                } else {
                    // create new column
                    dataColumn = new TreeColumn(tree, SWT.NONE);
                    dataColumn.setWidth(100);
                }
                // MultiSchemasMetadataColumn metadataColumn = metadataColumns.get(i);
                // dataColumn.setText(metadataColumn.getLabel());
                // dataColumn.setData(metadataColumn);
                columnProperties.add(new Integer(i).toString());
            }
            schemaDetailsViewer.setColumnProperties(columnProperties.toArray(new String[0]));
            schemaDetailsViewer.setInput(schemasData);
        } else {
            schemaDetailsViewer.setInput(null);
        }
        //
        tree.setRedraw(true);
        updateColumns(tree, colSize);
    }
}
Also used : TreeColumn(org.eclipse.swt.widgets.TreeColumn) ArrayList(java.util.ArrayList) Tree(org.eclipse.swt.widgets.Tree) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData) MultiMetadataColumn(org.talend.designer.filemultischemas.data.MultiMetadataColumn)

Example 12 with MultiMetadataColumn

use of org.talend.designer.filemultischemas.data.MultiMetadataColumn in project tdi-studio-se by Talend.

the class SchemaDetailsColumnsProvider method getColumnText.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
     */
public String getColumnText(Object element, int columnIndex) {
    if (element instanceof ColumnLineData) {
        ColumnLineData lineData = (ColumnLineData) element;
        final EPropertyName property = lineData.getProperty();
        if (columnIndex == 0) {
            if (UIManager.isFirstForColumnModel(property)) {
                //$NON-NLS-1$
                return EPropertyName.NAME.getName();
            } else if (property == EPropertyName.NAME) {
                //$NON-NLS-1$
                return "";
            }
            return property.getName();
        }
        List<MultiMetadataColumn> columnsData = lineData.getKeyData().getMetadataColumnsInModel();
        if (columnsData.size() >= columnIndex) {
            MultiMetadataColumn columnData = columnsData.get(columnIndex - 1);
            if (columnData != null) {
                if (UIManager.isFirstForColumnModel(property)) {
                    return columnData.getLabel();
                }
                switch(property) {
                    case NAME:
                        List<MultiSchemasMetadataColumn> dataColumns = columnData.getDataColumns();
                        if (dataColumns.size() > 0) {
                            // only use the first line
                            MultiSchemasMetadataColumn c = dataColumns.get(0);
                            return c.getData();
                        }
                        return columnData.getData();
                    case TAGLEVEL:
                        if (columnIndex == 1) {
                            // only the first data column display the level.
                            return validateValue(columnData.getContainerTagLevel());
                        }
                        break;
                    case KEY:
                        if (columnIndex == uiManager.getSelectedColumnIndex() + 1) {
                            // record type column.
                            return null;
                        }
                        return validateValue(columnData.isKey());
                    case TYPE:
                        return getTypeLabel(columnData.getTalendType());
                    // return validateValue(columnData.isNullable());
                    case LENGTH:
                        return validateValue(columnData.getLength());
                    // return columnData.getCard();
                    case PATTERN:
                        return columnData.getPattern();
                    default:
                }
            }
        }
    }
    return null;
}
Also used : MultiSchemasMetadataColumn(org.talend.designer.filemultischemas.data.MultiSchemasMetadataColumn) EPropertyName(org.talend.designer.filemultischemas.data.EPropertyName) MultiMetadataColumn(org.talend.designer.filemultischemas.data.MultiMetadataColumn)

Example 13 with MultiMetadataColumn

use of org.talend.designer.filemultischemas.data.MultiMetadataColumn in project tdi-studio-se by Talend.

the class SchemaDetailsPropertiesCellModifier method modify.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object)
     */
public void modify(Object element, String property, Object value) {
    if (element instanceof TreeItem) {
        final Object data = ((TreeItem) element).getData();
        if (data != null && data instanceof MultiMetadataColumn) {
            MultiMetadataColumn column = (MultiMetadataColumn) data;
            if (EPropertyName.NAME.name().equals(property)) {
                if (value != null && UIManager.checkSchemaDetailsValue(getSchemaDetailsViewer(), null, EPropertyName.NAME, value)) {
                    column.setLabel((String) value);
                }
            } else if (EPropertyName.TAGLEVEL.name().equals(property)) {
            // column.setTagLevel(Integer.parseInt((String) value));
            } else if (EPropertyName.KEY.name().equals(property)) {
                column.setKey((Boolean) value);
            } else if (EPropertyName.TYPE.name().equals(property)) {
                final String talendType = MultiSchemasUtil.getTalendTypeByIndex((Integer) value);
                if (talendType != null) {
                    column.setTalendType(talendType);
                }
            } else if (EPropertyName.LENGTH.name().equals(property)) {
                if (!"".equals(value)) {
                    //$NON-NLS-1$
                    if (UIManager.checkSchemaDetailsValue(getSchemaDetailsViewer(), null, EPropertyName.LENGTH, value)) {
                        column.setLength(Integer.parseInt((String) value));
                    }
                // else, don't change it.
                } else {
                    column.setLength(null);
                }
            // } else if (EPropertyName.CARD.name().equals(property)) {
            // column.setCard((String) value);
            } else if (EPropertyName.PATTERN.name().equals(property)) {
                column.setPattern((String) value);
            }
            this.getSchemaDetailsViewer().update(column, null);
        }
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) MultiMetadataColumn(org.talend.designer.filemultischemas.data.MultiMetadataColumn)

Example 14 with MultiMetadataColumn

use of org.talend.designer.filemultischemas.data.MultiMetadataColumn in project tdi-studio-se by Talend.

the class SchemaDetailsPropertiesProvider method getColumnText.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
     */
public String getColumnText(Object element, int columnIndex) {
    if (columnIndex == 0) {
        // column name
        if (element instanceof MultiMetadataColumn) {
            return ((MultiMetadataColumn) element).getLabel();
        }
        if (element instanceof MultiSchemasMetadataColumn) {
            return ((MultiSchemasMetadataColumn) element).getData();
        }
    } else if (columnIndex == 1) {
        // level
        if (element instanceof MultiMetadataColumn) {
            MultiMetadataColumn multiMetadataColumn = (MultiMetadataColumn) element;
            return validateValue(multiMetadataColumn.getContainerTagLevel());
        }
    } else if (columnIndex == 2) {
        // key
        if (element instanceof MultiMetadataColumn) {
            MultiMetadataColumn multiMetadataColumn = (MultiMetadataColumn) element;
            // first column(record type)
            SchemasKeyData container = multiMetadataColumn.getContainer();
            if (container != null && container.getMetadataColumnsInModel().indexOf(multiMetadataColumn) == uiManager.getSelectedColumnIndex()) {
                return null;
            }
            return validateValue(multiMetadataColumn.isKey());
        }
    } else {
        if (element instanceof MultiSchemasMetadataColumn) {
            MultiSchemasMetadataColumn column = (MultiSchemasMetadataColumn) element;
            switch(columnIndex) {
                case // type
                3:
                    return getTypeLabel(column.getTalendType());
                case // length
                4:
                    return validateValue(column.getLength());
                // return column.getCard();
                case // pattern
                5:
                    return column.getPattern();
            }
        }
    }
    return null;
}
Also used : MultiSchemasMetadataColumn(org.talend.designer.filemultischemas.data.MultiSchemasMetadataColumn) SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData) MultiMetadataColumn(org.talend.designer.filemultischemas.data.MultiMetadataColumn)

Aggregations

MultiMetadataColumn (org.talend.designer.filemultischemas.data.MultiMetadataColumn)14 SchemasKeyData (org.talend.designer.filemultischemas.data.SchemasKeyData)7 TreeItem (org.eclipse.swt.widgets.TreeItem)3 EPropertyName (org.talend.designer.filemultischemas.data.EPropertyName)3 MultiSchemasMetadataColumn (org.talend.designer.filemultischemas.data.MultiSchemasMetadataColumn)3 ArrayList (java.util.ArrayList)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)2 HashMap (java.util.HashMap)1 FocusAdapter (org.eclipse.swt.events.FocusAdapter)1 FocusEvent (org.eclipse.swt.events.FocusEvent)1 Point (org.eclipse.swt.graphics.Point)1 Control (org.eclipse.swt.widgets.Control)1 Tree (org.eclipse.swt.widgets.Tree)1 TreeColumn (org.eclipse.swt.widgets.TreeColumn)1 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)1 MetadataTable (org.talend.core.model.metadata.MetadataTable)1 MultiSchemaRowData (org.talend.designer.filemultischemas.data.MultiSchemaRowData)1 ColumnLineData (org.talend.designer.filemultischemas.ui.provider.column.ColumnLineData)1