Search in sources :

Example 31 with IDataMapTable

use of org.talend.designer.abstractmap.model.table.IDataMapTable in project tdi-studio-se by Talend.

the class SearchZoneMapper method moveScrollBarZoneAtSelectedTableItem.

public void moveScrollBarZoneAtSelectedTableItem(ITableEntry entry) {
    if (entry != null) {
        DataMapTableView dataMapTableView = mapperManager.retrieveAbstractDataMapTableView(entry.getParent());
        Rectangle tableViewBounds = dataMapTableView.getBounds();
        IDataMapTable table = entry.getParent();
        TableItem tableItem = mapperManager.retrieveTableItem(entry);
        if (table != null && tableItem != null) {
            Rectangle tableItemBounds = tableItem.getBounds();
            int selection = tableViewBounds.y + tableItemBounds.y;
            ScrolledComposite scrollComposite = null;
            if (table instanceof InputTable) {
                scrollComposite = uiManager.getScrolledCompositeViewInputs();
            } else if (table instanceof VarsTable) {
                scrollComposite = uiManager.getScrolledCompositeViewVars();
            } else if (table instanceof OutputTable) {
                scrollComposite = uiManager.getScrolledCompositeViewOutputs();
            }
            if (scrollComposite != null) {
                setPositionOfVerticalScrollBarZone(scrollComposite, selection);
            }
        }
    }
}
Also used : InputTable(org.talend.designer.mapper.model.table.InputTable) VarsTable(org.talend.designer.mapper.model.table.VarsTable) TableItem(org.eclipse.swt.widgets.TableItem) Rectangle(org.eclipse.swt.graphics.Rectangle) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 32 with IDataMapTable

use of org.talend.designer.abstractmap.model.table.IDataMapTable in project tdi-studio-se by Talend.

the class InputDataMapTableView method getMapSettingValueAccess.

