Search in sources :

Example 1 with ITableEntry

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

the class SearchZoneMapper method search.

public void search(Map<Integer, Map<Integer, ITableEntry>> searchMaps, String searchValue) {
    if (searchValue.equals("")) {
        uiManager.unselectAllEntriesOfAllTables();
        return;
    }
    // SearchPattern
    matcher.setPattern("*" + searchValue.trim() + "*");
    List<InputTable> inputTables = mapperManager.getInputTables();
    List<OutputTable> outputTables = mapperManager.getOutputTables();
    int index = -1;
    // for the InputTables
    for (InputTable inputTable : inputTables) {
        for (IColumnEntry column : inputTable.getColumnEntries()) {
            int i = -1;
            Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
            boolean modified = false;
            if (column.getExpression() != null && matcher.matches(column.getExpression())) {
                i++;
                map.put(i, column);
                modified = true;
            }
            if (column.getName() != null && matcher.matches(column.getName())) {
                i++;
                map.put(i, column);
                modified = true;
            }
            if (modified) {
                index++;
                searchMaps.put(index, map);
            }
        }
    }
    // for the OutputTables
    for (OutputTable outputTable : outputTables) {
        // OutputTable Filters
        for (FilterTableEntry entry : outputTable.getWhereFilterEntries()) {
            if (entry.getExpression() != null && matcher.matches(entry.getExpression())) {
                Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
                map.put(0, entry);
                index++;
                searchMaps.put(index, map);
            }
        }
        for (FilterTableEntry entry : outputTable.getOtherFilterEntries()) {
            if (entry.getExpression() != null && matcher.matches(entry.getExpression())) {
                Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
                map.put(0, entry);
                index++;
                searchMaps.put(index, map);
            }
        }
        // OutputTable Columns
        for (IColumnEntry column : outputTable.getColumnEntries()) {
            int i = -1;
            Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
            boolean modified = false;
            if (column.getExpression() != null && matcher.matches(column.getExpression())) {
                i++;
                map.put(i, column);
                modified = true;
            }
            if (column.getName() != null && matcher.matches(column.getName())) {
                i++;
                map.put(i, column);
                modified = true;
            }
            if (modified) {
                index++;
                searchMaps.put(index, map);
            }
        }
    }
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) HashMap(java.util.HashMap) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 2 with ITableEntry

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

the class VarsDataMapTableView method createToolItems.

