Search in sources :

Example 6 with XmlmapTreeNodeFigure

use of org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure in project tdi-studio-se by Talend.

the class TreeNodeEditPart method notifyChanged.

@Override
public void notifyChanged(Notification notification) {
    int type = notification.getEventType();
    int featureId = notification.getFeatureID(XmlmapPackage.class);
    XmlmapTreeNodeFigure treeNodeFigure = (XmlmapTreeNodeFigure) getFigure();
    switch(type) {
        case Notification.SET:
            switch(featureId) {
                case XmlmapPackage.TREE_NODE__LOOP:
                case XmlmapPackage.OUTPUT_TREE_NODE__GROUP:
                case XmlmapPackage.OUTPUT_TREE_NODE__AGGREGATE:
                case XmlmapPackage.TREE_NODE__OPTIONAL:
                    treeNodeFigure.getBranchContent().updateStatus();
                    break;
                case XmlmapPackage.TREE_NODE__NAME:
                    treeNodeFigure.getBranchContent().updataNameFigure();
                    break;
                case XmlmapPackage.TREE_NODE__DEFAULT_VALUE:
                    treeNodeFigure.getBranchContent().updateDefaultValueFigure();
                    break;
                case XmlmapPackage.TREE_NODE__TYPE:
                    refreshChildren();
                    break;
                case XmlmapPackage.TREE_NODE__EXPRESSION:
                    if (getModel() instanceof TreeNode && !(getModel() instanceof OutputTreeNode)) {
                        TreeNode inputTreeNodeRoot = XmlMapUtil.getTreeNodeRoot((TreeNode) getModel());
                        if (inputTreeNodeRoot != null && inputTreeNodeRoot.eContainer() instanceof InputXmlTree) {
                            InputXmlTree inputTree = (InputXmlTree) inputTreeNodeRoot.eContainer();
                            if (inputTree.isLookup()) {
                                if (((TreeNode) getModel()).getExpression() != null && !((TreeNode) getModel()).getExpression().trim().equals("")) {
                                    if (MATCHING_MODE.ALL_ROWS.toString().equals(inputTree.getMatchingMode())) {
                                        inputTree.setMatchingMode(MATCHING_MODE.UNIQUE_MATCH.toString());
                                    }
                                } else {
                                    boolean hasAtLeastOneHashKey = XmlMapUtil.hasAtLeastOneHashKey(inputTree);
                                    if (!hasAtLeastOneHashKey) {
                                        if (!MATCHING_MODE.ALL_ROWS.toString().equals(inputTree.getMatchingMode())) {
                                            inputTree.setMatchingMode(MATCHING_MODE.ALL_ROWS.toString());
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (getFigure() instanceof TableTreeEntityFigure) {
                        XmlmapTreeNodeFigure outputFigure = (XmlmapTreeNodeFigure) getFigure();
                        outputFigure.updateExpression();
                    }
                    break;
                case XmlmapPackage.INPUT_XML_TREE__MINIMIZED:
                    refreshSourceConnections();
                    refreshTargetConnections();
                    break;
                case XmlmapPackage.ABSTRACT_IN_OUT_TREE__MULTI_LOOPS:
                    break;
            }
            break;
        case Notification.ADD:
        case Notification.ADD_MANY:
            switch(featureId) {
                case XmlmapPackage.TREE_NODE__CHILDREN:
                    refreshChildren();
                    boolean expressionEditable = XmlMapUtil.isExpressionEditable((TreeNode) getModel());
                    if (!expressionEditable) {
                        ExpressionFigure expression = treeNodeFigure.getExpressionFigure();
                        if (expression != null) {
                            expression.setOpaque(true);
                            expression.setBackgroundColor(ColorProviderMapper.getColor(ColorInfo.COLOR_EXPREESION_DISABLE));
                        }
                    }
                    break;
                case XmlmapPackage.TREE_NODE__OUTGOING_CONNECTIONS:
                case XmlmapPackage.TREE_NODE__LOOKUP_OUTGOING_CONNECTIONS:
                case XmlmapPackage.TREE_NODE__FILTER_OUT_GOING_CONNECTIONS:
                    refreshSourceConnections();
                    break;
                case XmlmapPackage.OUTPUT_TREE_NODE__INCOMING_CONNECTIONS:
                case XmlmapPackage.TREE_NODE__LOOKUP_INCOMING_CONNECTIONS:
                    refreshTargetConnections();
                    break;
            }
            break;
        case Notification.REMOVE:
        case Notification.REMOVE_MANY:
            switch(featureId) {
                case XmlmapPackage.TREE_NODE__CHILDREN:
                    refreshChildren();
                    ExpressionFigure expression = treeNodeFigure.getExpressionFigure();
                    if (expression != null) {
                        if (XmlMapUtil.isExpressionEditable((TreeNode) getModel())) {
                            expression.setOpaque(false);
                        }
                    }
                case XmlmapPackage.TREE_NODE__OUTGOING_CONNECTIONS:
                case XmlmapPackage.TREE_NODE__LOOKUP_OUTGOING_CONNECTIONS:
                case XmlmapPackage.TREE_NODE__FILTER_OUT_GOING_CONNECTIONS:
                    refreshSourceConnections();
                    break;
                case XmlmapPackage.OUTPUT_TREE_NODE__INCOMING_CONNECTIONS:
                case XmlmapPackage.TREE_NODE__LOOKUP_INCOMING_CONNECTIONS:
                    refreshTargetConnections();
            }
            break;
    }
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) ExpressionFigure(org.talend.designer.gefabstractmap.figures.ExpressionFigure) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) TableTreeEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure) XmlmapTreeNodeFigure(org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

XmlmapTreeNodeFigure (org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure)6 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)4 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)4 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)3 Point (org.eclipse.draw2d.geometry.Point)2 ExpressionFigure (org.talend.designer.gefabstractmap.figures.ExpressionFigure)2 TableTreeEntityFigure (org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure)2 ArrayList (java.util.ArrayList)1 Figure (org.eclipse.draw2d.Figure)1 IFigure (org.eclipse.draw2d.IFigure)1 Viewport (org.eclipse.draw2d.Viewport)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 Adapter (org.eclipse.emf.common.notify.Adapter)1 DirectEditRequest (org.eclipse.gef.requests.DirectEditRequest)1 IWidgetCell (org.talend.designer.gefabstractmap.figures.cells.IWidgetCell)1 VarEntityFigure (org.talend.designer.gefabstractmap.figures.var.VarEntityFigure)1 MapperTablePart (org.talend.designer.gefabstractmap.part.MapperTablePart)1 XmlMapNodeCellEditorLocator (org.talend.designer.gefabstractmap.part.directedit.XmlMapNodeCellEditorLocator)1 XmlMapGraphicViewer (org.talend.designer.xmlmap.editor.XmlMapGraphicViewer)1 OutputXmlTreeFigure (org.talend.designer.xmlmap.figures.OutputXmlTreeFigure)1