Search in sources :

Example 1 with MultiMetadataColumn

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

the class SchemaDetailsColumnMouseAdapter method mouseDown.

@Override
public void mouseDown(MouseEvent e) {
    currentPoint = new Point(e.x, e.y);
    // Clean up any previous editor control
    Control oldEditor = getEditor();
    if (oldEditor != null) {
        oldEditor.dispose();
    }
    if (getViewerCell() == null) {
        return;
    }
    // Identify the selected row
    TreeItem item = (TreeItem) getViewerCell().getViewerRow().getItem();
    if (item == null) {
        return;
    }
    if (getColumnIndex() < 1) {
        // ingore first
        return;
    }
    final Object data = item.getData();
    if (!(data instanceof ColumnLineData)) {
        return;
    }
    ColumnLineData lineData = (ColumnLineData) data;
    List<MultiMetadataColumn> metadataColumnsInModel = lineData.getKeyData().getMetadataColumnsInModel();
    final MultiMetadataColumn multiMetadataColumn = metadataColumnsInModel.get(getColumnIndex() - 1);
    Control newEditor = null;
    final EPropertyName property = lineData.getProperty();
    if (UIManager.isFirstForColumnModel(property)) {
        newEditor = createTextControl(item, property, multiMetadataColumn);
    } else {
        switch(property) {
            case NAME:
            case TAGLEVEL:
                break;
            case TYPE:
                newEditor = createComboControl(item, multiMetadataColumn);
                break;
            case LENGTH:
            // case CARD:
            case PATTERN:
                newEditor = createTextControl(item, property, multiMetadataColumn);
                break;
            case KEY:
                /*
                 * ingore record type(first column);
                 * 
                 * if existed key column, should not edit other key.
                 */
                if (getColumnIndex() == uiManager.getSelectedColumnIndex() + 1 || UIManager.existedKeyColumn(metadataColumnsInModel, multiMetadataColumn)) {
                    break;
                }
                newEditor = createCheckBoxControl(item, property, multiMetadataColumn);
                break;
        }
    }
    if (newEditor != null) {
        newEditor.addFocusListener(new FocusAdapter() {

            public void focusLost(FocusEvent e) {
                if (getEditor() != null && !getEditor().isDisposed()) {
                    getEditor().dispose();
                }
            }
        });
        newEditor.setFocus();
        getTreeEditor().setEditor(newEditor, item, getColumnIndex());
    }
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) Control(org.eclipse.swt.widgets.Control) EPropertyName(org.talend.designer.filemultischemas.data.EPropertyName) TreeItem(org.eclipse.swt.widgets.TreeItem) Point(org.eclipse.swt.graphics.Point) FocusEvent(org.eclipse.swt.events.FocusEvent) MultiMetadataColumn(org.talend.designer.filemultischemas.data.MultiMetadataColumn)

Example 2 with MultiMetadataColumn

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

the class SchemaDetailsColumnsProvider method getColumnImage.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
     */
public Image getColumnImage(Object element, int columnIndex) {
    if (element instanceof ColumnLineData) {
        ColumnLineData lineData = (ColumnLineData) element;
        final EPropertyName property = lineData.getProperty();
        List<MultiMetadataColumn> columnsData = lineData.getKeyData().getMetadataColumnsInModel();
        if (columnsData.size() >= columnIndex && columnIndex > 1) {
            MultiMetadataColumn columnData = columnsData.get(columnIndex - 1);
            if (columnData != null && property == EPropertyName.KEY) {
                if (columnData.isKey()) {
                // return ImageProvider.getImage(EImage.CHECKED_ICON);
                } else {
                // return ImageProvider.getImage(EImage.UNCHECKED_ICON);
                }
            }
        }
    }
    return null;
}
Also used : EPropertyName(org.talend.designer.filemultischemas.data.EPropertyName) MultiMetadataColumn(org.talend.designer.filemultischemas.data.MultiMetadataColumn)

Example 3 with MultiMetadataColumn

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

the class ChangeMultiSchemasCommand method addSchemasMap.