@Override
protected void createToolItems() {
    // /////////////////////////////////////////////////////////////////
    ToolItem addEntryItem = new ToolItem(toolBarActions, SWT.PUSH);
    addEntryItem.setEnabled(!getMapperManager().componentIsReadOnly());
    //$NON-NLS-1$
    addEntryItem.setToolTipText(Messages.getString("VarsDataMapTableView.entryItemTooltip.addVariable"));
    addEntryItem.setImage(org.talend.commons.ui.runtime.image.ImageProvider.getImage(org.talend.commons.ui.runtime.image.ImageProvider.getImageDesc(EImage.ADD_ICON)));
    addEntryItem.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            TableViewerCreator<IColumnEntry> tableViewerCreator = getExtendedTableViewerForColumns().getTableViewerCreator();
            tableViewerCreator.applyActivatedCellEditor();
            Table table = getExtendedTableViewerForColumns().getTable();
            int[] indices = table.getSelectionIndices();
            int indexInsert = table.getItemCount();
            if (indices.length > 0) {
                indexInsert = indices[indices.length - 1] + 1;
            }
            IDataMapTable dataMapTable = VarsDataMapTableView.this.getDataMapTable();
            String varName = null;
            if (dataMapTable instanceof VarsTable) {
                //$NON-NLS-1$
                varName = ((VarsTable) dataMapTable).findUniqueColumnName("var");
            } else {
                throw new UnsupportedOperationException(Messages.getString(//$NON-NLS-1$
                "VarsDataMapTableView.exceptionMessage.caseNotFound"));
            }
            ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
            String type = null;
            if (currentLanguage.getCodeLanguage() == ECodeLanguage.JAVA) {
                type = JavaTypesManager.STRING.getId();
            } else {
                // fix bug 0018996 ,when add a var row,there is no default type,this bug exsit for long time
                type = PerlTypesManager.STRING;
            }
            mapperManager.addNewVarEntry(VarsDataMapTableView.this, varName, indexInsert, type);
            tableViewerCreatorForColumns.getTableViewer().refresh();
            if (canBeResizedAtPreferedSize()) {
                VarsDataMapTableView.this.changeSize(VarsDataMapTableView.this.getPreferredSize(true, true, false), true, true);
                changeMinimizeState(false);
            }
            mapperManager.getUiManager().refreshBackground(true, false);
            table.setSelection(indexInsert);
            removeEntryItem.setEnabled(true);
            moveUpEntryItem.setEnabled(true);
            moveDownEntryItem.setEnabled(true);
        }
    });
    // /////////////////////////////////////////////////////////////////
    // /////////////////////////////////////////////////////////////////
    removeEntryItem = new ToolItem(toolBarActions, SWT.PUSH);
    removeEntryItem.setEnabled(false);
    removeEntryItem.setImage(org.talend.commons.ui.runtime.image.ImageProvider.getImage(org.talend.commons.ui.runtime.image.ImageProvider.getImageDesc(EImage.MINUS_ICON)));
    //$NON-NLS-1$
    removeEntryItem.setToolTipText(Messages.getString("VarsDataMapTableView.entryItemTooltip.removeVariable"));
    removeEntryItem.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) tableViewerCreatorForColumns.getTableViewer().getSelection();
            List<ITableEntry> selectedBeans = selection.toList();
            for (ITableEntry entry : selectedBeans) {
                mapperManager.removeTableEntry(entry);
            }
            if (selectedBeans.size() > 0) {
                tableViewerCreatorForColumns.getTableViewer().refresh();
                mapperManager.getUiManager().refreshBackground(true, false);
                if (canBeResizedAtPreferedSize()) {
                    resizeAtExpandedSize();
                }
            }
            removeEntryItem.setEnabled(false);
        }
    });
    // /////////////////////////////////////////////////////////////////
    // /////////////////////////////////////////////////////////////////
    moveUpEntryItem = new ToolItem(toolBarActions, SWT.PUSH);
    moveUpEntryItem.setEnabled(false);
    moveUpEntryItem.setImage(ImageProvider.getImage(EImage.UP_ICON));
    //$NON-NLS-1$
    moveUpEntryItem.setToolTipText(Messages.getString("VarsDataMapTableView.entryItemTooltip.moveUpVariable"));
    moveUpEntryItem.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            AbstractExtendedTableViewer viewer = getExtendedTableViewerForColumns();
            ExtendedTableMoveCommand moveCommand = new ExtendedTableMoveCommand(viewer.getExtendedTableModel(), true, viewer.getTableViewerCreator().getTable().getSelectionIndices());
            viewer.getTableViewerCreator().applyActivatedCellEditor();
            viewer.executeCommand(moveCommand);
        }
    });
    // /////////////////////////////////////////////////////////////////
    // /////////////////////////////////////////////////////////////////
    moveDownEntryItem = new ToolItem(toolBarActions, SWT.PUSH);
    moveDownEntryItem.setEnabled(false);
    moveDownEntryItem.setImage(ImageProvider.getImage(EImage.DOWN_ICON));
    //$NON-NLS-1$
    moveDownEntryItem.setToolTipText(Messages.getString("VarsDataMapTableView.entryItemTooltip.movedownVariable"));
    moveDownEntryItem.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            AbstractExtendedTableViewer viewer = getExtendedTableViewerForColumns();
            ExtendedTableMoveCommand moveCommand = new ExtendedTableMoveCommand(viewer.getExtendedTableModel(), false, viewer.getTableViewerCreator().getTable().getSelectionIndices());
            viewer.getTableViewerCreator().applyActivatedCellEditor();
            viewer.executeCommand(moveCommand);
        }
    });
// /////////////////////////////////////////////////////////////////
}
Also used : ExtendedTableMoveCommand(org.talend.commons.ui.swt.advanced.dataeditor.commands.ExtendedTableMoveCommand) VarsTable(org.talend.designer.mapper.model.table.VarsTable) TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) Table(org.eclipse.swt.widgets.Table) VarsTable(org.talend.designer.mapper.model.table.VarsTable) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ILanguage(org.talend.designer.mapper.language.ILanguage) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) AbstractExtendedTableViewer(org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer) List(java.util.List) ToolItem(org.eclipse.swt.widgets.ToolItem) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 3 with ITableEntry

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

