Search in sources :

Example 1 with TablesZoneView

use of org.talend.designer.mapper.ui.visualmap.zone.scrollable.TablesZoneView in project tdi-studio-se by Talend.

the class MapperManager method addRejectOutput.

public void addRejectOutput() {
    String baseName = ERROR_REJECT;
    IProcess process = getAbstractMapComponent().getProcess();
    String tableName = baseName;
    if (!process.checkValidConnectionName(baseName) && process instanceof IProcess2) {
        final String uniqueName = ((IProcess2) process).generateUniqueConnectionName("row", baseName);
        tableName = uniqueName;
        ((IProcess2) process).addUniqueConnectionName(uniqueName);
    } else if (process instanceof IProcess2) {
        tableName = baseName;
        ((IProcess2) process).addUniqueConnectionName(baseName);
    }
    IMetadataTable metadataTable = getNewMetadataTable();
    metadataTable.setTableName(tableName);
    MetadataColumn errorMessageCol = new MetadataColumn();
    errorMessageCol.setLabel(ERROR_REJECT_MESSAGE);
    errorMessageCol.setTalendType(DesignerPlugin.getDefault().getPreferenceStore().getString(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE));
    errorMessageCol.setNullable(true);
    errorMessageCol.setOriginalDbColumnName(ERROR_REJECT_MESSAGE);
    errorMessageCol.setReadOnly(true);
    errorMessageCol.setCustom(true);
    errorMessageCol.setCustomId(0);
    metadataTable.getListColumns().add(errorMessageCol);
    MetadataColumn errorStackTrace = new MetadataColumn();
    errorStackTrace.setLabel(ERROR_REJECT_STACK_TRACE);
    errorStackTrace.setTalendType(DesignerPlugin.getDefault().getPreferenceStore().getString(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE));
    errorStackTrace.setNullable(true);
    errorStackTrace.setOriginalDbColumnName(ERROR_REJECT_STACK_TRACE);
    errorStackTrace.setReadOnly(true);
    errorStackTrace.setCustom(true);
    errorStackTrace.setCustomId(1);
    metadataTable.getListColumns().add(errorStackTrace);
    OutputTable abstractDataMapTable = new OutputTable(this, metadataTable, tableName);
    abstractDataMapTable.setErrorRejectTable(true);
    abstractDataMapTable.initFromExternalData(null);
    TablesZoneView tablesZoneViewOutputs = uiManager.getTablesZoneViewOutputs();
    DataMapTableView rejectDataMapTableView = uiManager.createNewOutputTableView(null, abstractDataMapTable, tablesZoneViewOutputs);
    tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    List<DataMapTableView> outputsTablesView = uiManager.getOutputsTablesView();
    int sizeList = outputsTablesView.size();
    for (int i = 0; i < sizeList; i++) {
        if (i + 1 < sizeList) {
            FormData formData = (FormData) outputsTablesView.get(i + 1).getLayoutData();
            formData.top = new FormAttachment(outputsTablesView.get(i));
        }
    }
    CustomTableManager.addCustomManagementToTable(uiManager.getOutputMetaEditorView(), true);
    tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    tablesZoneViewOutputs.layout();
    uiManager.moveOutputScrollBarZoneToMax();
    uiManager.refreshBackground(true, false);
    uiManager.selectDataMapTableView(rejectDataMapTableView, true, false);
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) FormData(org.eclipse.swt.layout.FormData) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) IProcess2(org.talend.core.model.process.IProcess2) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) TablesZoneView(org.talend.designer.mapper.ui.visualmap.zone.scrollable.TablesZoneView) IProcess(org.talend.core.model.process.IProcess) FormAttachment(org.eclipse.swt.layout.FormAttachment) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 2 with TablesZoneView

use of org.talend.designer.mapper.ui.visualmap.zone.scrollable.TablesZoneView in project tdi-studio-se by Talend.

the class MapperManager method addOutput.

/**
     * DOC amaumont Comment method "addOutput".
     */
