Search in sources :

Example 6 with Element

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

the class MultiFOXManager method getGroupTable.

@Override
public List<Map<String, String>> getGroupTable() {
    List<Map<String, String>> result = new ArrayList<Map<String, String>>();
    for (FOXTreeNode rootNode : this.getOriginalNodes()) {
        Element groupNode = (Element) TreeUtil.getGroupNode(rootNode);
        if (groupNode != null) {
            String path = TreeUtil.getPath(groupNode);
            //$NON-NLS-1$
            tableLoader(groupNode, path.substring(0, path.lastIndexOf("/")), result, groupNode.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)

Example 7 with Element

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

the class FOXManager method getLoopTable.

public List<Map<String, String>> getLoopTable() {
    if (currentSchema != null) {
        treeData = contents.get(currentSchema);
    }
    List<Map<String, String>> result = new ArrayList<Map<String, String>>();
    Element loopNode = (Element) TreeUtil.getLoopNode(this.treeData.get(0));
    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 : Element(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with Element

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

the class MoveUpTreeNodeButton method handleSelectionEvent.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.fileoutputxml.ui.footer.AbstractTreeNodeButton#handleSelectionEvent()
     */
@Override
protected void handleSelectionEvent(TreeSelection selection) {
    if (!selection.isEmpty()) {
        final Element parentNode = (Element) ((FOXTreeNode) selection.getFirstElement()).getParent();
        final List<? extends FOXTreeNode> attrChildren = parentNode.getAttributeChildren();
        final List<? extends FOXTreeNode> nameSpaceChildren = parentNode.getNameSpaceChildren();
        final List<FOXTreeNode> elementChildren = parentNode.getElementChildren();
        List<Integer> attrIndices = new ArrayList<Integer>();
        List<Integer> nameSpaceIndices = new ArrayList<Integer>();
        List<Integer> elementIndices = new ArrayList<Integer>();
        final Iterator iterator = selection.iterator();
        while (iterator.hasNext()) {
            final Object next = iterator.next();
            if (next instanceof Attribute) {
                if (attrChildren.contains(next)) {
                    attrIndices.add(attrChildren.indexOf(next));
                }
            } else if (next instanceof NameSpaceNode) {
                if (nameSpaceChildren.contains(next)) {
                    nameSpaceIndices.add(nameSpaceChildren.indexOf(next));
                }
            } else if (next instanceof Element) {
                if (elementChildren.contains(next)) {
                    elementIndices.add(elementChildren.indexOf(next));
                }
            }
        }
        Collections.sort(attrIndices);
        Collections.sort(nameSpaceIndices);
        Collections.sort(elementIndices);
        swapElements(attrChildren, attrIndices);
        swapElements(nameSpaceChildren, nameSpaceIndices);
        swapElements(elementChildren, elementIndices);
        treeViewer.refresh(parentNode);
        treeViewer.expandAll();
        manager.getUiManager().getFoxUI().redrawLinkers();
        treeViewer.setSelection(selection);
    }
}
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) Element(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 9 with Element

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

the class MoveDownTreeNodeButton method handleSelectionEvent.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.fileoutputxml.ui.footer.AbstractTreeNodeButton#handleSelectionEvent()
     */
@Override
protected void handleSelectionEvent(TreeSelection selection) {
    if (!selection.isEmpty()) {
        FOXTreeNode foxNode = (FOXTreeNode) selection.getFirstElement();
        if (!(foxNode.getParent() instanceof Element)) {
            return;
        }
        final Element parentNode = (Element) foxNode.getParent();
        final List<? extends FOXTreeNode> attrChildren = parentNode.getAttributeChildren();
        final List<? extends FOXTreeNode> nameSpaceChildren = parentNode.getNameSpaceChildren();
        final List<FOXTreeNode> elementChildren = parentNode.getElementChildren();
        List<Integer> attrIndices = new ArrayList<Integer>();
        List<Integer> nameSpaceIndices = new ArrayList<Integer>();
        List<Integer> elementIndices = new ArrayList<Integer>();
        final Iterator iterator = selection.iterator();
        while (iterator.hasNext()) {
            final Object next = iterator.next();
            if (next instanceof Attribute) {
                if (attrChildren.contains(next)) {
                    attrIndices.add(attrChildren.indexOf(next));
                }
            } else if (next instanceof NameSpaceNode) {
                if (nameSpaceChildren.contains(next)) {
                    nameSpaceIndices.add(nameSpaceChildren.indexOf(next));
                }
            } else if (next instanceof Element) {
                if (elementChildren.contains(next)) {
                    elementIndices.add(elementChildren.indexOf(next));
                }
            }
        }
        Collections.sort(attrIndices);
        Collections.sort(nameSpaceIndices);
        Collections.sort(elementIndices);
        swapElements(attrChildren, attrIndices);
        swapElements(nameSpaceChildren, nameSpaceIndices);
        swapElements(elementChildren, elementIndices);
        treeViewer.refresh(parentNode);
        treeViewer.expandAll();
        manager.getUiManager().getFoxUI().redrawLinkers();
        treeViewer.setSelection(selection);
    }
}
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) Element(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 10 with Element

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

the class MoveDownTreeNodeButton method updateStatus.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.fileoutputxml.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) == attrChildren.size() - 1) {
                    getButton().setEnabled(false);
                    return;
                }
            } else if (next instanceof NameSpaceNode) {
                if (nameSpaceChildren.contains(next) && nameSpaceChildren.indexOf(next) == nameSpaceChildren.size() - 1) {
                    getButton().setEnabled(false);
                    return;
                }
            } else if (next instanceof Element) {
                if (elementChildren.contains(next) && elementChildren.indexOf(next) == elementChildren.size() - 1) {
                    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)

Aggregations

Element (org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element)32 FOXTreeNode (org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode)29 Attribute (org.talend.metadata.managment.ui.wizard.metadata.xml.node.Attribute)18 NameSpaceNode (org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode)17 ArrayList (java.util.ArrayList)15 Iterator (java.util.Iterator)10 HashMap (java.util.HashMap)6 Map (java.util.Map)6 TreePath (org.eclipse.jface.viewers.TreePath)4 List (java.util.List)3 EList (org.eclipse.emf.common.util.EList)3 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)3 InputDialog (org.eclipse.jface.dialogs.InputDialog)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 ATreeNode (org.talend.datatools.xml.utils.ATreeNode)2 MetadataTable (org.talend.core.model.metadata.MetadataTable)1 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)1 MetadataEmfTableEditor (org.talend.core.ui.metadata.editor.MetadataEmfTableEditor)1