Search in sources :

Example 1 with DirectEditType

use of org.talend.designer.gefabstractmap.part.directedit.DirectEditType 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 DirectEditType

use of org.talend.designer.gefabstractmap.part.directedit.DirectEditType in project tdi-studio-se by Talend.

the class XmlMapNodeDirectEditManager method commit.

@Override
public void commit() {
    DirectEditType directEditType = cellAndType.get(getCellEditor());
    if (directEditType != null) {
        switch(directEditType) {
            case SERACH:
                VarNodeTextLabel figure = null;
                if (this.locator instanceof XmlMapNodeCellEditorLocator) {
                    XmlMapNodeCellEditorLocator lo = (XmlMapNodeCellEditorLocator) locator;
                    if (lo.getFigure() != null && lo.getFigure() instanceof VarNodeTextLabel) {
                        figure = (VarNodeTextLabel) lo.getFigure();
                        Object searchTextObject = getDirectEditRequest().getCellEditor().getValue();
                        if (searchTextObject != null) {
                            if (figure.getParent() != null && figure.getParent() instanceof XmlMapSearchZoneToolBar) {
                                XmlMapSearchZoneToolBar searchZone = (XmlMapSearchZoneToolBar) figure.getParent();
                                searchZone.search(searchTextObject.toString());
                                figure.setText(searchTextObject.toString());
                            }
                        }
                    }
                }
        }
    }
    super.commit();
}
Also used : XmlMapSearchZoneToolBar(org.talend.designer.xmlmap.figures.treetools.zone.XmlMapSearchZoneToolBar) VarNodeTextLabel(org.talend.designer.gefabstractmap.figures.VarNodeTextLabel) XmlMapNodeCellEditorLocator(org.talend.designer.gefabstractmap.part.directedit.XmlMapNodeCellEditorLocator) DirectEditType(org.talend.designer.gefabstractmap.part.directedit.DirectEditType)

Example 3 with DirectEditType

use of org.talend.designer.gefabstractmap.part.directedit.DirectEditType in project tdi-studio-se by Talend.

the class XmlDirectEditPolicy method getDirectEditCommand.

@Override
protected Command getDirectEditCommand(DirectEditRequest request) {
    Command command = null;
    CellEditor editor = request.getCellEditor();
    Object directEditFeature = request.getDirectEditFeature();
    if (directEditFeature instanceof DirectEditType) {
        DirectEditType type = (DirectEditType) directEditFeature;
        if (getHost().getModel() instanceof AbstractNode) {
            AbstractNode model = (AbstractNode) getHost().getModel();
            switch(type) {
                case EXPRESSION:
                case NODE_NAME:
                    command = new DirectEditCommand(getHost(), model, type, request.getCellEditor().getValue());
                    break;
                case VAR_NODE_TYPE:
                    if (editor instanceof ComboBoxCellEditor) {
                        ComboBoxCellEditor combo = (ComboBoxCellEditor) editor;
                        int selectIndex = (Integer) combo.getValue();
                        command = new DirectEditCommand(getHost(), model, type, combo.getItems()[selectIndex]);
                    }
                    break;
                case LOOKUP_MODEL:
                case MATCH_MODEL:
                case JOIN_MODEL:
                case PERSISTENT_MODEL:
                case OUTPUT_REJECT:
                case LOOK_UP_INNER_JOIN_REJECT:
                    if (editor instanceof ComboBoxCellEditor) {
                        ComboBoxCellEditor combo = (ComboBoxCellEditor) editor;
                        int selectIndex = (Integer) combo.getValue();
                        command = new TreeSettingDirectEditCommand(model, type, combo.getItems()[selectIndex]);
                    }
                    break;
                case EXPRESSION_FILTER:
                    if (editor instanceof TextCellEditor) {
                        command = new TreeSettingDirectEditCommand(model, type, request.getCellEditor().getValue());
                    }
                default:
                    break;
            }
        } else {
            switch(type) {
                case LOOKUP_MODEL:
                case MATCH_MODEL:
                case JOIN_MODEL:
                case PERSISTENT_MODEL:
                case OUTPUT_REJECT:
                case LOOK_UP_INNER_JOIN_REJECT:
                case ALL_IN_ONE:
                case ENABLE_EMPTY_ELEMENT:
                    if ((editor instanceof ComboBoxCellEditor)) {
                        ComboBoxCellEditor combo = (ComboBoxCellEditor) editor;
                        int selectIndex = (Integer) combo.getValue();
                        command = new TreeSettingDirectEditCommand(getHost().getModel(), type, combo.getItems()[selectIndex]);
                    }
                    break;
                case EXPRESSION_FILTER:
                    command = new TreeSettingDirectEditCommand(getHost().getModel(), type, request.getCellEditor().getValue());
            }
        }
    }
    return command;
}
Also used : DirectEditType(org.talend.designer.gefabstractmap.part.directedit.DirectEditType) DirectEditCommand(org.talend.designer.xmlmap.commands.DirectEditCommand) Command(org.eclipse.gef.commands.Command) TreeSettingDirectEditCommand(org.talend.designer.xmlmap.commands.TreeSettingDirectEditCommand) AbstractNode(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) DirectEditCommand(org.talend.designer.xmlmap.commands.DirectEditCommand) TreeSettingDirectEditCommand(org.talend.designer.xmlmap.commands.TreeSettingDirectEditCommand) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) TreeSettingDirectEditCommand(org.talend.designer.xmlmap.commands.TreeSettingDirectEditCommand) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor)

Aggregations

DirectEditType (org.talend.designer.gefabstractmap.part.directedit.DirectEditType)3 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)2 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Command (org.eclipse.gef.commands.Command)1 CellEditor (org.eclipse.jface.viewers.CellEditor)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 Text (org.eclipse.swt.widgets.Text)1 ExtendedTextCellEditor (org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor)1 VarNodeTextLabel (org.talend.designer.gefabstractmap.figures.VarNodeTextLabel)1 XmlMapNodeCellEditorLocator (org.talend.designer.gefabstractmap.part.directedit.XmlMapNodeCellEditorLocator)1 DirectEditCommand (org.talend.designer.xmlmap.commands.DirectEditCommand)1 TreeSettingDirectEditCommand (org.talend.designer.xmlmap.commands.TreeSettingDirectEditCommand)1 XmlMapSearchZoneToolBar (org.talend.designer.xmlmap.figures.treetools.zone.XmlMapSearchZoneToolBar)1 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)1 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)1