use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.
the class SetLoopAction method addInputLoopNodesToOutput.
private void addInputLoopNodesToOutput(TreeNode loopNode, List<Connection> connections) {
for (Connection connection : connections) {
if (connection.getTarget() instanceof OutputTreeNode) {
OutputTreeNode loopParentNode = (OutputTreeNode) XmlMapUtil.getLoopParentNode((OutputTreeNode) connection.getTarget());
if (loopParentNode != null) {
if (loopParentNode.getInputLoopNodesTable() != null) {
loopParentNode.getInputLoopNodesTable().getInputloopnodes().add(loopNode);
}
} else {
OutputXmlTree abstractInOutTree = (OutputXmlTree) XmlMapUtil.getAbstractInOutTree((OutputTreeNode) connection.getTarget());
if (!XmlMapUtil.hasDocument(abstractInOutTree)) {
EList<InputLoopNodesTable> inputLoopNodesTables = abstractInOutTree.getInputLoopNodesTables();
if (inputLoopNodesTables.size() == 1) {
InputLoopNodesTable inputLoopNodesTable = inputLoopNodesTables.get(0);
inputLoopNodesTable.getInputloopnodes().add(loopNode);
}
}
}
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.
the class SetAggregateAction method run.
@Override
public void run() {
OutputTreeNode model = (OutputTreeNode) nodePart.getModel();
model.setAggregate(!model.isAggregate());
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.
the class SetGroupAction method findGroupNodeTrace.
private void findGroupNodeTrace(List list, TreeNode loopNode) {
if (nodePart != null) {
OutputTreeNode selectedNode = (OutputTreeNode) nodePart.getModel();
OutputTreeNode rootNode = null;
if (loopNode instanceof OutputTreeNode) {
rootNode = (OutputTreeNode) XmlMapUtil.getTreeNodeRoot(loopNode);
}
Object parentNode = loopNode.eContainer();
if (parentNode instanceof OutputTreeNode && rootNode != null) {
OutputTreeNode parent = (OutputTreeNode) parentNode;
if (!parent.equals(rootNode)) {
if (!parent.equals(selectedNode)) {
list.add(parent);
findGroupNodeTrace(list, parent);
} else if (parent.equals(selectedNode)) {
list.add(parent);
}
}
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.
the class XmlDropTargetListener method handleDrop.
@Override
protected void handleDrop() {
final Object object = TemplateTransfer.getInstance().getObject();
if (object == null || !(object instanceof TransferedObject)) {
return;
}
updateTargetRequest();
updateTargetEditPart();
DropContextAnalyzer analyzer = new DropContextAnalyzer((TransferedObject) object, (AbstractGraphicalEditPart) getTargetEditPart(), getDropLocation());
if (analyzer.isDropValid()) {
NodeType selectedNodeType = NodeType.ELEMENT;
DropType dropType = analyzer.getDropType();
if (dropType == DropType.DROP_OUTPUT_DOC_CHILD && getTargetEditPart() instanceof OutputTreeNodeEditPart) {
OutputTreeNode targetOutputNode = (OutputTreeNode) ((OutputTreeNodeEditPart) getTargetEditPart()).getModel();
Shell shell = getViewer().getControl().getShell();
// if allNamespace , create output as namespace , if allsubTree , create output subtree , no need prompt
boolean needPrompt = false;
boolean hasSubTree = false;
for (Object o : ((TransferedObject) object).getToTransfer()) {
if (o instanceof VarNodeEditPart) {
needPrompt = true;
} else if (o instanceof TreeNodeEditPart) {
TreeNode treeNode = (TreeNode) ((TreeNodeEditPart) o).getModel();
if (NodeType.ATTRIBUT.equals(treeNode.getNodeType())) {
needPrompt = true;
}
if (NodeType.ELEMENT.equals(treeNode.getNodeType())) {
if (treeNode.getChildren().isEmpty()) {
needPrompt = true;
} else {
hasSubTree = true;
}
}
}
}
if (needPrompt) {
DragAndDrogDialog selectDialog = new DragAndDrogDialog(shell, !targetOutputNode.getChildren().isEmpty());
int open = selectDialog.open();
if (open == Window.OK) {
if (DragAndDrogDialog.CREATE_AS_SUBELEMENT.equals(selectDialog.getSelectValue())) {
selectedNodeType = NodeType.ELEMENT;
} else if (DragAndDrogDialog.CREATE_AS_ATTRIBUTE.equals(selectDialog.getSelectValue())) {
selectedNodeType = NodeType.ATTRIBUT;
} else if (DragAndDrogDialog.CREATE_AS_SUBELEMENT.equals(selectDialog.getSelectValue())) {
selectedNodeType = NodeType.NAME_SPACE;
} else if (DragAndDrogDialog.CREATE_AS_TEXT.equals(selectDialog.getSelectValue())) {
dropType = DropType.DROP_EXPRESSION;
}
} else {
return;
}
}
if (dropType != DropType.DROP_EXPRESSION) {
if (!targetOutputNode.getIncomingConnections().isEmpty() && ((selectedNodeType != NodeType.ATTRIBUT && selectedNodeType != NodeType.NAME_SPACE) || hasSubTree)) {
boolean canContinue = MessageDialog.openConfirm(null, "Warning", "Do you want to disconnect the existing linker and then add an sub element for the selected element ?");
if (canContinue) {
MapperManager mapperManager = ((XmlMapGraphicViewer) getViewer()).getMapperManager();
if (mapperManager != null && mapperManager.getExternalData() != null) {
XmlMapUtil.detachNodeConnections(targetOutputNode, mapperManager.getExternalData(), false);
}
} else {
return;
}
}
}
}
NewNodeCreationFactory factory = new NewNodeCreationFactory(dropType, selectedNodeType);
getCreateRequest().setFactory(factory);
}
if (getTargetEditPart() != null) {
Command command = getCommand();
if (command != null && command.canExecute()) {
getViewer().getEditDomain().getCommandStack().execute(command);
} else {
getCurrentEvent().detail = DND.DROP_NONE;
}
} else {
getCurrentEvent().detail = DND.DROP_NONE;
}
selectAddedObject();
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.
the class XmlMapInputZoneToolBar method changProperty.
/*
* (non-Javadoc)
*
* @see org.talend.designer.newabstractmap.figures.treetools.zone.InputZoneTooBar#changProperty()
*/
@Override
public void changProperty() {
boolean dieOnError = mapperManger.isDieOnError();
PropertySetDialog propertySet = new PropertySetDialog(null, dieOnError);
if (propertySet.open() == Window.OK) {
if (graphicViewer != null && propertySet.isValueChanged()) {
final boolean newValue = !dieOnError;
CommandStack commandStack = graphicViewer.getEditDomain().getCommandStack();
commandStack.execute(new Command() {
@Override
public void execute() {
mapperManger.setDieOnError(newValue);
if (newValue) {
if (!externalData.getOutputTrees().isEmpty()) {
OutputXmlTree outputTree = externalData.getOutputTrees().get(0);
if (outputTree.isErrorReject()) {
// mapperComponent.getMetadataList().add(metadataTable);
externalData.getOutputTrees().remove(0);
mapperComponent.getProcess().removeUniqueConnectionName(outputTree.getName());
removeMetadataTableByName(outputTree.getName());
if (!externalData.getOutputTrees().isEmpty()) {
int indexOf = externalPart.getModelChildren().indexOf(externalData.getOutputTrees().get(0));
if (indexOf != -1) {
graphicViewer.select((EditPart) externalPart.getChildren().get(indexOf));
}
}
}
}
} else {
boolean hasRejectTable = false;
if (!externalData.getOutputTrees().isEmpty()) {
OutputXmlTree outputTree = externalData.getOutputTrees().get(0);
if (outputTree.isErrorReject()) {
hasRejectTable = true;
}
}
if (!hasRejectTable) {
String baseName = MapperManager.ERROR_REJECT;
IProcess process = mapperComponent.getProcess();
String tableName = baseName;
if (!process.checkValidConnectionName(baseName) && process instanceof IProcess2) {
final String uniqueName = ((IProcess2) process).generateUniqueConnectionName("row", baseName);
tableName = uniqueName;
((IProcess2) process).addUniqueConnectionName(uniqueName);
} else if (process instanceof IProcess2) {
tableName = baseName;
((IProcess2) process).addUniqueConnectionName(baseName);
}
OutputXmlTree outputXmlTree = XmlmapFactory.eINSTANCE.createOutputXmlTree();
outputXmlTree.setErrorReject(true);
outputXmlTree.setName(tableName);
externalData.getOutputTrees().add(0, outputXmlTree);
MetadataTable metadataTable = new MetadataTable();
metadataTable.setLabel(tableName);
metadataTable.setTableName(tableName);
MetadataColumn errorMessageCol = new MetadataColumn();
errorMessageCol.setLabel(MapperManager.ERROR_REJECT_MESSAGE);
errorMessageCol.setTalendType(DesignerPlugin.getDefault().getPreferenceStore().getString(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE));
errorMessageCol.setNullable(true);
errorMessageCol.setOriginalDbColumnName(MapperManager.ERROR_REJECT_MESSAGE);
errorMessageCol.setReadOnly(true);
errorMessageCol.setCustom(true);
metadataTable.getListColumns().add(errorMessageCol);
MetadataColumn errorStackTrace = new MetadataColumn();
errorStackTrace.setLabel(MapperManager.ERROR_REJECT_STACK_TRACE);
errorStackTrace.setTalendType(DesignerPlugin.getDefault().getPreferenceStore().getString(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE));
errorStackTrace.setNullable(true);
errorStackTrace.setOriginalDbColumnName(MapperManager.ERROR_REJECT_STACK_TRACE);
errorStackTrace.setReadOnly(true);
errorStackTrace.setCustom(true);
metadataTable.getListColumns().add(errorStackTrace);
mapperComponent.getMetadataList().add(metadataTable);
OutputTreeNode errorMessageNode = XmlmapFactory.eINSTANCE.createOutputTreeNode();
errorMessageNode.setName(MapperManager.ERROR_REJECT_MESSAGE);
errorMessageNode.setType(errorMessageCol.getTalendType());
errorMessageNode.setNullable(true);
outputXmlTree.getNodes().add(errorMessageNode);
OutputTreeNode errorStackTraceNode = XmlmapFactory.eINSTANCE.createOutputTreeNode();
errorStackTraceNode.setName(MapperManager.ERROR_REJECT_STACK_TRACE);
errorStackTraceNode.setType(errorStackTrace.getTalendType());
errorStackTraceNode.setNullable(true);
outputXmlTree.getNodes().add(errorStackTraceNode);
int indexOf = externalPart.getModelChildren().indexOf(outputXmlTree);
if (indexOf != -1) {
graphicViewer.select((EditPart) externalPart.getChildren().get(indexOf));
}
}
}
}
});
}
}
}
Aggregations