use of org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree in project tdi-studio-se by Talend.
the class ExpressionProposalProvider method init.
public void init(Object source) {
XmlMapData mapData = mapperManager.getExternalData();
int index = 0;
boolean needVar = false;
if (source instanceof OutputTreeNode || source instanceof OutputXmlTree) {
needVar = true;
index = mapData.getInputTrees().size();
} else if (source instanceof TreeNode) {
AbstractInOutTree abstractTree = XmlMapUtil.getAbstractInOutTree((TreeNode) source);
index = mapData.getInputTrees().indexOf(abstractTree);
if (index == -1) {
index = 0;
}
} else if (source instanceof VarNode) {
index = mapData.getInputTrees().size();
} else if (source instanceof InputXmlTree) {
index = mapData.getInputTrees().indexOf(source) + 1;
}
for (int i = 0; i < index; i++) {
InputXmlTree inputTree = mapData.getInputTrees().get(i);
getProposalsInside(inputTree.getNodes(), proposalsInside);
}
if (needVar) {
getProposalsInside(mapData.getVarTables().get(0).getNodes(), proposalsInside);
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree in project tdi-studio-se by Talend.
the class MapperManager method onEntitySelection.
private void onEntitySelection(IStructuredSelection selection, AbstractInOutTree selectedTree) {
// do selection in metadata schema editor
EList<? extends TreeNode> nodes = null;
if (selectedTree instanceof InputXmlTree) {
nodes = ((InputXmlTree) selectedTree).getNodes();
} else {
nodes = ((OutputXmlTree) selectedTree).getNodes();
}
List<Integer> selectionIndices = new ArrayList<Integer>();
List<TreeNode> selectedDocChild = new ArrayList<TreeNode>();
Iterator iterator = selection.iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof TreeNodeEditPart) {
TreeNode model = (TreeNode) ((TreeNodeEditPart) obj).getModel();
if (model.eContainer() == selectedTree) {
selectionIndices.add(nodes.indexOf(model));
} else {
AbstractInOutTree abstractInOutTree = XmlMapUtil.getAbstractInOutTree(model);
if (abstractInOutTree == selectedTree) {
selectedDocChild.add(model);
}
}
}
}
int[] selections = new int[selectionIndices.size()];
for (int i = 0; i < selectionIndices.size(); i++) {
selections[i] = selectionIndices.get(i);
}
MetadataTableEditorView metaEditorView = null;
XmlTreeSchemaTableView treeEditorView = null;
if (selectedTree instanceof InputXmlTree) {
metaEditorView = mapperUI.getTabFolderEditors().getInputMetaEditorView();
treeEditorView = mapperUI.getTabFolderEditors().getInputTreeSchemaEditor();
} else {
metaEditorView = mapperUI.getTabFolderEditors().getOutputMetaEditorView();
treeEditorView = mapperUI.getTabFolderEditors().getOutputTreeSchemaEditor();
}
metaEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
metaEditorView.getExtendedTableViewer().getTableViewerCreator().getSelectionHelper().setSelection(selections);
metaEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
metaEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
// if no, change page
if (!selectedDocChild.isEmpty()) {
treeEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
TreeNode firstSelection = null;
if (selectedDocChild.size() > 1) {
selectionIndices = new ArrayList<Integer>();
List<TreeNode> allList = new ArrayList<TreeNode>();
for (TreeNode schemaNodes : nodes) {
if (XmlMapUtil.DOCUMENT.equals(schemaNodes.getType())) {
allList.addAll(SchemaTableUtils.getTreeSchemaEnties(schemaNodes));
}
}
int minIndex = allList.size();
for (TreeNode selected : selectedDocChild) {
int indexOf = allList.indexOf(selected);
if (indexOf != -1 && indexOf < minIndex) {
firstSelection = selected;
}
}
} else {
firstSelection = selectedDocChild.get(0);
}
treeEditorView.getExtendedTableModel().changePageIfNeeded(firstSelection);
// update selection
selectionIndices = new ArrayList<Integer>();
for (TreeNode selected : selectedDocChild) {
int indexOf = treeEditorView.getExtendedTableModel().getBeansList().indexOf(selected);
if (indexOf != -1) {
selectionIndices.add(indexOf);
}
}
selections = new int[selectionIndices.size()];
for (int i = 0; i < selectionIndices.size(); i++) {
selections[i] = selectionIndices.get(i);
}
treeEditorView.getExtendedTableViewer().getTableViewerCreator().getSelectionHelper().setSelection(selections);
treeEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
treeEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree in project tdi-studio-se by Talend.
the class InputLoopTableUtil method addSourceLoopToInputLoopTable.
public static void addSourceLoopToInputLoopTable(TreeNode connectionSource, OutputTreeNode targetOutputNode, InputXmlTree mainInputTree) {
// create InputLoopTable nodes only when main table is multiloops
if (mainInputTree == null || !mainInputTree.isMultiLoops()) {
return;
}
InputLoopNodesTable inputLoopNodesTable = null;
AbstractInOutTree abstractTree = XmlMapUtil.getAbstractInOutTree(targetOutputNode);
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);
}
} else {
OutputTreeNode loopParentOutputTreeNode = (OutputTreeNode) XmlMapUtil.getLoopParentNode(targetOutputNode);
if (loopParentOutputTreeNode != null) {
inputLoopNodesTable = loopParentOutputTreeNode.getInputLoopNodesTable();
if (inputLoopNodesTable == null) {
inputLoopNodesTable = XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
loopParentOutputTreeNode.setInputLoopNodesTable(inputLoopNodesTable);
listInputLoopNodesTablesEntry.add(inputLoopNodesTable);
}
}
}
if (inputLoopNodesTable == null) {
return;
}
List<TreeNode> soruceLoops = new ArrayList<TreeNode>();
getSourceLoopsFromConnectionSource(connectionSource, soruceLoops, mainInputTree);
for (TreeNode sourceLoop : soruceLoops) {
if (!inputLoopNodesTable.getInputloopnodes().contains(sourceLoop)) {
inputLoopNodesTable.getInputloopnodes().add(sourceLoop);
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree 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.AbstractInOutTree in project tdi-studio-se by Talend.
the class InputLoopTableUtil method getInputLoopNodesTable.
private static InputLoopNodesTable getInputLoopNodesTable(OutputTreeNode outputNode) {
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);
}
} 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);
}
}
}
return inputLoopNodesTable;
}
Aggregations