Search in sources :

Example 16 with OutputTable

use of org.talend.designer.mapper.model.table.OutputTable in project tdi-studio-se by Talend.

the class TableEntriesManager method remove.

public void remove(ITableEntry dataMapTableEntry) {
    if (dataMapTableEntry != null) {
        mapperManager.removeLinksOf(dataMapTableEntry);
        tableEntries.remove(TableEntriesManager.buildLocation(dataMapTableEntry));
        dataMapTableEntryToProperties.remove(dataMapTableEntry);
        IDataMapTable dataMapTable = dataMapTableEntry.getParent();
        if (dataMapTableEntry instanceof IColumnEntry) {
            dataMapTableEntry.getParent().removeColumnEntry((IColumnEntry) dataMapTableEntry);
        } else if (dataMapTableEntry instanceof GlobalMapEntry) {
            if (dataMapTable instanceof OutputTable) {
                ((InputTable) dataMapTable).removeGlobalMapEntry((GlobalMapEntry) dataMapTableEntry);
            }
        } else if (dataMapTableEntry instanceof FilterTableEntry) {
            if (dataMapTable instanceof OutputTable) {
                ((OutputTable) dataMapTable).removeFilterEntry((FilterTableEntry) dataMapTableEntry);
            }
        } else if (dataMapTableEntry instanceof ExpressionFilterEntry) {
        // nothing
        } else {
            String exceptionMessage = //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "TableEntriesManager.exceptionMessage.typeIsNotValid", dataMapTableEntry.getClass().toString());
            throw new IllegalArgumentException(exceptionMessage);
        }
    }
}
Also used : FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 17 with OutputTable

use of org.talend.designer.mapper.model.table.OutputTable in project tdi-studio-se by Talend.

the class UIManager method removeUnsavedOutputsFromProcess.

private void removeUnsavedOutputsFromProcess() {
    AbstractMapComponent abstractMapComponent = getAbstractMapperManager().getAbstractMapComponent();
    IProcess process = abstractMapComponent.getProcess();
    List<OutputTable> currentOutputTablesList = mapperManager.getOutputTables();
    HashSet<String> currentTables = new HashSet<String>(currentOutputTablesList.size());
    for (OutputTable outputTable : currentOutputTablesList) {
        currentTables.add(outputTable.getName());
    }
    ExternalMapperData originalExternalData = (ExternalMapperData) mapperManager.getOriginalExternalData();
    HashSet<String> originalTableNames = new HashSet<String>();
    if (originalExternalData != null) {
        List<ExternalMapperTable> originalOutputTables = originalExternalData.getOutputTables();
        for (ExternalMapperTable outputTable : originalOutputTables) {
            originalTableNames.add(outputTable.getName());
        }
    }
    for (String currentTable : currentTables) {
        if (!originalTableNames.contains(currentTable)) {
            process.removeUniqueConnectionName(currentTable);
        }
    }
}
Also used : AbstractMapComponent(org.talend.designer.abstractmap.AbstractMapComponent) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData) IProcess(org.talend.core.model.process.IProcess) OutputTable(org.talend.designer.mapper.model.table.OutputTable) HashSet(java.util.HashSet)

Example 18 with OutputTable

use of org.talend.designer.mapper.model.table.OutputTable in project tdi-studio-se by Talend.

the class OutputDataMapTableView method createMapSettingTable.

