Search in sources :

Example 1 with ExtendedTextCellEditor

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

the class XmlMapNodeDirectEditManager method initCellEditor.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.tools.DirectEditManager#initCellEditor()
     */
@Override
protected void initCellEditor() {
    DirectEditType directEditType = cellAndType.get(getCellEditor());
    if (model instanceof AbstractNode) {
        final AbstractNode abstractNode = (AbstractNode) model;
        if (directEditType != null) {
            switch(directEditType) {
                case EXPRESSION:
                    String expression = abstractNode.getExpression() == null ? "" : abstractNode.getExpression();
                    getCellEditor().setValue(expression);
                    Text text = ((ExtendedTextCellEditor) getCellEditor()).getTextControl();
                    text.selectAll();
                    break;
                case NODE_NAME:
                    String variable = abstractNode.getName();
                    if (variable == null) {
                        variable = "";
                    }
                    getCellEditor().setValue(variable);
                    final Text nametext = (Text) ((TextCellEditor) getCellEditor()).getControl();
                    nametext.selectAll();
                    if (model instanceof VarNode) {
                        nametext.addModifyListener(new ModifyListener() {

                            @Override
                            public void modifyText(ModifyEvent e) {
                                List<VarNode> children = new ArrayList<VarNode>();
                                children.addAll(((VarTable) abstractNode.eContainer()).getNodes());
                                children.remove(model);
                                String message = XmlMapUtil.isValidColumnName(children, ((Text) e.widget).getText());
                                if (message != null) {
                                    nametext.setBackground(ColorConstants.red);
                                } else {
                                    nametext.setBackground(ColorConstants.white);
                                }
                            }
                        });
                    }
                    break;
                case VAR_NODE_TYPE:
                    if (getCellEditor() instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) getCellEditor().getControl();
                        combo.setText(getTypeDisplayValue((VarNode) abstractNode));
                    }
                    break;
            }
        }
    } else if (model instanceof InputXmlTree) {
        InputXmlTree inputxmlTree = (InputXmlTree) model;
        if (directEditType != null) {
            switch(directEditType) {
                case EXPRESSION_FILTER:
                    String expressionFilter = inputxmlTree.getExpressionFilter();
                    if (expressionFilter == null) {
                        expressionFilter = "";
                    }
                    getCellEditor().setValue(expressionFilter);
                    Text textarea = ((ExtendedTextCellEditor) getCellEditor()).getTextControl();
                    textarea.selectAll();
                    break;
                case LOOKUP_MODEL:
                    if (getCellEditor() instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) getCellEditor().getControl();
                        combo.setText(getLookupDisplayName(inputxmlTree.getLookupMode()));
                    }
                    break;
                case MATCH_MODEL:
                    if (getCellEditor() instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) getCellEditor().getControl();
                        combo.setText(getMatchModelDisplayName(inputxmlTree.getMatchingMode()));
                    }
                    break;
                case JOIN_MODEL:
                    if (getCellEditor() instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) getCellEditor().getControl();
                        String join = "";
                        if (inputxmlTree.isInnerJoin()) {
                            join = joinModel[0];
                        } else {
                            join = joinModel[1];
                        }
                        combo.setText(join);
                    }
                    break;
                case PERSISTENT_MODEL:
                    if (getCellEditor() instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) getCellEditor().getControl();
                        combo.setText(String.valueOf(inputxmlTree.isPersistent()));
                    }
                    break;
            }
        }
    } else if (model instanceof OutputXmlTree) {
        OutputXmlTree outputTree = (OutputXmlTree) model;
        if (directEditType != null) {
            switch(directEditType) {
                case EXPRESSION_FILTER:
                    String expressionFilter = outputTree.getExpressionFilter();
                    if (expressionFilter == null) {
                        expressionFilter = "";
                    }
                    getCellEditor().setValue(expressionFilter);
                    Text textarea = ((ExtendedTextCellEditor) getCellEditor()).getTextControl();
                    textarea.selectAll();
                    break;
                case OUTPUT_REJECT:
                    if (getCellEditor() instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) getCellEditor().getControl();
                        combo.setText(String.valueOf(outputTree.isReject()));
                    }
                    break;
                case LOOK_UP_INNER_JOIN_REJECT:
                    if (getCellEditor() instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) getCellEditor().getControl();
                        combo.setText(String.valueOf(outputTree.isRejectInnerJoin()));
                    }
                    break;
                case ALL_IN_ONE:
                    if (getCellEditor() instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) getCellEditor().getControl();
                        combo.setText(String.valueOf(outputTree.isAllInOne()));
                    }
                    break;
                case ENABLE_EMPTY_ELEMENT:
                    if (getCellEditor() instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) getCellEditor().getControl();
                        combo.setText(String.valueOf(outputTree.isEnableEmptyElement()));
                    }
            }
        }
    } else if (model instanceof XmlMapData) {
        XmlMapData xmlMapData = (XmlMapData) model;
        if (directEditType != null) {
            switch(directEditType) {
                case SERACH:
                    Text text = (Text) getCellEditor().getControl();
                    text.selectAll();
                    break;
            }
        }
    }
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) ModifyListener(org.eclipse.swt.events.ModifyListener) AbstractNode(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) Text(org.eclipse.swt.widgets.Text) ExtendedTextCellEditor(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) ModifyEvent(org.eclipse.swt.events.ModifyEvent) DirectEditType(org.talend.designer.gefabstractmap.part.directedit.DirectEditType) CCombo(org.eclipse.swt.custom.CCombo) List(java.util.List) ArrayList(java.util.ArrayList) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 2 with ExtendedTextCellEditor

use of org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor 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 3 with ExtendedTextCellEditor

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

List (java.util.List)3 ExtendedTextCellEditor (org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor)3 ArrayList (java.util.ArrayList)2 TableViewerCreatorColumnNotModifiable (org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable)2 ButtonPushImageTableEditorContent (org.talend.commons.ui.runtime.swt.tableviewer.tableeditor.ButtonPushImageTableEditorContent)2 ExtendedTableRemoveCommand (org.talend.commons.ui.swt.advanced.dataeditor.commands.ExtendedTableRemoveCommand)2 TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)2 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)1 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)1 CCombo (org.eclipse.swt.custom.CCombo)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Text (org.eclipse.swt.widgets.Text)1 DefaultHeaderColumnSelectionListener (org.talend.commons.ui.runtime.swt.tableviewer.behavior.DefaultHeaderColumnSelectionListener)1 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)1 DirectEditType (org.talend.designer.gefabstractmap.part.directedit.DirectEditType)1 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)1 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)1 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)1