Search in sources :

Example 6 with TableViewerCreatorColumnNotModifiable

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

the class XmlMapLabelProvider method getColumnText.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
     */
@Override
public String getColumnText(Object element, int columnIndex) {
    String returnValue = null;
    TableViewerCreatorColumnNotModifiable column = (TableViewerCreatorColumnNotModifiable) this.tableViewerCreator.getColumns().get(columnIndex);
    if (column.getLabelProvider() != null) {
        returnValue = column.getLabelProvider().getLabel(element);
    }
    if (returnValue == null) {
        if (column.getDisplayedValue() != null || column.getDefaultDisplayedValue() != null || column.getBeanPropertyAccessors() == null) {
            String defaultValue = column.getDefaultDisplayedValue();
            String imposedDisplayedValue = column.getDisplayedValue();
            if (imposedDisplayedValue != null) {
                returnValue = imposedDisplayedValue;
            } else if (defaultValue == null) {
                //$NON-NLS-1$
                returnValue = "";
            } else {
                returnValue = defaultValue;
            }
        } else {
            Object value = AccessorUtils.get(element, column);
            CellEditor cellEditor = column.getCellEditor();
            CellEditorValueAdapter retrieverValue = column.getCellEditorValueAdapter();
            // add for bug TDI-21505
            if (value != null && column.getCellEditorValueAdapter() != null && column.getCellEditorValueAdapter() instanceof ComboEditorValueAdapter) {
                Object returnObject = column.getCellEditorValueAdapter().getCellEditorTypedValue(column.getCellEditor(), value);
                if ("-1".equals(returnObject + "")) {
                    return "";
                }
            }
            if (cellEditor != null && retrieverValue != null && value != null) {
                if (element instanceof TreeNode) {
                    if ((((TreeNode) element).getNodeType()).equals(NodeType.ELEMENT)) {
                        returnValue = retrieverValue.getColumnText(cellEditor, element, value);
                    }
                }
            } else if (value != null) {
                returnValue = String.valueOf(value);
            } else {
                //$NON-NLS-1$
                returnValue = "";
            }
        }
        // return the type
        if (columnIndex == 3) {
            if (element instanceof TreeNode) {
                TreeNode node = (TreeNode) element;
                returnValue = TalendTypeConvert.convertToJavaType(node.getType());
            }
        }
    }
    return returnValue;
}
Also used : CellEditor(org.eclipse.jface.viewers.CellEditor) ComboEditorValueAdapter(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ComboEditorValueAdapter) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) TableViewerCreatorColumnNotModifiable(org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable) CellEditorValueAdapter(org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter)

Example 7 with TableViewerCreatorColumnNotModifiable

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

the class XmlCellModifier method getValue.

@Override
public Object getValue(Object bean, String idColumn) {
    if (!AbstractXmlTreeSchemaTableView.ID_COLUMN_XPATH.equals(idColumn)) {
        return super.getValue(bean, idColumn);
    } else {
        TableViewerCreatorColumnNotModifiable column = tableViewerCreator.getColumn(idColumn);
        ModifiedObjectInfo modifiedObjectInfo = this.tableViewerCreator.getModifiedObjectInfo();
        modifiedObjectInfo.setCurrentModifiedBean(bean);
        modifiedObjectInfo.setCurrentModifiedColumn(column);
        modifiedObjectInfo.setCurrentModifiedIndex(this.tableViewerCreator.getInputList().indexOf(bean));
        Object returnValue = null;
        if (column.getColumnCellModifier() != null) {
            returnValue = column.getColumnCellModifier().getValue(bean);
        }
        if (returnValue == null) {
            Object value = AccessorUtils.get(bean, column);
            if (column.getCellEditorValueAdapter() != null) {
                returnValue = column.getCellEditorValueAdapter().getCellEditorTypedValue(column.getCellEditor(), value);
            } else {
                returnValue = value;
            }
            if (returnValue == null && column.getDefaultInternalValue() != null) {
                returnValue = column.getDefaultInternalValue();
            }
        }
        modifiedObjectInfo.setOriginalPropertyBeanValue(returnValue);
        modifiedObjectInfo.setPreviousPropertyBeanValue(returnValue);
        return returnValue;
    }
}
Also used : TableViewerCreatorColumnNotModifiable(org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable) ModifiedObjectInfo(org.talend.commons.ui.runtime.swt.tableviewer.data.ModifiedObjectInfo)

Example 8 with TableViewerCreatorColumnNotModifiable

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

the class TableController method updateConnectionList.

