Search in sources :

Example 1 with TreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.

the class EntryContentProposal method getDescription.

@Override
public String getDescription() {
    StringBuilder sb = new StringBuilder();
    //$NON-NLS-1$
    String separator = " - ";
    if (entry instanceof TreeNode) {
        TreeNode inputEntry = (TreeNode) entry;
        IMetadataColumn metadataColumn = null;
        if (inputEntry.eContainer() instanceof InputXmlTree) {
            InputXmlTree tree = (InputXmlTree) inputEntry.eContainer();
            List<IODataComponent> inputs = mapperManager.getMapperComponent().getIODataComponents().getInputs();
            IMetadataTable table = null;
            for (int i = 0; i < inputs.size(); i++) {
                IODataComponent ioDataComponent = inputs.get(i);
                if (tree.getName() != null && tree.getName().equals(ioDataComponent.getConnection().getName())) {
                    table = ioDataComponent.getTable();
                    break;
                }
            }
            if (table != null && table.getListColumns() != null) {
                for (IMetadataColumn column : table.getListColumns()) {
                    if (inputEntry.getName().equals(column.getLabel())) {
                        metadataColumn = column;
                    }
                }
            }
        }
        //$NON-NLS-1$ //$NON-NLS-2$
        sb.append(Messages.getString("EntryContentProposal.metadataColumn")).append(" '").append(inputEntry.getName()).append(//$NON-NLS-1$
        "' ");
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        sb.append(Messages.getString("EntryContentProposal.properties"));
        sb.append(CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.column")).append(inputEntry.getName());
        sb.append(CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.key")).append(inputEntry.isKey());
        sb.append(CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.type")).append(format(inputEntry.getType()));
        if (metadataColumn != null) {
            sb.append(CARRIAGE_RETURN);
            //$NON-NLS-1$
            sb.append(separator).append(Messages.getString("EntryContentProposal.length"));
            if (metadataColumn.getLength() != null && metadataColumn.getLength() > 0) {
                sb.append(format(metadataColumn.getLength()));
            }
            sb.append(CARRIAGE_RETURN);
            //$NON-NLS-1$
            sb.append(separator).append(Messages.getString("EntryContentProposal.precision"));
            if (metadataColumn.getPrecision() != null && metadataColumn.getPrecision() > 0) {
                sb.append(format(metadataColumn.getPrecision()));
            }
            sb.append(CARRIAGE_RETURN);
            sb.append(separator).append(Messages.getString("EntryContentProposal.default")).append(//$NON-NLS-1$
            format(metadataColumn.getDefault()));
            sb.append(CARRIAGE_RETURN);
            sb.append(separator).append(Messages.getString("EntryContentProposal.comment")).append(//$NON-NLS-1$
            format(metadataColumn.getComment()));
        }
        sb.append(CARRIAGE_RETURN);
        if (inputEntry.eContainer() instanceof TreeNode) {
            //$NON-NLS-1$
            sb.append(separator).append(Messages.getString("EntryContentProposal.xPath")).append(inputEntry.getXpath());
            sb.append(CARRIAGE_RETURN);
        }
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
        sb.append(CARRIAGE_RETURN);
        sb.append(format(entry.getExpression()));
        sb.append(CARRIAGE_RETURN);
    } else if (entry instanceof VarNode) {
        //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
        sb.append(Messages.getString("EntryContentProposal.variable")).append(" '").append(entry.getName()).append("' :");
        sb.append(CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
        sb.append(CARRIAGE_RETURN);
        sb.append(format(entry.getExpression()));
    }
    return sb.toString();
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IODataComponent(org.talend.core.model.components.IODataComponent)

Example 2 with TreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.

the class XmlMapFilterConnectionPart method calculateConnOffset.

protected int calculateConnOffset() {
    FilterConnection model = (FilterConnection) getModel();
    if (model.getSource() == null) {
        return 0;
    }
    TreeNode sourceTreeNode = (TreeNode) model.getSource();
    AbstractInOutTree inputTreeNodeRoot = XmlMapUtil.getAbstractInOutTree(sourceTreeNode);
    List<IConnection> outConns = new ArrayList<IConnection>();
    if (inputTreeNodeRoot instanceof InputXmlTree) {
        outConns.addAll(XmlMapUtil.getInputTreeFilterConnections((InputXmlTree) inputTreeNodeRoot));
    }
    int indexOf = outConns.indexOf(model);
    if (indexOf != -1) {
        return -(indexOf + 1) * XmlMapUtil.DEFAULT_OFFSET_FILTER;
    }
    return 0;
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) FilterConnection(org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) ArrayList(java.util.ArrayList) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) IConnection(org.talend.designer.xmlmap.model.emf.xmlmap.IConnection)

Example 3 with TreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.

the class TreeNodeEditPart method setModel.

@Override
public void setModel(Object model) {
    super.setModel(model);
    entityManger = new TreeNodeEntityManager((TreeNode) model, this);
}
Also used : TreeNodeEntityManager(org.talend.designer.xmlmap.figures.treeNode.TreeNodeEntityManager) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)

Example 4 with TreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.

the class TreeNodeEditPart method performRequest.

@Override
public void performRequest(Request req) {
    if (RequestConstants.REQ_DIRECT_EDIT.equals(req.getType())) {
        Figure figure = null;
        DirectEditRequest drequest = (DirectEditRequest) req;
        Point figureLocation = drequest.getLocation();
        if (getFigure() instanceof TableTreeEntityFigure) {
            XmlmapTreeNodeFigure treeNodeFigure = (XmlmapTreeNodeFigure) getFigure();
            ArrayList collection = new ArrayList();
            collection.add(treeNodeFigure.getExpressionFigure());
            collection.add(treeNodeFigure.getBranchContent());
            figure = (Figure) treeNodeFigure.findFigureAt(figureLocation.x, figureLocation.y, new FigureSearch(collection));
        }
        if (figure instanceof IWidgetCell) {
            directEditManager = new XmlMapNodeDirectEditManager(this, new XmlMapNodeCellEditorLocator(figure, this));
        }
        if (directEditManager != null) {
            TreeNode outputTreeNode = (TreeNode) getModel();
            if (figure instanceof ExpressionFigure) {
                if (XmlMapUtil.isExpressionEditable(outputTreeNode)) {
                    Point location = drequest.getLocation();
                    if (figure.containsPoint(location)) {
                        directEditManager.show();
                        ((XmlMapGraphicViewer) getViewer()).getMapperManager().setCurrentDirectEditManager(directEditManager);
                    }
                }
            } else if (!(((TreeNode) getModel()).eContainer() instanceof AbstractInOutTree)) {
            // disable for RC2
            // directEditManager.show();
            // ((XmlMapGraphicViewer)
            // getViewer()).getMapperManager().setCurrentDirectEditManager(directEditManager);
            }
        }
    }
    super.performRequest(req);
}
Also used : XmlMapNodeDirectEditManager(org.talend.designer.xmlmap.parts.directedit.XmlMapNodeDirectEditManager) TableTreeEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure) ArrayList(java.util.ArrayList) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) Point(org.eclipse.draw2d.geometry.Point) XmlmapTreeNodeFigure(org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure) IFigure(org.eclipse.draw2d.IFigure) ExpressionFigure(org.talend.designer.gefabstractmap.figures.ExpressionFigure) XmlmapTreeNodeFigure(org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure) TableTreeEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure) Figure(org.eclipse.draw2d.Figure) XmlMapNodeCellEditorLocator(org.talend.designer.gefabstractmap.part.directedit.XmlMapNodeCellEditorLocator) ExpressionFigure(org.talend.designer.gefabstractmap.figures.ExpressionFigure) DirectEditRequest(org.eclipse.gef.requests.DirectEditRequest) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) IWidgetCell(org.talend.designer.gefabstractmap.figures.cells.IWidgetCell)

