Search in sources :

Example 56 with TreeNode

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

the class MapperManager method refreshStyledTextEditor.

public void refreshStyledTextEditor(TableEntityPart nodePart) {
    if (nodePart == null) {
        mapperUI.getTabFolderEditors().getStyledTextHandler().setTextWithoutNotifyListeners("");
        mapperUI.getTabFolderEditors().getStyledTextHandler().getStyledText().setEnabled(false);
        mapperUI.getTabFolderEditors().getStyledTextHandler().getStyledText().setEditable(false);
        return;
    }
    AbstractNode node = (AbstractNode) nodePart.getModel();
    if (node instanceof TreeNode) {
        if (!((TreeNode) node).getChildren().isEmpty()) {
            mapperUI.getTabFolderEditors().getStyledTextHandler().setTextWithoutNotifyListeners("");
            mapperUI.getTabFolderEditors().getStyledTextHandler().getStyledText().setEnabled(false);
            mapperUI.getTabFolderEditors().getStyledTextHandler().getStyledText().setEditable(false);
            return;
        }
    }
    String expression = node.getExpression();
    if (expression == null) {
        expression = "";
    }
    mapperUI.getTabFolderEditors().getStyledTextHandler().setTextWithoutNotifyListeners(expression);
    mapperUI.getTabFolderEditors().getStyledTextHandler().getStyledText().setEnabled(true);
    mapperUI.getTabFolderEditors().getStyledTextHandler().getStyledText().setEditable(true);
    mapperUI.getTabFolderEditors().getStyledTextHandler().setSelectedNodePart(nodePart);
}
Also used : AbstractNode(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)

Example 57 with TreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode 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 58 with TreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode 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 59 with TreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode 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 60 with TreeNode

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

the class XmlMapTreeContainerLayout method getLookupConnectionSize.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.newabstractmap.figures.layout.TreeContainerLayout#getLookupConnectionSize()
     */
@Override
protected int getLookupConnectionSize(AbstractTableContainer tableContainer) {
    if (tableContainer instanceof InputXmlTreeFigure) {
        InputXmlTree inputModel = ((InputXmlTreeFigure) tableContainer).getInputXmlTree();
        List<TreeNode> nodeList = inputModel.getNodes();
        int maxSize = 0;
        List<IConnection> lookConnections = XmlMapUtil.getAllNodeLookConnections(inputModel);
        List<IConnection> filterConnections = XmlMapUtil.getInputTreeFilterConnections(inputModel);
        if (lookConnections.size() < filterConnections.size()) {
            maxSize = filterConnections.size();
        } else {
            maxSize = lookConnections.size();
        }
        return maxSize;
    }
    return 0;
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) IConnection(org.talend.designer.xmlmap.model.emf.xmlmap.IConnection) InputXmlTreeFigure(org.talend.designer.xmlmap.figures.InputXmlTreeFigure)

Aggregations

TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)119 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)88 ArrayList (java.util.ArrayList)39 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)34 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)26 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)25 TreeNodeEditPart (org.talend.designer.xmlmap.parts.TreeNodeEditPart)22 List (java.util.List)21 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)19 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)17 EList (org.eclipse.emf.common.util.EList)15 LookupConnection (org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)14 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)13 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)12 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)12 FilterConnection (org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection)11 FOXTreeNode (org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode)10 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)9 VarNodeEditPart (org.talend.designer.xmlmap.parts.VarNodeEditPart)9 OutputTreeNodeEditPart (org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)8