Search in sources :

Example 6 with MetadataTableEditor

use of org.talend.core.ui.metadata.editor.MetadataTableEditor in project tdi-studio-se by Talend.

the class MapperManager method addMetadataTableEditorEntry.

/**
     * DOC amaumont Comment method "addTableEntry".
     * 
     * @param dataMapTableEntry
     * @param index
     */
public void addMetadataTableEditorEntry(MetadataTableEditorView metadataTableEditorView, IMetadataColumn metadataColumn, Integer index) {
    MetadataTableEditor metadataTableEditor = metadataTableEditorView.getMetadataTableEditor();
    metadataTableEditor.add(metadataColumn, index);
}
Also used : MetadataTableEditor(org.talend.core.ui.metadata.editor.MetadataTableEditor)

Example 7 with MetadataTableEditor

use of org.talend.core.ui.metadata.editor.MetadataTableEditor in project tdi-studio-se by Talend.

the class MainConnectionComposite method addComponents.

@Override
public void addComponents(boolean forceRedraw) {
    if (conSchema()) {
        disposeChildren();
        curRowSize = 0;
        List<? extends IElementParameter> listParam = ((Connection) elem).getSource().getElementParameters();
        generator.initController(this);
        for (IElementParameter cur : listParam) {
            if (cur.getCategory() == this.section) {
                if ((cur.getFieldType() == EParameterFieldType.SCHEMA_TYPE || cur.getFieldType() == EParameterFieldType.SCHEMA_REFERENCE) && (cur.getContext().equals(((Connection) elem).getConnectorName()))) {
                    AbstractElementPropertySectionController contorller = generator.getController(EParameterFieldType.SCHEMA_TYPE, this);
                    contorller.createControl(composite, cur, 1, 1, 0, null);
                }
            }
        }
        if (((Connection) elem).getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
            IMetadataTable outputMetaTable = ((Connection) elem).getMetadataTable();
            if (outputMetaTable != null && this.section == EComponentCategory.BASIC) {
                // Composite compositeEditorView = new Composite(composite, SWT.BORDER);
                // compositeEditorView.setLayoutData(data);
                metadataTableEditor = new MetadataTableEditor(outputMetaTable, //$NON-NLS-1$
                "Schema from " + ((Connection) elem).getSource().getElementName() + //$NON-NLS-1$
                " output ");
                metadataTableEditorView = new MetadataTableEditorView(composite, SWT.NONE, metadataTableEditor, true, false, true, false);
                MetadataDialog.initializeMetadataTableView(metadataTableEditorView, ((Connection) elem).getSource(), outputMetaTable);
                metadataTableEditorView.initGraphicComponents();
                metadataTableEditorView.getExtendedTableViewer().setCommandStack(getCommandStack());
                CustomTableManager.addCustomManagementToTable(metadataTableEditorView, true);
                Composite compositeEditorView = metadataTableEditorView.getMainComposite();
                Table table = metadataTableEditorView.getTable();
                FormData data = new FormData();
                data.left = new FormAttachment(0, ITabbedPropertyConstants.HSPACE);
                data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
                data.top = new FormAttachment(0, curRowSize + ITabbedPropertyConstants.VSPACE);
                // to correct bug of table growing indefinitly
                data.width = 300;
                /*
                     * On windows it will adjust automatically the size depends the number of columns. Seems this system
                     * doesn't work on linux
                     */
                // fix bug 3893.
                int tableHeight = 160;
                int maxTableHeight = table.getHeaderHeight() + 22 * table.getItemHeight();
                int rows = outputMetaTable.getListColumns().size();
                int currentHeightEditor = table.getHeaderHeight() + rows * table.getItemHeight() + 50;
                if (currentHeightEditor > tableHeight) {
                    tableHeight = currentHeightEditor;
                }
                if (currentHeightEditor > maxTableHeight) {
                    tableHeight = maxTableHeight;
                }
                // fix bug 3893.
                data.height = tableHeight;
                compositeEditorView.setLayoutData(data);
                // compositeEditorView.getParent().layout();
                // Table table = metadataTableEditorView.getTable();
                // int currentHeightEditor = table.getHeaderHeight() + outputMetaTable.getListColumns().size()
                // * table.getItemHeight() + table.getItemHeight() + 50;
                curRowSize = tableHeight + ITabbedPropertyConstants.VSPACE + curRowSize;
            }
        }
        super.addComponents(forceRedraw, false, curRowSize);
    } else if (conIf()) {
        super.addComponents(forceRedraw);
    } else if (resumingIf()) {
        super.addComponents(forceRedraw);
    } else {
        disposeChildren();
    }
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) FormData(org.eclipse.swt.layout.FormData) MetadataTableEditor(org.talend.core.ui.metadata.editor.MetadataTableEditor) Table(org.eclipse.swt.widgets.Table) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MultipleThreadDynamicComposite(org.talend.designer.core.ui.views.properties.MultipleThreadDynamicComposite) Composite(org.eclipse.swt.widgets.Composite) AbstractElementPropertySectionController(org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController) Connection(org.talend.designer.core.ui.editor.connections.Connection) IElementParameter(org.talend.core.model.process.IElementParameter) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 8 with MetadataTableEditor

