Search in sources :

Example 6 with DataMapTableView

use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView 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 7 with DataMapTableView

use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.

the class MapperUI method createWindow.

/**
     * DOC amaumont Comment method "createUI".
     * 
     * @param display
     */
public Shell createWindow(final Display display, MapperModel model) {
    Shell activeShell = display.getActiveShell();
    Shell mapperShell = null;
    int style = SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX | SWT.APPLICATION_MODAL | SWT.RESIZE;
    if (activeShell == null) {
        mapperShell = new Shell(mapperShell, style);
    } else {
        mapperShell = new Shell(activeShell, style);
    }
    this.mapperUIParent = mapperShell;
    final Shell mapperShellFinal = mapperShell;
    mapperShell.addShellListener(new ShellListener() {

        public void shellActivated(ShellEvent e) {
        }

        public void shellClosed(ShellEvent e) {
            UIManager uiManager = mapperManager.getUiManager();
            if (uiManager.getMapperResponse() == SWT.NONE) {
                for (DataMapTableView dataMapTableView : uiManager.getInputsTablesView()) {
                    dataMapTableView.notifyFocusLost();
                }
                for (DataMapTableView dataMapTableView : uiManager.getOutputsTablesView()) {
                    dataMapTableView.notifyFocusLost();
                }
                for (DataMapTableView dataMapTableView : uiManager.getVarsTablesView()) {
                    dataMapTableView.notifyFocusLost();
                }
                uiManager.setMapperResponse(SWT.CANCEL);
                uiManager.prepareClosing(uiManager.getMapperResponse());
            }
            if (!mapperManager.componentIsReadOnly() && mapperManager.isDataChanged() && !mapperManager.getUiManager().isCloseWithoutPrompt()) {
                boolean closeWindow = MessageDialog.openConfirm(mapperShellFinal, //$NON-NLS-1$
                Messages.getString("MapperUI.CancelWithoutSaveModifications.Title"), //$NON-NLS-1$
                Messages.getString("MapperUI.CancelWithoutSaveModifications.Message"));
                if (!closeWindow) {
                    e.doit = false;
                } else {
                    mapperManager.getAbstractMapComponent().setExternalData(mapperManager.getOriginalExternalData());
                    mapperManager.getUiManager().prepareClosing(SWT.CANCEL);
                }
            }
        }

        public void shellDeactivated(ShellEvent e) {
        }

        public void shellDeiconified(ShellEvent e) {
        }

        public void shellIconified(ShellEvent e) {
        }
    });
    MapperComponent component = (MapperComponent) mapperManager.getAbstractMapComponent();
    ExternalMapperUiProperties uiProperties = mapperManager.getUiManager().getUiProperties();
    mapperShell.setImage(CoreImageProvider.getComponentIcon(component.getComponent(), ICON_SIZE.ICON_32));
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    String productName = brandingService.getFullProductName();
    mapperShell.setText(Messages.getString("MapperMain.ShellTitle", productName, component.getComponent().getName(), //$NON-NLS-1$
    component.getUniqueName()));
    Rectangle boundsMapper = uiProperties.getBoundsMapper();
    if (uiProperties.isShellMaximized()) {
        mapperShell.setMaximized(uiProperties.isShellMaximized());
    } else {
        if (uiProperties.getBoundsMapper().equals(ExternalMapperUiProperties.DEFAULT_BOUNDS_MAPPER)) {
            mapperShell.setMaximized(true);
        // boundsMapper = display.getBounds(); //no need this, will cause the full problems.
        } else {
            // // move shell at outer of display zone to avoid visual effect on loading
            // Rectangle tmpBoundsMapper = new Rectangle(-boundsMapper.width, boundsMapper.y, boundsMapper.width,
            // boundsMapper.height);
            // shell.setBounds(tmpBoundsMapper);
            boundsMapper = uiProperties.getBoundsMapper();
            if (boundsMapper.x < 0) {
                boundsMapper.x = 0;
            }
            if (boundsMapper.y < 0) {
                boundsMapper.y = 0;
            }
            mapperShell.setBounds(boundsMapper);
        }
    }
    createCompositeContent(model);
    mapperShell.open();
    return mapperShell;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ExternalMapperUiProperties(org.talend.designer.mapper.external.data.ExternalMapperUiProperties) ShellListener(org.eclipse.swt.events.ShellListener) Rectangle(org.eclipse.swt.graphics.Rectangle) ShellEvent(org.eclipse.swt.events.ShellEvent) UIManager(org.talend.designer.mapper.managers.UIManager) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IBrandingService(org.talend.core.ui.branding.IBrandingService) MapperComponent(org.talend.designer.mapper.MapperComponent)

Example 8 with DataMapTableView

use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView 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 9 with DataMapTableView

use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.

the class MapperUI method createVarsZoneWithTables.

private void createVarsZoneWithTables(MapperModel mapperModel, final Display display) {
    Control previousControl;
    // Feature TDI-26691 : Add search option
    SearchZone searchZone = new SearchZone(datasFlowViewSashForm, SWT.NONE, mapperManager);
    searchZone.createSearchZone();
    sc2 = new ScrolledComposite(searchZone, getBorder() | SWT.H_SCROLL | SWT.V_SCROLL);
    GridData sc2GridData = new GridData(GridData.FILL_BOTH);
    sc2.setLayoutData(sc2GridData);
    varsTableZoneView = new VarsTableZoneView(sc2, getBorder(), mapperManager);
    sc2.setContent(varsTableZoneView);
    sc2.setBackgroundMode(SWT.INHERIT_DEFAULT);
    sc2.setExpandHorizontal(true);
    sc2.addControlListener(new ControlListener() {

        public void controlMoved(ControlEvent e) {
        // System.out.println("sc2 controlMoved");
        }

        public void controlResized(ControlEvent e) {
            // System.out.println("sc2 controlResized");
            onSashResized(display);
        }
    });
    sc2MSListener = new MouseScrolledListener(mapperManager.getUiManager(), sc2);
    varsTableZoneView.initInsertionIndicator();
    // final Composite finalTablesZoneViewVars = tablesZoneViewVars;
    previousControl = null;
    for (VarsTable varsTable : mapperModel.getVarsDataMapTables()) {
        DataMapTableView dataMapTableView = new VarsDataMapTableView(varsTableZoneView, SWT.BORDER, varsTable, mapperManager);
        FormData formData = new FormData();
        formData.left = new FormAttachment(0, 0);
        formData.right = new FormAttachment(100, 0);
        formData.top = new FormAttachment(previousControl);
        dataMapTableView.setLayoutData(formData);
        previousControl = dataMapTableView;
        dataMapTableView.minimizeTable(varsTable.isMinimized());
        dataMapTableView.registerStyledExpressionEditor(getTabFolderEditors().getStyledTextHandler());
    // dataMapTableView.fillMinimumSize(false);
    }
    varsTableZoneView.setSize(varsTableZoneView.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    sc2MSListener.addMouseWheelListener(sc2);
}
Also used : FormData(org.eclipse.swt.layout.FormData) VarsTable(org.talend.designer.mapper.model.table.VarsTable) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) MouseScrolledListener(org.talend.designer.abstractmap.ui.listener.MouseScrolledListener) SearchZone(org.talend.designer.mapper.ui.visualmap.zone.SearchZone) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) Control(org.eclipse.swt.widgets.Control) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlListener(org.eclipse.swt.events.ControlListener) ControlEvent(org.eclipse.swt.events.ControlEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) VarsTableZoneView(org.talend.designer.mapper.ui.visualmap.zone.scrollable.VarsTableZoneView)

