use of org.talend.designer.xmlmap.model.emf.xmlmap.Connection in project tdi-studio-se by Talend.
the class InsertNewColumnCommand method createConnection.
private void createConnection(AbstractNode sourceNode, AbstractNode targetNode) {
Connection conn = XmlmapFactory.eINSTANCE.createConnection();
conn.setSource(sourceNode);
conn.setTarget(targetNode);
targetNode.getIncomingConnections().add(conn);
sourceNode.getOutgoingConnections().add(conn);
if (xmlMapData != null) {
xmlMapData.getConnections().add(conn);
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.Connection in project tdi-studio-se by Talend.
the class AddChoiceAction method run.
@Override
public void run() {
TreeNode treeNode = null;
boolean needWarning = false;
if (input) {
treeNode = XmlmapFactory.eINSTANCE.createTreeNode();
if (!parent.getOutgoingConnections().isEmpty()) {
needWarning = true;
}
} else {
treeNode = XmlmapFactory.eINSTANCE.createOutputTreeNode();
EList<Connection> incomingConnections = parent.getIncomingConnections();
if (!incomingConnections.isEmpty()) {
needWarning = true;
}
}
boolean canContinue = true;
// Shell shell = this.part.getSite().getShell();
if (needWarning) {
canContinue = MessageDialog.openConfirm(null, "Warning", "Do you want to disconnect the existing linker and then add a choice for the selected element ?");
}
if (canContinue) {
XmlMapUtil.detachNodeConnections(parent, mapperManager.getExternalData(), false);
treeNode.setName(parent.getName() + XSDPopulationUtil2.CHOICE);
treeNode.setNodeType(NodeType.ELEMENT);
treeNode.setXpath(XmlMapUtil.getXPath(this.parent.getXpath(), treeNode.getName(), treeNode.getNodeType()));
treeNode.setChoice(true);
parent.getChildren().add(treeNode);
if (!input) {
OutputTreeNode output = (OutputTreeNode) parent;
if (!XmlMapUtil.isExpressionEditable(output) && output.isAggregate()) {
output.setAggregate(false);
}
}
Object object = graphicViewer.getEditPartRegistry().get(treeNode);
if (object instanceof TreeNodeEditPart) {
graphicViewer.select((TreeNodeEditPart) object);
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.Connection in project tdi-studio-se by Talend.
the class XmlMapUtil method detachConnectionsSouce.
public static void detachConnectionsSouce(AbstractNode treeNode, XmlMapData mapData, boolean detachChildren) {
for (Connection connection : treeNode.getIncomingConnections()) {
AbstractNode source = connection.getSource();
if (source.getOutgoingConnections().contains(connection)) {
source.getOutgoingConnections().remove(connection);
mapData.getConnections().remove(connection);
}
}
treeNode.getIncomingConnections().clear();
if (treeNode instanceof OutputTreeNode) {
OutputTreeNode outputTreeNode = (OutputTreeNode) treeNode;
if (!XmlMapUtil.isExpressionEditable(outputTreeNode) && outputTreeNode.isAggregate()) {
outputTreeNode.setAggregate(false);
}
if (detachChildren && !outputTreeNode.getChildren().isEmpty()) {
for (int i = 0; i < outputTreeNode.getChildren().size(); i++) {
TreeNode child = outputTreeNode.getChildren().get(i);
detachConnectionsSouce(child, mapData);
}
}
}
treeNode.setExpression("");
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.Connection in project tdi-studio-se by Talend.
the class InputLoopTableUtil method removeSourceLoopFromInputLoopTable.
public static void removeSourceLoopFromInputLoopTable(List removedConnections, OutputTreeNode outputNode, InputXmlTree mainInputTree) {
if (mainInputTree == null || !mainInputTree.isMultiLoops()) {
return;
}
List<TreeNode> neededSource = new ArrayList<TreeNode>();
InputLoopNodesTable inputLoopNodesTable = null;
AbstractInOutTree abstractTree = XmlMapUtil.getAbstractInOutTree(outputNode);
List<InputLoopNodesTable> listInputLoopNodesTablesEntry = ((OutputXmlTree) abstractTree).getInputLoopNodesTables();
if (!XmlMapUtil.hasDocument(abstractTree)) {
if (listInputLoopNodesTablesEntry.size() == 0) {
inputLoopNodesTable = XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
listInputLoopNodesTablesEntry.add(inputLoopNodesTable);
} else if (listInputLoopNodesTablesEntry != null && listInputLoopNodesTablesEntry.size() == 1) {
inputLoopNodesTable = listInputLoopNodesTablesEntry.get(0);
}
OutputXmlTree outputTree = (OutputXmlTree) abstractTree;
getSourceLoop(neededSource, outputTree.getNodes(), mainInputTree);
} else {
OutputTreeNode loopParentOutputTreeNode = (OutputTreeNode) XmlMapUtil.getLoopParentNode(outputNode);
if (loopParentOutputTreeNode != null) {
inputLoopNodesTable = loopParentOutputTreeNode.getInputLoopNodesTable();
if (inputLoopNodesTable == null) {
inputLoopNodesTable = XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
loopParentOutputTreeNode.setInputLoopNodesTable(inputLoopNodesTable);
listInputLoopNodesTablesEntry.add(inputLoopNodesTable);
}
List<OutputTreeNode> nodes = new ArrayList<OutputTreeNode>();
nodes.add(loopParentOutputTreeNode);
getSourceLoop(neededSource, nodes, mainInputTree);
}
}
if (inputLoopNodesTable == null) {
return;
}
List<TreeNode> sourceLoopsToRemove = new ArrayList<TreeNode>();
for (Object object : removedConnections) {
if (object instanceof Connection) {
Connection connection = (Connection) object;
if (connection.getSource() instanceof TreeNode) {
getSourceLoopsFromConnectionSource((TreeNode) connection.getSource(), sourceLoopsToRemove, mainInputTree);
}
}
}
for (TreeNode sourceToRemove : sourceLoopsToRemove) {
if (!neededSource.contains(sourceToRemove)) {
inputLoopNodesTable.getInputloopnodes().remove(sourceToRemove);
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.Connection in project tdi-studio-se by Talend.
the class SetSubstitutionAction method run.
@Override
public void run() {
TreeNode treeNode = null;
boolean needWarning = false;
if (input) {
treeNode = XmlmapFactory.eINSTANCE.createTreeNode();
if (!selectedNode.getOutgoingConnections().isEmpty()) {
needWarning = true;
}
} else {
treeNode = XmlmapFactory.eINSTANCE.createOutputTreeNode();
EList<Connection> incomingConnections = selectedNode.getIncomingConnections();
if (!incomingConnections.isEmpty()) {
needWarning = true;
}
}
boolean canContinue = true;
// Shell shell = this.part.getSite().getShell();
if (needWarning) {
canContinue = MessageDialog.openConfirm(null, "Warning", "Do you want to disconnect the existing linker and then add a choice for the selected element ?");
}
if (canContinue) {
AbstractUIPlugin plugin = (AbstractUIPlugin) Platform.getPlugin(PlatformUI.PLUGIN_ID);
IDialogSettings workbenchSettings = plugin.getDialogSettings();
//$NON-NLS-1$
IDialogSettings section = workbenchSettings.getSection("SetSubstitutionAction.SubsMessageDialog");
if (section == null) {
//$NON-NLS-1$
section = workbenchSettings.addNewSection("SetSubstitutionAction.SubsMessageDialog");
}
boolean popupMessageDialog = !section.getBoolean(HIDE_MESSAGE);
if (popupMessageDialog) {
String message = "This element will be copied as part of the substitution group automatically." + "\n" + "If this element must be abstract and must be extended only, you can delete it.";
SubsMessageDialog dialog = new SubsMessageDialog(null, message);
int open = dialog.open();
if (open == Window.OK) {
boolean hideDialogNextTime = dialog.getResult();
if (hideDialogNextTime) {
section.put(HIDE_MESSAGE, true);
}
}
if (open == Window.CANCEL) {
return;
}
}
XmlMapUtil.detachNodeConnections(selectedNode, mapperManager.getExternalData(), false);
treeNode.setName(selectedNode.getName() + XSDPopulationUtil2.SUBS);
treeNode.setNodeType(NodeType.ELEMENT);
treeNode.setXpath(selectedNode.getXpath() + XmlMapUtil.XPATH_SEPARATOR + treeNode.getName());
treeNode.setSubstitution(true);
TreeNode parentNode = (TreeNode) selectedNode.eContainer();
int index = parentNode.getChildren().indexOf(selectedNode);
parentNode.getChildren().remove(selectedNode);
treeNode.getChildren().add(selectedNode);
parentNode.getChildren().add(index, treeNode);
if (!input) {
OutputTreeNode output = (OutputTreeNode) selectedNode;
if (!XmlMapUtil.isExpressionEditable(output) && output.isAggregate()) {
output.setAggregate(false);
}
}
Object object = graphicViewer.getEditPartRegistry().get(treeNode);
if (object instanceof TreeNodeEditPart) {
graphicViewer.select((TreeNodeEditPart) object);
}
}
}
Aggregations