Search in sources :

Example 31 with TableViewerCreator

use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator in project tdi-studio-se by Talend.

the class UIManager method selectLinkedMetadataEditorEntries.

/**
     * DOC amaumont Comment method "selectTableEntries".
     * 
     * @param view
     * @param selectedTableEntries
     * @param selectionIndices
     */
public void selectLinkedMetadataEditorEntries(DataMapTableView view, int[] selectionIndices) {
    MetadataTableEditorView metadataTableEditorView = null;
    MetadataTableEditorView otherMetadataTableEditorView = null;
    if (view.getZone() == Zone.INPUTS) {
        metadataTableEditorView = getInputMetaEditorView();
        otherMetadataTableEditorView = getOutputMetaEditorView();
    } else if (view.getZone() == Zone.OUTPUTS) {
        metadataTableEditorView = getOutputMetaEditorView();
        otherMetadataTableEditorView = getInputMetaEditorView();
    }
    if (metadataTableEditorView != null) {
        metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
        metadataTableEditorView.getExtendedTableViewer().getTableViewerCreator().getSelectionHelper().setSelection(selectionIndices);
        metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
        metadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
    }
    if (otherMetadataTableEditorView != null) {
        otherMetadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
    }
    TableViewerCreator tableViewerCreatorForColumns = view.getTableViewerCreatorForColumns();
    if (tableViewerCreatorForColumns != null) {
        final TableViewer tableViewerForEntries = tableViewerCreatorForColumns.getTableViewer();
        if (tableViewerForEntries.getSelection() != null) {
            List<ITableEntry> extractSelectedTableEntries = extractSelectedTableEntries(tableViewerForEntries.getSelection());
            for (ITableEntry entry : extractSelectedTableEntries) {
                if (entry instanceof OutputColumnTableEntry) {
                    if (((OutputColumnTableEntry) entry).getMetadataColumn().isCustom() && view.getZone() == Zone.OUTPUTS) {
                        metadataTableEditorView.getExtendedToolbar().getRemoveButton().getButton().setEnabled(false);
                        break;
                    }
                }
            }
        }
    }
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) OutputColumnTableEntry(org.talend.designer.mapper.model.tableentry.OutputColumnTableEntry) AbstractMetadataTableEditorView(org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 32 with TableViewerCreator

use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator in project tdi-studio-se by Talend.

the class UIManager method applyActivatedCellEditorsForAllTables.

/**
     * 
     * "applyActivatedCellEditorsForAllTables".
     * 
     * @param exceptThisTableViewerCreator
     */
public void applyActivatedCellEditorsForAllTables(TableViewerCreator exceptThisTableViewerCreator) {
    Collection<DataMapTableView> tablesView = mapperManager.getTablesView();
    for (DataMapTableView dataMapTableView : tablesView) {
        TableViewerCreator tableViewerCreatorForColumns = dataMapTableView.getTableViewerCreatorForColumns();
        if (tableViewerCreatorForColumns != exceptThisTableViewerCreator) {
            applyActivatedCellEditors(tableViewerCreatorForColumns);
        }
        TableViewerCreator tableViewerCreatorForGlobalMap = dataMapTableView.getTableViewerCreatorForGlobalMap();
        if (tableViewerCreatorForGlobalMap != null && tableViewerCreatorForGlobalMap != exceptThisTableViewerCreator) {
            applyActivatedCellEditors(tableViewerCreatorForGlobalMap);
        }
    }
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) 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)

Example 33 with TableViewerCreator

use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator in project tdi-studio-se by Talend.

the class ProblemsManager method checkProblemsForTableEntry.

