Search in sources :

Example 11 with MetadataTableEditorView

use of org.talend.core.ui.metadata.editor.MetadataTableEditorView in project tdi-studio-se by Talend.

the class TabFolderEditors method createComponents.

/**
     * DOC amaumont Comment method "createComponents".
     */
private void createComponents() {
    setSimple(false);
    // TableEditorCompositeBase metaDatasDescriptorView3 = new TableEditorCompositeBase(tabFolder1);
    // item.setControl(metaDatasDescriptorView3);
    CTabItem item = new CTabItem(tabFolderEditors, SWT.BORDER);
    //$NON-NLS-1$
    item.setText(Messages.getString("TabFolderEditors.schemaEditor"));
    SashForm inOutMetaEditorContainer = new SashForm(tabFolderEditors, SWT.SMOOTH | SWT.HORIZONTAL | SWT.SHADOW_OUT);
    inOutMetaEditorContainer.setLayout(new RowLayout(SWT.HORIZONTAL));
    item.setControl(inOutMetaEditorContainer);
    CommandStack commandStack = mapperManager.getCommandStack();
    inputMetaEditor = new MetadataTableEditorView(inOutMetaEditorContainer, SWT.BORDER);
    inputMetaEditor.setMetadataTalendTypeFilter(NodeUtil.createMetadataTalendTypeFilter(mapperManager.getAbstractMapComponent()));
    inputMetaEditor.initGraphicComponents();
    inputMetaEditor.getExtendedTableViewer().setCommandStack(commandStack);
    addListenersToInputButtons();
    outputMetaEditor = new MetadataTableEditorView(inOutMetaEditorContainer, SWT.BORDER);
    outputMetaEditor.setMetadataTalendTypeFilter(NodeUtil.createMetadataTalendTypeFilter(mapperManager.getAbstractMapComponent()));
    outputMetaEditor.initGraphicComponents();
    outputMetaEditor.getExtendedTableViewer().setCommandStack(commandStack);
    addListenersToOutputButtons();
    item = new CTabItem(tabFolderEditors, SWT.BORDER);
    //$NON-NLS-1$
    item.setText(Messages.getString("TabFolderEditors.expressionEditor"));
    StyledText styledText = createStyledText(item);
    this.styledTextHandler = new StyledTextHandler(styledText, mapperManager);
    tabFolderEditors.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            lastSelectedTab = tabFolderEditors.getSelectionIndex();
        }
    });
    tabFolderEditors.setSelection(0);
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) CommandStack(org.eclipse.gef.commands.CommandStack) StyledText(org.eclipse.swt.custom.StyledText) UnnotifiableColorStyledText(org.talend.commons.ui.swt.colorstyledtext.UnnotifiableColorStyledText) DisposeListener(org.eclipse.swt.events.DisposeListener) IExtendedButtonListener(org.talend.commons.ui.swt.extended.table.IExtendedButtonListener) Listener(org.eclipse.swt.widgets.Listener) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) RowLayout(org.eclipse.swt.layout.RowLayout) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Event(org.eclipse.swt.widgets.Event) ExtendedButtonEvent(org.talend.commons.ui.swt.extended.table.ExtendedButtonEvent) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) CTabItem(org.eclipse.swt.custom.CTabItem) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView)

Example 12 with MetadataTableEditorView

use of org.talend.core.ui.metadata.editor.MetadataTableEditorView in project tdi-studio-se by Talend.

the class UIManager method removeOutputTableView.

/**
     * Call mapperManager.removeSelectedOutput() to remove a table view.
     * 
     * @param dataMapTableViewToRemove
     */
public void removeOutputTableView(OutputDataMapTableView dataMapTableViewToRemove) {
    List<DataMapTableView> outputsTablesView = getOutputsTablesView();
    int sizeList = outputsTablesView.size();
    for (int i = 0; i < sizeList; i++) {
        Control control = outputsTablesView.get(i);
        if (control == dataMapTableViewToRemove && i < sizeList - 1 && i > 0) {
            FormData formData = (FormData) outputsTablesView.get(i + 1).getLayoutData();
            formData.top = new FormAttachment(outputsTablesView.get(i - 1));
            break;
        }
    }
    mapperManager.removeTablePair(dataMapTableViewToRemove);
    MetadataTableEditorView outputMetaEditorView = getOutputMetaEditorView();
    OutputTable outputTable = (OutputTable) dataMapTableViewToRemove.getDataMapTable();
    if (outputMetaEditorView.getMetadataTableEditor().getMetadataTable() == outputTable.getMetadataTable()) {
        getOutputMetaEditorView().setMetadataTableEditor(null);
    }
    dataMapTableViewToRemove.dispose();
    dataMapTableViewToRemove = null;
    getTablesZoneViewOutputs().layout();
    refreshBackground(true, false);
    setCurrentSelectedOutputTableView(null);
}
Also used : FormData(org.eclipse.swt.layout.FormData) Control(org.eclipse.swt.widgets.Control) 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) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) AbstractMetadataTableEditorView(org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView) Point(org.eclipse.swt.graphics.Point) FormAttachment(org.eclipse.swt.layout.FormAttachment) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 13 with MetadataTableEditorView