@Override
protected void createMapSettingTable() {
    ExtendedTableModel<GlobalMapEntry> tableMapSettingEntriesModel = ((OutputTable) abstractDataMapTable).getTableMapSettingEntriesModel();
    extendedTableViewerForMapSetting = new AbstractExtendedTableViewer<GlobalMapEntry>(tableMapSettingEntriesModel, centerComposite) {

        @Override
        protected void createColumns(TableViewerCreator<GlobalMapEntry> tableViewerCreator, Table table) {
            initMapSettingColumns(tableViewerCreator);
        }

        @Override
        protected void setTableViewerCreatorOptions(TableViewerCreator<GlobalMapEntry> newTableViewerCreator) {
            super.setTableViewerCreatorOptions(newTableViewerCreator);
            newTableViewerCreator.setBorderVisible(false);
        }
    };
    if (tableMapSettingEntriesModel != null) {
        tableMapSettingEntriesModel.add(new GlobalMapEntry(abstractDataMapTable, OUTPUT_REJECT, null));
        tableMapSettingEntriesModel.add(new GlobalMapEntry(abstractDataMapTable, LOOK_UP_INNER_JOIN_REJECT, null));
        if (getOutputTable().getIsJoinTableOf() == null) {
            tableMapSettingEntriesModel.add(new GlobalMapEntry(abstractDataMapTable, SCHEMA_TYPE, null));
            if (getOutputTable().isRepository()) {
                tableMapSettingEntriesModel.add(new GlobalMapEntry(abstractDataMapTable, SCHEMA_ID, null));
            }
        }
    }
    mapSettingViewerCreator = extendedTableViewerForMapSetting.getTableViewerCreator();
    mapSettingTable = extendedTableViewerForMapSetting.getTable();
    tableForMapSettingGridData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
    mapSettingTable.setLayoutData(tableForMapSettingGridData);
    mapSettingTable.setHeaderVisible(true);
    mapSettingTable.setLinesVisible(true);
    boolean mappingSettingVisible = false;
    if (abstractDataMapTable instanceof AbstractInOutTable) {
        mappingSettingVisible = ((AbstractInOutTable) abstractDataMapTable).isActivateCondensedTool();
    }
    tableForMapSettingGridData.exclude = !mappingSettingVisible;
    mapSettingTable.setVisible(mappingSettingVisible);
    mapSettingViewerCreator.getTableViewer().setSelection(null);
    mapSettingTable.addFocusListener(new FocusListener() {

        public void focusLost(FocusEvent e) {
            mapSettingViewerCreator.getTableViewer().setSelection(null);
        }

        public void focusGained(FocusEvent e) {
        }
    });
    final TableViewer mapSettingTableViewer = mapSettingViewerCreator.getTableViewer();
    mapSettingTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            selectThisDataMapTableView();
        }
    });
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) Table(org.eclipse.swt.widgets.Table) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) OutputTable(org.talend.designer.mapper.model.table.OutputTable) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) OutputTable(org.talend.designer.mapper.model.table.OutputTable) GridData(org.eclipse.swt.layout.GridData) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry) FocusListener(org.eclipse.swt.events.FocusListener) TableViewer(org.eclipse.jface.viewers.TableViewer) AbstractExtendedTableViewer(org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer)

Example 19 with OutputTable

use of org.talend.designer.mapper.model.table.OutputTable in project tdi-studio-se by Talend.

the class OutputDataMapTableView method initColumnsOfTableColumns.

@Override
public void initColumnsOfTableColumns(final TableViewerCreator tableViewerCreatorForColumns) {
    IOConnection connection = ((OutputTable) getDataMapTable()).getConnection();
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("OutputDataMapTableView.columnTitle.expression"));
    column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
    expressionCellEditor = createExpressionCellEditor(tableViewerCreatorForColumns, column, new Zone[] { Zone.INPUTS, Zone.VARS }, false);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {

        public String get(OutputColumnTableEntry bean) {
            return bean.getExpression();
        }

        public void set(OutputColumnTableEntry bean, String value) {
            bean.setExpression(value);
            mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
            tableViewerCreatorForColumns.getTableViewer().refresh(bean);
        }
    });
    column.setModifiable(!mapperManager.componentIsReadOnly());
    //$NON-NLS-1$
    column.setDefaultInternalValue("");
    column.setWeight(COLUMN_EXPRESSION_SIZE_WEIGHT);
    column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
    column.setTitle(DataMapTableView.COLUMN_NAME);
    column.setId(DataMapTableView.ID_NAME_COLUMN);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {

        public String get(OutputColumnTableEntry bean) {
            return bean.getMetadataColumn().getLabel();
        }

        public void set(OutputColumnTableEntry bean, String value) {
            bean.getMetadataColumn().setLabel(value);
        }
    });
    column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
    if (PluginChecker.isTraceDebugPluginLoaded() && mapperManager.isTracesActive() && connection != null) {
        column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
        column.setTitle("Preview");
        column.setId(DataMapTableView.PREVIEW_COLUMN);
        column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
        column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {

            public String get(OutputColumnTableEntry bean) {
                IMetadataColumn metadataColumn = bean.getMetadataColumn();
                if (metadataColumn != null) {
                    String label = metadataColumn.getLabel();
                    TraceData preview = bean.getPreviewValue();
                    if (preview != null && preview.getData() != null) {
                        return preview.getData().get(label);
                    }
                }
                return "";
            }

            public void set(OutputColumnTableEntry bean, String value) {
            // do nothing
            }
        });
    }
    configureCellModifier(tableViewerCreatorForColumns);
}
Also used : IOConnection(org.talend.designer.mapper.external.connection.IOConnection) Zone(org.talend.designer.mapper.ui.visualmap.zone.Zone) TraceData(org.talend.core.model.process.TraceData) OutputColumnTableEntry(org.talend.designer.mapper.model.tableentry.OutputColumnTableEntry) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 20 with OutputTable