private void updateConnectionList(IElementParameter param) {
    // update table values
    TableViewerCreator tableViewerCreator = (TableViewerCreator) hashCurControls.get(param.getName());
    Object[] itemsValue = param.getListItemsValue();
    if (tableViewerCreator != null) {
        List colList = tableViewerCreator.getColumns();
        for (int j = 0; j < itemsValue.length; j++) {
            if ((j + 1) >= colList.size()) {
                break;
            }
            if (itemsValue[j] instanceof IElementParameter) {
                IElementParameter tmpParam = (IElementParameter) itemsValue[j];
                if (tmpParam.getFieldType() == EParameterFieldType.CONNECTION_LIST) {
                    String[] contextParameterNames = null;
                    ConnectionListController.updateConnectionList(elem, tmpParam);
                    contextParameterNames = tmpParam.getListItemsDisplayName();
                    tmpParam.setListItemsDisplayCodeName(contextParameterNames);
                    // tmpParam.setListItemsValue(contextParameterNames);
                    if (contextParameterNames.length > 0) {
                        tmpParam.setDefaultClosedListValue(contextParameterNames[0]);
                    } else {
                        //$NON-NLS-1$
                        tmpParam.setDefaultClosedListValue("");
                    }
                    // j + 1 because first column is masked
                    TableViewerCreatorColumnNotModifiable column = (TableViewerCreatorColumnNotModifiable) colList.get(j + 1);
                    CCombo combo = (CCombo) column.getCellEditor().getControl();
                    String[] oldItems = combo.getItems();
                    combo.setItems(contextParameterNames);
                    List<Map<String, Object>> paramValues = (List<Map<String, Object>>) param.getValue();
                    String[] items = param.getListItemsDisplayCodeName();
                    for (int currentIndex = 0; currentIndex < paramValues.size(); currentIndex++) {
                        Map<String, Object> currentLine = paramValues.get(currentIndex);
                        Object o = currentLine.get(items[j]);
                        if (o instanceof Integer) {
                            Integer nb = (Integer) o;
                            if ((nb >= oldItems.length) || (nb == -1)) {
                                nb = new Integer(tmpParam.getIndexOfItemFromList((String) tmpParam.getDefaultClosedListValue()));
                                currentLine.put(items[j], nb);
                            } else {
                                nb = new Integer(tmpParam.getIndexOfItemFromList(oldItems[nb]));
                                currentLine.put(items[j], nb);
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) TableViewerCreatorColumnNotModifiable(org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable) Point(org.eclipse.swt.graphics.Point) CCombo(org.eclipse.swt.custom.CCombo) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 9 with TableViewerCreatorColumnNotModifiable

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

the class OutputDataMapTableView method createFiltersColumns.

public void createFiltersColumns(final TableViewerCreator<FilterTableEntry> tableViewerCreatorForFilters) {
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreatorForFilters);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("OutputDataMapTableView.columnTitle.filterCondition"));
    column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
    final ExtendedTextCellEditor expressionCellEditor = createExpressionCellEditor(tableViewerCreatorForFilters, column, new Zone[] { Zone.INPUTS, Zone.VARS }, true);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<FilterTableEntry, String>() {

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

        public void set(FilterTableEntry bean, String value) {
            bean.setExpression(value);
            mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
        }
    });
    column.setModifiable(true);
    //$NON-NLS-1$
    column.setDefaultInternalValue("");
    column.setWeight(99);
    column.setMoveable(false);
    column.setResizable(false);
    // Column with remove button
    column = new TableViewerCreatorColumn(tableViewerCreatorForFilters);
    //$NON-NLS-1$
    column.setTitle("");
    //$NON-NLS-1$
    column.setDefaultDisplayedValue("");
    column.setWidth(16);
    column.setMoveable(false);
    column.setResizable(false);
    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) {
            ExtendedTableRemoveCommand removeCommand = new ExtendedTableRemoveCommand(bean, extendedTableViewerForFilters.getExtendedTableModel());
            mapperManager.removeTableEntry((ITableEntry) bean);
            mapperManager.executeCommand(removeCommand);
            tableViewerCreatorForFilters.getTableViewer().refresh();
            List list = tableViewerCreatorForFilters.getInputList();
            updateGridDataHeightForTableConstraints();
            if (list != null && list.size() == 0) {
                showTableConstraints(false);
            } else {
                showTableConstraints(true);
            }
        }
    };
    buttonImage.setImage(ImageProvider.getImage(EImage.MINUS_ICON));
    column.setTableEditorContent(buttonImage);
}
Also used : TableViewerCreatorColumnNotModifiable(org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable) ExtendedTableRemoveCommand(org.talend.commons.ui.swt.advanced.dataeditor.commands.ExtendedTableRemoveCommand) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) ButtonPushImageTableEditorContent(org.talend.commons.ui.runtime.swt.tableviewer.tableeditor.ButtonPushImageTableEditorContent) ExtendedTextCellEditor(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor) List(java.util.List) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)

Example 10 with TableViewerCreatorColumnNotModifiable

use of org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable 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)

Aggregations

TableViewerCreatorColumnNotModifiable (org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable)23 List (java.util.List)11 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)11 Point (org.eclipse.swt.graphics.Point)10 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)8 Map (java.util.Map)8 CCombo (org.eclipse.swt.custom.CCombo)8 IElementParameter (org.talend.core.model.process.IElementParameter)8 CellEditor (org.eclipse.jface.viewers.CellEditor)3 TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)3 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)3 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)2 TableColumn (org.eclipse.swt.widgets.TableColumn)2 ExtendedTextCellEditor (org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor)2 ButtonPushImageTableEditorContent (org.talend.commons.ui.runtime.swt.tableviewer.tableeditor.ButtonPushImageTableEditorContent)2 ExtendedTableRemoveCommand (org.talend.commons.ui.swt.advanced.dataeditor.commands.ExtendedTableRemoveCommand)2 IConnection (org.talend.core.model.process.IConnection)2 IContext (org.talend.core.model.process.IContext)2 IContextParameter (org.talend.core.model.process.IContextParameter)2