Search in sources :

Example 1 with InputDataMapTableView

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

the class MapperUI method init.

public void init(MapperModel mapperModel) {
    // long time1 = System.currentTimeMillis();
    // CommandStack commandStack = new CommandStackForComposite(this.mapperUIParent);
    // mapperManager.setCommandStack(commandStack);
    final UIManager uiManager = mapperManager.getUiManager();
    final ExternalDbMapUiProperties uiProperties = uiManager.getUiProperties();
    addParentListeners(uiManager, uiProperties);
    final Display display = mapperUIParent.getDisplay();
    bgColorLinksZone = ColorProviderMapper.getColor(ColorInfo.COLOR_BACKGROUND_LINKS_ZONE);
    GridLayout parentLayout = new GridLayout(1, true);
    mapperUIParent.setLayout(parentLayout);
    addKeyListener(uiManager, display);
    addBackgroundRefreshLimiters(display);
    this.dropTargetOperationListener = new DropTargetOperationListener(mapperManager);
    dropTargetOperationListener.addControl(this.mapperUIParent.getShell());
    mainSashForm = new SashForm(mapperUIParent, SWT.SMOOTH | SWT.VERTICAL);
    GridData mainSashFormGridData = new GridData(GridData.FILL_BOTH);
    mainSashForm.setLayoutData(mainSashFormGridData);
    datasFlowViewSashForm = new SashForm(mainSashForm, SWT.SMOOTH | SWT.HORIZONTAL | SWT.BORDER);
    datasFlowViewSashForm.setBackgroundMode(SWT.INHERIT_FORCE);
    initBackgroundComponents();
    if (WindowSystem.isGTK()) {
        datasFlowViewSashForm.setBackground(display.getSystemColor(SWT.COLOR_DARK_GRAY));
    }
    // dropTargetOperationListener.addControl(datasFlowViewSashForm);
    // datasFlowViewSashForm.addControlListener(new ControlListener() {
    //
    // public void controlMoved(ControlEvent e) {
    // }
    //
    // public void controlResized(ControlEvent e) {
    // createBgImages();
    // updateBackground(true, false);
    // }
    //
    // });
    /* Create the tabs */
    String dbmsId = null;
    if (mapperModel.getInputDataMapTables() != null && !mapperModel.getInputDataMapTables().isEmpty()) {
        InputTable input = mapperModel.getInputDataMapTables().get(0);
        if (input.getMetadataTable() != null) {
            dbmsId = input.getMetadataTable().getDbms();
        }
    }
    tabFolderEditors = new TabFolderEditors(mainSashForm, SWT.BORDER, mapperManager, dbmsId);
    createInputZoneWithTables(mapperModel, uiManager, display);
    createVarsZoneWithTables(mapperModel, display);
    createOutputZoneWithTables(mapperModel, uiManager, display);
    mapperManager.initInternalData();
    uiManager.parseAllExpressionsForAllTables();
    mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
    this.draggingInfosPopup = DraggingInfosPopup.getNewShell(this.mapperUIParent.getShell());
    configureZoneScrollBars(display);
    int[] weightsDatasFlowViewSashForm = uiProperties.getWeightsDatasFlowViewSashForm();
    datasFlowViewSashForm.setWeights(weightsDatasFlowViewSashForm.length != 0 ? weightsDatasFlowViewSashForm : ExternalDbMapUiProperties.DEFAULT_WEIGHTS_DATAS_FLOW_SASH_FORM);
    int[] weightsMainSashForm = uiProperties.getWeightsMainSashForm();
    mainSashForm.setWeights(weightsMainSashForm.length != 0 ? weightsMainSashForm : ExternalDbMapUiProperties.DEFAULT_WEIGHTS_MAIN_SASH_FORM);
    new FooterComposite(this.mapperUIParent, SWT.NONE, mapperManager);
    if (WindowSystem.isGTK()) {
        // resize especially for GTK
        new AsynchronousThreading(1000, false, display, new Runnable() {

            public void run() {
                resizeNotMinimizedTablesAtExpandedSize(display);
                mapperUIParent.getShell().layout();
            }
        }).start();
    }
    if (WindowSystem.isWIN32()) {
        List<DataMapTableView> inputsTablesView = uiManager.getInputsTablesView();
        for (DataMapTableView view : inputsTablesView) {
            ((InputDataMapTableView) view).refreshLabelForJoinDropDown();
        }
    }
    selectFirstInOutTablesView();
    mapperManager.getUiManager().refreshSqlExpression();
}
Also used : TabFolderEditors(org.talend.designer.dbmap.ui.tabs.TabFolderEditors) FooterComposite(org.talend.designer.dbmap.ui.footer.FooterComposite) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) UIManager(org.talend.designer.dbmap.managers.UIManager) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) ExternalDbMapUiProperties(org.talend.designer.dbmap.external.data.ExternalDbMapUiProperties) AsynchronousThreading(org.talend.commons.ui.runtime.thread.AsynchronousThreading) SashForm(org.eclipse.swt.custom.SashForm) InputTable(org.talend.designer.dbmap.model.table.InputTable) GridLayout(org.eclipse.swt.layout.GridLayout) DropTargetOperationListener(org.talend.designer.abstractmap.ui.listener.DropTargetOperationListener) GridData(org.eclipse.swt.layout.GridData) Display(org.eclipse.swt.widgets.Display)

