Search in sources :

Example 1 with ComboEditorValueAdapter

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

Aggregations

CellEditor (org.eclipse.jface.viewers.CellEditor)1 TableViewerCreatorColumnNotModifiable (org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable)1 CellEditorValueAdapter (org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter)1 ComboEditorValueAdapter (org.talend.commons.ui.runtime.swt.tableviewer.behavior.ComboEditorValueAdapter)1 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)1