use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode 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.OutputTreeNode in project tdi-studio-se by Talend.
the class DragAndDropEditPolicy method getCommand.
@Override
public Command getCommand(Request request) {
if (request instanceof CreateNodeConnectionRequest) {
CreateNodeConnectionRequest rq = (CreateNodeConnectionRequest) request;
EditPart targetEditPart = rq.getTargetEditPart();
Command command = null;
if (targetEditPart != null && TemplateTransfer.getInstance().getObject() instanceof TransferedObject) {
TransferedObject toDrop = (TransferedObject) TemplateTransfer.getInstance().getObject();
MapperManager manager = ((XmlMapGraphicViewer) targetEditPart.getViewer()).getMapperManager();
if (manager != null && manager.getExternalData() != null) {
DropType dropType = rq.getNewObjectType();
if (dropType != null) {
switch(dropType) {
case DROP_FILTER:
if (targetEditPart instanceof MapperTablePart) {
command = new UpdateFilterExpressionCommand(toDrop, (MapperTablePart) targetEditPart, manager.getExternalData());
}
break;
case DROP_EXPRESSION:
if (targetEditPart instanceof TableEntityPart) {
command = new UpdateExpressionCommand(toDrop, (TableEntityPart) targetEditPart, manager);
}
break;
case DROP_OUTPUT_DOC_CHILD:
if (targetEditPart instanceof OutputTreeNodeEditPart && rq.getNewObject() instanceof OutputTreeNode) {
command = new CreateDocChildrenCommand(toDrop, (OutputTreeNodeEditPart) targetEditPart, rq, manager);
}
break;
case DROP_INSERT_OUTPUT:
case DROP_INSERT_VAR:
case DROP_INSERT_INPUT:
command = new InsertNewColumnCommand(toDrop, targetEditPart, rq, manager, dropType);
default:
break;
}
}
}
}
if (command != null) {
return command;
}
// drop expression
// boolean update = rq.getDropType() == CreateNodeConnectionRequest.DROP_EXPRESSION ? true : false;
// return new CreateNodeAndConnectionCommand(rq.getNewObject(), rq.getTargetEditPart(), update);
}
return super.getCommand(request);
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.
the class MapperManager method selectionChanged.
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (!event.getSelection().isEmpty() && event.getSelection() instanceof IStructuredSelection) {
Iterator iterator = ((IStructuredSelection) event.getSelection()).iterator();
while (iterator.hasNext()) {
Object firstElement = iterator.next();
if (firstElement instanceof TableEntityPart) {
AbstractNode model = (AbstractNode) ((TableEntityPart) firstElement).getModel();
boolean isInputMain = false;
if (model instanceof OutputTreeNode) {
OutputTreeNode outputTreeNodeRoot = (OutputTreeNode) XmlMapUtil.getTreeNodeRoot((OutputTreeNode) model);
if (outputTreeNodeRoot != null && outputTreeNodeRoot.eContainer() instanceof OutputXmlTree) {
selectOutputXmlTree((OutputXmlTree) outputTreeNodeRoot.eContainer());
onEntitySelection((IStructuredSelection) event.getSelection(), selectedOutputTree);
}
} else if (model instanceof TreeNode) {
TreeNode inputTreeNodeRoot = XmlMapUtil.getTreeNodeRoot((TreeNode) model);
if (inputTreeNodeRoot != null && inputTreeNodeRoot.eContainer() instanceof InputXmlTree) {
selectInputXmlTree((InputXmlTree) inputTreeNodeRoot.eContainer());
isInputMain = !((InputXmlTree) inputTreeNodeRoot.eContainer()).isLookup();
onEntitySelection((IStructuredSelection) event.getSelection(), selectedInputTree);
}
}
if (!isInputMain) {
refreshStyledTextEditor((TableEntityPart) firstElement);
} else {
refreshStyledTextEditor(null);
}
selectedFigure = ((TableEntityPart) firstElement).getFigure();
} else if (firstElement instanceof InputXmlTreeEditPart) {
selectInputXmlTree((InputXmlTree) ((InputXmlTreeEditPart) firstElement).getModel());
refreshStyledTextEditor(null);
} else if (firstElement instanceof OutputXmlTreeEditPart) {
selectOutputXmlTree((OutputXmlTree) ((OutputXmlTreeEditPart) firstElement).getModel());
refreshStyledTextEditor(null);
}
}
}
// else {
// ExtendedTableModel<TreeSchemaTableEntry> oldModel = mapperUI.getTabFolderEditors().getInputTreeSchemaEditor()
// .getExtendedTableModel();
// if (oldModel != null && oldModel.getBeanCount() != 0) {
// List<TreeSchemaTableEntry> treeSchemaEntrys = new ArrayList<TreeSchemaTableEntry>();
// mapperUI.getTabFolderEditors().getInputTreeSchemaEditor()
// .setExtendedControlModel(new ExtendedTableModel<TreeSchemaTableEntry>("Tree Schema", treeSchemaEntrys));
// mapperUI.getTabFolderEditors().getInputTreeSchemaEditor().getTableViewerCreator().refresh();
// }
// refreshStyledTextEditor(null);
// }
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode 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.OutputTreeNode 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);
}
}
}
Aggregations