Search in sources :

Example 21 with NameSpaceNode

use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode in project tdi-studio-se by Talend.

the class AddTreeNodeButton method updateStatus.

@Override
protected void updateStatus(TreeSelection selection) {
    if (selection.getFirstElement() instanceof FOXTreeNode) {
        FOXTreeNode node = (FOXTreeNode) selection.getFirstElement();
        if (node == null) {
            getButton().setEnabled(false);
            return;
        }
        if (node instanceof Attribute) {
            getButton().setEnabled(false);
            return;
        }
        if (node instanceof NameSpaceNode) {
            getButton().setEnabled(false);
            return;
        }
        getButton().setEnabled(true);
    } else {
        getButton().setEnabled(false);
    }
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) NameSpaceNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode) Attribute(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Attribute)

Example 22 with NameSpaceNode

use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode in project tdi-studio-se by Talend.

the class AddTreeNodeButton method updateStatus.

@Override
protected void updateStatus(TreeSelection selection) {
    if (selection.getFirstElement() instanceof FOXTreeNode) {
        FOXTreeNode node = (FOXTreeNode) selection.getFirstElement();
        if (node == null) {
            getButton().setEnabled(false);
            return;
        }
        if (node instanceof Attribute) {
            getButton().setEnabled(false);
            return;
        }
        if (node instanceof NameSpaceNode) {
            getButton().setEnabled(false);
            return;
        }
        getButton().setEnabled(true);
    } else {
        getButton().setEnabled(false);
    }
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) NameSpaceNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode) Attribute(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Attribute)

Example 23 with NameSpaceNode

use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode in project tdi-studio-se by Talend.

the class MoveUpTreeNodeButton method updateStatus.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.fileoutputJSON.ui.footer.AbstractTreeNodeButton#updateButtonStatus()
     */
@Override
protected void updateStatus(TreeSelection selection) {
    if (selection.isEmpty()) {
        getButton().setEnabled(false);
        return;
    }
    final TreePath[] paths = selection.getPaths();
    boolean sameSegment = true;
    for (int i = 0; i < paths.length - 1; i++) {
        if (paths[i].getSegmentCount() != paths[i + 1].getSegmentCount()) {
            sameSegment = false;
        }
    }
    if (sameSegment) {
        getButton().setEnabled(true);
    } else {
        getButton().setEnabled(false);
        return;
    }
    // if same segment ,they have the same parent and parent must be an element
    FOXTreeNode foxNode = (FOXTreeNode) selection.getFirstElement();
    if (foxNode.getParent() instanceof Element) {
        final Element parent = (Element) foxNode.getParent();
        if (parent == null) {
            getButton().setEnabled(false);
            return;
        }
        final List<? extends FOXTreeNode> attrChildren = parent.getAttributeChildren();
        final List<? extends FOXTreeNode> nameSpaceChildren = parent.getNameSpaceChildren();
        final List<FOXTreeNode> elementChildren = parent.getElementChildren();
        final Iterator iterator = selection.iterator();
        while (iterator.hasNext()) {
            final Object next = iterator.next();
            if (next instanceof Attribute) {
                if (attrChildren.contains(next) && attrChildren.indexOf(next) == 0) {
                    getButton().setEnabled(false);
                    return;
                }
            } else if (next instanceof NameSpaceNode) {
                if (nameSpaceChildren.contains(next) && nameSpaceChildren.indexOf(next) == 0) {
                    getButton().setEnabled(false);
                    return;
                }
            } else if (next instanceof Element) {
                if (elementChildren.contains(next) && elementChildren.indexOf(next) == 0) {
                    getButton().setEnabled(false);
                    return;
                }
            }
        }
    }
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) TreePath(org.eclipse.jface.viewers.TreePath) NameSpaceNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode) Attribute(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Attribute) Element(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element) Iterator(java.util.Iterator)

Example 24 with NameSpaceNode

use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode in project tdi-studio-se by Talend.

the class ImportTreeFromXml method prepareEmfTreeNode.

