Search in sources :

Example 21 with TableViewerCreatorColumnNotModifiable

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

the class DataMapTableView method getCellColor.

/**
     * DOC amaumont Comment method "getCellColor".
     * 
     * @param tableViewerCreator
     * @param element
     * @param columnIndex
     * @param isBackground TODO
     * @return
     */
protected Color getCellColor(TableViewerCreatorNotModifiable tableViewerCreator, Object element, int columnIndex, boolean isBackground) {
    ITableEntry entry = (ITableEntry) element;
    TableViewerCreatorColumnNotModifiable column = (TableViewerCreatorColumnNotModifiable) tableViewerCreator.getColumns().get(columnIndex);
    if (column.getId().equals(ID_EXPRESSION_COLUMN)) {
        return expressionColorProvider.getColor(isBackground, entry.getProblems(), ProblemsManager.KEY_INPUT_EXPRESSION_EMPTY, ProblemsManager.KEY_OUTPUT_EXPRESSION_EMPTY);
    }
    return null;
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) TableViewerCreatorColumnNotModifiable(org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable)

Example 22 with TableViewerCreatorColumnNotModifiable

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

the class TableByRowController method updateContextList.

private void updateContextList(IElementParameter param) {
    List<String> contextParameterNamesList = new ArrayList<String>();
    IElementParameter processTypeParam = elem.getElementParameterFromField(EParameterFieldType.PROCESS_TYPE);
    if (processTypeParam == null) {
        processTypeParam = elem.getElementParameterFromField(EParameterFieldType.ROUTE_INPUT_PROCESS_TYPE);
        if (processTypeParam == null) {
            return;
        }
    }
    boolean haveContextParamList = false;
    for (Object valueParam : param.getListItemsValue()) {
        if (valueParam instanceof IElementParameter) {
            IElementParameter vParam = (IElementParameter) valueParam;
            if (vParam.getFieldType() == EParameterFieldType.CONTEXT_PARAM_NAME_LIST) {
                haveContextParamList = true;
                break;
            }
        }
    }
    if (!haveContextParamList) {
        return;
    }
    IElementParameter jobElemParam = processTypeParam.getChildParameters().get(EParameterName.PROCESS_TYPE_PROCESS.getName());
    IElementParameter jobVersionParam = processTypeParam.getChildParameters().get(EParameterName.PROCESS_TYPE_VERSION.getName());
    IElementParameter contextElemParam = processTypeParam.getChildParameters().get(EParameterName.PROCESS_TYPE_CONTEXT.getName());
    // get context list
    String processId = (String) jobElemParam.getValue();
    String contextName = (String) contextElemParam.getValue();
    if (contextName == null) {
        contextName = new String();
    }
    if (processId == null || contextName == null) {
        revertToolBarButtonState(false);
        return;
    }
    ProcessItem processItem = ItemCacheManager.getProcessItem(processId, (String) jobVersionParam.getValue());
    Process process = null;
    String[] contextParameterNames = null;
    if (processItem != null) {
        // achen modify to fix bug 0006107
        IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
        process = (Process) service.getProcessFromItem(processItem);
        // process = new Process(processItem.getProperty());
        // process.loadXmlFile();
        IContext context = process.getContextManager().getContext(contextName);
        for (IContextParameter contextParam : context.getContextParameterList()) {
            contextParameterNamesList.add(contextParam.getName());
        }
        contextParameterNames = contextParameterNamesList.toArray(new String[0]);
    } else {
        contextParameterNames = new String[0];
    }
    // 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.CONTEXT_PARAM_NAME_LIST) {
                    tmpParam.setListItemsDisplayCodeName(contextParameterNames);
                    tmpParam.setListItemsDisplayName(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)) {
                                currentLine.put(items[j], tmpParam.getDefaultClosedListValue());
                            } else {
                                currentLine.put(items[j], oldItems[nb]);
                            }
                        } else {
                            if (o instanceof String) {
                                Integer nb = new Integer(tmpParam.getIndexOfItemFromList((String) o));
                                if (nb == -1) {
                                    currentLine.put(items[j], tmpParam.getDefaultClosedListValue());
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // (bug 3740)
    boolean checked = contextParameterNames != null && contextParameterNames.length > 0;
    if (!checked) {
        Object value = param.getValue();
        if (value != null && value instanceof List) {
            if (!((List) value).isEmpty()) {
                ((List) value).clear();
                if (part != null && part.getTalendEditor() != null) {
                    part.getTalendEditor().setDirty(true);
                }
            }
        }
    }
    revertToolBarButtonState(checked);
}
Also used : IContext(org.talend.core.model.process.IContext) TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) TableViewerCreatorColumnNotModifiable(org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable) ArrayList(java.util.ArrayList) Process(org.talend.designer.core.ui.editor.process.Process) IContextParameter(org.talend.core.model.process.IContextParameter) Point(org.eclipse.swt.graphics.Point) CCombo(org.eclipse.swt.custom.CCombo) ProcessItem(org.talend.core.model.properties.ProcessItem) IElementParameter(org.talend.core.model.process.IElementParameter) List(java.util.List) ArrayList(java.util.ArrayList) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) Map(java.util.Map) HashMap(java.util.HashMap)

Example 23 with TableViewerCreatorColumnNotModifiable

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

the class TableByRowController method updateComponentList.

private void updateComponentList(IElementParameter param) {
    // update table values
    TableViewerCreator tableViewerCreator = (TableViewerCreator) hashCurControls.get(param.getName());
    Object[] itemsValue = param.getListItemsValue();
    if (tableViewerCreator != null && itemsValue != 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.COMPONENT_LIST) {
                    String[] contextParameterNames = null;
                    ComponentListController.updateComponentList(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) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

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