Search in sources :

Example 1 with FilterTableEntry

use of org.talend.designer.dbmap.model.tableentry.FilterTableEntry in project tdi-studio-se by Talend.

the class DataMapTableView method addTablesListeners.

/**
     * DOC amaumont Comment method "addTableForColumnsListeners".
     */
private void addTablesListeners() {
    tableViewerCreatorForColumns.addCellValueModifiedListener(new ITableCellValueModifiedListener() {

        @Override
        public void cellValueModified(TableCellValueModifiedEvent e) {
            unselectAllEntriesIfErrorDetected(e);
        }
    });
    abstractDataMapTable.getTableColumnsEntriesModel().addAfterOperationListListener(new IListenableListListener<FilterTableEntry>() {

        @Override
        public void handleEvent(ListenableListEvent<FilterTableEntry> event) {
            mapperManager.getUiManager().refreshSqlExpression();
        }
    });
    final TableViewer tableViewerForEntries = tableViewerCreatorForColumns.getTableViewer();
    tableViewerForEntries.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            int[] selectionIndices = tableViewerForEntries.getTable().getSelectionIndices();
            if (selectionIndices.length > 0) {
                selectThisDataMapTableView();
                onSelectedEntries(event.getSelection(), selectionIndices);
                // bug 18414
                MetadataTableEditorView metadataTableEditorView = null;
                if (getZone() == Zone.INPUTS) {
                    metadataTableEditorView = mapperManager.getUiManager().getInputMetaEditorView();
                } else if (getZone() == Zone.OUTPUTS) {
                    metadataTableEditorView = mapperManager.getUiManager().getOutputMetaEditorView();
                }
                if (metadataTableEditorView != null) {
                    metadataTableEditorView.getTableViewerCreator().refresh();
                }
            }
        }
    });
    tableForEntries.addListener(SWT.DragDetect, new Listener() {

        @Override
        public void handleEvent(Event event) {
            onSelectedEntries(tableViewerForEntries.getSelection(), tableViewerForEntries.getTable().getSelectionIndices());
        }
    });
    tableViewerCreatorForColumns.getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() {

        @Override
        public void handle(LineSelectionEvent e) {
            if (forceExecuteSelectionEvent) {
                forceExecuteSelectionEvent = false;
                onSelectedEntries(tableViewerForEntries.getSelection(), tableViewerForEntries.getTable().getSelectionIndices());
            }
        }
    });
    tableForEntries.addListener(SWT.KeyDown, new Listener() {

        @Override
        public void handleEvent(Event event) {
            processEnterKeyDown(tableViewerCreatorForColumns, event);
        }
    });
    abstractDataMapTable.getTableColumnsEntriesModel().addModifiedBeanListener(new IModifiedBeanListener<IColumnEntry>() {

        @Override
        public void handleEvent(ModifiedBeanEvent<IColumnEntry> event) {
            TableViewerCreator tableViewerCreator = tableViewerCreatorForColumns;
            ITableEntry tableEntry = event.bean;
            parseExpressionIfNeeded(event, tableViewerCreator, tableEntry);
            mapperManager.getUiManager().refreshSqlExpression();
        }
    });
    if (abstractDataMapTable instanceof OutputTable) {
        OutputTable outputTable = (OutputTable) abstractDataMapTable;
        outputTable.getWhereTableFiltersEntriesModel().addAfterOperationListListener(new IListenableListListener<FilterTableEntry>() {

            @Override
            public void handleEvent(ListenableListEvent<FilterTableEntry> event) {
                resizeAtExpandedSize();
                mapperManager.getUiManager().refreshSqlExpression();
            }
        });
        outputTable.getWhereTableFiltersEntriesModel().addModifiedBeanListener(new IModifiedBeanListener<FilterTableEntry>() {

            @Override
            public void handleEvent(ModifiedBeanEvent<FilterTableEntry> event) {
                onOutputTableFiltersModified(event, extendedTableViewerForFilters);
                mapperManager.getUiManager().refreshSqlExpression();
            }
        });
        outputTable.getOtherTableFiltersEntriesModel().addAfterOperationListListener(new IListenableListListener<FilterTableEntry>() {

            @Override
            public void handleEvent(ListenableListEvent<FilterTableEntry> event) {
                resizeAtExpandedSize();
                mapperManager.getUiManager().refreshSqlExpression();
            }
        });
        outputTable.getOtherTableFiltersEntriesModel().addModifiedBeanListener(new IModifiedBeanListener<FilterTableEntry>() {

            @Override
            public void handleEvent(ModifiedBeanEvent<FilterTableEntry> event) {
                onOutputTableFiltersModified(event, entendedTableViewerForOtherClauses);
                mapperManager.getUiManager().refreshSqlExpression();
            }
        });
    }
}
Also used : SelectionListener(org.eclipse.swt.events.SelectionListener) ControlListener(org.eclipse.swt.events.ControlListener) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) DisposeListener(org.eclipse.swt.events.DisposeListener) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) IModifiedBeanListener(org.talend.commons.ui.swt.tableviewer.IModifiedBeanListener) ICellEditorListener(org.eclipse.jface.viewers.ICellEditorListener) MouseListener(org.eclipse.swt.events.MouseListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IListenableListListener(org.talend.commons.utils.data.list.IListenableListListener) FocusListener(org.eclipse.swt.events.FocusListener) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) KeyListener(org.eclipse.swt.events.KeyListener) TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) OutputTable(org.talend.designer.dbmap.model.table.OutputTable) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) ModifiedBeanEvent(org.talend.commons.ui.swt.tableviewer.ModifiedBeanEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ListenableListEvent(org.talend.commons.utils.data.list.ListenableListEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) AbstractExtendedTableViewer(org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView)

Example 2 with FilterTableEntry

use of org.talend.designer.dbmap.model.tableentry.FilterTableEntry in project tdi-studio-se by Talend.

the class StyleLinkFactory method getStyleLink.

// public static DrawableLinkFactory getInstance() {
// if (instance == null) {
// instance = new DrawableLinkFactory();
// }
// return instance;
// }
//
// public IDrawableLink getDrawableLink(IMapperLink link) {
// IDrawableLink drawableLink = null;
// PointLinkDescriptor pointLinkDescriptorSource = link.getPointLinkDescriptorSource();
// PointLinkDescriptor pointLinkDescriptorTarget = link.getPointLinkDescriptorTarget();
// if (pointLinkDescriptorSource.getZone() != pointLinkDescriptorTarget.getZone()) {
// drawableLink = new HorizontalBezierLink();
// } else if (pointLinkDescriptorSource.getZone() == pointLinkDescriptorTarget.getZone()) {
// drawableLink = new VerticalRoundedCornerLink();
// }
// return drawableLink;
// }
//
public IStyleLink getStyleLink(IMapperLink link) {
    ILinkState linkState = link.getState();
    PointLinkDescriptor pointLinkDescriptorSource = link.getPointLinkDescriptor1();
    PointLinkDescriptor pointLinkDescriptorTarget = link.getPointLinkDescriptor2();
    ITableEntry targetTableEntry = pointLinkDescriptorTarget.getTableEntry();
    boolean targetIsConstraint = false;
    if (targetTableEntry instanceof FilterTableEntry) {
        targetIsConstraint = true;
    }
    IStyleLink style = null;
    if (pointLinkDescriptorSource.getZone() != pointLinkDescriptorTarget.getZone()) {
        if (linkState == LinkState.SELECTED) {
            if (targetIsConstraint) {
                style = selectedFilterStyle;
            } else {
                style = selectedZoneToZoneStyle;
            }
        } else if (linkState == LinkState.UNSELECTED) {
            if (targetIsConstraint) {
                style = unselectedFilterStyle;
            } else {
                style = unselectedZoneToZoneStyle;
            }
        }
    } else if ((pointLinkDescriptorSource.getZone() == Zone.INPUTS || pointLinkDescriptorSource.getZone() == Zone.OUTPUTS) && pointLinkDescriptorSource.getZone() == pointLinkDescriptorTarget.getZone()) {
        if (linkState == LinkState.SELECTED) {
            style = selectedSameInputZoneStyle;
        } else if (linkState == LinkState.UNSELECTED) {
            style = unselectedSameZoneStyle;
        }
    }
    return style;
}
Also used : PointLinkDescriptor(org.talend.designer.abstractmap.ui.visualmap.link.PointLinkDescriptor) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ILinkState(org.talend.designer.abstractmap.ui.visualmap.link.ILinkState) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) IStyleLink(org.talend.commons.ui.swt.drawing.link.IStyleLink)

