Search in sources :

Example 1 with TraceData

use of org.talend.core.model.process.TraceData 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 2 with TraceData

use of org.talend.core.model.process.TraceData in project tdi-studio-se by Talend.

the class InputDataMapTableView method initColumnsOfTableColumns.

@Override
public void initColumnsOfTableColumns(final TableViewerCreator tableViewerCreatorForColumns) {
    boolean isMainConnection = ((InputTable) getDataMapTable()).isMainConnection();
    TableViewerCreatorColumn column = null;
    if (!isMainConnection) {
        column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
        //$NON-NLS-1$
        column.setTitle(Messages.getString("InputDataMapTableView.columnTitle.Expr"));
        column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
        expressionCellEditor = createExpressionCellEditor(tableViewerCreatorForColumns, column, new Zone[] { Zone.INPUTS }, false);
        column.setBeanPropertyAccessors(new IBeanPropertyAccessors<InputColumnTableEntry, String>() {

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

            public void set(InputColumnTableEntry bean, String value) {
                // System.out.println("value='" + value + "'");
                bean.setExpression(value);
                InputTable inputTable = getInputTable();
                boolean tableHasAtLeastOneHashKey = mapperManager.isTableHasAtLeastOneHashKey(inputTable);
                if (!tableHasAtLeastOneHashKey) {
                    IUIMatchingMode matchingMode = inputTable.getMatchingMode();
                    if (matchingMode != TMAP_MATCHING_MODE.ALL_ROWS) {
                        inputTable.setMatchingMode(TMAP_MATCHING_MODE.ALL_ROWS);
                        refreshCondensedImage(inputTable, MATCH_MODEL_SETTING);
                    }
                } else {
                    IUIMatchingMode matchingMode = inputTable.getMatchingMode();
                    if (matchingMode == TMAP_MATCHING_MODE.ALL_ROWS) {
                        IUIMatchingMode newMatchModel = previousMatchingModeSelected == null || previousMatchingModeSelected == TMAP_MATCHING_MODE.ALL_ROWS ? TMAP_MATCHING_MODE.UNIQUE_MATCH : previousMatchingModeSelected;
                        inputTable.setMatchingMode(newMatchModel);
                        refreshCondensedImage(inputTable, MATCH_MODEL_SETTING);
                    }
                    mapperManager.getUiManager().setStatusBarValues(STATUS.EMPTY, null);
                }
                mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true, true);
                if (!mapperManager.isCheckSyntaxEnabled()) {
                    mapperManager.getUiManager().applyActivatedCellEditors(tableViewerCreatorForColumns);
                    Display.getDefault().asyncExec(new Runnable() {

                        public void run() {
                            mapperManager.getProblemsManager().checkLookupExpressionProblem();
                        }
                    });
                }
            }
        });
        column.setModifiable(!mapperManager.componentIsReadOnly());
        //$NON-NLS-1$
        column.setDefaultInternalValue("");
        column.setWeight(COLUMN_EXPRESSION_SIZE_WEIGHT);
        column.setImageProvider(new IColumnImageProvider<InputColumnTableEntry>() {

            public Image getImage(InputColumnTableEntry bean) {
                if (bean.getExpression() != null && !bean.getExpression().trim().equals("")) {
                    //$NON-NLS-1$
                    if (mapperManager.isAdvancedMap()) {
                        return ImageProviderMapper.getImage(ImageInfo.LOOKUP_KEY_ICON);
                    } else {
                        return null;
                    }
                } else {
                    return null;
                }
            }
        });
    }
    column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
    column.setTitle(DataMapTableView.COLUMN_NAME);
    column.setId(DataMapTableView.ID_NAME_COLUMN);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<InputColumnTableEntry, String>() {

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

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

            public String get(InputColumnTableEntry 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(InputColumnTableEntry bean, String value) {
            // do nothing
            }
        });
    }
}
Also used : Zone(org.talend.designer.mapper.ui.visualmap.zone.Zone) IUIMatchingMode(org.talend.designer.mapper.model.table.IUIMatchingMode) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) Image(org.eclipse.swt.graphics.Image) EImage(org.talend.commons.ui.runtime.image.EImage) InputTable(org.talend.designer.mapper.model.table.InputTable) TraceData(org.talend.core.model.process.TraceData) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)

Example 3 with TraceData

use of org.talend.core.model.process.TraceData in project tdi-studio-se by Talend.

the class DataMapTableEntry method getPreviewValue.

