use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree in project tdi-studio-se by Talend.
the class XmlMapOutputZoneToolBar method addTable.
/*
* (non-Javadoc)
*
* @see org.talend.designer.newabstractmap.figures.treetools.zone.OutputZoneToolBar#addTable()
*/
@Override
protected void addTable() {
final OutputXmlTree createOutputXmlTree = XmlmapFactory.eINSTANCE.createOutputXmlTree();
CommandStack commandStack = externalPart.getViewer().getEditDomain().getCommandStack();
commandStack.execute(new Command() {
@Override
public void execute() {
if (externalPart.getViewer() instanceof XmlMapGraphicViewer) {
XmlMapGraphicViewer viewer = (XmlMapGraphicViewer) externalPart.getViewer();
MapperManager manager = viewer.getMapperManager();
String outputName = manager.getMapperUI().openNewOutputCreationDialog();
if (outputName == null) {
return;
}
createOutputXmlTree.setName(outputName);
externalData.getOutputTrees().add(createOutputXmlTree);
MetadataTable metadataTable = new MetadataTable();
metadataTable.setLabel(outputName);
metadataTable.setTableName(outputName);
mapperComponent.getMetadataList().add(metadataTable);
mapperComponent.getProcess().addUniqueConnectionName(outputName);
int indexOf = externalPart.getModelChildren().indexOf(createOutputXmlTree);
if (indexOf != -1) {
externalPart.getViewer().select((EditPart) externalPart.getChildren().get(indexOf));
}
if (!min_size.isEnabled()) {
min_size.setEnabled(true);
}
// check problem for created output incase input main is multiloop
mapperManger.getProblemsAnalyser().checkProblems(createOutputXmlTree);
mapperManger.getMapperUI().updateStatusBar();
}
}
});
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree in project tdi-studio-se by Talend.
the class XmlMapOutputZoneToolBar method removeTable.
/*
* (non-Javadoc)
*
* @see org.talend.designer.newabstractmap.figures.treetools.zone.OutputZoneToolBar#removeTable()
*/
@Override
protected void removeTable() {
CommandStack commandStack = graphicViewer.getEditDomain().getCommandStack();
commandStack.execute(new Command() {
@Override
public void execute() {
OutputXmlTreeEditPart currentSelectedOutputXmlTree = graphicViewer.getFiguresManager().getCurrentSelectedOutputTable();
if (currentSelectedOutputXmlTree != null) {
OutputXmlTree outputTree = (OutputXmlTree) currentSelectedOutputXmlTree.getModel();
int indexOf = externalPart.getModelChildren().indexOf(outputTree);
mapperComponent.getProcess().removeUniqueConnectionName(outputTree.getName());
removeMetadataTableByName(outputTree.getName());
for (OutputTreeNode treeNode : outputTree.getNodes()) {
XmlMapUtil.detachConnectionsSouce(treeNode, externalData);
}
externalData.getOutputTrees().remove(outputTree);
XmlMapUtil.detachFilterSource(outputTree, externalData);
indexOf = indexOf - 1;
if (indexOf > -1 && (EditPart) externalPart.getChildren().get(indexOf) instanceof OutputXmlTreeEditPart) {
graphicViewer.select((EditPart) externalPart.getChildren().get(indexOf));
} else if (indexOf > -1 && indexOf + 1 < externalPart.getChildren().size() && (EditPart) externalPart.getChildren().get(indexOf + 1) instanceof OutputXmlTreeEditPart) {
graphicViewer.select((EditPart) externalPart.getChildren().get(indexOf + 1));
} else {
mapperManger.getMapperUI().getTabFolderEditors().getOutputMetaEditorView().setMetadataTableEditor(null);
}
mapperManger.getProblemsAnalyser().clearProblemsForTree(outputTree);
mapperManger.getMapperUI().updateStatusBar();
}
if (externalData.getOutputTrees().isEmpty() && min_size.isEnabled()) {
min_size.setEnabled(false);
}
}
});
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree in project tdi-studio-se by Talend.
the class TXMLMapChangeAllInOneValueMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see
* org.talend.core.model.migration.TXMLMapChangeAllInOneValueMigrationTask
* (org .talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
IProxyRepositoryFactory factory = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
ProcessType processType = getProcessType(item);
boolean modified = false;
if (processType != null) {
for (Object obj : processType.getNode()) {
NodeType nodeType = (NodeType) obj;
if (nodeType.getComponentName().startsWith("tXMLMap")) {
XmlMapData xmlMapdata = (XmlMapData) nodeType.getNodeData();
EList<OutputXmlTree> outputTables = xmlMapdata.getOutputTrees();
EList<InputXmlTree> inputTables = xmlMapdata.getInputTrees();
boolean hasDocumentInTheMainInputTable = false;
for (InputXmlTree inputTable : inputTables) {
if (!(inputTable.isLookup())) {
for (TreeNode inputEntry : inputTable.getNodes()) {
if ("id_Document".equals(inputEntry.getType())) {
hasDocumentInTheMainInputTable = true;
}
}
}
}
if (hasDocumentInTheMainInputTable) {
for (OutputXmlTree outputTable : outputTables) {
for (TreeNode outputEntry : outputTable.getNodes()) {
if ("id_Document".equals(outputEntry.getType())) {
if (!outputTable.isAllInOne()) {
outputTable.setAllInOne(true);
modified = true;
break;
}
}
}
}
}
}
}
}
try {
if (modified) {
factory.save(item, true);
return ExecutionResult.SUCCESS_WITH_ALERT;
} else {
return ExecutionResult.SUCCESS_NO_ALERT;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree in project tdi-studio-se by Talend.
the class SetLoopAction method run.
@Override
public void run() {
TreeNode model = (TreeNode) nodePart.getModel();
TreeNode docRoot = XmlMapUtil.getTreeNodeRoot(model);
AbstractInOutTree abstractTree = (AbstractInOutTree) docRoot.eContainer();
boolean isLookup = abstractTree != mapperManager.getMainInputTree() && !(abstractTree instanceof OutputXmlTree);
// remove old group
if (model instanceof OutputTreeNode) {
OutputTreeNode outputNode = (OutputTreeNode) model;
if (docRoot != null) {
XmlMapUtil.cleanSubGroup(outputNode);
List<TreeNode> newLoopUpGroups = new ArrayList<TreeNode>();
findUpGroupNode(newLoopUpGroups, outputNode);
// clean all groups except the ancestor of new loop
XmlMapUtil.cleanSubGroup(docRoot, newLoopUpGroups);
// reset the group in case some element ancestor of loop element are not group but under the group
if (!newLoopUpGroups.isEmpty()) {
TreeNode rootGroup = newLoopUpGroups.get(newLoopUpGroups.size() - 1);
upsetGroup(outputNode, rootGroup);
}
}
}
if (!isLookup) {
// TDI-20147
List<TreeNode> loopNodes = new ArrayList<TreeNode>();
checkSubElementIsLoop(model, loopNodes);
checkParentElementIsLoop(model, loopNodes);
if (!loopNodes.isEmpty()) {
if (MessageDialog.openConfirm(Display.getDefault().getActiveShell(), Messages.getString("SetLoopAction.cleanSubLoopTitle"), Messages.getString("SetLoopAction.cleanSubLoopMessages"))) {
} else {
return;
}
}
for (TreeNode treeNode : loopNodes) {
treeNode.setLoop(false);
}
model.setLoop(true);
XmlMapUtil.clearMainNode(model);
XmlMapUtil.upsetMainNode(model);
abstractTree.setMultiLoops(XmlMapUtil.checkMultiLoopsStatus(abstractTree));
if (input) {
// check if child is mapped to output remove the old loop in output node
XmlMapUtil.removeloopInOutputTree(mapperManager, loopNodes);
// disable the function to add sourceloop into InputLoopNodesTable automatically
// add input loopNodes to InputLoopNodesTable
// addInputLoopNodesToOutput(model, model);
} else {
// clean the InputLoopNodesTable for the old loops
InputXmlTree mainInput = mapperManager.getMainInputTree();
XmlMapUtil.removeLoopTableForOutput((OutputXmlTree) abstractTree, loopNodes, mainInput == null ? false : mainInput.isMultiLoops());
}
} else {
if (docRoot != null) {
cleanSubLoop(docRoot);
}
model.setLoop(true);
XmlMapUtil.clearMainNode(docRoot);
XmlMapUtil.upsetMainNode(model);
}
if (abstractTree != null) {
mapperManager.getProblemsAnalyser().checkProblems(abstractTree);
mapperManager.getMapperUI().updateStatusBar();
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree in project tdi-studio-se by Talend.
the class SetAggregateAction method calculateEnabled.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
*/
@Override
protected boolean calculateEnabled() {
if (getSelectedObjects().isEmpty()) {
return false;
}
Object s = getSelectedObjects().get(0);
if (s instanceof List && !((List) s).isEmpty()) {
List selectedarts = (List) s;
Object obj = selectedarts.get(selectedarts.size() - 1);
if (obj instanceof OutputTreeNodeEditPart) {
nodePart = (OutputTreeNodeEditPart) obj;
OutputTreeNode model = (OutputTreeNode) nodePart.getModel();
// root can't be aggregate
if (NodeType.NAME_SPACE.equals(model.getNodeType()) || !(model.eContainer() instanceof OutputTreeNode) || model.isChoice() || model.isSubstitution()) {
return false;
}
if (!XmlMapUtil.isExpressionEditable(model)) {
return false;
}
boolean isInputMultiLoops = false;
if (mapperManager.getMainInputTree() != null && mapperManager.getMainInputTree().isMultiLoops()) {
isInputMultiLoops = true;
}
AbstractInOutTree abstractTree = XmlMapUtil.getAbstractInOutTree(model);
if (abstractTree instanceof OutputXmlTree) {
OutputXmlTree outputTree = ((OutputXmlTree) abstractTree);
if (outputTree.isAllInOne()) {
return false;
}
// fixed for TDI-20808 ,disable group and aggregate for 501
if (isInputMultiLoops && outputTree.isMultiLoops()) {
return false;
}
}
if (!model.isAggregate()) {
setText("As aggregate element");
} else {
setText("Remove aggregate element");
}
} else {
return false;
}
}
return true;
}
Aggregations