use of org.talend.core.ui.metadata.editor.MetadataTableEditorView 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)

Example 14 with MetadataTableEditorView

use of org.talend.core.ui.metadata.editor.MetadataTableEditorView in project tdi-studio-se by Talend.

the class UIManager method refreshInOutTableAndMetaTable.

/**
     * DOC amaumont Comment method "refreshInOutTableAndMetaTable".
     * 
     * @param currentModifiedTableEntry can be null
     */
private void refreshInOutTableAndMetaTable(AbstractInOutTableEntry currentModifiedTableEntry) {
    DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentModifiedTableEntry);
    IMetadataTable metadataTableTarget = ((AbstractInOutTable) dataMapTableView.getDataMapTable()).getMetadataTable();
    dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(currentModifiedTableEntry);
    MetadataTableEditorView metadataEditorView = getMetadataEditorView(dataMapTableView.getZone());
    if (metadataEditorView != null && metadataEditorView.getMetadataTableEditor() != null && metadataEditorView.getMetadataTableEditor().getMetadataTable() == metadataTableTarget) {
        metadataEditorView.getTableViewerCreator().getTableViewer().refresh(currentModifiedTableEntry.getMetadataColumn());
        metadataEditorView.getTableViewerCreator().refreshTableEditorControls();
    }
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) AbstractInOutTable(org.talend.designer.dbmap.model.table.AbstractInOutTable) 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) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) AbstractMetadataTableEditorView(org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView)

Example 15 with MetadataTableEditorView

use of org.talend.core.ui.metadata.editor.MetadataTableEditorView in project tdi-studio-se by Talend.

the class UIManager method removeInputTableView.

/**
     * Call mapperManager.removeSelectedOutput() to remove a table view.
     * 
     * @param dataMapTableViewToRemove
     */
public void removeInputTableView(InputDataMapTableView dataMapTableViewToRemove) {
    List<DataMapTableView> outputsTablesView = getInputsTablesView();
    int sizeList = outputsTablesView.size();
    for (int i = 0; i < sizeList; i++) {
        Control control = outputsTablesView.get(i);
        if (control == dataMapTableViewToRemove && i < sizeList - 1 && i > 0) {
            FormData formData = (FormData) outputsTablesView.get(i + 1).getLayoutData();
            formData.top = new FormAttachment(outputsTablesView.get(i - 1));
            break;
        }
    }
    mapperManager.removeTablePair(dataMapTableViewToRemove);
    MetadataTableEditorView outputMetaEditorView = getInputMetaEditorView();
    if (outputMetaEditorView.getMetadataTableEditor().getMetadataTable() == ((InputTable) dataMapTableViewToRemove.getDataMapTable()).getMetadataTable()) {
        getInputMetaEditorView().setMetadataTableEditor(null);
    }
    dataMapTableViewToRemove.dispose();
    dataMapTableViewToRemove = null;
    getTablesZoneViewInputs().layout();
    refreshBackground(true, false);
    setCurrentSelectedInputTableView(null);
}
Also used : FormData(org.eclipse.swt.layout.FormData) Control(org.eclipse.swt.widgets.Control) 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) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) AbstractMetadataTableEditorView(org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView) Point(org.eclipse.swt.graphics.Point) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

MetadataTableEditorView (org.talend.core.ui.metadata.editor.MetadataTableEditorView)25 AbstractMetadataTableEditorView (org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView)14 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)12 ArrayList (java.util.ArrayList)7 Point (org.eclipse.swt.graphics.Point)7 Table (org.eclipse.swt.widgets.Table)6 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)6 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)6 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)6 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)6 FormAttachment (org.eclipse.swt.layout.FormAttachment)5 FormData (org.eclipse.swt.layout.FormData)5 IListenableListListener (org.talend.commons.utils.data.list.IListenableListListener)5 ListenableListEvent (org.talend.commons.utils.data.list.ListenableListEvent)5 MetadataTableEditor (org.talend.core.ui.metadata.editor.MetadataTableEditor)5 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)5 List (java.util.List)4 TableViewer (org.eclipse.jface.viewers.TableViewer)4 MetadataTable (org.talend.core.model.metadata.MetadataTable)4 OutputTable (org.talend.designer.dbmap.model.table.OutputTable)4