Search in sources :

Example 1 with FOXTreeNode

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

the class DisconnectAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    FOXTreeNode node = (FOXTreeNode) this.getStructuredSelection().getFirstElement();
    if (node == null) {
        return;
    }
    node.setColumn(null);
    xmlViewer.refresh(node);
    xmlViewer.expandToLevel(node, 1);
    foxui.redrawLinkers();
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode)

Example 2 with FOXTreeNode

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

the class FixValueAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    FOXTreeNode node = (FOXTreeNode) this.getStructuredSelection().getFirstElement();
    setFixValue(node);
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode)

Example 3 with FOXTreeNode

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

the class ImportTreeFromXMLAction method treeNodeAdapt.

private List<FOXTreeNode> treeNodeAdapt(String file) {
    List<FOXTreeNode> list = new ArrayList<FOXTreeNode>();
    try {
        ATreeNode treeNode = SchemaPopulationUtil.getSchemaTree(file, true, 0);
        String schemaName = getSelectedSchema();
        String rootName = "";
        if (treeNode.getValue() instanceof String) {
            rootName += "/" + treeNode.getValue();
        }
        FOXTreeNode root = cloneATreeNode(treeNode, schemaName, rootName);
        Element rootElement = (Element) root;
        if (rootElement.getElementChildren() != null && rootElement.getElementChildren().size() > 0) {
            for (FOXTreeNode foxTreeNode : rootElement.getElementChildren()) {
                foxTreeNode.setParent(null);
                list.add(foxTreeNode);
            }
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    return list;
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) ATreeNode(org.talend.datatools.xml.utils.ATreeNode) Element(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element) ArrayList(java.util.ArrayList)

Example 4 with FOXTreeNode

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

the class ImportTreeFromXMLAction method selectionChanged.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
     */
@Override
public void selectionChanged(IStructuredSelection selection) {
    this.setEnabled(true);
    FOXTreeNode node = (FOXTreeNode) this.getStructuredSelection().getFirstElement();
    if (node != null) {
        foxui.setSelectedText(node.getLabel());
    }
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode)

Example 5 with FOXTreeNode

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

the class ImportTreeFromXMLAction method cloneATreeNode.

private FOXTreeNode cloneATreeNode(ATreeNode treeNode, String schemaName, String currentPath) throws Exception {
    FOXTreeNode node = null;
    if (treeNode.getType() == ATreeNode.ATTRIBUTE_TYPE) {
        node = new Attribute();
    } else {
        node = new Element();
    }
    // zli fixed for bug 7414
    if (treeNode.getType() == ATreeNode.NAMESPACE_TYPE) {
        node = new NameSpaceNode();
        //$NON-NLS-1$
        node.setLabel("");
        node.setDefaultValue((String) treeNode.getValue());
    } else {
        node.setLabel((String) treeNode.getValue());
    }
    Object[] children = treeNode.getChildren();
    if (children != null) {
        for (Object element : children) {
            if (element instanceof ATreeNode) {
                ATreeNode child = (ATreeNode) element;
                String newPath = currentPath + "/";
                if (child.getValue() instanceof String) {
                    String elementName = (String) child.getValue();
                    if (currentPath.contains("/" + elementName + "/")) {
                        ExceptionHandler.process(new Exception("XSD ERROR: loop found. Item: " + elementName + " is already in the currentPath (" + currentPath + ")."));
                        continue;
                    }
                    newPath += elementName;
                } else {
                    newPath += "unknownElement";
                }
                FOXTreeNode foxChild = cloneATreeNode(child, schemaName, newPath);
                foxChild.setRow(schemaName);
                node.addChild(foxChild);
            }
        }
    }
    return node;
}
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) ATreeNode(org.talend.datatools.xml.utils.ATreeNode) Element(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element)

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