Search in sources :

Example 6 with IDataMapTable

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

the class ExpressionProposalProvider method getProposals.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.fieldassist.IContentProposalProvider#getProposals(java.lang.String, int)
     */
public IContentProposal[] getProposals(String contents, int position) {
    List<IContentProposal> proposals = new ArrayList<IContentProposal>();
    TableEntryLocation sourceEntryLocation = new TableEntryLocation();
    for (IDataMapTable table : this.tables) {
        List<IColumnEntry> dataMapTableEntries = table.getColumnEntries();
        for (IColumnEntry entrySource : dataMapTableEntries) {
            sourceEntryLocation.tableName = entrySource.getParentName();
            sourceEntryLocation.columnName = entrySource.getName();
            if (mapperManager.getUiManager().checkSourceLocationIsValid(entrySource, currentModifiedEntry)) {
                proposals.add(new EntryContentProposal(entrySource, this.currentLanguage));
            }
        }
        // for the globalMap
        if (table instanceof InputTable) {
            InputTable inputTable = (InputTable) table;
            List<GlobalMapEntry> globalMapEntries = inputTable.getGlobalMapEntries();
            for (GlobalMapEntry entry : globalMapEntries) {
                proposals.add(new EntryContentProposal(entry, this.currentLanguage));
            }
        }
    }
    for (IContentProposalProvider contentProposalProvider : otherContentProposalProviders) {
        proposals.addAll(Arrays.asList(contentProposalProvider.getProposals(contents, position)));
    }
    IContentProposal[] res = new IContentProposal[proposals.size()];
    res = proposals.toArray(res);
    return res;
}
Also used : IContentProposalProvider(org.eclipse.jface.fieldassist.IContentProposalProvider) ArrayList(java.util.ArrayList) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) IContentProposal(org.eclipse.jface.fieldassist.IContentProposal) InputTable(org.talend.designer.mapper.model.table.InputTable) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

Example 7 with IDataMapTable

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

the class ExpressionProposalProvider method getVariables.

public List<Variable> getVariables() {
    List<Variable> variables = new ArrayList<Variable>();
    for (IDataMapTable table : this.tables) {
        List<IColumnEntry> dataMapTableEntries = table.getColumnEntries();
        for (IColumnEntry entrySource : dataMapTableEntries) {
            String variable = null;
            if (table instanceof VarsTable) {
                variable = entrySource.getExpression();
            } else {
                variable = LanguageProvider.getCurrentLanguage().getLocation(entrySource.getParentName(), entrySource.getName());
            }
            String talendType = null;
            boolean nullable = true;
            if (entrySource instanceof AbstractInOutTableEntry) {
                talendType = ((AbstractInOutTableEntry) entrySource).getMetadataColumn().getTalendType();
                nullable = ((AbstractInOutTableEntry) entrySource).getMetadataColumn().isNullable();
            } else if (entrySource instanceof VarTableEntry) {
                talendType = ((VarTableEntry) entrySource).getType();
                nullable = ((VarTableEntry) entrySource).isNullable();
            }
            if (talendType != null) {
                if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
                    boolean exist = false;
                    for (Variable v : variables) {
                        if (variable != null && v.getName() != null && v.getName().trim().equals(variable.trim())) {
                            exist = true;
                            break;
                        }
                    }
                    if (!exist) {
                        variables.add(new Variable(variable, JavaTypesManager.getDefaultValueFromJavaIdType(talendType, nullable).toString(), talendType, nullable));
                    }
                } else {
                    //$NON-NLS-1$
                    variables.add(new Variable(variable, "", talendType, nullable));
                }
            }
        }
    }
    return variables;
}
Also used : VarsTable(org.talend.designer.mapper.model.table.VarsTable) Variable(org.talend.commons.runtime.model.expressionbuilder.Variable) ArrayList(java.util.ArrayList) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) AbstractInOutTableEntry(org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry)

Example 8 with IDataMapTable

use of org.talend.designer.abstractmap.model.table.IDataMapTable 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)

Example 9 with IDataMapTable

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

the class MapperUI method getMinimizedButtonState.

/**
     * DOC amaumont Comment method "getCommonMinimizedStateOfTables".
     * 
     * @param tables
     * @return new Boolean(true) if button state should be to minimize, else new Boolean(false)
     */
private Boolean getMinimizedButtonState(List<? extends AbstractDataMapTable> tables) {
    boolean allTablesAreMinimized = true;
    boolean allTablesAreNotMinimized = true;
    for (IDataMapTable table : tables) {
        if (table.isMinimized()) {
            allTablesAreNotMinimized = false;
        } else {
            allTablesAreMinimized = false;
        }
    }
    if (allTablesAreMinimized) {
        return new Boolean(true);
    } else if (allTablesAreNotMinimized) {
        return new Boolean(false);
    }
    return new Boolean(false);
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable)

Example 10 with IDataMapTable

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

the class DropContextAnalyzer method checkZoonTarget.

private boolean checkZoonTarget() {
    IDataMapTable dataMapTable = dataMapTableViewTarget.getDataMapTable();
    if (zoneTarget == Zone.OUTPUTS) {
        OutputTable outputTable = (OutputTable) dataMapTable;
        if (outputTable.isErrorRejectTable()) {
            if (currentTableTarget != null && event != null) {
                if (event.item instanceof TableItem) {
                    Object data = event.item.getData();
                    if (data instanceof OutputColumnTableEntry) {
                        String label = ((OutputColumnTableEntry) data).getName();
                        if (mapperManager.ERROR_REJECT_MESSAGE.equals(label) || mapperManager.ERROR_REJECT_STACK_TRACE.equals(label)) {
                            return false;
                        }
                    }
                }
            }
        }
        boolean useRepositoryMeta = (outputTable.isRepository()) || (outputTable.getId() != null && !"".equals(outputTable.getId()));
        // for join table if main table use repository metadata
        if (!useRepositoryMeta && outputTable.getIsJoinTableOf() != null && !"".equals(outputTable.getIsJoinTableOf())) {
            OutputTable mainTable = mapperManager.getOutputTableByName(outputTable.getIsJoinTableOf());
            if (mainTable != null) {
                useRepositoryMeta = mainTable.getId() != null && !"".equals(mainTable.getId());
            }
        }
        if (useRepositoryMeta && currentStyledTextTarget != null) {
            return true;
        }
        if (useRepositoryMeta && isCursorOverHeader || useRepositoryMeta && !isCursorOverExpressionCell) {
            return false;
        }
    }
    return true;
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) OutputColumnTableEntry(org.talend.designer.mapper.model.tableentry.OutputColumnTableEntry) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Aggregations

IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)39 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)14 ArrayList (java.util.ArrayList)9 OutputTable (org.talend.designer.mapper.model.table.OutputTable)8 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)7 OutputTable (org.talend.designer.dbmap.model.table.OutputTable)7 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)6 InputTable (org.talend.designer.dbmap.model.table.InputTable)5 FilterTableEntry (org.talend.designer.dbmap.model.tableentry.FilterTableEntry)5 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)5 List (java.util.List)4 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)4 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)4 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)4 OutputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView)4 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)4 InputTable (org.talend.designer.mapper.model.table.InputTable)4 VarsTable (org.talend.designer.mapper.model.table.VarsTable)4 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)4 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)3