Search in sources :

Example 71 with FOXTreeNode

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

the class ImportTreeFromRepository method isMappedChoiceSubsOutput.

private boolean isMappedChoiceSubsOutput(FOXTreeNode node, String pXpath) {
    List<FOXTreeNode> children = node.getChildren();
    List<FOXTreeNode> subsChoice = new ArrayList<FOXTreeNode>();
    XMLFileNode found = null;
    for (FOXTreeNode child : children) {
        if (child.isSubstitution() || child.isChoice()) {
            subsChoice.add(child);
        } else {
            String childXpath = "";
            if (child instanceof Element) {
                childXpath = XmlMapUtil.getXPath(pXpath, child.getLabel(), NodeType.ELEMENT);
            } else if (child instanceof Attribute) {
                childXpath = XmlMapUtil.getXPath(pXpath, child.getLabel(), NodeType.ATTRIBUT);
            } else if (child instanceof NameSpaceNode) {
                childXpath = XmlMapUtil.getXPath(pXpath, child.getLabel(), NodeType.NAME_SPACE);
            }
            found = findXmlFileNode(childXpath, root);
            if (found == null) {
                found = findXmlFileNode(childXpath, group);
            }
            if (found == null) {
                found = findXmlFileNode(childXpath, loop);
            }
            if (found != null) {
                break;
            }
        }
    }
    if (found != null) {
        return true;
    }
    if (!subsChoice.isEmpty()) {
        for (FOXTreeNode foxNode : subsChoice) {
            boolean isChildMapped = isMappedChoiceSubsOutput(foxNode, pXpath);
            if (isChildMapped) {
                return true;
            }
        }
    }
    return found != null;
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) XMLFileNode(org.talend.core.model.metadata.builder.connection.XMLFileNode) 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)

Example 72 with FOXTreeNode

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

the class FOXUI method initLinker.

/**
     * DOC ke Comment method "initLinker".
     * 
     * @param node
     * @param tableItems
     */
private void initLinker(TreeItem node, TableItem[] tableItems) {
    FOXTreeNode treeNode = (FOXTreeNode) node.getData();
    IMetadataColumn column = treeNode.getColumn();
    if (column != null) {
        if (this.getFoxManager().getFoxComponent().istFileOutputMSXML() && treeNode.getChildren().size() <= 0) {
            for (TableItem tableItem : tableItems) {
                IMetadataColumn mColumn = (IMetadataColumn) tableItem.getData();
                if (mColumn.getLabel().equals(column.getLabel())) {
                    linker.addLoopLink(tableItem, tableItem.getData(), xmlViewer.getTree(), treeNode);
                    linker.getBackgroundRefresher().refreshBackground();
                    break;
                }
            }
        }
        for (TableItem tableItem : tableItems) {
            IMetadataColumn mColumn = (IMetadataColumn) tableItem.getData();
            if (mColumn.getLabel().equals(column.getLabel())) {
                linker.addLoopLink(tableItem, tableItem.getData(), xmlViewer.getTree(), treeNode);
                linker.getBackgroundRefresher().refreshBackground();
                break;
            }
        }
    }
    TreeItem[] children = node.getItems();
    for (TreeItem element : children) {
        initLinker(element, tableItems);
    }
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) TreeItem(org.eclipse.swt.widgets.TreeItem) TableItem(org.eclipse.swt.widgets.TableItem) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 73 with FOXTreeNode

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

the class FOXUI method addXMLViewer.

/**
     * create xml viewer.
     * 
     * @param mainComposite
     * @param form
     * @param width
     * @param height
     */
