Search in sources :

Example 76 with FOXTreeNode

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

the class FOXManager method orderNode.

/**
     * 
     * wzhang Comment method "orderNode".
     * 
     * @param node
     */
public void orderNode(FOXTreeNode node) {
    // reset the order.
    if (node != null) {
        List<FOXTreeNode> firstSubChildren = node.getChildren();
        FOXTreeNode foundNode = null;
        for (FOXTreeNode childen : firstSubChildren) {
            if (childen.isLoop()) {
                foundNode = childen;
                sortOrder(foundNode, node);
                break;
            } else if (childen.isGroup()) {
                foundNode = childen;
                sortOrder(foundNode, node);
                orderNode(childen);
            } else {
                orderNode(childen);
            }
        }
    }
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode)

Example 77 with FOXTreeNode

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

the class FOXManager method tableLoader.

protected void tableLoader(Element element, String parentPath, List<Map<String, String>> table, String defaultValue) {
    Map<String, String> newMap = new HashMap<String, String>();
    //$NON-NLS-1$
    String currentPath = parentPath + "/" + element.getLabel();
    newMap.put(FileOutputXMLComponent.PATH, currentPath);
    newMap.put(FileOutputXMLComponent.COLUMN, element.getColumnLabel());
    //$NON-NLS-1$ //$NON-NLS-2$
    newMap.put(FileOutputXMLComponent.ATTRIBUTE, element.isMain() ? "main" : "branch");
    //$NON-NLS-1$
    newMap.put(FileOutputXMLComponent.VALUE, defaultValue);
    newMap.put(FileOutputXMLComponent.ORDER, String.valueOf(getNodeOrder(element)));
    table.add(newMap);
    for (FOXTreeNode att : element.getAttributeChildren()) {
        newMap = new HashMap<String, String>();
        newMap.put(FileOutputXMLComponent.PATH, att.getLabel());
        newMap.put(FileOutputXMLComponent.COLUMN, att.getColumnLabel());
        //$NON-NLS-1$
        newMap.put(FileOutputXMLComponent.ATTRIBUTE, "attri");
        //$NON-NLS-1$
        newMap.put(FileOutputXMLComponent.VALUE, att.getDefaultValue());
        newMap.put(FileOutputXMLComponent.ORDER, String.valueOf(getNodeOrder(att)));
        table.add(newMap);
    }
    for (FOXTreeNode att : element.getNameSpaceChildren()) {
        newMap = new HashMap<String, String>();
        newMap.put(FileOutputXMLComponent.PATH, att.getLabel());
        newMap.put(FileOutputXMLComponent.COLUMN, att.getColumnLabel());
        //$NON-NLS-1$
        newMap.put(FileOutputXMLComponent.ATTRIBUTE, "ns");
        //$NON-NLS-1$
        newMap.put(FileOutputXMLComponent.VALUE, att.getDefaultValue());
        newMap.put(FileOutputXMLComponent.ORDER, String.valueOf(getNodeOrder(att)));
        table.add(newMap);
    }
    List<FOXTreeNode> children = element.getElementChildren();
    for (FOXTreeNode child : children) {
        if (!child.isGroup() && !child.isLoop()) {
            tableLoader((Element) child, currentPath, table, child.getDefaultValue());
        }
    }
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) HashMap(java.util.HashMap)

Example 78 with FOXTreeNode

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

the class FOXManager method addElement.

protected FOXTreeNode addElement(FOXTreeNode current, String currentPath, String newPath, String defaultValue) {
    //$NON-NLS-1$
    String name = newPath.substring(newPath.lastIndexOf("/") + 1);
    //$NON-NLS-1$
    String parentPath = newPath.substring(0, newPath.lastIndexOf("/"));
    FOXTreeNode temp = new Element(name, defaultValue);
    if (current == null) {
        // root node
        return temp;
    }
    if (currentPath.equals(parentPath)) {
        current.addChild(temp);
    } else {
        //$NON-NLS-1$
        String[] nods = currentPath.split("/");
        //$NON-NLS-1$
        String[] newNods = parentPath.split("/");
        int parentLevel = 0;
        int checkLength = nods.length < newNods.length ? nods.length : newNods.length;
        for (int i = 1; i < checkLength; i++) {
            if (nods[i].equals(newNods[i])) {
                parentLevel = i;
            }
        }
        FOXTreeNode parent = current;
        for (int i = 0; i < nods.length - (parentLevel + 1); i++) {
            FOXTreeNode tmpParent = parent.getParent();
            if (tmpParent == null) {
                break;
            }
            parent = tmpParent;
        }
        if (parent != null)
            parent.addChild(temp);
    }
    return temp;
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) Element(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element)

Example 79 with FOXTreeNode

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

the class MultiFOXManager method initNodeOrder.

public void initNodeOrder(FOXTreeNode node) {
    if (node == null) {
        return;
    }
    FOXTreeNode parent = node.getParent();
    if (parent == null) {
        node.setOrder(1);
        String path = TreeUtil.getPath(node);
        Map<String, Integer> xpathMap = orderMap.get(node.getRow());
        if (xpathMap == null) {
            xpathMap = new HashMap<String, Integer>();
            orderMap.put(node.getRow(), xpathMap);
        }
        xpathMap.put(path, order);
        order++;
    }
    List<FOXTreeNode> childNode = node.getChildren();
    for (FOXTreeNode child : childNode) {
        child.setOrder(order);
        String path = TreeUtil.getPath(child);
        Map<String, Integer> xpathMap = orderMap.get(child.getRow());
        if (xpathMap == null) {
            xpathMap = new HashMap<String, Integer>();
            orderMap.put(child.getRow(), xpathMap);
        }
        xpathMap.put(path, order);
        order++;
        if (child.getChildren().size() > 0) {
            initNodeOrder(child);
        }
    }
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode)

Example 80 with FOXTreeNode

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

the class MultiFOXManager method getLoopTable.

@Override
public List<Map<String, String>> getLoopTable() {
    List<Map<String, String>> result = new ArrayList<Map<String, String>>();
    for (FOXTreeNode rootNode : this.getOriginalNodes()) {
        Element loopNode = (Element) org.talend.metadata.managment.ui.wizard.metadata.xml.utils.TreeUtil.getLoopNode(rootNode);
        if (loopNode != null) {
            String path = TreeUtil.getPath(loopNode);
            //$NON-NLS-1$
            tableLoader(loopNode, path.substring(0, path.lastIndexOf("/")), result, loopNode.getDefaultValue());
        }
    }
    return result;
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) Element(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

FOXTreeNode (org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode)93 Attribute (org.talend.metadata.managment.ui.wizard.metadata.xml.node.Attribute)29 Element (org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element)29 NameSpaceNode (org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode)28 ArrayList (java.util.ArrayList)23 Iterator (java.util.Iterator)10 HashMap (java.util.HashMap)8 TreeItem (org.eclipse.swt.widgets.TreeItem)7 Map (java.util.Map)6 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)5 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)5 List (java.util.List)4 InputDialog (org.eclipse.jface.dialogs.InputDialog)4 TreePath (org.eclipse.jface.viewers.TreePath)4 EList (org.eclipse.emf.common.util.EList)3 TableItem (org.eclipse.swt.widgets.TableItem)3 Tree (org.eclipse.swt.widgets.Tree)3 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)3 IConnection (org.talend.core.model.process.IConnection)3 ATreeNode (org.talend.datatools.xml.utils.ATreeNode)3