Example 5 with TreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.

the class TreeNodeEditPart method getExpressionIndex.

protected int getExpressionIndex(TreeNode treeNode, TreeNode treeRoot, int index, Map<TreeNode, Integer> nodeAndIndex) {
    for (int i = 0; i < treeRoot.getChildren().size(); i++) {
        index++;
        TreeNode treeNode2 = treeRoot.getChildren().get(i);
        nodeAndIndex.put(treeNode2, new Integer(index));
        if (treeNode == treeNode2) {
            return index;
        } else if (!treeNode2.getChildren().isEmpty()) {
            index = getExpressionIndex(treeNode, treeNode2, index, nodeAndIndex);
            if (nodeAndIndex.get(treeNode) != null) {
                return index;
            }
        }
    }
    return index;
}
Also used : OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)119 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)88 ArrayList (java.util.ArrayList)39 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)34 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)26 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)25 TreeNodeEditPart (org.talend.designer.xmlmap.parts.TreeNodeEditPart)22 List (java.util.List)21 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)19 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)17 EList (org.eclipse.emf.common.util.EList)15 LookupConnection (org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)14 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)13 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)12 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)12 FilterConnection (org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection)11 FOXTreeNode (org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode)10 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)9 VarNodeEditPart (org.talend.designer.xmlmap.parts.VarNodeEditPart)9 OutputTreeNodeEditPart (org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)8