Search in sources :

Example 56 with FOXTreeNode

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

the class SetForJSONLoopAction method selectionChanged.

@Override
public void selectionChanged(IStructuredSelection selection) {
    FOXTreeNode node = (FOXTreeNode) this.getStructuredSelection().getFirstElement();
    if (node == null) {
        this.setEnabled(false);
        return;
    }
    // fix for TDI-18802
    this.setEnabled(TreeUtil.canSetAsLoop(node));
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode)

Example 57 with FOXTreeNode

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

the class SetJSONGroupAction 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) || node.hasLink())) {
        this.setEnabled(TreeUtil.checkTreeGoupNode(node));
        return;
    }
    if (node instanceof NameSpaceNode) {
        this.setEnabled(false);
        return;
    }
    this.setEnabled(TreeUtil.checkTreeGoupNode(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)

Example 58 with FOXTreeNode

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

the class CreateJSONElementAction method createChildNode.

private boolean createChildNode(FOXTreeNode node) {
    if (node.getColumn() != null) {
        if (!MessageDialog.openConfirm(jsonViewer.getControl().getShell(), "Warning", "Do you want to disconnect the existing linker and then add an sub element for the selected element " + node.getLabel() + " \"?")) {
            return false;
        }
        node.setColumn(null);
    }
    String label = "";
    while (!JSONUtil.validateLabelForJSON(label)) {
        InputDialog dialog = new InputDialog(null, "Input element's label", "Input the new element's valid label", "", null);
        int status = dialog.open();
        if (status == InputDialog.OK) {
            label = dialog.getValue().trim();
        }
        if (status == InputDialog.CANCEL) {
            return false;
        }
    }
    FOXTreeNode child = new Element(label);
    // child.setRow(node.getRow());
    node.addChild(child);
    // fix for TDI-18802
    if (node.getParent() == null && node.isLoop()) {
        node.setLoop(false);
    }
    this.jsonViewer.refresh();
    this.jsonViewer.expandAll();
    return true;
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) InputDialog(org.eclipse.jface.dialogs.InputDialog) Element(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element)

Example 59 with FOXTreeNode

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

the class CreateJSONNameSpaceAction method createChildNode.

private void createChildNode(FOXTreeNode node) {
    String label = null;
    String defaultValue = null;
    while (!JSONUtil.validateLabelForNameSpace(label) || !JSONUtil.validateLabelForFixedValue(defaultValue)) {
        NameSpaceDialog nsDialog = new NameSpaceDialog(null);
        int status = nsDialog.open();
        if (status == nsDialog.OK) {
            defaultValue = nsDialog.getNSValue();
            if (defaultValue != null) {
                defaultValue = defaultValue.trim();
            }
            label = nsDialog.getPrefix().trim();
        }
        if (status == nsDialog.CANCEL) {
            return;
        }
    }
    FOXTreeNode child = new NameSpaceNode(label);
    child.setDefaultValue(defaultValue);
    // add by wzhang. set the row name
    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) NameSpaceDialog(org.talend.metadata.managment.ui.wizard.metadata.xml.dialog.NameSpaceDialog) NameSpaceNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode)

Example 60 with FOXTreeNode

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

the class JSONFileOutputStep2Form method updateConnection.

public void updateConnection() {
    ConnectionHelper.getTables(getConnection());
    EList root = getConnection().getRoot();
    EList loop = getConnection().getLoop();
    EList group = getConnection().getGroup();
    root.clear();
    loop.clear();
    group.clear();
    List<FOXTreeNode> node = (List<FOXTreeNode>) JSONViewer.getInput();
    FOXTreeNode foxTreeNode = node.get(0);
    if (foxTreeNode != null) {
        initNodeOrder(foxTreeNode);
        if (!foxTreeNode.isLoop()) {
            tableLoader((Element) foxTreeNode, "", root, foxTreeNode.getDefaultValue());
        }
        Element loopNode = (Element) TreeUtil.getLoopNode(foxTreeNode);
        if (loopNode != null) {
            String path = TreeUtil.getPath(loopNode);
            tableLoader(loopNode, path.substring(0, path.lastIndexOf("/")), loop, loopNode.getDefaultValue());
        }
        Element groupNode = (Element) TreeUtil.getGroupNode(foxTreeNode);
        if (groupNode != null) {
            String path = TreeUtil.getPath(groupNode);
            tableLoader(groupNode, path.substring(0, path.lastIndexOf("/")), group, groupNode.getDefaultValue());
        }
    }
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) EList(org.eclipse.emf.common.util.EList) Element(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList)

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