public void addOutput() {
    String joinTableName = null;
    OutputTable abstractDataMapTable = null;
    String name = uiManager.openNewOutputCreationDialog();
    if (name == null) {
        return;
    }
    String[] split = name.split(uiManager.NAME_SEPARATOR);
    String tableName = split[0];
    boolean isCreatingJoinTable = split.length == 2;
    if (isCreatingJoinTable) {
        joinTableName = split[1];
    }
    IProcess process = getAbstractMapComponent().getProcess();
    OutputTable orignalOutputTable = null;
    if (isCreatingJoinTable) {
        orignalOutputTable = getOutputTableByName(tableName);
        if (orignalOutputTable != null) {
            IMetadataTable metadataTable = orignalOutputTable.getMetadataTable();
            if (metadataTable != null) {
                process.addUniqueConnectionName(joinTableName);
                abstractDataMapTable = new OutputTable(this, metadataTable, joinTableName);
                abstractDataMapTable.setIsJoinTableOf(tableName);
            }
        }
    } else {
        process.addUniqueConnectionName(tableName);
        IMetadataTable metadataTable = getNewMetadataTable();
        metadataTable.setTableName(tableName);
        abstractDataMapTable = new OutputTable(this, metadataTable, tableName);
    }
    if (abstractDataMapTable == null) {
        return;
    }
    abstractDataMapTable.initFromExternalData(null);
    List<DataMapTableView> outputsTablesView = uiManager.getOutputsTablesView();
    int sizeOutputsView = outputsTablesView.size();
    Control lastChild = null;
    if (sizeOutputsView - 1 >= 0) {
        lastChild = outputsTablesView.get(sizeOutputsView - 1);
    }
    TablesZoneView tablesZoneViewOutputs = uiManager.getTablesZoneViewOutputs();
    DataMapTableView dataMapTableView = uiManager.createNewOutputTableView(lastChild, abstractDataMapTable, tablesZoneViewOutputs);
    tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    tablesZoneViewOutputs.layout();
    uiManager.moveOutputScrollBarZoneToMax();
    uiManager.refreshBackground(true, false);
    tablesZoneViewOutputs.layout();
    uiManager.selectDataMapTableView(dataMapTableView, true, false);
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) Control(org.eclipse.swt.widgets.Control) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) TablesZoneView(org.talend.designer.mapper.ui.visualmap.zone.scrollable.TablesZoneView) IProcess(org.talend.core.model.process.IProcess) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 3 with TablesZoneView

use of org.talend.designer.mapper.ui.visualmap.zone.scrollable.TablesZoneView in project tdi-studio-se by Talend.

the class InsertionIndicator method updatePosition.

/**
     * Update position of the indicator at top of <code>itemIndexTarget</code> position of the
     * <code>draggableTable</code>.
     * 
     * @param currentTable
     * @param itemIndexTarget
     */
public void updatePosition(Table currentTable, int itemIndexTarget) {
    //        System.out.println(itemIndexTarget);
    this.draggableTable = currentTable;
    removeTablePaintListener();
    if (tablePaintListener == null) {
        tablePaintListener = new Listener() {

            public void handleEvent(Event event) {
                drawIndicatorLineInTable(event);
            }
        };
    }
    FormLayout formLayout = tablesZoneViewParent.getLayout();
    UIManager uiManager = mapperManager.getUiManager();
    TablesZoneView tablesZoneViewOutputs = uiManager.getTablesZoneViewOutputs();
    Display display = tablesZoneViewOutputs.getDisplay();
    Point tablePositionRefZone = display.map(currentTable, tablesZoneViewParent, new Point(0, 0));
    FormData formDataLeftArrow = (FormData) leftArrowDraggingIndicator.getLayoutData();
    FormData formDataRightArrow = (FormData) rightArrowDraggingIndicator.getLayoutData();
    ScrollBar verticalBar = currentTable.getVerticalBar();
    // System.out.println("verticalBar.getSelection()="+verticalBar.getSelection() + "
    // currentTable.getItemHeight()="+currentTable.getItemHeight());
    DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentTable);
    int indicYPositionRefZone = 0;
    if (WindowSystem.isGTK()) {
        int offsetVerticalBar = -verticalBar.getSelection();
        if (itemIndexTarget == 0) {
            indicYPositionRefTable = 0 + offsetVerticalBar;
        } else {
            indicYPositionRefTable = itemIndexTarget * (currentTable.getItemHeight() + 2) + offsetVerticalBar;
        }
        // System.out.println("indicYPositionRefTable="+indicYPositionRefTable);
        indicYPositionRefZone = indicYPositionRefTable + tablePositionRefZone.y + formLayout.marginTop - HEIGHT_INDICATOR / 2;
        indicYPositionRefZone -= currentTable.getItemHeight() + 1;
    // System.out.println("indicYPositionRefZone="+indicYPositionRefZone);
    } else {
        int offsetVerticalBar = -verticalBar.getSelection() * currentTable.getItemHeight();
        if (itemIndexTarget == 0) {
            indicYPositionRefTable = 0 + offsetVerticalBar;
        } else {
            indicYPositionRefTable = itemIndexTarget * currentTable.getItemHeight() - 1 + offsetVerticalBar;
        }
        Point point = currentTable.getDisplay().map(currentTable, tablesZoneViewParent, new Point(0, indicYPositionRefTable));
        indicYPositionRefZone = point.y + 5;
    }
    Rectangle boundsTableView = dataMapTableView.getBounds();
    int testValue = boundsTableView.y + boundsTableView.height - formLayout.marginTop - HEIGHT_INDICATOR / 2 - 5;
    if (indicYPositionRefZone > testValue) {
        indicYPositionRefZone = testValue;
    }
    currentTable.addListener(SWT.Paint, tablePaintListener);
    if (lastIndicYPositionRefZone != indicYPositionRefZone) {
        formDataLeftArrow.top.offset = indicYPositionRefZone;
        formDataRightArrow.top.offset = indicYPositionRefZone;
        formDataRightArrow.left.offset = currentTable.getSize().x + 2;
        currentTable.redraw();
        tablesZoneViewParent.layout();
    }
    lastIndicYPositionRefZone = indicYPositionRefZone;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Listener(org.eclipse.swt.widgets.Listener) Rectangle(org.eclipse.swt.graphics.Rectangle) Event(org.eclipse.swt.widgets.Event) UIManager(org.talend.designer.mapper.managers.UIManager) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) Point(org.eclipse.swt.graphics.Point) TablesZoneView(org.talend.designer.mapper.ui.visualmap.zone.scrollable.TablesZoneView) ScrollBar(org.eclipse.swt.widgets.ScrollBar) Point(org.eclipse.swt.graphics.Point) Display(org.eclipse.swt.widgets.Display)