public boolean checkProblemsForTableEntry(ITableEntry tableEntry, boolean forceRefreshData, boolean checkLookupProblem) {
    if (!mapperManager.isCheckSyntaxEnabled()) {
        return false;
    }
    if (forceRefreshData) {
        mapperManager.getAbstractMapComponent().restoreMapperModelFromInternalData();
        checkProblems();
    }
    String expression = tableEntry.getExpression();
    List<Problem> problems = null;
    if (expression == null || EMPTY_STRING.equals(expression.trim())) {
        problems = null;
    } else {
        // System.out.println("check=" + expression);
        if (codeLanguage == ECodeLanguage.PERL) {
            problems = codeChecker.checkProblemsForExpression(expression);
        } else if (codeLanguage == ECodeLanguage.JAVA) {
            PROBLEM_KEY_FIELD problemKeyField = JavaGenerationManager.PROBLEM_KEY_FIELD.METADATA_COLUMN;
            String entryName = tableEntry.getName();
            if (tableEntry instanceof FilterTableEntry || tableEntry instanceof ExpressionFilterEntry) {
                problemKeyField = JavaGenerationManager.PROBLEM_KEY_FIELD.FILTER;
                entryName = null;
            }
            problems = checkJavaProblemsForEntry(problemKeyField, tableEntry.getParent().getName(), entryName, forceRefreshData);
        }
        if (problems != null) {
            for (Iterator iter = problems.iterator(); iter.hasNext(); ) {
                Problem problem = (Problem) iter.next();
                ProblemStatus status = problem.getStatus();
                if (status != ProblemStatus.ERROR) {
                    iter.remove();
                }
            }
        } else {
            problems = null;
        }
    }
    if (problems != null) {
        if (problems.size() == 0) {
            tableEntry.setProblems(null);
        } else {
            hasProblems = true;
            tableEntry.setProblems(problems);
        }
    } else {
        tableEntry.setProblems(problems);
    }
    // check problem for M/R process , only needed if modify lookup expressions
    if (checkLookupProblem) {
        checkLookupExpressionProblem();
    }
    // no need to update again
    TableViewerCreator tableViewerCreator = mapperManager.retrieveTableViewerCreator(tableEntry);
    DataMapTableView retrieveDataMapTableView = mapperManager.retrieveDataMapTableView(tableEntry);
    mapperManager.getUiManager().applyActivatedCellEditors(tableViewerCreator);
    return problems != null;
}
Also used : ProblemStatus(org.talend.core.model.process.Problem.ProblemStatus) TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) Iterator(java.util.Iterator) Problem(org.talend.core.model.process.Problem) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) PROBLEM_KEY_FIELD(org.talend.designer.mapper.language.generation.JavaGenerationManager.PROBLEM_KEY_FIELD)

Example 34 with TableViewerCreator

use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator in project tesb-studio-se by Talend.

the class ConfigOptionController method refresh.

@Override
public void refresh(IElementParameter param, boolean check) {
    TableViewerCreator tableViewerCreator = (TableViewerCreator) hashCurControls.get("NEED_UPDATE_LIST");
    if (tableViewerCreator == null || tableViewerCreator.getTable() == null || tableViewerCreator.getTable().isDisposed()) {
        return;
    } else {
        tableViewerCreator.getTableViewer().refresh();
        TableViewerCreatorColumn ttt = (TableViewerCreatorColumn) tableViewerCreator.getColumns().get(1);
        ttt.getTableColumn().setWidth(0);
        ttt.getTableColumn().setText("");
        ttt.getTableColumn().setResizable(false);
    }
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)

Example 35 with TableViewerCreator

use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator in project tdi-studio-se by Talend.

the class CompleteDropTargetTableListener method drop.