private void addSchemasMap(List<Map<String, String>> newValueList, List<IMetadataTable> newTables, SchemasKeyData keyData) {
    if (keyData == null) {
        return;
    }
    if (keyData.getParent() != null) {
        // not root
        //
        Map<String, String> map = new HashMap<String, String>();
        final String uniqueRecord = keyData.getUniqueRecord();
        final String recordType = keyData.getRecordType();
        map.put(IMultiSchemaConstant.SCHEMA, uniqueRecord);
        map.put(IMultiSchemaConstant.RECORD, TalendTextUtils.addQuotes(recordType));
        map.put(IMultiSchemaConstant.PARENT_RECORD, TalendTextUtils.addQuotes(keyData.getParent().getRecordType()));
        map.put(IMultiSchemaConstant.CARDINALITY, keyData.getCard());
        map.put(IMultiSchemaConstant.FIELDDELIMITED, TalendTextUtils.addQuotes(keyData.getSeparator()));
        newValueList.add(map);
        //
        String connectionBaseName = MetadataToolHelper.validateColumnName(MultiSchemasUtil.getConnectionBaseName(uniqueRecord), 0);
        String uniqueConnName = node.getProcess().generateUniqueConnectionName(connectionBaseName);
        MetadataTable table = new MetadataTable();
        table.setLabel(uniqueRecord);
        table.setTableName(uniqueConnName);
        //$NON-NLS-1$
        String keyIndex = "";
        boolean first = true;
        List<MultiMetadataColumn> metadataColumnsInModel = keyData.getMetadataColumnsInModel();
        for (int i = 0; i < metadataColumnsInModel.size(); i++) {
            MultiMetadataColumn column = metadataColumnsInModel.get(i);
            table.getListColumns().add(column.clone(true));
            if (column.isKey()) {
                if (first) {
                    keyIndex += i;
                } else {
                    //$NON-NLS-1$
                    keyIndex += "," + i;
                }
                first = false;
            }
        }
        map.put(IMultiSchemaConstant.KEY_COLUMN_INDEX, TalendTextUtils.addQuotes(keyIndex));
        newTables.add(table);
    }
    for (SchemasKeyData child : keyData.getChildren()) {
        addSchemasMap(newValueList, newTables, child);
    }
}
Also used : HashMap(java.util.HashMap) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData) MultiMetadataColumn(org.talend.designer.filemultischemas.data.MultiMetadataColumn)

Example 4 with MultiMetadataColumn

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

the class SchemaDetailsPropertiesCellModifier method canModify.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String)
     */
public boolean canModify(Object element, String property) {
    if (element instanceof MultiMetadataColumn) {
        MultiMetadataColumn column = (MultiMetadataColumn) element;
        SchemasKeyData container = column.getContainer();
        if (container == null) {
            return false;
        }
        List<MultiMetadataColumn> metadataColumnsInModel = container.getMetadataColumnsInModel();
        /*
             * ingore record type(first column);
             * 
             * if existed key column, should not edit other key.
             */
        if (EPropertyName.KEY.name().equals(property) && (metadataColumnsInModel.indexOf(column) == uiManager.getSelectedColumnIndex() || UIManager.existedKeyColumn(metadataColumnsInModel, column))) {
            return false;
        }
        if (!EPropertyName.TAGLEVEL.name().equals(property)) {
            return true;
        }
    }
    return false;
}
Also used : SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData) MultiMetadataColumn(org.talend.designer.filemultischemas.data.MultiMetadataColumn)

Example 5 with MultiMetadataColumn

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

the class SchemaDetailsPropertiesProvider method getColumnImage.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
     */
public Image getColumnImage(Object element, int columnIndex) {
    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) == 0) {
                return null;
            }
            if (multiMetadataColumn.isKey()) {
            // return ImageProvider.getImage(EImage.CHECKED_ICON);
            } else {
            // return ImageProvider.getImage(EImage.UNCHECKED_ICON);
            }
        }
    }
    return null;
}
Also used : 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