the class InputDataMapTableView method createGlobalMapColumns.

public void createGlobalMapColumns(final TableViewerCreator<GlobalMapEntry> tableViewerCreatorForGlobalMap) {
    TableViewerCreatorColumn<GlobalMapEntry, String> column = new TableViewerCreatorColumn<GlobalMapEntry, String>(tableViewerCreatorForGlobalMap);
    //        column.setTitle(Messages.getString("InputDataMapTableView.columnTitle.globalMapVar")); //$NON-NLS-1$
    //$NON-NLS-1$
    column.setTitle("Expr.");
    column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
    final ExtendedTextCellEditor expressionCellEditor = createExpressionCellEditor(tableViewerCreatorForGlobalMap, column, new Zone[] { Zone.INPUTS }, false);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<GlobalMapEntry, String>() {

        public String get(GlobalMapEntry bean) {
            return bean.getExpression();
        }

        public void set(GlobalMapEntry bean, String value) {
            bean.setExpression(value);
            mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
        }
    });
    column.setModifiable(true);
    //$NON-NLS-1$
    column.setDefaultInternalValue("");
    column.setWeight(COLUMN_EXPRESSION_SIZE_WEIGHT);
    column.setMoveable(false);
    column.setResizable(true);
    column = new TableViewerCreatorColumn<GlobalMapEntry, String>(tableViewerCreatorForGlobalMap);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("InputDataMapTableView.globalMapKey"));
    column.setId(DataMapTableView.ID_NAME_COLUMN);
    column.setModifiable(true);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<GlobalMapEntry, String>() {

        public String get(GlobalMapEntry bean) {
            return bean.getName();
        }

        public void set(GlobalMapEntry bean, String value) {
            bean.setName(value);
        }
    });
    column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
    final TextCellEditor cellEditor = new TextCellEditor(tableViewerCreatorForGlobalMap.getTable());
    column.setCellEditor(cellEditor);
    // Column with remove button
    column = new TableViewerCreatorColumn(tableViewerCreatorForGlobalMap);
    //$NON-NLS-1$
    column.setTitle("");
    //$NON-NLS-1$
    column.setDefaultDisplayedValue("");
    //$NON-NLS-1$
    column.setToolTipHeader(Messages.getString("InputDataMapTableView.addNewGlobalMapVar.tooltip"));
    column.setWeight(10);
    column.setWidth(25);
    column.setMoveable(false);
    column.setResizable(true);
    column.setImageHeader(org.talend.commons.ui.runtime.image.ImageProvider.getImage(org.talend.commons.ui.runtime.image.ImageProvider.getImageDesc(EImage.ADD_ICON)));
    column.setTableColumnSelectionListener(new DefaultHeaderColumnSelectionListener(column, tableViewerCreatorForGlobalMap) {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
             */
        @Override
        public void widgetSelected(SelectionEvent arg0) {
            if (!mapperManager.componentIsReadOnly()) {
                getInputTable().addGlobalMapEntry(//$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
                new GlobalMapEntry(getInputTable(), "\"" + findUniqueName("myKey") + "\"", ""));
                updateGridDataHeightForTableGlobalMap();
                resizeAtExpandedSize();
            }
        }
    });
    ButtonPushImageTableEditorContent buttonImage = new ButtonPushImageTableEditorContent() {

        /*
             * (non-Javadoc)
             * 
             * @see
             * org.talend.commons.ui.swt.tableviewer.tableeditor.ButtonImageTableEditorContent#selectionEvent(org.talend
             * .commons.ui.swt.tableviewer.TableViewerCreatorColumn, java.lang.Object)
             */
        @Override
        protected void selectionEvent(TableViewerCreatorColumnNotModifiable column, Object bean) {
            ITableEntry tableEntry = (ITableEntry) bean;
            if (!mapperManager.componentIsReadOnly()) {
                boolean removeEntry = MessageDialog.openConfirm(getShell(), //$NON-NLS-1$
                Messages.getString("InputDataMapTableView.removeGlobalMapVar.Title"), //$NON-NLS-1$
                Messages.getString("InputDataMapTableView.removeGlobalMapVar.Message", tableEntry.getName()));
                if (removeEntry) {
                    ExtendedTableRemoveCommand removeCommand = new ExtendedTableRemoveCommand(bean, extendedTableViewerForGlobalMap.getExtendedTableModel());
                    mapperManager.removeTableEntry((ITableEntry) bean);
                    mapperManager.executeCommand(removeCommand);
                    tableViewerCreatorForGlobalMap.getTableViewer().refresh();
                    List list = tableViewerCreatorForGlobalMap.getInputList();
                    updateGridDataHeightForTableGlobalMap();
                    resizeAtExpandedSize();
                }
            }
        }
    };
    buttonImage.setImage(ImageProvider.getImage(EImage.MINUS_ICON));
    column.setTableEditorContent(buttonImage);
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) TableViewerCreatorColumnNotModifiable(org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable) ButtonPushImageTableEditorContent(org.talend.commons.ui.runtime.swt.tableviewer.tableeditor.ButtonPushImageTableEditorContent) ExtendedTextCellEditor(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor) DefaultHeaderColumnSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.DefaultHeaderColumnSelectionListener) ExtendedTableRemoveCommand(org.talend.commons.ui.swt.advanced.dataeditor.commands.ExtendedTableRemoveCommand) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) ArrayList(java.util.ArrayList) ExtendedTextCellEditor(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

Example 4 with ITableEntry

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

the class VarsTable method checkValidColumnName.

/**
     * Check if the given name will be unique in the process. If another link already exists with that name, false will
     * be returned.
     * 
     * @param uniqueName
     * @return true if the name is unique
     */
public boolean checkValidColumnName(String connectionName) {
    for (ITableEntry entry : dataMapTableEntries) {
        if (entry.getName().equals(connectionName)) {
            return false;
        }
    }
    Perl5Matcher matcher = new Perl5Matcher();
    Perl5Compiler compiler = new Perl5Compiler();
    Pattern pattern;
    try {
        //$NON-NLS-1$
        pattern = compiler.compile("^[A-Za-z_][A-Za-z0-9_]*$");
        if (!matcher.matches(connectionName, pattern)) {
            return false;
        }
    } catch (MalformedPatternException e) {
        throw new RuntimeException(e);
    }
    return true;
}
Also used : Perl5Compiler(org.apache.oro.text.regex.Perl5Compiler) Pattern(org.apache.oro.text.regex.Pattern) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) Perl5Matcher(org.apache.oro.text.regex.Perl5Matcher) MalformedPatternException(org.apache.oro.text.regex.MalformedPatternException)

