use of org.talend.designer.gefabstractmap.figures.ExpressionFigure in project tdi-studio-se by Talend.
the class XmlmapTreeNodeFigure method createEntityItems.
/*
* (non-Javadoc)
*
* @see org.talend.designer.newabstractmap.figures.table.entity.TableEntityFigure#createEntityItems()
*/
@Override
protected void createEntityItems(TableEntityElement entityElement) {
this.treeNode = getEntityManager().getModel();
boolean isLookup = false;
if (treeNode instanceof OutputTreeNode) {
isLookup = true;
} else {
TreeNode inputTreeNodeRoot = XmlMapUtil.getTreeNodeRoot(treeNode);
if (inputTreeNodeRoot != null && inputTreeNodeRoot.eContainer() instanceof InputXmlTree) {
isLookup = ((InputXmlTree) inputTreeNodeRoot.eContainer()).isLookup();
}
}
if (isLookup) {
expression = new ExpressionFigure();
expression.setText(treeNode.getExpression());
if (!XmlMapUtil.isExpressionEditable(treeNode)) {
expression.setOpaque(true);
expression.setBackgroundColor(ColorProviderMapper.getColor(ColorInfo.COLOR_EXPREESION_DISABLE));
} else {
expression.setOpaque(false);
}
entityElement.add(expression);
}
branchContent = new XmlmapBranchContent(getEntityManager());
TreeBranch treeBranch = new TreeBranch(branchContent, !isRoot());
entityElement.add(treeBranch);
}
use of org.talend.designer.gefabstractmap.figures.ExpressionFigure in project tdi-studio-se by Talend.
the class DropContextAnalyzer method checkDropIsValid.
private boolean checkDropIsValid() {
if (objects == null || objects.getToTransfer().isEmpty() || targetEditPart == null) {
return false;
}
Object targetModel = targetEditPart.getModel();
targetFigure = targetEditPart.getFigure().findFigureAt(dropLocation.x, dropLocation.y);
boolean isTragetOutputNode = targetModel instanceof OutputTreeNode;
boolean isTragetInputNode = targetModel instanceof TreeNode && !(targetModel instanceof OutputTreeNode);
boolean isVar = targetModel instanceof VarNode;
boolean isDropInputTree = targetModel instanceof InputXmlTree;
boolean isDropOutputTree = targetModel instanceof OutputXmlTree;
boolean isDropVarTable = targetModel instanceof VarTable;
// drop expression
if (targetFigure instanceof ExpressionFigure) {
dropType = DropType.DROP_EXPRESSION;
if (isTragetOutputNode) {
// INPUT => OUTPUT
return XmlMapUtil.isExpressionEditable((TreeNode) targetModel);
} else if (isTragetInputNode) {
// INPUT => INPUT ,can't dnd in the same tree
boolean isValid = checkDropInputValid(targetModel);
if (isValid) {
isValid = XmlMapUtil.isExpressionEditable((TreeNode) targetModel);
}
return isValid;
}
return true;
} else // drop tree filter
if (targetFigure instanceof FilterTextArea) {
dropType = DropType.DROP_FILTER;
return true;
} else {
if (objects.getType() == TransferdType.INPUT) {
if (isTragetOutputNode) {
return checkDropOutputDocChildValid(targetModel);
} else if (isVar || isDropVarTable) {
dropType = DropType.DROP_INSERT_VAR;
return true;
} else if (isDropInputTree) {
dropType = DropType.DROP_INSERT_INPUT;
return checkDropInputValid(targetModel);
} else if (isDropOutputTree) {
dropType = DropType.DROP_INSERT_OUTPUT;
return true;
}
} else if (objects.getType() == TransferdType.VAR) {
if (isTragetOutputNode) {
return checkDropOutputDocChildValid(targetModel);
} else if (isDropOutputTree) {
dropType = DropType.DROP_INSERT_OUTPUT;
return true;
}
}
}
return false;
}
use of org.talend.designer.gefabstractmap.figures.ExpressionFigure in project tdi-studio-se by Talend.
the class TreeNodeEditPart method performRequest.
@Override
public void performRequest(Request req) {
if (RequestConstants.REQ_DIRECT_EDIT.equals(req.getType())) {
Figure figure = null;
DirectEditRequest drequest = (DirectEditRequest) req;
Point figureLocation = drequest.getLocation();
if (getFigure() instanceof TableTreeEntityFigure) {
XmlmapTreeNodeFigure treeNodeFigure = (XmlmapTreeNodeFigure) getFigure();
ArrayList collection = new ArrayList();
collection.add(treeNodeFigure.getExpressionFigure());
collection.add(treeNodeFigure.getBranchContent());
figure = (Figure) treeNodeFigure.findFigureAt(figureLocation.x, figureLocation.y, new FigureSearch(collection));
}
if (figure instanceof IWidgetCell) {
directEditManager = new XmlMapNodeDirectEditManager(this, new XmlMapNodeCellEditorLocator(figure, this));
}
if (directEditManager != null) {
TreeNode outputTreeNode = (TreeNode) getModel();
if (figure instanceof ExpressionFigure) {
if (XmlMapUtil.isExpressionEditable(outputTreeNode)) {
Point location = drequest.getLocation();
if (figure.containsPoint(location)) {
directEditManager.show();
((XmlMapGraphicViewer) getViewer()).getMapperManager().setCurrentDirectEditManager(directEditManager);
}
}
} else if (!(((TreeNode) getModel()).eContainer() instanceof AbstractInOutTree)) {
// disable for RC2
// directEditManager.show();
// ((XmlMapGraphicViewer)
// getViewer()).getMapperManager().setCurrentDirectEditManager(directEditManager);
}
}
}
super.performRequest(req);
}
use of org.talend.designer.gefabstractmap.figures.ExpressionFigure 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;
}
}
use of org.talend.designer.gefabstractmap.figures.ExpressionFigure in project tdi-studio-se by Talend.
the class GlobalMapKeysEntityFigure method createEntityItems.
@Override
protected void createEntityItems(TableEntityElement entityElement) {
this.globalMapNode = getEntityManager().getModel();
expression = new ExpressionFigure();
expression.setText(globalMapNode.getExpression());
globalMapKey = new TextCellLabel();
globalMapKey.setDirectEditType(DirectEditType.NODE_NAME);
globalMapKey.setText(globalMapNode.getName());
globalMapKey.setLabelAlignment(PositionConstants.LEFT);
deleteImage = new ImageFigure(ImageProviderMapper.getImage(ImageInfo.DELETE));
entityElement.add(expression);
entityElement.add(globalMapKey);
entityElement.add(deleteImage);
addCheckListener();
}
Aggregations