Search in sources :

Example 46 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 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)

Example 47 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 run.

@Override
public void run() {
    FOXTreeNode node = (FOXTreeNode) this.getStructuredSelection().getFirstElement();
    if (createChildNode(node)) {
        form.redrawLinkers();
    }
    form.updateConnection();
    form.updateStatus();
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode)

Example 48 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 run.

@Override
public void run() {
    FOXTreeNode node = (FOXTreeNode) this.getStructuredSelection().getFirstElement();
    if (node != null) {
        createChildNode(node);
    }
    form.updateConnection();
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode)

Example 49 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 initLinker.

private void initLinker(TreeItem node, TableItem[] tableItems) {
    FOXTreeNode treeNode = (FOXTreeNode) node.getData();
    IMetadataColumn column = treeNode.getColumn();
    Properties prop = System.getProperties();
    String os = prop.getProperty("os.name");
    boolean isLastOne = false;
    if (column != null) {
        for (int i = 0; i < tableItems.length; i++) {
            MetadataColumn metadataColumn = (MetadataColumn) tableItems[i].getData();
            if (metadataColumn.getLabel().equals(column.getLabel())) {
                // "isLastOne" directly to false
                if (os.startsWith("Linux")) {
                    isLastOne = true;
                }
                linker.addLoopLink(tableItems[i], tableItems[i].getData(), JSONViewer.getTree(), treeNode, isLastOne);
                break;
            }
        }
    }
    TreeItem[] children = node.getItems();
    for (int i = 0; i < children.length; i++) {
        initLinker(children[i], tableItems);
    }
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) TreeItem(org.eclipse.swt.widgets.TreeItem) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) Properties(java.util.Properties)

Example 50 with FOXTreeNode

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

the class JSONFileOutputStep1Form method updateConnection.

private void updateConnection(String text) {
    if (text == null || "".equals(text)) {
        return;
    }
    List<FOXTreeNode> rootFoxTreeNodes = null;
    if (JSONFileOutputStep1Form.this.tempPath == null) {
        JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(text);
    }
    if (treeNode == null) {
        rootFoxTreeNodes = TreeUtil.getFoxTreeNodes(JSONFileOutputStep1Form.this.tempPath);
    } else {
        rootFoxTreeNodes = getCorrespondingFoxTreeNodes(treeNode, true);
    }
    if (rootFoxTreeNodes.size() == 0) {
        return;
    }
    if (ConnectionHelper.getTables(getConnection()).isEmpty()) {
        MetadataTable table = ConnectionFactory.eINSTANCE.createMetadataTable();
        RecordFile record = (RecordFile) ConnectionHelper.getPackage(getConnection().getName(), getConnection(), RecordFile.class);
        if (record != null) {
            // hywang
            PackageHelper.addMetadataTable(table, record);
        } else {
            RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
            newrecord.setName(connection.getName());
            ConnectionHelper.addPackage(newrecord, connection);
            PackageHelper.addMetadataTable(table, newrecord);
        }
    }
    EList schemaMetadataColumn = ConnectionHelper.getTables(getConnection()).toArray(new MetadataTable[0])[0].getColumns();
    schemaMetadataColumn.clear();
    initMetadataTable(rootFoxTreeNodes, schemaMetadataColumn);
    updateConnectionProperties(rootFoxTreeNodes.get(0));
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) EList(org.eclipse.emf.common.util.EList) RecordFile(orgomg.cwm.resource.record.RecordFile) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable)

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