@Override
protected IBeanPropertyAccessors<GlobalMapEntry, Object> getMapSettingValueAccess(final CellEditor cellEditor) {
    return new IBeanPropertyAccessors<GlobalMapEntry, Object>() {

        public Object get(GlobalMapEntry bean) {
            IDataMapTable parent = bean.getParent();
            InputTable inputTable = (InputTable) parent;
            if (cellEditor instanceof ComboBoxCellEditor) {
                ComboBoxCellEditor functComboBox = (ComboBoxCellEditor) cellEditor;
                if (LOOKUP_MODEL_SETTING.equals(bean.getName())) {
                    IUILookupMode[] availableJoins = { TMAP_LOOKUP_MODE.LOAD_ONCE, TMAP_LOOKUP_MODE.RELOAD, TMAP_LOOKUP_MODE.CACHE_OR_RELOAD };
                    List<String> names = new ArrayList<String>();
                    for (IUILookupMode availableJoin : availableJoins) {
                        names.add(availableJoin.getLabel());
                    }
                    functComboBox.setItems(names.toArray(new String[names.size()]));
                    final IUILookupMode lookupMode = ((InputTable) parent).getLookupMode();
                    if (lookupMode != null) {
                        return lookupMode.getLabel();
                    }
                } else if (MATCH_MODEL_SETTING.equals(bean.getName())) {
                    IUIMatchingMode[] matchModel = getMatchModel();
                    List<String> names = new ArrayList<String>();
                    for (IUIMatchingMode element : matchModel) {
                        names.add(element.getLabel());
                    }
                    functComboBox.setItems(names.toArray(new String[names.size()]));
                    IUIMatchingMode matchingMode = ((InputTable) parent).getMatchingMode();
                    if (names.contains(matchingMode.getLabel())) {
                        return matchingMode.getLabel();
                    }
                } else if (JOIN_MODEL_SETTING.equals(bean.getName())) {
                    String[] items = new String[] { INNER_JOIN, LEFT_OUTER_JOIN };
                    functComboBox.setItems(items);
                    boolean innerJoin = ((InputTable) parent).isInnerJoin();
                    if (innerJoin) {
                        return items[0];
                    }
                    return items[1];
                } else if (PERSISTENCE_MODEL_SETTING.equals(bean.getName())) {
                    functComboBox.setItems(new String[] { "true", "false" });
                    boolean persistent = ((InputTable) parent).isPersistent();
                    return String.valueOf(persistent);
                }
            } else if (cellEditor instanceof CustomDialogCellEditor) {
                CustomDialogCellEditor customDialogCellEditor = (CustomDialogCellEditor) cellEditor;
                if (LOOKUP_MODEL_SETTING.equals(bean.getName())) {
                    customDialogCellEditor.setType(CellValueType.LOOKUP_MODEL);
                    final IUILookupMode lookupMode = inputTable.getLookupMode();
                    if (lookupMode != null) {
                        return lookupMode.getLabel();
                    }
                } else if (MATCH_MODEL_SETTING.equals(bean.getName())) {
                    customDialogCellEditor.setType(CellValueType.MATCH_MODEL);
                    IUIMatchingMode matchingMode = inputTable.getMatchingMode();
                    if (matchingMode != null) {
                        return matchingMode.getLabel();
                    }
                } else if (JOIN_MODEL_SETTING.equals(bean.getName())) {
                    customDialogCellEditor.setType(CellValueType.JOIN_MODEL);
                    boolean innerJoin = inputTable.isInnerJoin();
                    return innerJoin ? INNER_JOIN : LEFT_OUTER_JOIN;
                } else if (PERSISTENCE_MODEL_SETTING.equals(bean.getName())) {
                    customDialogCellEditor.setType(CellValueType.BOOL);
                    boolean persistent = inputTable.isPersistent();
                    return String.valueOf(persistent);
                } else if (SCHEMA_TYPE.equals(bean.getName())) {
                    customDialogCellEditor.setType(CellValueType.SCHEMA_TYPE);
                    enableDiaplayViewer(inputTable.isRepository());
                    return inputTable.isRepository() ? REPOSITORY : BUILT_IN;
                } else if (SCHEMA_ID.equals(bean.getName())) {
                    customDialogCellEditor.setType(CellValueType.SCHEMA_ID);
                    return getSchemaDisplayName(inputTable.getId());
                }
            }
            return "";
        }

        public void set(GlobalMapEntry bean, Object value) {
            IDataMapTable parent = bean.getParent();
            InputTable inputTable = (InputTable) parent;
            if (LOOKUP_MODEL_SETTING.equals(bean.getName())) {
                IUILookupMode[] availableJoins = { TMAP_LOOKUP_MODE.LOAD_ONCE, TMAP_LOOKUP_MODE.RELOAD, TMAP_LOOKUP_MODE.CACHE_OR_RELOAD };
                for (final IUILookupMode lookupMode : availableJoins) {
                    if (value != null && value.equals(lookupMode.getLabel())) {
                        inputTable.setLookupMode(lookupMode);
                        if (TMAP_LOOKUP_MODE.CACHE_OR_RELOAD == lookupMode) {
                            persistentCheckEditable = false;
                        } else {
                            persistentCheckEditable = true;
                        }
                        if (lookupMode == TMAP_LOOKUP_MODE.RELOAD || lookupMode == TMAP_LOOKUP_MODE.CACHE_OR_RELOAD) {
                            showTableGlobalMap(true);
                        } else {
                            showTableGlobalMap(false);
                        }
                        enableDisablePersistentMode((TMAP_LOOKUP_MODE) lookupMode);
                        mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
                        checkChangementsAfterEntryModifiedOrAdded(true);
                    }
                }
            } else if (MATCH_MODEL_SETTING.equals(bean.getName())) {
                for (IUIMatchingMode model : TMAP_MATCHING_MODE.values()) {
                    if (value != null && value.equals(model.getLabel())) {
                        inputTable.setMatchingMode(model);
                        previousMatchingModeSelected = model;
                    }
                }
            } else if (JOIN_MODEL_SETTING.equals(bean.getName())) {
                if (LEFT_OUTER_JOIN.equals(value)) {
                    ((InputTable) parent).setInnerJoin(false);
                    previousInnerJoinSelection = false;
                } else {
                    ((InputTable) parent).setInnerJoin(true);
                    previousInnerJoinSelection = true;
                }
            } else if (PERSISTENCE_MODEL_SETTING.equals(bean.getName())) {
                if ("true".equals(value) || "false".equals(value)) {
                    ((InputTable) parent).setPersistent(Boolean.valueOf(value.toString()));
                    previousValidPersistentMode = Boolean.valueOf(value.toString());
                }
            } else if (SCHEMA_TYPE.equals(bean.getName())) {
                inputTable.setRepository(REPOSITORY.equals(value));
                showSchemaIDSetting(REPOSITORY.equals(value));
                enableDiaplayViewer(REPOSITORY.equals(value));
            } else if (SCHEMA_ID.equals(bean.getName())) {
                inputTable.setId(String.valueOf(value));
            }
            refreshCondensedImage((InputTable) bean.getParent(), bean.getName());
        }
    };
}
Also used : IUILookupMode(org.talend.designer.mapper.model.table.IUILookupMode) ArrayList(java.util.ArrayList) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) IUIMatchingMode(org.talend.designer.mapper.model.table.IUIMatchingMode) InputTable(org.talend.designer.mapper.model.table.InputTable) IBeanPropertyAccessors(org.talend.commons.utils.data.bean.IBeanPropertyAccessors) List(java.util.List) ArrayList(java.util.ArrayList) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