Example 3 with FilterTableEntry

use of org.talend.designer.dbmap.model.tableentry.FilterTableEntry in project tdi-studio-se by Talend.

the class OutputDataMapTableView method initTableFilters.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView#initTableConstraints()
     */
@Override
protected void initTableFilters(Composite parent) {
    /**
         * create whereFiltersTable
         */
    // createFiltersTable(parent);
    //$NON-NLS-1$
    filterColumnLabel = Messages.getString("OutputDataMapTableView.columnTitle.AdditionalWhereClauses");
    extendedTableViewerForFilters = new ExtendedTableViewerForFilters(((OutputTable) abstractDataMapTable).getWhereTableFiltersEntriesModel(), parent) {

        /*
             * (non-Javadoc)
             * 
             * @see org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView.ExtendedTableViewerForFilters#
             * getTableConstraintSize()
             */
        @Override
        protected int getTableConstraintSize() {
            int retSize = 0;
            if (abstractDataMapTable instanceof OutputTable) {
                retSize = ((OutputTable) abstractDataMapTable).getWhereFilterEntries().size();
            }
            return retSize;
        }

        @Override
        protected void setTextCellEditor(TextCellEditor textEditor) {
            if (textEditor != null) {
                whereConstraintExpressionTextEditor = (Text) textEditor.getControl();
            }
        }
    };
    // correct partially layout problem with GTK when cell editor value is applied
    ((ExtendedTableViewerForFilters) extendedTableViewerForFilters).createFiltersTable();
    TableViewerCreator tableViewerCreatorForWhereClauses = extendedTableViewerForFilters.getTableViewerCreator();
    tableViewerCreatorForWhereClauses.setAdjustWidthValue(WindowSystem.isGTK() ? -20 : ADJUST_WIDTH_VALUE);
    List<FilterTableEntry> whereEntries = ((OutputTable) getDataMapTable()).getWhereFilterEntries();
    tableViewerCreatorForWhereClauses.init(whereEntries);
    /**
         * create otherFiltersTable
         */
    IComponent component = getMapperManager().getComponent().getComponent();
    if (component != null && "tELTOracleMap".equals(component.getName())) {
        //$NON-NLS-1$
        //$NON-NLS-1$
        filterColumnLabel = Messages.getString("OutputDataMapTableView.columnTitle.AdditionalOtherClauses.oracle");
    } else {
        //$NON-NLS-1$
        filterColumnLabel = Messages.getString("OutputDataMapTableView.columnTitle.AdditionalOtherClauses");
    }
    entendedTableViewerForOtherClauses = new ExtendedTableViewerForFilters(((OutputTable) abstractDataMapTable).getOtherTableFiltersEntriesModel(), parent) {

        /*
             * (non-Javadoc)
             * 
             * @see org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView.ExtendedTableViewerForFilters#
             * getTableConstraintSize()
             */
        @Override
        public int getTableConstraintSize() {
            int retSize = 0;
            if (abstractDataMapTable instanceof OutputTable) {
                retSize = ((OutputTable) abstractDataMapTable).getOtherFilterEntries().size();
            }
            return retSize;
        }

        @Override
        protected void setTextCellEditor(TextCellEditor textEditor) {
            if (textEditor != null) {
                otherConstraintExpressionTextEditor = (Text) textEditor.getControl();
            }
        }
    };
    ((ExtendedTableViewerForFilters) entendedTableViewerForOtherClauses).createFiltersTable();
    TableViewerCreator tableViewerCreatorForOtherClauses = entendedTableViewerForOtherClauses.getTableViewerCreator();
    tableViewerCreatorForOtherClauses.setAdjustWidthValue(WindowSystem.isGTK() ? -20 : ADJUST_WIDTH_VALUE);
    List<FilterTableEntry> otherEntries = ((OutputTable) getDataMapTable()).getOtherFilterEntries();
    tableViewerCreatorForOtherClauses.init(otherEntries);
    // updateGridDataHeightForTableConstraints(entendedTableViewerForOtherClauses.getTable());
    updateGridDataHeightForTableConstraints();
    if (WindowSystem.isGTK()) {
        tableViewerCreatorForWhereClauses.layout();
        entendedTableViewerForOtherClauses.getTableViewerCreator().layout();
    }
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) IComponent(org.talend.core.model.components.IComponent) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) Text(org.eclipse.swt.widgets.Text) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 4 with FilterTableEntry