private void addXMLViewer(final Composite mainComposite, final int width, final int height) {
    // Group Schema Viewer
    //$NON-NLS-1$
    Group group = Form.createGroup(mainComposite, 1, Messages.getString("FOXUI.0"), height);
    // group.setBackgroundMode(SWT.INHERIT_FORCE);
    xmlViewer = new TreeViewer(group, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.VIRTUAL);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    xmlViewer.getControl().setLayoutData(gridData);
    xmlViewer.setUseHashlookup(true);
    Tree tree = xmlViewer.getTree();
    // see bug 7087
    if (canModify || isRepository) {
        tree.setEnabled(false);
    }
    tree.setLinesVisible(true);
    tree.setBackground(tree.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
    //$NON-NLS-1$
    column1.setText(Messages.getString("FOXUI.1"));
    column1.setWidth(170);
    // Related Column
    TreeColumn column2 = new TreeColumn(tree, SWT.CENTER);
    //$NON-NLS-1$ 
    column2.setText(Messages.getString("FOXUI.2"));
    column2.setWidth(100);
    TreeColumn column3 = new TreeColumn(tree, SWT.CENTER);
    //$NON-NLS-1$
    column3.setText(Messages.getString("FOXUI.3"));
    column3.setWidth(90);
    TreeColumn column4 = new TreeColumn(tree, SWT.CENTER);
    //$NON-NLS-1$
    column4.setText(Messages.getString("FOXUI.4"));
    column4.setWidth(90);
    tree.setHeaderVisible(true);
    // tree.setBackgroundMode(SWT.INHERIT_NONE);
    FOXTargetTreeViewerProvider provider = new FOXTargetTreeViewerProvider();
    xmlViewer.setLabelProvider(provider);
    xmlViewer.setCellModifier(new ICellModifier() {

        @Override
        public boolean canModify(Object element, String property) {
            FOXTreeNode node = (FOXTreeNode) element;
            if (property.equals("C1")) {
                //$NON-NLS-1$
                if (node.getLabel() != null && node.getLabel().length() > 0) {
                    return true;
                }
            }
            if (property.equals("C4")) {
                //$NON-NLS-1$
                if (node.getDefaultValue() != null && node.getDefaultValue().length() > 0) {
                    return true;
                }
            }
            return false;
        }

        @Override
        public Object getValue(Object element, String property) {
            FOXTreeNode node = (FOXTreeNode) element;
            if (property.equals("C1")) {
                //$NON-NLS-1$
                return node.getLabel();
            }
            if (property.equals("C4")) {
                //$NON-NLS-1$
                return node.getDefaultValue();
            }
            return null;
        }

        @Override
        public void modify(Object element, String property, Object value) {
            TreeItem treeItem = (TreeItem) element;
            FOXTreeNode node = (FOXTreeNode) treeItem.getData();
            if (property.equals("C1")) {
                //$NON-NLS-1$
                node.setLabel((String) value);
            }
            if (property.equals("C4")) {
                //$NON-NLS-1$
                node.setDefaultValue((String) value);
            }
            xmlViewer.refresh(node);
        }
    });
    //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    xmlViewer.setColumnProperties(new String[] { "C1", "C2", "C3", "C4" });
    CellEditor editor = new TextCellEditor(xmlViewer.getTree());
    //$NON-NLS-1$
    editor.addListener(new DialogErrorXMLLabelCellEditor(editor, "C1"));
    // add by wzhang for bug 8572. set Default value column to be edit.
    CellEditor editorDefault = new TextCellEditor(xmlViewer.getTree());
    //$NON-NLS-1$
    editorDefault.addListener(new DialogErrorXMLLabelCellEditor(editorDefault, "C4"));
    xmlViewer.setCellEditors(new CellEditor[] { editor, null, null, editorDefault });
    xmlViewer.setContentProvider(provider);
    xmlViewer.setInput(this.foxManager.getTreeData());
    createAction();
    //$NON-NLS-1$
    MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager manager) {
            FOXUI.this.fillContextMenu(manager);
        }
    });
    Menu menu = menuMgr.createContextMenu(xmlViewer.getControl());
    xmlViewer.getControl().setMenu(menu);
    xmlViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
        // TODO Auto-generated method stub
        }
    });
    refreshXMLViewer(null);
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) Group(org.eclipse.swt.widgets.Group) FOXTargetTreeViewerProvider(org.talend.designer.fileoutputxml.ui.edit.FOXTargetTreeViewerProvider) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IMenuListener(org.eclipse.jface.action.IMenuListener) TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData) ICellModifier(org.eclipse.jface.viewers.ICellModifier) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Tree(org.eclipse.swt.widgets.Tree) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu)

Example 74 with FOXTreeNode

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

the class FOXUI method updateStatus.

public void updateStatus() {
    List<FOXTreeNode> allRootTreeData = foxManager.getTreeData();
    int num = 0, rootNum = 0;
    int groupNum = 0;
    List<FOXTreeNode> onLoopNodes = new ArrayList<FOXTreeNode>();
    for (FOXTreeNode node : allRootTreeData) {
        FOXTreeNode rootFOXTreeNode = foxManager.getRootFOXTreeNode(node);
        if (rootFOXTreeNode != null) {
            if (existedLoopNode(rootFOXTreeNode)) {
                num++;
            } else {
                onLoopNodes.add(rootFOXTreeNode);
            }
            rootNum++;
            if (existedGroupNode(rootFOXTreeNode)) {
                groupNum++;
            } else {
            // onLoopNodes.add(rootFOXTreeNode);
            }
        }
    }
    if (this.getValue()) {
        if (num != rootNum || groupNum != rootNum) {
            //$NON-NLS-1$
            String message = Messages.getString("FOXUI.NoLoopOfAdvance");
            if (rootNum > 1) {
                //$NON-NLS-1$
                message = "";
                for (FOXTreeNode node : onLoopNodes) {
                    //$NON-NLS-1$
                    message += node.getRow() + ",";
                }
                message = message.substring(0, message.length() - 1);
                //$NON-NLS-1$
                message += Messages.getString("FOXUI.needLoop");
            }
            header.updateStatus(message);
        } else {
            header.clearStatus();
        }
    } else {
        if (num != rootNum) {
            //$NON-NLS-1$
            String message = Messages.getString("FOXUI.NoLoop");
            if (rootNum > 1) {
                //$NON-NLS-1$
                message = "";
                for (FOXTreeNode node : onLoopNodes) {
                    //$NON-NLS-1$
                    message += node.getRow() + ",";
                }
                message = message.substring(0, message.length() - 1);
                //$NON-NLS-1$
                message += Messages.getString("FOXUI.needLoop");
            }
            header.updateStatus(message);
        } else {
            header.clearStatus();
        }
    }
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) ArrayList(java.util.ArrayList)

Example 75 with FOXTreeNode

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

the class FOXTargetTreeViewerProvider method getChildren.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
     */
public Object[] getChildren(Object parentElement) {
    FOXTreeNode treeNode = (FOXTreeNode) parentElement;
    List<FOXTreeNode> children = treeNode.getChildren();
    return children.toArray();
}
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