Example 2 with InputDataMapTableView

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

the class MapperUI method createInputZoneWithTables.

private void createInputZoneWithTables(MapperModel mapperModel, UIManager uiManager, final Display display) {
    inputsZone = new InputsZone(datasFlowViewSashForm, SWT.NONE, mapperManager);
    inputsZone.createHeaderZoneComponents();
    sc1 = new ScrolledComposite(inputsZone, getBorder() | SWT.H_SCROLL | SWT.V_SCROLL);
    // this.dropTargetOperationListener.addControl(sc1);
    GridData sc1GridData = new GridData(GridData.FILL_BOTH);
    sc1.setLayoutData(sc1GridData);
    sc1.setBackgroundMode(SWT.INHERIT_DEFAULT);
    sc1.addControlListener(new ControlListener() {

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

        public void controlResized(ControlEvent e) {
            // System.out.println("sc1 controlResized");
            onSashResized(display);
        }
    });
    inputTablesZoneView = new InputTablesZoneView(sc1, getBorder(), mapperManager);
    // this.dropTargetOperationListener.addControl(inputTablesZoneView);
    inputTablesZoneView.setBackgroundMode(SWT.INHERIT_DEFAULT);
    sc1.setExpandHorizontal(true);
    sc1.setContent(inputTablesZoneView);
    sc1MSListener = new MouseScrolledListener(mapperManager.getUiManager(), sc1);
    inputTablesZoneView.initInsertionIndicator();
    Control previousControl = null;
    List<InputTable> tables = mapperModel.getInputDataMapTables();
    Boolean minimizeStateOfTables = getMinimizedButtonState(tables);
    if (minimizeStateOfTables != null) {
        inputsZone.getToolbar().setMinimizeButtonState(minimizeStateOfTables.booleanValue());
    }
    for (InputTable inputTable : tables) {
        InputDataMapTableView dataMapTableView = uiManager.createNewInputTableView(previousControl, inputTable, inputTablesZoneView);
        if (previousControl == null) {
            uiManager.updateDropDownJoinTypeForInputs();
        }
        previousControl = dataMapTableView;
    }
    inputTablesZoneView.setSize(inputTablesZoneView.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) Control(org.eclipse.swt.widgets.Control) InputsZone(org.talend.designer.dbmap.ui.visualmap.zone.InputsZone) InputTablesZoneView(org.talend.designer.dbmap.ui.visualmap.zone.scrollable.InputTablesZoneView) GridData(org.eclipse.swt.layout.GridData) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlListener(org.eclipse.swt.events.ControlListener) ControlEvent(org.eclipse.swt.events.ControlEvent) MouseScrolledListener(org.talend.designer.abstractmap.ui.listener.MouseScrolledListener)

Example 3 with InputDataMapTableView

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

the class UIManager method updateDropDownJoinTypeForInputs.

/**
     * DOC amaumont Comment method "updateDropDownJoinTypeForInputs".
     */
public void updateDropDownJoinTypeForInputs() {
    List<DataMapTableView> inputsTablesView;
    inputsTablesView = getInputsTablesView();
    if (inputsTablesView.size() >= 1) {
        InputDataMapTableView inputView0 = (InputDataMapTableView) inputsTablesView.get(0);
        inputView0.setEnableJoinTypeDropDown(false);
    }
    if (inputsTablesView.size() >= 2) {
        InputDataMapTableView inputView1 = (InputDataMapTableView) inputsTablesView.get(1);
        inputView1.setEnableJoinTypeDropDown(true);
    }
}
Also used : InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)

