Search in sources :

Example 1 with IUILookupMode

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

the class InputDataMapTableView method createGlobalMapTable.

protected void createGlobalMapTable() {
    this.extendedTableViewerForGlobalMap = new AbstractExtendedTableViewer<GlobalMapEntry>(((InputTable) abstractDataMapTable).getTableGlobalMapEntriesModel(), centerComposite) {

        @Override
        protected void createColumns(TableViewerCreator<GlobalMapEntry> tableViewerCreator, Table table) {
            createGlobalMapColumns(tableViewerCreator);
        }

        /*
             * (non-Javadoc)
             * 
             * @see
             * org.talend.commons.ui.swt.extended.macrotable.AbstractExtendedTableViewer#setTableViewerCreatorOptions
             * (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)
             */
        @Override
        protected void setTableViewerCreatorOptions(TableViewerCreator<GlobalMapEntry> newTableViewerCreator) {
            super.setTableViewerCreatorOptions(newTableViewerCreator);
            newTableViewerCreator.setColumnsResizableByDefault(true);
            newTableViewerCreator.setShowLineSelection(SHOW_ROW_SELECTION.FULL);
            newTableViewerCreator.setBorderVisible(false);
            newTableViewerCreator.setLayoutMode(LAYOUT_MODE.FILL_HORIZONTAL);
            newTableViewerCreator.setKeyboardManagementForCellEdition(true);
            newTableViewerCreator.setHorizontalScroll(false);
            newTableViewerCreator.setVerticalScroll(false);
            // tableViewerCreatorForColumns.setUseCustomItemColoring(this.getDataMapTable()
            // instanceof
            // AbstractInOutTable);
            newTableViewerCreator.setFirstColumnMasked(true);
        }
    };
    tableViewerCreatorForGlobalMap = this.extendedTableViewerForGlobalMap.getTableViewerCreator();
    if (mapperManager.componentIsReadOnly()) {
        tableViewerCreatorForGlobalMap.setReadOnly(true);
    }
    this.extendedTableViewerForGlobalMap.setCommandStack(mapperManager.getCommandStack());
    tableForGlobalMap = tableViewerCreatorForGlobalMap.getTable();
    tableForGlobalMapGridData = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
    tableForGlobalMap.setLayoutData(tableForGlobalMapGridData);
    boolean tableGlobalMapVisible = false;
    if (abstractDataMapTable instanceof InputTable) {
        IUILookupMode lookupMode = ((InputTable) abstractDataMapTable).getLookupMode();
        tableGlobalMapVisible = lookupMode == TMAP_LOOKUP_MODE.RELOAD || lookupMode == TMAP_LOOKUP_MODE.CACHE_OR_RELOAD;
    }
    tableForGlobalMapGridData.exclude = !tableGlobalMapVisible;
    tableForGlobalMap.setVisible(tableGlobalMapVisible);
    if (!mapperManager.componentIsReadOnly()) {
        new DragNDrop(mapperManager, tableForGlobalMap, false, true);
    }
    tableViewerCreatorForGlobalMap.addCellValueModifiedListener(new ITableCellValueModifiedListener() {

        public void cellValueModified(TableCellValueModifiedEvent e) {
            unselectAllEntriesIfErrorDetected(e);
        }
    });
    final TableViewer tableViewer = tableViewerCreatorForGlobalMap.getTableViewer();
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            selectThisDataMapTableView();
            UIManager uiManager = mapperManager.getUiManager();
            uiManager.selectLinks(InputDataMapTableView.this, uiManager.extractSelectedTableEntries(selection), false, false);
        }
    });
    tableForGlobalMap.addListener(SWT.KeyDown, new Listener() {

        public void handleEvent(Event event) {
            processEnterKeyDown(tableViewerCreatorForGlobalMap, event);
        }
    });
    tableViewerCreatorForGlobalMap.setLabelProvider(new DefaultTableLabelProvider(tableViewerCreatorForGlobalMap) {

        @Override
        public Color getBackground(Object element, int columnIndex) {
            return getBackgroundCellColor(tableViewerCreator, element, columnIndex);
        }

        @Override
        public Color getForeground(Object element, int columnIndex) {
            return getForegroundCellColor(tableViewerCreator, element, columnIndex);
        }
    });
    initShowMessageErrorListener(tableForGlobalMap);
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) InputTable(org.talend.designer.mapper.model.table.InputTable) Table(org.eclipse.swt.widgets.Table) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) DefaultHeaderColumnSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.DefaultHeaderColumnSelectionListener) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ArmListener(org.eclipse.swt.events.ArmListener) FocusListener(org.eclipse.swt.events.FocusListener) Listener(org.eclipse.swt.widgets.Listener) IUILookupMode(org.talend.designer.mapper.model.table.IUILookupMode) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Color(org.eclipse.swt.graphics.Color) UIManager(org.talend.designer.mapper.managers.UIManager) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) Point(org.eclipse.swt.graphics.Point) InputTable(org.talend.designer.mapper.model.table.InputTable) DragNDrop(org.talend.designer.mapper.ui.dnd.DragNDrop) GridData(org.eclipse.swt.layout.GridData) ISelection(org.eclipse.jface.viewers.ISelection) DefaultTableLabelProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.DefaultTableLabelProvider) FocusEvent(org.eclipse.swt.events.FocusEvent) ArmEvent(org.eclipse.swt.events.ArmEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry) TableViewer(org.eclipse.jface.viewers.TableViewer) AbstractExtendedTableViewer(org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer)