use of org.talend.designer.mapper.model.table.OutputTable in project tdi-studio-se by Talend.

the class OutputDataMapTableView method getMapSettingValueAccess.

@Override
protected IBeanPropertyAccessors<GlobalMapEntry, Object> getMapSettingValueAccess(final CellEditor cellEditor) {
    return new IBeanPropertyAccessors<GlobalMapEntry, Object>() {

        public Object get(GlobalMapEntry bean) {
            IDataMapTable parent = bean.getParent();
            OutputTable outputTable = (OutputTable) parent;
            if (cellEditor instanceof ComboBoxCellEditor) {
                ComboBoxCellEditor functComboBox = (ComboBoxCellEditor) cellEditor;
                functComboBox.setItems(new String[] { "true", "false" });
                if (OUTPUT_REJECT.equals(bean.getName())) {
                    return String.valueOf(outputTable.isReject());
                } else if (LOOK_UP_INNER_JOIN_REJECT.equals(bean.getName())) {
                    return String.valueOf(outputTable.isRejectInnerJoin());
                } else if (SCHEMA_TYPE.equals(bean.getName())) {
                    functComboBox.setItems(new String[] { BUILT_IN, REPOSITORY });
                    return outputTable.isRepository() ? REPOSITORY : BUILT_IN;
                }
            } else if (cellEditor instanceof CustomDialogCellEditor) {
                CustomDialogCellEditor customDialogCellEditor = (CustomDialogCellEditor) cellEditor;
                if (OUTPUT_REJECT.equals(bean.getName())) {
                    customDialogCellEditor.setType(CellValueType.BOOL);
                    return String.valueOf(outputTable.isReject());
                } else if (LOOK_UP_INNER_JOIN_REJECT.equals(bean.getName())) {
                    customDialogCellEditor.setType(CellValueType.BOOL);
                    return String.valueOf(outputTable.isRejectInnerJoin());
                } else if (SCHEMA_TYPE.equals(bean.getName())) {
                    customDialogCellEditor.setType(CellValueType.SCHEMA_TYPE);
                    enableDiaplayViewer(outputTable.isRepository());
                    return outputTable.isRepository() ? REPOSITORY : BUILT_IN;
                } else if (SCHEMA_ID.equals(bean.getName())) {
                    customDialogCellEditor.setType(CellValueType.SCHEMA_ID);
                    return getSchemaDisplayName(outputTable.getId());
                }
            }
            return "";
        }

        public void set(GlobalMapEntry bean, Object value) {
            if (value == null) {
                return;
            }
            IDataMapTable parent = bean.getParent();
            OutputTable outputTable = (OutputTable) parent;
            if (OUTPUT_REJECT.equals(bean.getName())) {
                outputTable.setReject(Boolean.valueOf(value.toString()));
            } else if (LOOK_UP_INNER_JOIN_REJECT.equals(bean.getName())) {
                outputTable.setRejectInnerJoin(Boolean.valueOf(value.toString()));
            } else if (SCHEMA_TYPE.equals(bean.getName())) {
                outputTable.setRepository(REPOSITORY.equals(value));
                showSchemaIDSetting(REPOSITORY.equals(value));
                enableDiaplayViewer(REPOSITORY.equals(value));
            } else if (SCHEMA_ID.equals(bean.getName())) {
                outputTable.setId(String.valueOf(value));
            }
            refreshCondensedImage(outputTable, bean.getName());
        }
    };
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) IBeanPropertyAccessors(org.talend.commons.utils.data.bean.IBeanPropertyAccessors) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Aggregations

OutputTable (org.talend.designer.mapper.model.table.OutputTable)30 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)11 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)10 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)8 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)6 ArrayList (java.util.ArrayList)5 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)5 IProcess (org.talend.core.model.process.IProcess)5 InputTable (org.talend.designer.mapper.model.table.InputTable)5 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)5 OutputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView)5 Point (org.eclipse.swt.graphics.Point)4 TableItem (org.eclipse.swt.widgets.TableItem)4 ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)4 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)4 InputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView)4 VarsDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView)4 HashMap (java.util.HashMap)3 TableViewer (org.eclipse.jface.viewers.TableViewer)3 GridData (org.eclipse.swt.layout.GridData)3