Search in sources :

Example 1 with OutputTreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.

the class XmlmapBranchContent method createContent.

@Override
protected void createContent() {
    super.createContent();
    statusFigure = new Label();
    statusFigure.setForegroundColor(ColorConstants.red);
    statusFigure.setText(getStatus());
    defaultValue = new Label();
    defaultValue.setForegroundColor(ColorConstants.blue);
    defaultValue.setText(getDefaultValue());
    ImageInfo infor = ImageInfo.SETLOOPFUNCTION_BUTTON;
    if (treeNode instanceof OutputTreeNode) {
        InputLoopNodesTable inputLoopNodesTable = ((OutputTreeNode) treeNode).getInputLoopNodesTable();
        infor = (inputLoopNodesTable == null || inputLoopNodesTable.getInputloopnodes().isEmpty()) ? ImageInfo.SETLOOPFUNCTION_BUTTON_ERROR : ImageInfo.SETLOOPFUNCTION_BUTTON;
    }
    loopButtonFigure = new ToolBarButtonImageFigure(ImageProviderMapper.getImage(infor));
    loopButtonFigure.addMouseListener(new MouseListener.Stub() {

        @Override
        public void mousePressed(MouseEvent me) {
            OutputTreeNode outputTreeNode = (OutputTreeNode) treeNode;
            List<TreeNode> loopNodes = new ArrayList<TreeNode>();
            if (manager.isMainTableMultiLoop()) {
                loopNodes.addAll(XmlMapUtil.getMultiLoopsForXmlTree(manager.getMainInputTree()));
            }
            InputLoopNodesTable inputLoopNodesTable = null;
            if (outputTreeNode.getInputLoopNodesTable() != null) {
                inputLoopNodesTable = outputTreeNode.getInputLoopNodesTable();
            } else {
                inputLoopNodesTable = XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
                outputTreeNode.setInputLoopNodesTable(inputLoopNodesTable);
                AbstractInOutTree abstractInOutTree = XmlMapUtil.getAbstractInOutTree(outputTreeNode);
                if (abstractInOutTree != null) {
                    ((OutputXmlTree) abstractInOutTree).getInputLoopNodesTables().add(inputLoopNodesTable);
                }
            }
            SetLoopFunctionDialog nsDialog = new SetLoopFunctionDialog(null, outputTreeNode.getInputLoopNodesTable(), loopNodes);
            if (nsDialog.open() == Window.OK) {
                manager.getProblemsAnalyser().checkProblems(XmlMapUtil.getAbstractInOutTree(outputTreeNode));
                manager.getMapperUI().updateStatusBar();
            }
        }
    });
    if (treeNode != null && treeNode instanceof OutputTreeNode) {
        // display loop setup button only when input main is multiloop
        if (treeNode.isLoop() && manager.isMainTableMultiLoop()) {
            this.add(loopButtonFigure);
        }
    }
    this.add(statusFigure);
    this.add(defaultValue);
}
Also used : InputLoopNodesTable(org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable) ToolBarButtonImageFigure(org.talend.designer.gefabstractmap.figures.treetools.ToolBarButtonImageFigure) MouseEvent(org.eclipse.draw2d.MouseEvent) Label(org.eclipse.draw2d.Label) SetLoopFunctionDialog(org.talend.designer.xmlmap.ui.dialog.SetLoopFunctionDialog) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) MouseListener(org.eclipse.draw2d.MouseListener) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) ArrayList(java.util.ArrayList) List(java.util.List) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) ImageInfo(org.talend.designer.gefabstractmap.resource.ImageInfo)

Example 2 with OutputTreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.

the class XmlmapTreeNodeFigure method createEntityItems.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.newabstractmap.figures.table.entity.TableEntityFigure#createEntityItems()
     */
@Override
protected void createEntityItems(TableEntityElement entityElement) {
    this.treeNode = getEntityManager().getModel();
    boolean isLookup = false;
    if (treeNode instanceof OutputTreeNode) {
        isLookup = true;
    } else {
        TreeNode inputTreeNodeRoot = XmlMapUtil.getTreeNodeRoot(treeNode);
        if (inputTreeNodeRoot != null && inputTreeNodeRoot.eContainer() instanceof InputXmlTree) {
            isLookup = ((InputXmlTree) inputTreeNodeRoot.eContainer()).isLookup();
        }
    }
    if (isLookup) {
        expression = new ExpressionFigure();
        expression.setText(treeNode.getExpression());
        if (!XmlMapUtil.isExpressionEditable(treeNode)) {
            expression.setOpaque(true);
            expression.setBackgroundColor(ColorProviderMapper.getColor(ColorInfo.COLOR_EXPREESION_DISABLE));
        } else {
            expression.setOpaque(false);
        }
        entityElement.add(expression);
    }
    branchContent = new XmlmapBranchContent(getEntityManager());
    TreeBranch treeBranch = new TreeBranch(branchContent, !isRoot());
    entityElement.add(treeBranch);
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) TreeBranch(org.talend.designer.gefabstractmap.figures.table.entity.TreeBranch) ExpressionFigure(org.talend.designer.gefabstractmap.figures.ExpressionFigure) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)