Example 33 with IDataMapTable

use of org.talend.designer.abstractmap.model.table.IDataMapTable in project tdi-studio-se by Talend.

the class MapperUI method getMinimizedButtonState.

/**
     * DOC amaumont Comment method "getCommonMinimizedStateOfTables".
     * 
     * @param tables
     * @return new Boolean(true) if button state should be to minimize, else new Boolean(false)
     */
private Boolean getMinimizedButtonState(List<? extends IDataMapTable> tables) {
    boolean allTablesAreMinimized = true;
    boolean allTablesAreNotMinimized = true;
    for (IDataMapTable table : tables) {
        if (table.isMinimized()) {
            allTablesAreNotMinimized = false;
        } else {
            allTablesAreMinimized = false;
        }
    }
    if (allTablesAreMinimized) {
        return new Boolean(true);
    } else if (allTablesAreNotMinimized) {
        return new Boolean(false);
    }
    return new Boolean(false);
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable)

Example 34 with IDataMapTable

use of org.talend.designer.abstractmap.model.table.IDataMapTable in project tdi-studio-se by Talend.

the class MapperUI method createOutputZoneWithTables.

private void createOutputZoneWithTables(MapperModel mapperModel, final UIManager uiManager, final Display display) {
    Control previousControl;
    outputsZone = new OutputsZone(datasFlowViewSashForm, SWT.NONE, mapperManager);
    outputsZone.createHeaderZoneComponents();
    // this.dropTargetOperationListener.addControl(outputsZone);
    sc3 = new ScrolledComposite(outputsZone, getBorder() | SWT.H_SCROLL | SWT.V_SCROLL);
    // this.dropTargetOperationListener.addControl(sc3);
    GridData sc3GridData = new GridData(GridData.FILL_BOTH);
    sc3.setLayoutData(sc3GridData);
    sc3.setBackgroundMode(SWT.INHERIT_DEFAULT);
    sc3.addControlListener(new ControlListener() {

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

        public void controlResized(ControlEvent e) {
            // System.out.println("sc3 controlResized");
            onSashResized(display);
        }
    });
    outputTablesZoneView = new OutputTablesZoneView(sc3, getBorder(), mapperManager);
    // this.dropTargetOperationListener.addControl(outputTablesZoneView);
    outputTablesZoneView.setBackgroundMode(SWT.INHERIT_DEFAULT);
    sc3.setExpandHorizontal(true);
    sc3.setContent(outputTablesZoneView);
    sc3MSListener = new MouseScrolledListener(mapperManager.getUiManager(), sc3);
    outputTablesZoneView.initInsertionIndicator();
    previousControl = null;
    List<OutputTable> tables = mapperModel.getOutputDataMapTables();
    Boolean minimizeStateOfTables = getMinimizedButtonState(tables);
    if (minimizeStateOfTables != null) {
        outputsZone.getToolbar().setMinimizeButtonState(minimizeStateOfTables.booleanValue());
    }
    for (IDataMapTable abstractDataMapTable : tables) {
        OutputDataMapTableView dataMapTableView = uiManager.createNewOutputTableView(previousControl, abstractDataMapTable, outputTablesZoneView);
        previousControl = dataMapTableView;
    }
    outputTablesZoneView.setSize(outputTablesZoneView.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) OutputsZone(org.talend.designer.dbmap.ui.visualmap.zone.OutputsZone) OutputTablesZoneView(org.talend.designer.dbmap.ui.visualmap.zone.scrollable.OutputTablesZoneView) MouseScrolledListener(org.talend.designer.abstractmap.ui.listener.MouseScrolledListener) OutputTable(org.talend.designer.dbmap.model.table.OutputTable) 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) OutputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView)