public TraceData getPreviewValue() {
    if (getParent() instanceof AbstractInOutTable) {
        AbstractInOutTable abstractTable = (AbstractInOutTable) getParent();
        if (abstractTable.getConnection() != null) {
            IConnection connection = abstractTable.getConnection().getConnecion();
            if (connection != null) {
                Map<String, TraceData> traceData = connection.getTraceData();
                if (traceData != null) {
                    if (abstractTable instanceof OutputTable) {
                        OutputTable output = (OutputTable) abstractTable;
                        String key = null;
                        if (output.getIsJoinTableOf() != null) {
                            key = output.getIsJoinTableOf() + ":" + output.getName();
                        } else if (hasJoinedTable(output)) {
                            key = output.getName() + "[MAIN]";
                        } else {
                            // single output
                            key = output.getName();
                        }
                        return traceData.get(key);
                    } else {
                        return traceData.get(abstractTable.getName());
                    }
                }
            }
        }
    }
    return null;
}
Also used : AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) TraceData(org.talend.core.model.process.TraceData) IConnection(org.talend.core.model.process.IConnection) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 4 with TraceData

use of org.talend.core.model.process.TraceData in project tdi-studio-se by Talend.

the class ConnectionTraceEditPart method refreshVisuals.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
     */
@Override
protected void refreshVisuals() {
    ConnectionPart connectionPart;
    connectionPart = (ConnectionPart) getParent();
    Connection conn = (Connection) connectionPart.getModel();
    IElementParameter element = conn.getElementParameter(EParameterName.TRACES_CONNECTION_ENABLE.getName());
    Boolean flag = false;
    if (element != null) {
        flag = (Boolean) element.getValue();
    }
    ConnectionTraceFigure htmlFigure = (ConnectionTraceFigure) getFigure();
    ConnectionTrace connectionTrace = (ConnectionTrace) getModel();
    TraceData trace = connectionTrace.getTrace();
    if (trace == null) {
        Point offset = conn.getConnectionLabel().getOffset();
        connectionTrace.getOffset().x = offset.x;
        connectionTrace.getOffset().y = offset.y;
        this.removeEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE);
    } else {
        this.installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ConnTextMovePolicy());
    }
    htmlFigure.setTraceData(trace, flag, conn.checkTraceShowEnable());
    Dimension size = htmlFigure.getPreferredSize();
    connectionTrace.setSize(size);
    String connectionName = ((Connection) connectionPart.getModel()).getConnectionLabel().getLabelText();
    Point offset = ((ConnectionTrace) getModel()).getOffset();
    ConnectionTraceConstraint constraint = new //$NON-NLS-1$
    ConnectionTraceConstraint(//$NON-NLS-1$
    connectionName, //$NON-NLS-1$
    size, //$NON-NLS-1$
    "center", //$NON-NLS-1$
    offset, (PolylineConnection) connectionPart.getFigure());
    connectionPart.setLayoutConstraint(this, getFigure(), constraint);
}
Also used : PolylineConnection(org.eclipse.draw2d.PolylineConnection) IElementParameter(org.talend.core.model.process.IElementParameter) TraceData(org.talend.core.model.process.TraceData) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 5 with TraceData

use of org.talend.core.model.process.TraceData in project tdi-studio-se by Talend.

the class ConnectionTest method testSetTraceData.

@Test
public void testSetTraceData() {
    Map<String, TraceData> map = new HashMap<String, TraceData>();
    TraceData data = new TraceData();
    map.put("key", data);
    connection.setTraceData(map);
    TraceData value = connection.getTraceData().get("key");
    assertEquals(data, value);
    connection.setTraceData(null);
    assertNull(connection.getTraceData());
}
Also used : HashMap(java.util.HashMap) TraceData(org.talend.core.model.process.TraceData) Test(org.junit.Test)

Aggregations

TraceData (org.talend.core.model.process.TraceData)5 TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)2 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)2 OutputTable (org.talend.designer.mapper.model.table.OutputTable)2 Zone (org.talend.designer.mapper.ui.visualmap.zone.Zone)2 HashMap (java.util.HashMap)1 PolylineConnection (org.eclipse.draw2d.PolylineConnection)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 Point (org.eclipse.draw2d.geometry.Point)1 Image (org.eclipse.swt.graphics.Image)1 Test (org.junit.Test)1 EImage (org.talend.commons.ui.runtime.image.EImage)1 IConnection (org.talend.core.model.process.IConnection)1 IElementParameter (org.talend.core.model.process.IElementParameter)1 IOConnection (org.talend.designer.mapper.external.connection.IOConnection)1 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)1 IUIMatchingMode (org.talend.designer.mapper.model.table.IUIMatchingMode)1 InputTable (org.talend.designer.mapper.model.table.InputTable)1 InputColumnTableEntry (org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)1 OutputColumnTableEntry (org.talend.designer.mapper.model.tableentry.OutputColumnTableEntry)1