use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class CreateNameSpaceAction method run.
@Override
public void run() {
String prefix = null;
String defaultValue = null;
NameSpaceDialog nsDialog = new NameSpaceDialog(null);
nsDialog.setParentNode(parent);
int status = nsDialog.open();
if (status == nsDialog.OK) {
defaultValue = nsDialog.getNSValue();
if (defaultValue != null) {
defaultValue = defaultValue.trim();
}
prefix = nsDialog.getPrefix().trim();
}
if (status == nsDialog.CANCEL) {
return;
}
TreeNode createdNode = null;
if (input) {
createdNode = XmlmapFactory.eINSTANCE.createTreeNode();
} else {
createdNode = XmlmapFactory.eINSTANCE.createOutputTreeNode();
}
createdNode.setName(prefix);
createdNode.setNodeType(NodeType.NAME_SPACE);
createdNode.setDefaultValue(defaultValue);
createdNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
String label = createdNode.getName();
if (prefix == null || "".equals(prefix)) {
label = XmlMapUtil.DEFAULT_NAME_SPACE_PREFIX;
createdNode.setName(XmlMapUtil.DEFAULT_NAME_SPACE_PREFIX);
}
String parentXpath = parent.getXpath();
if (parent.isChoice() || parent.isSubstitution()) {
TreeNode realPrant = XmlMapUtil.getRealParentNode(parent);
if (realPrant != null) {
parentXpath = realPrant.getXpath();
}
}
createdNode.setXpath(XmlMapUtil.getXPath(parentXpath, label, NodeType.NAME_SPACE));
final EList<TreeNode> children = parent.getChildren();
int index = 0;
for (int i = 0; i < children.size(); i++) {
final TreeNode treeNode = children.get(i);
if (treeNode.getNodeType() == NodeType.NAME_SPACE) {
if (i == children.size() - 1) {
index = children.size();
}
continue;
} else {
index = i;
break;
}
}
children.add(index, createdNode);
// children.add(createdNode);
// if (input) {
// mapperManager.inputTreeSchemaBeanListModified();
// } else {
// mapperManager.outputTreeSchemaBeanListModified();
// }
Object object = graphicViewer.getEditPartRegistry().get(createdNode);
if (object instanceof TreeNodeEditPart) {
graphicViewer.select((TreeNodeEditPart) object);
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode 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.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class ProblemsAnalyser method checkTreeNodesProblem.
private void checkTreeNodesProblem(AbstractInOutTree treeToCheck, List<? extends TreeNode> treeNodes) {
for (TreeNode treeNode : treeNodes) {
if (XmlMapUtil.DOCUMENT.equals(treeNode.getType())) {
if (!hasDocumentLoop(treeNode)) {
String message = ERROR_MESSAGE_START + treeNode.getXpath();
addProblem(treeToCheck, new Problem(null, message, ProblemStatus.ERROR));
}
if (!isMultipleDocType) {
isMultipleDocType = true;
} else {
String message = ERROR_MESSAGE_MULTIPLE_DOC_TYPE + treeNode.getXpath();
addProblem(treeToCheck, new Problem(null, message, ProblemStatus.ERROR));
}
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class ProblemsAnalyser method checkInputLoopTablesProblem.
private void checkInputLoopTablesProblem(OutputXmlTree outputTree, InputXmlTree mainInputTree) {
if (mainInputTree == null) {
return;
}
if (mainInputTree.isMultiLoops()) {
if (!XmlMapUtil.hasDocument(outputTree)) {
if (outputTree.getInputLoopNodesTables().isEmpty() || outputTree.getInputLoopNodesTables().get(0).getInputloopnodes().isEmpty()) {
String message = outputTree.getName() + " have no source loop";
addProblem(outputTree, new Problem(null, message, ProblemStatus.ERROR));
}
} else {
List<TreeNode> loopNodes = new ArrayList<TreeNode>();
XmlMapUtil.getChildLoops(loopNodes, outputTree.getNodes());
if (!loopNodes.isEmpty()) {
for (TreeNode node : loopNodes) {
InputLoopNodesTable inutLoopTable = ((OutputTreeNode) node).getInputLoopNodesTable();
if (inutLoopTable == null || inutLoopTable.getInputloopnodes().isEmpty()) {
String message = node.getXpath() + " have no source loop";
addProblem(outputTree, new Problem(null, message, ProblemStatus.ERROR));
}
}
}
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class XmlMapConnectionBuilder method rebuildLinks.
public void rebuildLinks(TreeNode docNode, XmlMapData mapData) {
if (docNode == null || mapData == null) {
return;
}
AbstractInOutTree inputTree = XmlMapUtil.getAbstractInOutTree(docNode);
int index = mapData.getInputTrees().indexOf(inputTree);
if (index == -1) {
index = mapData.getInputTrees().size();
}
List<TreeNode> nodes = new ArrayList<TreeNode>();
nodes.add(docNode);
rebuildLink(index, nodes, mapData);
}
Aggregations