Search in sources :

Example 1 with DirectEditCommand

use of org.talend.designer.xmlmap.commands.DirectEditCommand in project tdi-studio-se by Talend.

the class StyledTextHandler method updateCellExpression.

private void updateCellExpression() {
    if (selectedNode != null && styledText != null && !styledText.getText().equals(selectedNode.getExpression())) {
        DirectEditCommand command = new DirectEditCommand(selectedNodePart, selectedNode, DirectEditType.EXPRESSION, styledText.getText());
        ((XmlMapGraphicViewer) selectedNodePart.getViewer()).getEditDomain().getCommandStack().execute(command);
    }
}
Also used : DirectEditCommand(org.talend.designer.xmlmap.commands.DirectEditCommand) XmlMapGraphicViewer(org.talend.designer.xmlmap.editor.XmlMapGraphicViewer)

Example 2 with DirectEditCommand

use of org.talend.designer.xmlmap.commands.DirectEditCommand 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

DirectEditCommand (org.talend.designer.xmlmap.commands.DirectEditCommand)2 Command (org.eclipse.gef.commands.Command)1 CellEditor (org.eclipse.jface.viewers.CellEditor)1 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)1 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)1 DirectEditType (org.talend.designer.gefabstractmap.part.directedit.DirectEditType)1 TreeSettingDirectEditCommand (org.talend.designer.xmlmap.commands.TreeSettingDirectEditCommand)1 XmlMapGraphicViewer (org.talend.designer.xmlmap.editor.XmlMapGraphicViewer)1 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)1