Example 35 with IDataMapTable

use of org.talend.designer.abstractmap.model.table.IDataMapTable in project tdi-studio-se by Talend.

the class UIManager method processColumnNameChanged.

/**
     * DOC amaumont Comment method "processNewProcessColumnName".
     * 
     * @param previousColumnName TODO
     * @param dataMapTableView
     * @param text
     * @param entry
     */
public void processColumnNameChanged(final String previousColumnName, final String newColumnName, final DataMapTableView dataMapTableView, final ITableEntry currentModifiedITableEntry) {
    mapperManager.changeColumnName(currentModifiedITableEntry, previousColumnName, newColumnName);
    Collection<DataMapTableView> tableViews = mapperManager.getTablesView();
    boolean atLeastOneLinkHasBeenRemoved = false;
    for (DataMapTableView view : tableViews) {
        IDataMapTable dataMapTable = view.getDataMapTable();
        List<IColumnEntry> metadataTableEntries = dataMapTable.getColumnEntries();
        for (IColumnEntry entry : metadataTableEntries) {
            if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
                atLeastOneLinkHasBeenRemoved = true;
            }
        }
        // for the input/output table expression filter
        if (dataMapTable instanceof AbstractInOutTable) {
            ExpressionFilterEntry expressionFilterEntry = ((AbstractInOutTable) dataMapTable).getExpressionFilter();
            if (expressionFilterEntry != null && expressionFilterEntry.getExpression() != null) {
                if (parseExpression(expressionFilterEntry.getExpression(), expressionFilterEntry, true, true, false).isAtLeastOneLinkRemoved()) {
                    atLeastOneLinkHasBeenRemoved = true;
                }
            }
        }
    }
    mapperManager.getUiManager().refreshBackground(false, false);
    dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(currentModifiedITableEntry);
    if (atLeastOneLinkHasBeenRemoved) {
        new AsynchronousThreading(20, false, dataMapTableView.getDisplay(), new Runnable() {

            public void run() {
                TableViewerCreator tableViewerCreatorForColumns = dataMapTableView.getTableViewerCreatorForColumns();
                boolean propagate = MessageDialog.openQuestion(tableViewerCreatorForColumns.getTable().getShell(), //$NON-NLS-1$
                Messages.getString("UIManager.propagateTitle"), //$NON-NLS-1$
                Messages.getString("UIManager.propagateMessage"));
                if (propagate) {
                    TableEntryLocation previousLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), previousColumnName);
                    TableEntryLocation newLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), newColumnName);
                    mapperManager.replacePreviousLocationInAllExpressions(previousLocation, newLocation);
                }
            }
        }).start();
    }
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) 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) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) AsynchronousThreading(org.talend.commons.ui.runtime.thread.AsynchronousThreading)

Aggregations

IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)39 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)14 ArrayList (java.util.ArrayList)9 OutputTable (org.talend.designer.mapper.model.table.OutputTable)8 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)7 OutputTable (org.talend.designer.dbmap.model.table.OutputTable)7 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)6 InputTable (org.talend.designer.dbmap.model.table.InputTable)5 FilterTableEntry (org.talend.designer.dbmap.model.tableentry.FilterTableEntry)5 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)5 List (java.util.List)4 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)4 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)4 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)4 OutputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView)4 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)4 InputTable (org.talend.designer.mapper.model.table.InputTable)4 VarsTable (org.talend.designer.mapper.model.table.VarsTable)4 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)4 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)3