use of org.talend.core.ui.metadata.editor.MetadataTableEditor in project tdi-studio-se by Talend.

the class MainConnectionSection method addComponents.

@Override
public void addComponents(boolean forceRedraw) {
    if (conSchema()) {
        disposeChildren();
        curRowSize = 0;
        List<? extends IElementParameter> listParam = ((Connection) elem).getSource().getElementParameters();
        generator.initController(this);
        for (IElementParameter cur : listParam) {
            if ((cur.getFieldType() == EParameterFieldType.SCHEMA_TYPE || cur.getFieldType() == EParameterFieldType.SCHEMA_REFERENCE) && (cur.getContext().equals(((Connection) elem).getConnectorName()))) {
                AbstractElementPropertySectionController contorller = generator.getController(EParameterFieldType.SCHEMA_TYPE, this);
                contorller.createControl(composite, cur, 0, 0, 0, null);
            }
        }
        FormData data = new FormData();
        data.left = new FormAttachment(0, ITabbedPropertyConstants.HSPACE);
        data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
        data.top = new FormAttachment(0, curRowSize + ITabbedPropertyConstants.VSPACE);
        // to correct bug of table growing indefinitly
        data.width = 300;
        IMetadataTable outputMetaTable = ((Connection) elem).getMetadataTable();
        if (outputMetaTable != null) {
            // Composite compositeEditorView = new Composite(composite, SWT.BORDER);
            // compositeEditorView.setLayoutData(data);
            metadataTableEditor = new MetadataTableEditor(outputMetaTable, //$NON-NLS-1$
            "Schema from " + ((Connection) elem).getSource().getElementName() + //$NON-NLS-1$
            " output ");
            metadataTableEditorView = new MetadataTableEditorView(composite, SWT.NONE, metadataTableEditor, true, false, true, false);
            MetadataDialog.initializeMetadataTableView(metadataTableEditorView, ((Connection) elem).getSource(), outputMetaTable);
            metadataTableEditorView.initGraphicComponents();
            metadataTableEditorView.getExtendedTableViewer().setCommandStack(getCommandStack());
            CustomTableManager.addCustomManagementToTable(metadataTableEditorView, true);
            Composite compositeEditorView = metadataTableEditorView.getMainComposite();
            compositeEditorView.setLayoutData(data);
            // compositeEditorView.getParent().layout();
            Table table = metadataTableEditorView.getTable();
            int currentHeightEditor = table.getHeaderHeight() + outputMetaTable.getListColumns().size() * table.getItemHeight() + table.getItemHeight() + 50;
            curRowSize = currentHeightEditor + ITabbedPropertyConstants.VSPACE + curRowSize;
        }
        super.addComponents(forceRedraw, false);
    } else if (conIf()) {
        super.addComponents(forceRedraw);
    } else {
        disposeChildren();
    }
}
Also used : FormData(org.eclipse.swt.layout.FormData) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTableEditor(org.talend.core.ui.metadata.editor.MetadataTableEditor) Table(org.eclipse.swt.widgets.Table) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) Composite(org.eclipse.swt.widgets.Composite) AbstractElementPropertySectionController(org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController) Connection(org.talend.designer.core.ui.editor.connections.Connection) IElementParameter(org.talend.core.model.process.IElementParameter) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 9 with MetadataTableEditor