private void prepareEmfTreeNode(List<FOXTreeNode> list, TreeNode parent) {
    if (list == null || list.isEmpty()) {
        return;
    }
    String xPath = parent.getXpath();
    TreeNode realParentNode = parent;
    if (parent.isSubstitution() || parent.isChoice()) {
        realParentNode = XmlMapUtil.getRealParentNode(parent);
        if (realParentNode != null) {
            xPath = realParentNode.getXpath();
        }
    }
    for (FOXTreeNode foxNode : list) {
        TreeNode createTreeNode = null;
        if (input) {
            createTreeNode = XmlmapFactory.eINSTANCE.createTreeNode();
        } else {
            createTreeNode = XmlmapFactory.eINSTANCE.createOutputTreeNode();
        }
        String label = foxNode.getLabel();
        createTreeNode.setName(label);
        createTreeNode.setOptional(foxNode.isOptional());
        if (foxNode instanceof Element) {
            createTreeNode.setNodeType(NodeType.ELEMENT);
            if (foxNode.isChoice()) {
                createTreeNode.setChoice(foxNode.isChoice());
            } else if (foxNode.isSubstitution()) {
                createTreeNode.setSubstitution(foxNode.isSubstitution());
            }
        } else if (foxNode instanceof Attribute) {
            createTreeNode.setNodeType(NodeType.ATTRIBUT);
        } else if (foxNode instanceof NameSpaceNode) {
            createTreeNode.setNodeType(NodeType.NAME_SPACE);
            createTreeNode.setDefaultValue(foxNode.getDefaultValue());
            if (createTreeNode.getName() == null || createTreeNode.getName().equals("")) {
                createTreeNode.setName(XmlMapUtil.DEFAULT_NAME_SPACE_PREFIX);
            }
        }
        createTreeNode.setXpath(XmlMapUtil.getXPath(xPath, label, createTreeNode.getNodeType()));
        if (foxNode.getDataType() != null && !"".equals(foxNode.getDataType())) {
            if (foxNode.getDataType().equals("id_Date")) {
                //$NON-NLS-1$
                createTreeNode.setPattern("\"dd-MM-yyyy\"");
            }
            createTreeNode.setType(foxNode.getDataType());
        } else {
            createTreeNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
        }
        parent.getChildren().add(createTreeNode);
        if (foxNode.getChildren() != null && !foxNode.getChildren().isEmpty()) {
            prepareEmfTreeNode(foxNode.getChildren(), createTreeNode);
        }
    }
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) NameSpaceNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode) Attribute(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Attribute) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) Element(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element)

Example 25 with NameSpaceNode

use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode in project tdi-studio-se by Talend.

the class ImportTreeFromRepository method isMappedChoiceSubsOutput.

private boolean isMappedChoiceSubsOutput(FOXTreeNode node, String pXpath) {
    List<FOXTreeNode> children = node.getChildren();
    List<FOXTreeNode> subsChoice = new ArrayList<FOXTreeNode>();
    XMLFileNode found = null;
    for (FOXTreeNode child : children) {
        if (child.isSubstitution() || child.isChoice()) {
            subsChoice.add(child);
        } else {
            String childXpath = "";
            if (child instanceof Element) {
                childXpath = XmlMapUtil.getXPath(pXpath, child.getLabel(), NodeType.ELEMENT);
            } else if (child instanceof Attribute) {
                childXpath = XmlMapUtil.getXPath(pXpath, child.getLabel(), NodeType.ATTRIBUT);
            } else if (child instanceof NameSpaceNode) {
                childXpath = XmlMapUtil.getXPath(pXpath, child.getLabel(), NodeType.NAME_SPACE);
            }
            found = findXmlFileNode(childXpath, root);
            if (found == null) {
                found = findXmlFileNode(childXpath, group);
            }
            if (found == null) {
                found = findXmlFileNode(childXpath, loop);
            }
            if (found != null) {
                break;
            }
        }
    }
    if (found != null) {
        return true;
    }
    if (!subsChoice.isEmpty()) {
        for (FOXTreeNode foxNode : subsChoice) {
            boolean isChildMapped = isMappedChoiceSubsOutput(foxNode, pXpath);
            if (isChildMapped) {
                return true;
            }
        }
    }
    return found != null;
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) XMLFileNode(org.talend.core.model.metadata.builder.connection.XMLFileNode) NameSpaceNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode) Attribute(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Attribute) Element(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element) ArrayList(java.util.ArrayList)

Aggregations

FOXTreeNode (org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode)28 NameSpaceNode (org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode)28 Attribute (org.talend.metadata.managment.ui.wizard.metadata.xml.node.Attribute)26 Element (org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element)17 Iterator (java.util.Iterator)8 ArrayList (java.util.ArrayList)7 TreePath (org.eclipse.jface.viewers.TreePath)4 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)2 XMLFileNode (org.talend.core.model.metadata.builder.connection.XMLFileNode)2 IConnection (org.talend.core.model.process.IConnection)2 NameSpaceDialog (org.talend.metadata.managment.ui.wizard.metadata.xml.dialog.NameSpaceDialog)2 EList (org.eclipse.emf.common.util.EList)1 MetadataTable (org.talend.core.model.metadata.MetadataTable)1 ATreeNode (org.talend.datatools.xml.utils.ATreeNode)1 NodeType (org.talend.designer.xmlmap.model.emf.xmlmap.NodeType)1 JSONFileNode (org.talend.repository.model.json.JSONFileNode)1