Search in sources :

Example 36 with FOXTreeNode

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

the class MoveDownTreeNodeButton method handleSelectionEvent.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.fileoutputJSON.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();
        form.redrawLinkers();
        treeViewer.setSelection(selection);
        form.updateConnection();
    }
}
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 37 with FOXTreeNode

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

the class MoveUpTreeNodeButton method handleSelectionEvent.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.fileoutputJSON.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();
        form.redrawLinkers();
        treeViewer.setSelection(selection);
        form.updateConnection();
    }
}
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 38 with FOXTreeNode

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

the class DeleteJSONNodeAction method run.

@Override
public void run() {
    List<FOXTreeNode> objectToRemove = new ArrayList<FOXTreeNode>();
    final Iterator iterator = this.getStructuredSelection().iterator();
    while (iterator.hasNext()) {
        FOXTreeNode selectedNode = (FOXTreeNode) iterator.next();
        objectToRemove.add(selectedNode);
    }
    for (FOXTreeNode node : objectToRemove) {
        if (node == null) {
            return;
        }
        FOXTreeNode parent = node.getParent();
        if (parent == null) {
            return;
        }
        if (node instanceof Element) {
            disconnectSubTree(node);
        }
        parent.removeChild(node);
        if (node.isLoop() || node.isGroup()) {
            form.updateStatus();
        }
        jsonViewer.refresh(parent);
    }
    jsonViewer.expandAll();
    form.updateConnection();
    form.redrawLinkers();
}
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) Iterator(java.util.Iterator)

Example 39 with FOXTreeNode

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

the class ImportTreeFromJSONAction method selectionChanged.

@Override
public void selectionChanged(IStructuredSelection selection) {
    this.setEnabled(true);
    FOXTreeNode node = (FOXTreeNode) this.getStructuredSelection().getFirstElement();
    if (node != null) {
        form.setSelectedText(node.getLabel());
    }
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode)

Example 40 with FOXTreeNode

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

the class JSONDisconnectAction method run.

public void run() {
    FOXTreeNode node = (FOXTreeNode) this.getStructuredSelection().getFirstElement();
    if (node == null) {
        return;
    }
    node.setColumn(null);
    jsonViewer.refresh(node);
    jsonViewer.expandAll();
    form.redrawLinkers();
    form.updateConnection();
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode)

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