use of org.talend.core.ui.metadata.editor.MetadataTableEditor in project tdi-studio-se by Talend.

the class UIManager method modifySelectionChangedListener.

private void modifySelectionChangedListener(final Zone currentZone, final MetadataTableEditorView metadataTableEditorViewFinal, final TableViewerCreator metadataTVCreator, final MetadataTableEditor metadataTableEditor, final DataMapTableView dataMapTableView, DataMapTableView previousSelectedTableView) {
    final TableViewer tableViewer = dataMapTableView.getTableViewerCreatorForColumns().getTableViewer();
    IModifiedBeanListener<IMetadataColumn> modifiedBeanListener = new IModifiedBeanListener<IMetadataColumn>() {

        public void handleEvent(ModifiedBeanEvent<IMetadataColumn> event) {
            if (AbstractMetadataTableEditorView.ID_COLUMN_NAME.equals(event.column.getId()) && !event.previousValue.equals(event.newValue)) {
                IMetadataColumn modifiedObject = event.bean;
                if (modifiedObject != null) {
                    TableEntryLocation tableEntryLocation = new TableEntryLocation(dataMapTableView.getDataMapTable().getName(), (String) event.previousValue);
                    final ITableEntry dataMapTableEntry = mapperManager.retrieveTableEntry(tableEntryLocation);
                    // see bug 7471,record the modification about the column value
                    String curConnName = null;
                    if (dataMapTableEntry != null) {
                        curConnName = dataMapTableEntry.getParentName();
                    }
                    List<? extends IConnection> curInConns = mapperManager.getAbstractMapComponent().getIncomingConnections();
                    List<? extends IConnection> curOutConns = mapperManager.getAbstractMapComponent().getOutgoingConnections();
                    for (IConnection curInConn : curInConns) {
                        if (curConnName.equals(curInConn.getUniqueName())) {
                            Map<String, String> changedNameInColumns = new HashMap<String, String>();
                            changedNameInColumns.put((String) event.newValue, (String) event.previousValue);
                            changedNameColumns.put(curInConn, changedNameInColumns);
                        }
                    }
                    for (IConnection curOutConn : curOutConns) {
                        if (curConnName.equals(curOutConn.getUniqueName())) {
                            Map<String, String> changedNameOutColumns = new HashMap<String, String>();
                            changedNameOutColumns.put((String) event.newValue, (String) event.previousValue);
                            changedNameColumns.put(curOutConn, changedNameOutColumns);
                        }
                    }
                    processColumnNameChanged((String) event.previousValue, (String) event.newValue, dataMapTableView, dataMapTableEntry);
                    // related tables
                    List<DataMapTableView> relatedOutputsTableView = getRelatedOutputsTableView(dataMapTableView);
                    for (DataMapTableView relatedView : relatedOutputsTableView) {
                        TableEntryLocation relatedEntryLocation = new TableEntryLocation(relatedView.getDataMapTable().getName(), (String) event.previousValue);
                        ITableEntry relatedTableEntry = mapperManager.retrieveTableEntry(relatedEntryLocation);
                        processColumnNameChanged((String) event.previousValue, (String) event.newValue, relatedView, relatedTableEntry);
                    }
                }
                // dataMapTableViewer.refresh(event.bean, true);
                tableViewer.refresh(true);
            } else if (AbstractMetadataTableEditorView.ID_COLUMN_KEY.equals(event.column.getId())) {
                tableViewer.refresh(true);
                IColumnEntry entry = dataMapTableView.getDataMapTable().getColumnEntries().get(event.index);
                parseExpression(entry.getExpression(), entry, false, false, false);
            } else if (AbstractMetadataTableEditorView.ID_COLUMN_TYPE.equals(event.column.getId()) || AbstractMetadataTableEditorView.ID_COLUMN_NULLABLE.equals(event.column.getId())) {
                mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
            }
        }
    };
    ILineSelectionListener metadataEditorViewerSelectionChangedListener = new ILineSelectionListener() {

        public void handle(LineSelectionEvent e) {
            if (metadataTableEditorViewFinal.getTableViewerCreator() == e.source) {
                if (metadataTableEditorViewFinal.getExtendedTableViewer().isExecuteSelectionEvent()) {
                    mapperManager.getUiManager().selectLinkedTableEntries(metadataTableEditor.getMetadataTable(), metadataTVCreator.getTable().getSelectionIndices());
                }
            } else {
            // if (dataMapTableView.getExtendedTableViewerForColumns().isExecuteSelectionEvent()) {
            // int[] selectionIndices =
            // dataMapTableView.getTableViewerCreatorForColumns().getTable().getSelectionIndices();
            // mapperManager.getUiManager().selectLinkedMetadataEditorEntries(dataMapTableView,
            // selectionIndices);
            // }
            }
        }
    };
    // ISelectionChangedListener previousSelectionChangedListener = null;
    ILineSelectionListener previousSelectionChangedListener = null;
    IModifiedBeanListener<IMetadataColumn> previousModifiedBeanListener = null;
    if (currentZone == Zone.INPUTS) {
        previousSelectionChangedListener = inputsSelectionChangedListener;
        previousModifiedBeanListener = inputModifiedBeanListener;
    } else if (currentZone == Zone.OUTPUTS) {
        previousSelectionChangedListener = outputsSelectionChangedListener;
        previousModifiedBeanListener = outputModifiedBeanListener;
    }
    if (previousSelectionChangedListener != null) {
        // metadataTVCreator.removeSelectionChangedListener(previousSelectionChangedListener);
        metadataTVCreator.getSelectionHelper().removeAfterSelectionListener(previousSelectionChangedListener);
        if (previousSelectedTableView != null) {
            previousSelectedTableView.getTableViewerCreatorForColumns().getSelectionHelper().removeAfterSelectionListener(previousSelectionChangedListener);
        }
    }
    if (previousModifiedBeanListener != null) {
        metadataTableEditor.removeModifiedBeanListener(previousModifiedBeanListener);
    }
    if (currentZone == Zone.INPUTS) {
        inputsSelectionChangedListener = metadataEditorViewerSelectionChangedListener;
        inputModifiedBeanListener = modifiedBeanListener;
    } else if (currentZone == Zone.OUTPUTS) {
        outputsSelectionChangedListener = metadataEditorViewerSelectionChangedListener;
        outputModifiedBeanListener = modifiedBeanListener;
    }
    // metadataTVCreator.addSelectionChangedListener(metadataEditorViewerSelectionChangedListener);
    metadataTVCreator.getSelectionHelper().addAfterSelectionListener(metadataEditorViewerSelectionChangedListener);
    dataMapTableView.getTableViewerCreatorForColumns().getSelectionHelper().addAfterSelectionListener(metadataEditorViewerSelectionChangedListener);
    metadataTableEditor.addModifiedBeanListener(modifiedBeanListener);
    if (this.commonMetadataDisposeListener == null) {
        this.commonMetadataDisposeListener = new DisposeListener() {

            public void widgetDisposed(DisposeEvent e) {
                if (inputsSelectionChangedListener != null) {
                    getMetadataEditorView(Zone.INPUTS).getTableViewerCreator().getSelectionHelper().removeAfterSelectionListener(inputsSelectionChangedListener);
                }
                if (outputsSelectionChangedListener != null) {
                    getMetadataEditorView(Zone.OUTPUTS).getTableViewerCreator().getSelectionHelper().removeAfterSelectionListener(outputsSelectionChangedListener);
                }
                if (inputModifiedBeanListener != null) {
                    MetadataTableEditor metadataTableEditor = getMetadataEditorView(Zone.INPUTS).getMetadataTableEditor();
                    if (metadataTableEditor != null) {
                        metadataTableEditor.removeModifiedBeanListener(inputModifiedBeanListener);
                    }
                }
                if (outputModifiedBeanListener != null) {
                    MetadataTableEditor metadataTableEditor = getMetadataEditorView(Zone.OUTPUTS).getMetadataTableEditor();
                    if (metadataTableEditor != null) {
                        metadataTableEditor.removeModifiedBeanListener(outputModifiedBeanListener);
                    }
                }
            }
        };
        metadataTVCreator.getTable().addDisposeListener(this.commonMetadataDisposeListener);
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) MetadataTableEditor(org.talend.core.ui.metadata.editor.MetadataTableEditor) HashMap(java.util.HashMap) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) IConnection(org.talend.core.model.process.IConnection) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IModifiedBeanListener(org.talend.commons.ui.swt.tableviewer.IModifiedBeanListener) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ModifiedBeanEvent(org.talend.commons.ui.swt.tableviewer.ModifiedBeanEvent) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 10 with MetadataTableEditor