Example 3 with OutputTreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.

the class SetSubstitutionAction method run.

@Override
public void run() {
    TreeNode treeNode = null;
    boolean needWarning = false;
    if (input) {
        treeNode = XmlmapFactory.eINSTANCE.createTreeNode();
        if (!selectedNode.getOutgoingConnections().isEmpty()) {
            needWarning = true;
        }
    } else {
        treeNode = XmlmapFactory.eINSTANCE.createOutputTreeNode();
        EList<Connection> incomingConnections = selectedNode.getIncomingConnections();
        if (!incomingConnections.isEmpty()) {
            needWarning = true;
        }
    }
    boolean canContinue = true;
    // Shell shell = this.part.getSite().getShell();
    if (needWarning) {
        canContinue = MessageDialog.openConfirm(null, "Warning", "Do you want to disconnect the existing linker and then add a choice for the selected element ?");
    }
    if (canContinue) {
        AbstractUIPlugin plugin = (AbstractUIPlugin) Platform.getPlugin(PlatformUI.PLUGIN_ID);
        IDialogSettings workbenchSettings = plugin.getDialogSettings();
        //$NON-NLS-1$
        IDialogSettings section = workbenchSettings.getSection("SetSubstitutionAction.SubsMessageDialog");
        if (section == null) {
            //$NON-NLS-1$
            section = workbenchSettings.addNewSection("SetSubstitutionAction.SubsMessageDialog");
        }
        boolean popupMessageDialog = !section.getBoolean(HIDE_MESSAGE);
        if (popupMessageDialog) {
            String message = "This element will be copied as part of the substitution group automatically." + "\n" + "If this element must be abstract and must be extended only, you can delete it.";
            SubsMessageDialog dialog = new SubsMessageDialog(null, message);
            int open = dialog.open();
            if (open == Window.OK) {
                boolean hideDialogNextTime = dialog.getResult();
                if (hideDialogNextTime) {
                    section.put(HIDE_MESSAGE, true);
                }
            }
            if (open == Window.CANCEL) {
                return;
            }
        }
        XmlMapUtil.detachNodeConnections(selectedNode, mapperManager.getExternalData(), false);
        treeNode.setName(selectedNode.getName() + XSDPopulationUtil2.SUBS);
        treeNode.setNodeType(NodeType.ELEMENT);
        treeNode.setXpath(selectedNode.getXpath() + XmlMapUtil.XPATH_SEPARATOR + treeNode.getName());
        treeNode.setSubstitution(true);
        TreeNode parentNode = (TreeNode) selectedNode.eContainer();
        int index = parentNode.getChildren().indexOf(selectedNode);
        parentNode.getChildren().remove(selectedNode);
        treeNode.getChildren().add(selectedNode);
        parentNode.getChildren().add(index, treeNode);
        if (!input) {
            OutputTreeNode output = (OutputTreeNode) selectedNode;
            if (!XmlMapUtil.isExpressionEditable(output) && output.isAggregate()) {
                output.setAggregate(false);
            }
        }
        Object object = graphicViewer.getEditPartRegistry().get(treeNode);
        if (object instanceof TreeNodeEditPart) {
            graphicViewer.select((TreeNodeEditPart) object);
        }
    }
}
Also used : AbstractUIPlugin(org.eclipse.ui.plugin.AbstractUIPlugin) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) Connection(org.talend.designer.xmlmap.model.emf.xmlmap.Connection) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart)

Example 4 with OutputTreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.

the class SearchZoneMapper method search.

