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;
}
}
Aggregations