use of org.talend.designer.dbmap.model.tableentry.FilterTableEntry in project tdi-studio-se by Talend.

the class OutputTable method initFromExternalData.

@Override
public void initFromExternalData(ExternalDbMapTable externalMapperTable) {
    super.initFromExternalData(externalMapperTable);
    List<IMetadataColumn> columns = this.metadataTable.getListColumns();
    Map<String, ExternalDbMapEntry> nameToPerTabEntry = new HashMap<String, ExternalDbMapEntry>();
    if (externalMapperTable != null && externalMapperTable.getMetadataTableEntries() != null) {
        for (ExternalDbMapEntry perTableEntry : externalMapperTable.getMetadataTableEntries()) {
            nameToPerTabEntry.put(perTableEntry.getName(), perTableEntry);
        }
    }
    for (IMetadataColumn column : columns) {
        AbstractInOutTableEntry columnEntry = getNewTableEntry(column);
        ExternalDbMapEntry externalMapperTableEntry = nameToPerTabEntry.get(columnEntry.getMetadataColumn().getLabel());
        // Entry match with current column
        if (externalMapperTableEntry != null) {
            columnEntry.setExpression(externalMapperTableEntry.getExpression());
        }
        dataMapTableEntries.add(columnEntry);
    }
    if (externalMapperTable != null) {
        List<ExternalDbMapEntry> externalWhereConstraintTableEntries = externalMapperTable.getCustomWhereConditionsEntries();
        if (externalWhereConstraintTableEntries != null) {
            for (ExternalDbMapEntry entry : externalWhereConstraintTableEntries) {
                FilterTableEntry whereFilterTableEntry = new FilterTableEntry(this, entry.getName(), entry.getExpression(), FilterTableEntry.WHERE_FILTER);
                // mapperManager.getProblemsManager().checkProblemsForTableEntry(filterTableEntry, false);
                addWhereFilterEntry(whereFilterTableEntry);
            }
        }
        List<ExternalDbMapEntry> externalOtherConstraintTableEntries = externalMapperTable.getCustomOtherConditionsEntries();
        if (externalOtherConstraintTableEntries != null) {
            for (ExternalDbMapEntry entry : externalOtherConstraintTableEntries) {
                FilterTableEntry otherFilterTableEntry = new FilterTableEntry(this, entry.getName(), entry.getExpression(), FilterTableEntry.OTHER_FILTER);
                // mapperManager.getProblemsManager().checkProblemsForTableEntry(filterTableEntry, false);
                addOtherFilterEntry(otherFilterTableEntry);
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) AbstractInOutTableEntry(org.talend.designer.dbmap.model.tableentry.AbstractInOutTableEntry) ExternalDbMapEntry(org.talend.designer.dbmap.external.data.ExternalDbMapEntry)

Example 5 with FilterTableEntry

use of org.talend.designer.dbmap.model.tableentry.FilterTableEntry in project tdi-studio-se by Talend.

the class TableEntriesManager method remove.

public void remove(ITableEntry dataMapTableEntry, boolean removingPhysicalInputTable) {
    if (dataMapTableEntry != null) {
        mapperManager.removeLinksOf(dataMapTableEntry);
        tableEntries.remove(TableEntriesManager.buildLocation(dataMapTableEntry));
        dataMapTableEntryToProperties.remove(dataMapTableEntry);
        IDataMapTable dataMapTable = dataMapTableEntry.getParent();
        if (dataMapTableEntry instanceof IColumnEntry) {
            dataMapTableEntry.getParent().removeColumnEntry((IColumnEntry) dataMapTableEntry);
            InputTable inputTable = isPhysicalTable(dataMapTable);
            if (inputTable != null && !removingPhysicalInputTable) {
                removeMetadataColumnFromDbTable(inputTable.getTableName(), dataMapTableEntry.getName());
            }
        } else if (dataMapTableEntry instanceof FilterTableEntry) {
            if (dataMapTable instanceof OutputTable) {
                if (FilterTableEntry.WHERE_FILTER.equals(((FilterTableEntry) dataMapTableEntry).getFilterKind())) {
                    ((OutputTable) dataMapTable).removeWhereFilterEntry((FilterTableEntry) dataMapTableEntry);
                } else if (FilterTableEntry.OTHER_FILTER.equals(((FilterTableEntry) dataMapTableEntry).getFilterKind())) {
                    ((OutputTable) dataMapTable).removeOtherFilterEntry((FilterTableEntry) dataMapTableEntry);
                }
            }
        } else {
            String exceptionMessage = //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "TableEntriesManager.exceptionMessage.typeIsNotValid", dataMapTableEntry.getClass().toString());
            throw new IllegalArgumentException(exceptionMessage);
        }
    }
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Aggregations

FilterTableEntry (org.talend.designer.dbmap.model.tableentry.FilterTableEntry)16 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)11 OutputTable (org.talend.designer.dbmap.model.table.OutputTable)8 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)5 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)5 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)5 TableViewer (org.eclipse.jface.viewers.TableViewer)3 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)3 InputTable (org.talend.designer.dbmap.model.table.InputTable)3 HashMap (java.util.HashMap)2 AbstractExtendedTableViewer (org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer)2 TableEntryLocation (org.talend.designer.dbmap.model.tableentry.TableEntryLocation)2 InputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView)2 OutputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView)2 ArrayList (java.util.ArrayList)1 ICellEditorListener (org.eclipse.jface.viewers.ICellEditorListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)1 ControlEvent (org.eclipse.swt.events.ControlEvent)1