// private void showInfos(DropTargetEvent event) {
// System.out.println(event);
// System.out.println("event.feedback=" + event.feedback);
// System.out.println("event.detail=" + event.detail);
// System.out.println("event.operations=" + event.operations);
//
// System.out.println("DND.DROP_DEFAULT=" + DND.DROP_DEFAULT);
// System.out.println("DND.DROP_COPY=" + DND.DROP_COPY);
// System.out.println("DND.DROP_MOVE=" + DND.DROP_MOVE);
// System.out.println("DND.DROP_LINK=" + DND.DROP_LINK);
// System.out.println("DND.DROP_TARGET_MOVE=" + DND.DROP_TARGET_MOVE);
// }
//
@Override
public void drop(DropTargetEvent event) {
    super.drop(event);
    retrieveInsertionIndicator().setVisible(false);
    UIManager uiManager = getUiManager();
    DraggedData draggedData = TableEntriesTransfer.getInstance().getDraggedData();
    DropContextAnalyzer analyzer = analyzeDropTarget(event, draggedData);
    // System.out.println("\n>>drop");
    // System.out.println(event);
    Point cursorPosition = new Point(event.x, event.y);
    // int startInsertAtThisIndex = getItemIndexWhereInsertFromPosition(cursorPosition);
    int startInsertAtThisIndex = TableUtils.getItemIndexWhereInsertFromPosition(draggableTargetControl, cursorPosition);
    ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
    DataMapTableView dataMapTableViewTarget = getMapperManager().retrieveDataMapTableView(draggableTargetControl);
    Zone zoneTarget = dataMapTableViewTarget.getZone();
    uiManager.selectDataMapTableView(dataMapTableViewTarget, true, false);
    MetadataTableEditorView metadataEditorView = getUiManager().getMetadataEditorView(dataMapTableViewTarget.getZone());
    List<TransferableEntry> transferableEntryList = draggedData.getTransferableEntryList();
    int currentIndex = startInsertAtThisIndex;
    uiManager.clearLastCreatedInOutColumnEntries();
    draggableTargetControl.deselectAll();
    ITableEntry currentEntryTarget = getEntryFromPosition(cursorPosition);
    ArrayList<String> columnsBeingAdded = new ArrayList<String>();
    ArrayList<Integer> columnIndicesToSelect = new ArrayList<Integer>();
    ArrayList<ITableEntry> sourceEntriesOfEntriesBeingAdded = new ArrayList<ITableEntry>();
    ArrayList<IMetadataColumn> metadataColumnsBeingAdded = new ArrayList<IMetadataColumn>();
    boolean targetTableIsFiltersTable = analyzer.targetTableIsFiltersTable();
    boolean targetTableIsGlobalMapTable = analyzer.targetTableIsGlobalMapTable();
    boolean atLeastOneEntryInserted = false;
    boolean insertionEntryMode = analyzer.isInsertionEntryMode();
    boolean mapEachSourceToNextTargets = analyzer.isMapOneToOneMode();
    TableViewerCreator tableViewerCreatorTarget = null;
    if (!analyzer.targetIsExpressionFilterText()) {
        if (targetTableIsFiltersTable) {
            tableViewerCreatorTarget = dataMapTableViewTarget.getTableViewerCreatorForFilters();
        } else if (targetTableIsGlobalMapTable) {
            tableViewerCreatorTarget = dataMapTableViewTarget.getTableViewerCreatorForGlobalMap();
        } else {
            tableViewerCreatorTarget = dataMapTableViewTarget.getTableViewerCreatorForColumns();
        }
    }
    uiManager.applyActivatedCellEditors(tableViewerCreatorTarget);
    // MapperDropCommand dropCommand = new MapperDropCommand();
    // MetadataEditorEvent metadataEditorEvent = new MetadataEditorEvent(MetadataEditorEvent.TYPE.ADD);
    ITableEntry lastEntryTarget = null;
    for (TransferableEntry transferableEntry : transferableEntryList) {
        ITableEntry tableEntrySource = transferableEntry.getTableEntrySource();
        IMetadataColumn metadataColumnDragged = transferableEntry.getMetadataColumn();
        Zone zoneSourceEntry = (Zone) transferableEntry.getZoneSourceEntry();
        TableEntryLocation tableEntryLocationTarget = new TableEntryLocation(dataMapTableViewTarget.getDataMapTable().getName(), tableEntrySource.getName());
        if (zoneSourceEntry == Zone.INPUTS && zoneTarget == Zone.INPUTS && tableEntrySource.getParentName().equals(tableEntryLocationTarget.tableName)) {
            continue;
        } else if (currentEntryTarget != null && !insertionEntryMode) {
            // set the default operator.
            if (currentEntryTarget instanceof InputColumnTableEntry) {
                ((InputColumnTableEntry) currentEntryTarget).setOperator(Operator.EQUALS.getLiteral());
            }
            boolean overwrite = (lastEntryTarget != currentEntryTarget && analyzer.isOverwriteExpression());
            modifyExistingExpression(currentLanguage, currentEntryTarget, tableEntrySource, overwrite, zoneSourceEntry);
            uiManager.parseExpression(currentEntryTarget.getExpression(), currentEntryTarget, false, true, true);
            int indexOfEntry = tableViewerCreatorTarget.getInputList().indexOf(currentEntryTarget);
            columnIndicesToSelect.add(indexOfEntry);
        } else {
            String columnName = transferableEntry.getTableEntrySource().getName();
            tableEntryLocationTarget = getMapperManager().findUniqueLocation(tableEntryLocationTarget, dataMapTableViewTarget.getDataMapTable());
            columnName = tableEntryLocationTarget.columnName;
            if (currentEntryTarget == null && analyzer.isMapOneToOneMode()) {
                currentIndex = tableViewerCreatorTarget.getInputList().size();
                columnIndicesToSelect.add(currentIndex);
            }
            if (zoneSourceEntry == Zone.INPUTS && zoneTarget == Zone.VARS || zoneSourceEntry == Zone.VARS && zoneTarget == Zone.VARS) {
                columnIndicesToSelect.add(currentIndex);
                currentIndex = insertNewVarEntry(currentLanguage, dataMapTableViewTarget, currentIndex, tableEntrySource, columnName);
                atLeastOneEntryInserted = true;
            } else if (zoneSourceEntry == Zone.VARS && zoneTarget == Zone.OUTPUTS) {
                insertNewOutputEntryFromVarEntry(sourceEntriesOfEntriesBeingAdded, metadataColumnsBeingAdded, // metadataEditorEvent,
                tableEntrySource, columnName);
                atLeastOneEntryInserted = true;
            } else if (zoneSourceEntry == Zone.INPUTS && targetTableIsGlobalMapTable) {
                insertNewGlobalMapEntryFromInputEntry(currentLanguage, dataMapTableViewTarget, currentIndex, tableEntrySource);
                atLeastOneEntryInserted = true;
            } else if (zoneSourceEntry == Zone.INPUTS && zoneTarget != Zone.VARS) {
                insertNewInOutEntryFromInputEntry(sourceEntriesOfEntriesBeingAdded, metadataColumnsBeingAdded, // metadataEditorEvent,
                tableEntrySource, metadataColumnDragged, columnName);
                atLeastOneEntryInserted = true;
            } else if (zoneSourceEntry == Zone.OUTPUTS && zoneTarget == Zone.VARS) {
            // nothing
            } else if (zoneSourceEntry == Zone.OUTPUTS && zoneTarget == Zone.OUTPUTS) {
                insertOutpuEntryCopyToOtherOutput(sourceEntriesOfEntriesBeingAdded, metadataColumnsBeingAdded, // metadataEditorEvent,
                tableEntrySource, metadataColumnDragged, columnName);
                atLeastOneEntryInserted = true;
            } else {
            // throw new IllegalStateException("Drop case not found !");
            }
            columnsBeingAdded.add(columnName);
        }
        lastEntryTarget = currentEntryTarget;
        if (mapEachSourceToNextTargets && currentEntryTarget != null) {
            currentEntryTarget = getNextEntryTarget(currentEntryTarget, tableViewerCreatorTarget);
        }
    }
    if (!atLeastOneEntryInserted) {
        tableViewerCreatorTarget.getTableViewer().refresh();
    } else {
        updateExpressionsOfInsertedEntries(currentLanguage, metadataEditorView, currentIndex, sourceEntriesOfEntriesBeingAdded, targetTableIsFiltersTable, tableViewerCreatorTarget, // , metadataEditorEvent
        metadataColumnsBeingAdded);
        for (int i = currentIndex; i < currentIndex + sourceEntriesOfEntriesBeingAdded.size(); i++) {
            columnIndicesToSelect.add(i);
        }
    }
    if (zoneTarget == Zone.VARS) {
        dataMapTableViewTarget.resizeAtExpandedSize();
    }
    if (targetTableIsGlobalMapTable) {
        dataMapTableViewTarget.updateGridDataHeightForTableGlobalMap();
        dataMapTableViewTarget.resizeAtExpandedSize();
    }
    uiManager.unselectAllEntriesOfAllTables();
    uiManager.refreshBackground(true, false);
    if (metadataEditorView != null && !targetTableIsFiltersTable) {
        metadataEditorView.getTableViewerCreator().getTableViewer().refresh();
    }
    int[] selection = ArrayUtils.toPrimitive(columnIndicesToSelect.toArray(new Integer[0]));
    tableViewerCreatorTarget.getSelectionHelper().setSelection(selection);
    ISelection iselection = tableViewerCreatorTarget.getTableViewer().getSelection();
    List<ITableEntry> selectedEntries = uiManager.extractSelectedTableEntries(iselection);
    tableViewerCreatorTarget.getTable().deselectAll();
    uiManager.unselectAllOutputMetaDataEntries();
    uiManager.unselectAllInputMetaDataEntries();
    uiManager.parseAllExpressionsForAllTables();
    getMapperManager().getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
    getMapperManager().getProblemsManager().checkLookupExpressionProblem();
    uiManager.selectLinks(dataMapTableViewTarget, selectedEntries, true, false);
    dataMapTableViewTarget.checkChangementsAfterEntryModifiedOrAdded(false);
    tableViewerCreatorTarget.getTable().setFocus();
    uiManager.setDragging(false);
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ArrayList(java.util.ArrayList) AbstractUIManager(org.talend.designer.abstractmap.managers.AbstractUIManager) UIManager(org.talend.designer.mapper.managers.UIManager) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) ISelection(org.eclipse.jface.viewers.ISelection) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) TransferableEntry(org.talend.designer.abstractmap.ui.dnd.TransferableEntry) Zone(org.talend.designer.mapper.ui.visualmap.zone.Zone) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) DraggedData(org.talend.designer.abstractmap.ui.dnd.DraggedData) Point(org.eclipse.swt.graphics.Point) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) Point(org.eclipse.swt.graphics.Point) ILanguage(org.talend.designer.mapper.language.ILanguage) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)

Aggregations

TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)36 ArrayList (java.util.ArrayList)14 List (java.util.List)14 Point (org.eclipse.swt.graphics.Point)14 TableViewerCreatorColumnNotModifiable (org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable)11 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)11 HashMap (java.util.HashMap)10 Map (java.util.Map)10 CCombo (org.eclipse.swt.custom.CCombo)8 IElementParameter (org.talend.core.model.process.IElementParameter)8 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)8 MetadataTableEditorView (org.talend.core.ui.metadata.editor.MetadataTableEditorView)6 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)6 TableViewer (org.eclipse.jface.viewers.TableViewer)4 DisposeEvent (org.eclipse.swt.events.DisposeEvent)4 DisposeListener (org.eclipse.swt.events.DisposeListener)4 ILineSelectionListener (org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener)4 LineSelectionEvent (org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent)4 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)4 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)4