Example 4 with TablesZoneView

use of org.talend.designer.mapper.ui.visualmap.zone.scrollable.TablesZoneView in project tdi-studio-se by Talend.

the class UIManager method minimizeAllTables.

public void minimizeAllTables(Zone zone, boolean minimize, ToolItem minimizeButton) {
    List<DataMapTableView> tablesView = null;
    TablesZoneView tablesZoneView = null;
    if (zone == Zone.INPUTS) {
        tablesView = mapperManager.getUiManager().getInputsTablesView();
        tablesZoneView = getTablesZoneViewInputs();
    } else if (zone == Zone.OUTPUTS) {
        tablesZoneView = getTablesZoneViewOutputs();
        tablesView = mapperManager.getUiManager().getOutputsTablesView();
    } else {
        //$NON-NLS-1$
        throw new RuntimeException("Case not found:" + zone);
    }
    Layout layout = tablesZoneView.getLayout();
    try {
        tablesZoneView.setLayout(null);
        for (DataMapTableView view : tablesView) {
            view.minimizeTable(minimize);
        }
    } catch (RuntimeException e) {
        ExceptionHandler.process(e);
    } finally {
        tablesZoneView.setLayout(layout);
    }
    tablesZoneView.layout();
    for (DataMapTableView view : tablesView) {
        view.layout();
    }
    resizeTablesZoneViewAtComputedSize(zone);
    moveScrollBarZoneAtSelectedTable(zone);
}
Also used : Layout(org.eclipse.swt.widgets.Layout) 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) TablesZoneView(org.talend.designer.mapper.ui.visualmap.zone.scrollable.TablesZoneView)

Example 5 with TablesZoneView

use of org.talend.designer.mapper.ui.visualmap.zone.scrollable.TablesZoneView in project tdi-studio-se by Talend.

the class UIManager method resizeTablesZoneViewAtComputedSize.

/**
     * recalculate parent size don't hide DataMapTableView when resized.
     */
public void resizeTablesZoneViewAtComputedSize(Zone zone) {
    TablesZoneView tablesZoneView = null;
    if (zone == Zone.INPUTS) {
        tablesZoneView = getTablesZoneViewInputs();
    } else if (zone == Zone.OUTPUTS) {
        tablesZoneView = getTablesZoneViewOutputs();
    } else if (zone == Zone.VARS) {
        tablesZoneView = getTablesZoneViewVars();
    }
    tablesZoneView.setSize(tablesZoneView.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
Also used : TablesZoneView(org.talend.designer.mapper.ui.visualmap.zone.scrollable.TablesZoneView)

Aggregations

TablesZoneView (org.talend.designer.mapper.ui.visualmap.zone.scrollable.TablesZoneView)6 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)5 FormData (org.eclipse.swt.layout.FormData)2 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)2 IProcess (org.talend.core.model.process.IProcess)2 OutputTable (org.talend.designer.mapper.model.table.OutputTable)2 Point (org.eclipse.swt.graphics.Point)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 Control (org.eclipse.swt.widgets.Control)1 Display (org.eclipse.swt.widgets.Display)1 Event (org.eclipse.swt.widgets.Event)1 Layout (org.eclipse.swt.widgets.Layout)1 Listener (org.eclipse.swt.widgets.Listener)1 ScrollBar (org.eclipse.swt.widgets.ScrollBar)1 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)1 MetadataColumn (org.talend.core.model.metadata.MetadataColumn)1 IProcess2 (org.talend.core.model.process.IProcess2)1 UIManager (org.talend.designer.mapper.managers.UIManager)1