Example 5 with ITableEntry

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

the class CompleteDropTargetTableListener method insertNewGlobalMapEntryFromInputEntry.

private int insertNewGlobalMapEntryFromInputEntry(ILanguage currentLanguage, DataMapTableView dataMapTableViewTarget, int currentIndex, ITableEntry tableEntrySource) {
    ITableEntry dataMapTableEntry;
    dataMapTableEntry = getMapperManager().addNewGlobalMapEntry(dataMapTableViewTarget, tableEntrySource, currentIndex++);
    String location = currentLanguage.getLocation(tableEntrySource.getParentName(), tableEntrySource.getName());
    //$NON-NLS-1$
    dataMapTableEntry.setExpression(location + " ");
    return currentIndex;
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry)

Aggregations

ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)59 ArrayList (java.util.ArrayList)14 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)14 Point (org.eclipse.swt.graphics.Point)12 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)11 IMapperLink (org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink)11 List (java.util.List)9 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)9 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)9 TableViewer (org.eclipse.jface.viewers.TableViewer)7 FilterTableEntry (org.talend.designer.dbmap.model.tableentry.FilterTableEntry)7 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)7 HashMap (java.util.HashMap)6 MetadataTableEditorView (org.talend.core.ui.metadata.editor.MetadataTableEditorView)6 AbstractUIManager (org.talend.designer.abstractmap.managers.AbstractUIManager)6 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)6 TableEntryLocation (org.talend.designer.dbmap.model.tableentry.TableEntryLocation)6 Zone (org.talend.designer.mapper.ui.visualmap.zone.Zone)6 HashSet (java.util.HashSet)5 Iterator (java.util.Iterator)4