public void search(Map<Integer, Map<Integer, Figure>> searchMaps, String searchValue) {
    if (searchValue.equals("") || searchValue == null) {
        return;
    }
    List<InputXmlTree> inputTrees = mapperManager.getExternalData().getInputTrees();
    List<VarTable> varTables = mapperManager.getExternalData().getVarTables();
    List<OutputXmlTree> outputTrees = mapperManager.getExternalData().getOutputTrees();
    matcher.setPattern("*" + searchValue.trim() + "*");
    int index = -1;
    // for the InputTables
    for (InputXmlTree inputXmlTree : inputTrees) {
        // ExpressionFilter
        if (inputXmlTree.getExpressionFilter() != null && matcher.matches(inputXmlTree.getExpressionFilter())) {
            EList<Adapter> adapter = inputXmlTree.eAdapters();
            if (adapter.size() > 0) {
                if (adapter.get(0) instanceof InputXmlTreeEditPart) {
                    InputXmlTreeEditPart inputXmlTreeEditPart = (InputXmlTreeEditPart) adapter.get(0);
                    if (inputXmlTreeEditPart != null && inputXmlTreeEditPart.getFigure() != null && inputXmlTreeEditPart.getFigure() instanceof InputXmlTreeFigure) {
                        InputXmlTreeFigure inputXmlTreeFigure = (InputXmlTreeFigure) inputXmlTreeEditPart.getFigure();
                        Map<Integer, Figure> map = new HashMap<Integer, Figure>();
                        map.put(0, inputXmlTreeFigure.getFilterContainer());
                        index++;
                        searchMaps.put(index, map);
                    }
                }
            }
        }
        // TreeNode
        for (TreeNode node : inputXmlTree.getNodes()) {
            // id_Document type
            if (XmlMapUtil.DOCUMENT.equals(node.getType())) {
                for (TreeNode nodeTemp : XmlMapUtil.getFlatChildrenList(node)) {
                    if (getMatcherNodeFigure(nodeTemp).size() > 0) {
                        index++;
                        searchMaps.put(index, getMatcherNodeFigure(nodeTemp));
                    }
                }
            }
            if (getMatcherNodeFigure(node).size() > 0) {
                index++;
                searchMaps.put(index, getMatcherNodeFigure(node));
            }
        }
    }
    // for the VarsTables
    for (VarTable varTable : varTables) {
        for (VarNode node : varTable.getNodes()) {
            if (getMatcherNodeFigure(node).size() > 0) {
                index++;
                searchMaps.put(index, getMatcherNodeFigure(node));
            }
        }
    }
    // for the OutputTables
    for (OutputXmlTree outputXmlTree : outputTrees) {
        // ExpressionFilter
        if (outputXmlTree.getExpressionFilter() != null && matcher.matches(outputXmlTree.getExpressionFilter())) {
            EList<Adapter> adapter = outputXmlTree.eAdapters();
            if (adapter.size() > 0) {
                if (adapter.get(0) instanceof OutputXmlTreeEditPart) {
                    OutputXmlTreeEditPart outputXmlTreeEditPart = (OutputXmlTreeEditPart) adapter.get(0);
                    if (outputXmlTreeEditPart != null && outputXmlTreeEditPart.getFigure() != null && outputXmlTreeEditPart.getFigure() instanceof OutputXmlTreeFigure) {
                        OutputXmlTreeFigure outputXmlTreeFigure = (OutputXmlTreeFigure) outputXmlTreeEditPart.getFigure();
                        Map<Integer, Figure> map = new HashMap<Integer, Figure>();
                        map.put(0, outputXmlTreeFigure.getFilterContainer());
                        index++;
                        searchMaps.put(index, map);
                    }
                }
            }
        }
        // OutputTreeNode
        for (OutputTreeNode node : outputXmlTree.getNodes()) {
            // id_Document type
            if (XmlMapUtil.DOCUMENT.equals(node.getType())) {
                for (TreeNode nodeTemp : XmlMapUtil.getFlatChildrenList(node)) {
                    if (getMatcherNodeFigure(nodeTemp).size() > 0) {
                        index++;
                        searchMaps.put(index, getMatcherNodeFigure(nodeTemp));
                    }
                }
            } else {
                if (getMatcherNodeFigure(node).size() > 0) {
                    index++;
                    searchMaps.put(index, getMatcherNodeFigure(node));
                }
            }
        }
    }
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) HashMap(java.util.HashMap) Adapter(org.eclipse.emf.common.notify.Adapter) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) InputXmlTreeFigure(org.talend.designer.xmlmap.figures.InputXmlTreeFigure) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart) IFigure(org.eclipse.draw2d.IFigure) OutputXmlTreeFigure(org.talend.designer.xmlmap.figures.OutputXmlTreeFigure) TableEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure) XmlmapTreeNodeFigure(org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure) VarNodeFigure(org.talend.designer.xmlmap.figures.varnode.VarNodeFigure) InputXmlTreeFigure(org.talend.designer.xmlmap.figures.InputXmlTreeFigure) VarEntityFigure(org.talend.designer.gefabstractmap.figures.var.VarEntityFigure) Figure(org.eclipse.draw2d.Figure) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) InputXmlTreeEditPart(org.talend.designer.xmlmap.parts.InputXmlTreeEditPart) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) OutputXmlTreeFigure(org.talend.designer.xmlmap.figures.OutputXmlTreeFigure)

Example 5 with OutputTreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode 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);
            }
        }
    });
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) Command(org.eclipse.gef.commands.Command) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart) XmlMapDataEditPart(org.talend.designer.xmlmap.parts.XmlMapDataEditPart) EditPart(org.eclipse.gef.EditPart) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart)

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