Search in sources :

Example 51 with OutputTreeNode

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);
                    }
                }
            }
        }
    }
}
Also used : InputLoopNodesTable(org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable) Connection(org.talend.designer.xmlmap.model.emf.xmlmap.Connection) LookupConnection(org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)

Example 52 with OutputTreeNode

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());
}
Also used : OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)

Example 53 with OutputTreeNode

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);
                }
            }
        }
    }
}
Also used : OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)

Example 54 with OutputTreeNode

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();
}
Also used : VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) MapperManager(org.talend.designer.xmlmap.ui.tabs.MapperManager) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) Point(org.eclipse.draw2d.geometry.Point) Shell(org.eclipse.swt.widgets.Shell) Command(org.eclipse.gef.commands.Command) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) NodeType(org.talend.designer.xmlmap.model.emf.xmlmap.NodeType) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) XmlMapGraphicViewer(org.talend.designer.xmlmap.editor.XmlMapGraphicViewer)

Example 55 with OutputTreeNode

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));
                            }
                        }
                    }
                }
            });
        }
    }
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) PropertySetDialog(org.talend.designer.xmlmap.ui.dialog.PropertySetDialog) XmlMapDataEditPart(org.talend.designer.xmlmap.parts.XmlMapDataEditPart) InputXmlTreeEditPart(org.talend.designer.xmlmap.parts.InputXmlTreeEditPart) EditPart(org.eclipse.gef.EditPart) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) Command(org.eclipse.gef.commands.Command) IProcess2(org.talend.core.model.process.IProcess2) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) IProcess(org.talend.core.model.process.IProcess)

Aggregations

OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)57 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)42 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)27 ArrayList (java.util.ArrayList)16 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)16 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)15 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)15 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)11 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)11 TreeNodeEditPart (org.talend.designer.xmlmap.parts.TreeNodeEditPart)10 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)9 List (java.util.List)8 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)8 LookupConnection (org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)8 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)8 InputLoopNodesTable (org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable)7 OutputTreeNodeEditPart (org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)7 VarNodeEditPart (org.talend.designer.xmlmap.parts.VarNodeEditPart)6 FilterConnection (org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection)5 InputXmlTreeEditPart (org.talend.designer.xmlmap.parts.InputXmlTreeEditPart)5