Search in sources :

Example 16 with Attribute

use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.Attribute 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 17 with Attribute

use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.Attribute 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 18 with Attribute

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

the class RemoveJSONGroupAction method selectionChanged.

@Override
public void selectionChanged(IStructuredSelection selection) {
    FOXTreeNode node = (FOXTreeNode) this.getStructuredSelection().getFirstElement();
    if (node == null) {
        this.setEnabled(false);
        return;
    }
    if (node instanceof Attribute) {
        this.setEnabled(false);
        return;
    }
    if (node instanceof NameSpaceNode) {
        this.setEnabled(false);
        return;
    }
    this.setEnabled(node.isGroup());
}
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 19 with Attribute

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

the class CreateJSONAttributeAction method createChildNode.

private void createChildNode(FOXTreeNode node) {
    String label = "";
    while (!JSONUtil.validateLabelForJSON(label)) {
        InputDialog dialog = new InputDialog(null, "Input attribute's label", "Input the new attribute's valid label", "", null);
        int status = dialog.open();
        if (status == InputDialog.OK) {
            label = dialog.getValue().trim();
        }
        if (status == InputDialog.CANCEL) {
            return;
        }
    }
    FOXTreeNode child = new Attribute(label);
    // child.setRow(node.getRow());
    node.addChild(child);
    this.jsonViewer.refresh();
    jsonViewer.expandAll();
    form.redrawLinkers();
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) InputDialog(org.eclipse.jface.dialogs.InputDialog) Attribute(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Attribute)

Example 20 with Attribute

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

the class CreateJSONElementAction method selectionChanged.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.ISelection)
     */
@Override
public void selectionChanged(IStructuredSelection selection) {
    FOXTreeNode node = (FOXTreeNode) this.getStructuredSelection().getFirstElement();
    if (node == null) {
        this.setEnabled(false);
        return;
    }
    if (node instanceof Attribute) {
        this.setEnabled(false);
        return;
    }
    if (node instanceof NameSpaceNode) {
        this.setEnabled(false);
        return;
    }
    this.setEnabled(true);
}
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)

Aggregations

Attribute (org.talend.metadata.managment.ui.wizard.metadata.xml.node.Attribute)29 FOXTreeNode (org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode)29 NameSpaceNode (org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode)26 Element (org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element)18 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 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 EList (org.eclipse.emf.common.util.EList)1 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 ATreeNode (org.talend.datatools.xml.utils.ATreeNode)1