Example 10 with DataMapTableView

use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.

the class MapperUI method selectFirstInOutTablesView.

private void selectFirstInOutTablesView() {
    List<DataMapTableView> inputsTablesView = mapperManager.getUiManager().getInputsTablesView();
    UIManager uiManager = mapperManager.getUiManager();
    if (inputsTablesView.size() > 0) {
        uiManager.selectDataMapTableView(inputsTablesView.get(0), true, false);
    }
    List<DataMapTableView> outputsTablesView = mapperManager.getUiManager().getOutputsTablesView();
    if (outputsTablesView.size() > 0) {
        uiManager.selectDataMapTableView(outputsTablesView.get(0), true, false);
    }
}
Also used : UIManager(org.talend.designer.mapper.managers.UIManager) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)

Aggregations

DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)47 InputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView)24 OutputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView)24 VarsDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView)24 Point (org.eclipse.swt.graphics.Point)11 OutputTable (org.talend.designer.mapper.model.table.OutputTable)10 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)9 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)9 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)8 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)7 ArrayList (java.util.ArrayList)6 FormData (org.eclipse.swt.layout.FormData)6 UIManager (org.talend.designer.mapper.managers.UIManager)6 ExpressionFilterEntry (org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)6 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)5 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)5 TableEntryLocation (org.talend.designer.mapper.model.tableentry.TableEntryLocation)5 Zone (org.talend.designer.mapper.ui.visualmap.zone.Zone)5 List (java.util.List)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4