Example 4 with InputDataMapTableView

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

the class UIManager method createNewInputTableView.

public InputDataMapTableView createNewInputTableView(Control previousControl, InputTable inputTable, Composite parent) {
    InputDataMapTableView dataMapTableView = new InputDataMapTableView(parent, SWT.BORDER, inputTable, 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);
    dataMapTableView.minimizeTable(inputTable.isMinimized());
    dataMapTableView.registerStyledExpressionEditor(getTabFolderEditors().getStyledTextHandler());
    this.mapperUI.getInputMouseSrolledListener().addMouseWheelListener(dataMapTableView);
    return dataMapTableView;
}
Also used : FormData(org.eclipse.swt.layout.FormData) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 5 with InputDataMapTableView

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

the class UIManager method selectDataMapTableView.

/**
     * Select a table view.
     * 
     * @param dataMapTableView
     * @param useNewCommand
     * @param selectAllEntries TODO
     */
public void selectDataMapTableView(final DataMapTableView dataMapTableView, boolean useNewCommand, boolean selectAllEntries) {
    TabFolderEditors tabFolderEditors = mapperUI.getTabFolderEditors();
    // tabFolderEditors.setSelection(TabFolderEditors.INDEX_TAB_METADATA_EDITOR);
    MetadataTableEditorView metadataTableEditorView = null;
    MetadataTableEditorView otherMetadataTableEditorView = null;
    final Zone currentZone = dataMapTableView.getZone();
    List<? extends IDataMapTable> tables = null;
    DataMapTableView previousSelectedTableView = null;
    DataMapTableView newSelectedTableView = null;
    if (currentZone == Zone.INPUTS) {
        metadataTableEditorView = tabFolderEditors.getInputMetaEditor();
        otherMetadataTableEditorView = tabFolderEditors.getOutputMetaEditor();
        tables = mapperManager.getInputTables();
        previousSelectedTableView = this.currentSelectedInputTableView;
        setCurrentSelectedInputTableView((InputDataMapTableView) dataMapTableView);
        newSelectedTableView = dataMapTableView;
    } else if (currentZone == Zone.OUTPUTS) {
        metadataTableEditorView = tabFolderEditors.getOutputMetaEditor();
        otherMetadataTableEditorView = tabFolderEditors.getInputMetaEditor();
        tables = mapperManager.getOutputTables();
        previousSelectedTableView = this.currentSelectedOutputTableView;
        newSelectedTableView = dataMapTableView;
        setCurrentSelectedOutputTableView((OutputDataMapTableView) dataMapTableView);
    }
    updateToolbarButtonsStates(currentZone);
    final AbstractInOutTable abstractDataMapTable = (AbstractInOutTable) mapperManager.retrieveIDataMapTable(dataMapTableView);
    MetadataTableEditor currentMetadataTableEditor = metadataTableEditorView.getMetadataTableEditor();
    final TableViewerCreator dataMapTVCreator = dataMapTableView.getTableViewerCreatorForColumns();
    final TableViewer dataMapTableViewer = dataMapTableView.getTableViewerCreatorForColumns().getTableViewer();
    if (currentMetadataTableEditor == null || currentMetadataTableEditor != null && newSelectedTableView != previousSelectedTableView) {
        if (useNewCommand) {
            DataMapTableViewSelectedCommand command = new DataMapTableViewSelectedCommand(this, previousSelectedTableView, dataMapTableView);
            mapperManager.executeCommand(command);
        }
        currentMetadataTableEditor = new MetadataTableEditor(abstractDataMapTable.getMetadataTable(), abstractDataMapTable.getTitle());
        currentMetadataTableEditor.setModifiedBeanListenable(metadataTableEditorView.getTableViewerCreator());
        final MetadataTableEditorView metadataTableEditorViewFinal = metadataTableEditorView;
        final TableViewerCreator metadataTVCreator = metadataTableEditorViewFinal.getTableViewerCreator();
        final MetadataTableEditor metadataTableEditor = currentMetadataTableEditor;
        modifySelectionChangedListener(currentZone, metadataTableEditorViewFinal, metadataTVCreator, metadataTableEditor, dataMapTableView, previousSelectedTableView);
        // init actions listeners for list which contains metadata
        metadataTableEditor.addAfterOperationListListener(new IListenableListListener() {

            /**
                 * DOC acer Comment method "handleEvent".
                 * 
                 * @param event
                 */
            @Override
            public void handleEvent(ListenableListEvent event) {
                DataMapTableView view = mapperManager.retrieveIDataMapTableView(abstractDataMapTable);
                if (event.type == TYPE.ADDED) {
                    // metadataEditorTableViewer.refresh();
                    List<IMetadataColumn> metadataColumns = (List<IMetadataColumn>) event.addedObjects;
                    lastCreatedInOutColumnEntries.clear();
                    if (event.index != null) {
                        int index = event.index;
                        for (IMetadataColumn metadataColumn : metadataColumns) {
                            lastCreatedInOutColumnEntries.add(mapperManager.addNewColumnEntry(dataMapTableView, metadataColumn, index++));
                        }
                    } else if (event.indicesTarget != null) {
                        List<Integer> indicesTarget = event.indicesTarget;
                        int lstSize = indicesTarget.size();
                        for (int i = 0; i < lstSize; i++) {
                            Integer indice = indicesTarget.get(i);
                            IMetadataColumn metadataColumn = metadataColumns.get(i);
                            lastCreatedInOutColumnEntries.add(mapperManager.addNewColumnEntry(dataMapTableView, metadataColumn, indice));
                        }
                    } else {
                        //$NON-NLS-1$
                        throw new IllegalStateException(Messages.getString("UIManager.1"));
                    }
                    refreshBackground(false, false);
                    if (event.index != null) {
                        dataMapTableView.changeSize(view.getPreferredSize(true, false, false), true, true);
                        dataMapTableViewer.refresh();
                        dataMapTVCreator.getSelectionHelper().setSelection(event.index);
                    } else if (event.indicesTarget != null) {
                        dataMapTableViewer.refresh();
                        dataMapTableView.changeSize(view.getPreferredSize(false, true, false), true, true);
                        int[] selection = ArrayUtils.toPrimitive((Integer[]) event.indicesTarget.toArray(new Integer[0]));
                        dataMapTVCreator.getSelectionHelper().setSelection(selection);
                    }
                    mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
                }
                if (event.type == TYPE.REMOVED) {
                    // metadataEditorTableViewer.refresh();
                    List<IMetadataColumn> metadataColumns = (List<IMetadataColumn>) event.removedObjects;
                    for (IMetadataColumn metadataColumn : metadataColumns) {
                        ITableEntry metadataTableEntry = mapperManager.retrieveTableEntry(new TableEntryLocation(abstractDataMapTable.getName(), metadataColumn.getLabel()));
                        mapperManager.removeTableEntry(metadataTableEntry);
                    }
                    dataMapTableViewer.refresh();
                    dataMapTableView.resizeAtExpandedSize();
                    resizeTablesZoneViewAtComputedSize(dataMapTableView.getZone());
                    moveScrollBarZoneAtSelectedTable(dataMapTableView.getZone());
                    refreshBackground(true, false);
                    mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
                }
                if (event.type == TYPE.SWAPED) {
                    List<Integer> listIndexTarget = event.indicesTarget;
                    abstractDataMapTable.swapColumnElements(event.indicesOrigin, listIndexTarget);
                    // dataMapTableViewer.refresh();
                    refreshBackground(true, false);
                }
            }
        });
        metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
        metadataTableEditorView.setMetadataTableEditor(metadataTableEditor);
        metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
        metadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
        dataMapTVCreator.getSelectionHelper().setActiveFireSelectionChanged(false);
        metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setSelection(dataMapTableViewer.getTable().getSelectionIndices());
        dataMapTVCreator.getSelectionHelper().setActiveFireSelectionChanged(true);
        // disable highlight for other DataMapTableView and highlight selected DataMapTableView
        for (IDataMapTable table : tables) {
            DataMapTableView otherDataMapTableView = mapperManager.retrieveIDataMapTableView(table);
            otherDataMapTableView.setBackground(dataMapTableView.getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
        }
        dataMapTableView.setBackground(dataMapTableView.getDisplay().getSystemColor(SWT.COLOR_YELLOW));
    }
    if (selectAllEntries) {
        dataMapTVCreator.getTable().selectAll();
        selectAllLinks(dataMapTableView);
        metadataTableEditorView.getTableViewerCreator().getTable().selectAll();
        metadataTableEditorView.getToolBar().updateEnabledStateOfButtons();
        if (currentZone == Zone.OUTPUTS) {
            dataMapTableView.getTableViewerCreatorForWhereFilters().getTable().selectAll();
            dataMapTableView.getTableViewerCreatorForOtherFilters().getTable().selectAll();
        }
    }
    if (otherMetadataTableEditorView != null) {
        otherMetadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
    }
}
Also used : TabFolderEditors(org.talend.designer.dbmap.ui.tabs.TabFolderEditors) ListenableListEvent(org.talend.commons.utils.data.list.ListenableListEvent) MetadataTableEditor(org.talend.core.ui.metadata.editor.MetadataTableEditor) TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) OutputsZone(org.talend.designer.dbmap.ui.visualmap.zone.OutputsZone) InputsZone(org.talend.designer.dbmap.ui.visualmap.zone.InputsZone) Zone(org.talend.designer.dbmap.ui.visualmap.zone.Zone) ToolbarInputZone(org.talend.designer.dbmap.ui.visualmap.zone.toolbar.ToolbarInputZone) ToolbarOutputZone(org.talend.designer.dbmap.ui.visualmap.zone.toolbar.ToolbarOutputZone) ToolbarZone(org.talend.designer.dbmap.ui.visualmap.zone.toolbar.ToolbarZone) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) AbstractInOutTable(org.talend.designer.dbmap.model.table.AbstractInOutTable) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IListenableListListener(org.talend.commons.utils.data.list.IListenableListListener) Point(org.eclipse.swt.graphics.Point) DataMapTableViewSelectedCommand(org.talend.designer.dbmap.ui.commands.DataMapTableViewSelectedCommand) TableEntryLocation(org.talend.designer.dbmap.model.tableentry.TableEntryLocation) List(java.util.List) ArrayList(java.util.ArrayList) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) AbstractMetadataTableEditorView(org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView) TableViewer(org.eclipse.jface.viewers.TableViewer) OutputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView)

Aggregations

InputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView)7 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)4 OutputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView)4 Point (org.eclipse.swt.graphics.Point)2 FormAttachment (org.eclipse.swt.layout.FormAttachment)2 FormData (org.eclipse.swt.layout.FormData)2 GridData (org.eclipse.swt.layout.GridData)2 Control (org.eclipse.swt.widgets.Control)2 AbstractMetadataTableEditorView (org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView)2 MetadataTableEditorView (org.talend.core.ui.metadata.editor.MetadataTableEditorView)2 InputTable (org.talend.designer.dbmap.model.table.InputTable)2 TabFolderEditors (org.talend.designer.dbmap.ui.tabs.TabFolderEditors)2 InputsZone (org.talend.designer.dbmap.ui.visualmap.zone.InputsZone)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 SashForm (org.eclipse.swt.custom.SashForm)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 ControlEvent (org.eclipse.swt.events.ControlEvent)1 ControlListener (org.eclipse.swt.events.ControlListener)1