use of org.talend.core.ui.metadata.editor.MetadataTableEditor in project tdi-studio-se by Talend.

the class spssComponent method getSchemaFromSPSSFile.

private void getSchemaFromSPSSFile() {
    try {
        List<IMetadataTable> metadataList = getMetadataList();
        MetadataTable metaTable = (MetadataTable) metadataList.get(0);
        metaTable.getListColumns().clear();
        MetadataTableEditor tableEditor = new MetadataTableEditor(metaTable, "");
        spss spssIn = new spss();
        spssfile spssFile = spssIn.openFile(strFileName, spssfile.SPSS_READ);
        String strComponentName = this.getComponent().getName();
        spssvariables spssVars = spssFile.getVariables();
        spssvariable spssVar;
        for (int i = 0; i < spssVars.getNumberOfVariables(); i++) {
            spssVar = spssVars.getVariabelAtPos(i);
            IMetadataColumn column = tableEditor.createNewMetadataColumn();
            String lableName = MetadataToolHelper.validateColumnName(spssVar.getName(), i);
            column.setLabel(lableName);
            column.setOriginalDbColumnName(spssVar.getName());
            if (spssVar.hasLabels() && strTranslateLabels.toLowerCase().equals("true")) {
                column.setLength(spssVar.getMaxLengthByLableTranslation());
                column.setPrecision(0);
                column.setTalendType("id_String");
            } else {
                switch(spssVar.getJAVAType()) {
                    case spssvariable.JAVA_TYPE_DOUBLE:
                        column.setTalendType("id_Double");
                        break;
                    case spssvariable.JAVA_TYPE_STRING:
                        column.setTalendType("id_String");
                        break;
                    case spssvariable.JAVA_TYPE_DATE:
                        column.setTalendType("id_Date");
                        break;
                }
                column.setLength(spssVar.getDecimals());
                column.setPrecision(spssVar.getPrecision());
            }
            String strLabel = spssVar.getLabel();
            if (null != strLabel && strLabel.length() > 0)
                column.setComment(strLabel);
            else
                column.setComment("");
            if (null == strComponentName || strComponentName.toLowerCase().equals("tspssinput"))
                column.setReadOnly(true);
            else
                column.setReadOnly(false);
            metaTable.getListColumns().add(column);
        }
        spssFile.close();
    } catch (Exception e) {
        log.error("", e);
    }
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) org.talend.jspss.spssvariable(org.talend.jspss.spssvariable) MetadataTableEditor(org.talend.core.ui.metadata.editor.MetadataTableEditor) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) org.talend.jspss.spss(org.talend.jspss.spss) org.talend.jspss.spssvariables(org.talend.jspss.spssvariables) org.talend.jspss.spssfile(org.talend.jspss.spssfile) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Aggregations

MetadataTableEditor (org.talend.core.ui.metadata.editor.MetadataTableEditor)12 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)8 MetadataTableEditorView (org.talend.core.ui.metadata.editor.MetadataTableEditorView)6 ArrayList (java.util.ArrayList)5 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)5 List (java.util.List)4 TableViewer (org.eclipse.jface.viewers.TableViewer)4 IModifiedBeanListener (org.talend.commons.ui.swt.tableviewer.IModifiedBeanListener)4 ModifiedBeanEvent (org.talend.commons.ui.swt.tableviewer.ModifiedBeanEvent)4 IListenableListListener (org.talend.commons.utils.data.list.IListenableListListener)4 ListenableListEvent (org.talend.commons.utils.data.list.ListenableListEvent)4 AbstractMetadataTableEditorView (org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView)4 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)4 HashMap (java.util.HashMap)3 EList (org.eclipse.emf.common.util.EList)2 DisposeEvent (org.eclipse.swt.events.DisposeEvent)2 DisposeListener (org.eclipse.swt.events.DisposeListener)2 Point (org.eclipse.swt.graphics.Point)2 FormAttachment (org.eclipse.swt.layout.FormAttachment)2 FormData (org.eclipse.swt.layout.FormData)2