Example 2 with IUILookupMode

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

the class InputDataMapTableView method openCustomCellDialog.

@Override
protected Object openCustomCellDialog(Shell shell, CellValueType type) {
    if (type == CellValueType.LOOKUP_MODEL) {
        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());
        }
        ListStringValueDialog<String> dialog = new ListStringValueDialog<String>(shell, names);
        if (dialog.open() == IDialogConstants.OK_ID) {
            return dialog.getSelectStr();
        }
    } else if (type == CellValueType.MATCH_MODEL) {
        IUIMatchingMode[] matchModel = getMatchModel();
        List<String> names = new ArrayList<String>();
        for (IUIMatchingMode element : matchModel) {
            names.add(element.getLabel());
        }
        ListStringValueDialog<String> dialog = new ListStringValueDialog<String>(shell, names);
        if (dialog.open() == IDialogConstants.OK_ID) {
            return dialog.getSelectStr();
        }
    } else if (type == CellValueType.JOIN_MODEL) {
        String[] items = new String[] { INNER_JOIN, LEFT_OUTER_JOIN };
        ListStringValueDialog<String> dialog = new ListStringValueDialog<String>(shell, items);
        if (dialog.open() == IDialogConstants.OK_ID) {
            return dialog.getSelectStr();
        }
    }
    return null;
}
Also used : IUILookupMode(org.talend.designer.mapper.model.table.IUILookupMode) ArrayList(java.util.ArrayList) IUIMatchingMode(org.talend.designer.mapper.model.table.IUIMatchingMode) List(java.util.List) ArrayList(java.util.ArrayList) ListStringValueDialog(org.talend.designer.mapper.ui.dialog.ListStringValueDialog)

Example 3 with IUILookupMode

use of org.talend.designer.mapper.model.table.IUILookupMode 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)

Aggregations

IUILookupMode (org.talend.designer.mapper.model.table.IUILookupMode)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)2 IUIMatchingMode (org.talend.designer.mapper.model.table.IUIMatchingMode)2 InputTable (org.talend.designer.mapper.model.table.InputTable)2 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)2 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 ArmEvent (org.eclipse.swt.events.ArmEvent)1 ArmListener (org.eclipse.swt.events.ArmListener)1 FocusEvent (org.eclipse.swt.events.FocusEvent)1 FocusListener (org.eclipse.swt.events.FocusListener)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Color (org.eclipse.swt.graphics.Color)1 Point (org.eclipse.swt.graphics.Point)1 GridData (org.eclipse.swt.layout.GridData)1