Search in sources :

Example 46 with OutputTreeNode

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

the class MapperManager method getSelectedOutputTreeSchemaModel.

public ExtendedTableModel<TreeSchemaTableEntry> getSelectedOutputTreeSchemaModel(OutputXmlTree outputXmlTree) {
    if (outputXmlTree == null && !getExternalData().getOutputTrees().isEmpty()) {
        outputXmlTree = getExternalData().getOutputTrees().get(0);
    }
    List<TreeSchemaTableEntry> treeSchemaEntrys = new ArrayList<TreeSchemaTableEntry>();
    ExtendedTableModel<TreeSchemaTableEntry> tableModel = new ExtendedTableModel<TreeSchemaTableEntry>("Tree Schema", treeSchemaEntrys);
    if (outputXmlTree != null) {
        tableModel.setName(outputXmlTree.getName());
        EList<OutputTreeNode> nodes = outputXmlTree.getNodes();
        for (TreeNode node : nodes) {
            if (XmlMapUtil.DOCUMENT.equals(node.getType())) {
                addTreeSchemaEnties(tableModel, node.getChildren());
            }
        }
    }
    return tableModel;
}
Also used : OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) ArrayList(java.util.ArrayList) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) ExtendedTableModel(org.talend.commons.ui.swt.extended.table.ExtendedTableModel) TreeSchemaTableEntry(org.talend.designer.xmlmap.ui.tabs.table.TreeSchemaTableEntry)

Example 47 with OutputTreeNode

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

the class XmlMapNodeDirectEditManager method createCellEditorOn.

@Override
protected CellEditor createCellEditorOn(Composite composite) {
    Composite parent = (Composite) source.getViewer().getControl();
    CellEditor cellEditor = null;
    Figure figure = null;
    if (this.locator instanceof XmlMapNodeCellEditorLocator) {
        XmlMapNodeCellEditorLocator lo = (XmlMapNodeCellEditorLocator) locator;
        figure = lo.getFigure();
    }
    if (figure instanceof IComboCell) {
        try {
            // tree setting can be edit or not
            if (source instanceof InputXmlTreeEditPart) {
                InputXmlTree inputTree = (InputXmlTree) ((InputXmlTreeEditPart) source).getModel();
                if (DirectEditType.JOIN_MODEL.equals(((IComboCell) figure).getDirectEditType())) {
                    if (!XmlMapUtil.hasAtLeastOneHashKey(inputTree)) {
                        return null;
                    }
                }
                if (DirectEditType.PERSISTENT_MODEL.equals(((IComboCell) figure).getDirectEditType())) {
                    if (LOOKUP_MODE.CACHE_OR_RELOAD.toString().equals(inputTree.getLookupMode())) {
                        return null;
                    }
                }
            }
            if (source instanceof OutputXmlTreeEditPart) {
                OutputXmlTree outputTree = (OutputXmlTree) ((OutputXmlTreeEditPart) source).getModel();
                if (DirectEditType.ALL_IN_ONE.equals(((IComboCell) figure).getDirectEditType())) {
                    if (!XmlMapUtil.hasDocument(outputTree)) {
                        return null;
                    }
                    boolean hasAggregate = false;
                    for (int i = 0; i < outputTree.getNodes().size(); i++) {
                        OutputTreeNode outputTreeNode = outputTree.getNodes().get(i);
                        hasAggregate = hasAggreage(outputTreeNode);
                        if (hasAggregate) {
                            break;
                        }
                    }
                    if (hasAggregate) {
                        return null;
                    }
                } else if (DirectEditType.ENABLE_EMPTY_ELEMENT.equals(((IComboCell) figure).getDirectEditType())) {
                    if (!XmlMapUtil.hasDocument(outputTree)) {
                        return null;
                    }
                }
            }
            cellEditor = new XmlComboCellEditor();
            cellEditor.create(composite);
            ((XmlComboCellEditor) cellEditor).setItems(getComboItemsByType(((IComboCell) figure).getDirectEditType()));
            cellAndType.put(cellEditor, ((IComboCell) figure).getDirectEditType());
        } catch (Exception e) {
            return null;
        }
    } else if (figure instanceof ITextCell) {
        // this one is created for direct doc child name , no use anymore...
        cellEditor = new TextCellEditor(composite);
        cellAndType.put(cellEditor, ((ITextCell) figure).getDirectEditType());
        // for the search
        XmlMapNodeCellEditorLocator lo = (XmlMapNodeCellEditorLocator) locator;
        if (lo.getFigure() != null && lo.getFigure() instanceof VarNodeTextLabel) {
            figure = (VarNodeTextLabel) lo.getFigure();
            if (figure.getParent() != null && figure.getParent() instanceof XmlMapSearchZoneToolBar) {
                XmlMapSearchZoneToolBar searchZone = (XmlMapSearchZoneToolBar) figure.getParent();
                if (searchZone.getSearchMaps().size() > 0) {
                    searchZone.getSearchZoneMapper().hightlightAll(searchZone.getSearchMaps(), false);
                    searchZone.getSearchZoneMapper().setHightlightAll(false);
                    searchZone.getSearchMaps().clear();
                    searchZone.hightLightAll.setSelected(false);
                }
            }
        }
    } else if (figure instanceof IExpressionBuilderCell && model instanceof AbstractNode) {
        IService expressionBuilderDialogService = GlobalServiceRegister.getDefault().getService(IExpressionBuilderDialogService.class);
        CellEditorDialogBehavior behavior = new CellEditorDialogBehavior();
        cellEditor = new ExpressionCellEditor(composite, behavior, source, DirectEditType.EXPRESSION);
        ((ExpressionCellEditor) cellEditor).setOwnerId(((AbstractNode) model).getExpression());
        IExpressionBuilderDialogController dialog = ((IExpressionBuilderDialogService) expressionBuilderDialogService).getExpressionBuilderInstance(parent, (ExpressionCellEditor) cellEditor, null);
        cellAndType.put(cellEditor, DirectEditType.EXPRESSION);
        behavior.setCellEditorDialog(dialog);
    } else if (figure instanceof ITextAreaCell) {
        TextAreaBehavior behavior = new TextAreaBehavior();
        cellEditor = new ExpressionCellEditor(composite, behavior, source, DirectEditType.EXPRESSION_FILTER);
        cellAndType.put(cellEditor, DirectEditType.EXPRESSION_FILTER);
    } else if (figure instanceof IExpressionBuilderCell && model instanceof InputXmlTree) {
        IService expressionBuilderDialogService = GlobalServiceRegister.getDefault().getService(IExpressionBuilderDialogService.class);
        CellEditorDialogBehavior behavior = new CellEditorDialogBehavior();
        cellEditor = new ExpressionCellEditor(composite, behavior, source, DirectEditType.EXPRESSION);
        ((ExpressionCellEditor) cellEditor).setOwnerId(((InputXmlTree) model).getLookupMode());
        IExpressionBuilderDialogController dialog = ((IExpressionBuilderDialogService) expressionBuilderDialogService).getExpressionBuilderInstance(parent, (ExpressionCellEditor) cellEditor, null);
        cellAndType.put(cellEditor, DirectEditType.EXPRESSION);
        behavior.setCellEditorDialog(dialog);
    }
    // }
    return cellEditor;
}
Also used : IExpressionBuilderDialogService(org.talend.core.runtime.services.IExpressionBuilderDialogService) AbstractNode(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode) CellEditor(org.eclipse.jface.viewers.CellEditor) ExtendedTextCellEditor(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) IExpressionBuilderDialogController(org.talend.commons.ui.runtime.expressionbuilder.IExpressionBuilderDialogController) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) XmlMapSearchZoneToolBar(org.talend.designer.xmlmap.figures.treetools.zone.XmlMapSearchZoneToolBar) ITextAreaCell(org.talend.designer.gefabstractmap.figures.cells.ITextAreaCell) XmlMapNodeCellEditorLocator(org.talend.designer.gefabstractmap.part.directedit.XmlMapNodeCellEditorLocator) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) ITextCell(org.talend.designer.gefabstractmap.figures.cells.ITextCell) IService(org.talend.core.IService) Composite(org.eclipse.swt.widgets.Composite) IExpressionBuilderCell(org.talend.designer.gefabstractmap.figures.cells.IExpressionBuilderCell) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) Figure(org.eclipse.draw2d.Figure) VarNodeTextLabel(org.talend.designer.gefabstractmap.figures.VarNodeTextLabel) CellEditorDialogBehavior(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.CellEditorDialogBehavior) InputXmlTreeEditPart(org.talend.designer.xmlmap.parts.InputXmlTreeEditPart) ExtendedTextCellEditor(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) IComboCell(org.talend.designer.gefabstractmap.figures.cells.IComboCell)

Example 48 with OutputTreeNode

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

the class MapperUI method prepareClosing.

public void prepareClosing(int response) {
    List<IMetadataTable> newMetadatas = new ArrayList<IMetadataTable>();
    EList<OutputXmlTree> outputTrees = null;
    if (response == SWT.OK || response == SWT.APPLICATION_MODAL) {
        // fix for bug TDI-18185
        mapperManager.fireCurrentDirectEditApply();
        // if press ok or apply , use copyOfMapData to check the metadata list
        outputTrees = copyOfMapData.getOutputTrees();
    } else {
        // if press cancel , use the original mapData
        outputTrees = ((XmlMapData) mapperComponent.getExternalEmfData()).getOutputTrees();
    }
    List<IMetadataTable> copyOfMetadata = new ArrayList<IMetadataTable>(mapperComponent.getMetadataList());
    for (OutputXmlTree outputTree : outputTrees) {
        IMetadataTable found = null;
        for (IMetadataTable table : mapperComponent.getMetadataList()) {
            if (outputTree.getName().equals(table.getTableName())) {
                found = table;
            }
        }
        if (found != null) {
            newMetadatas.add(found);
        } else {
            // create a new metadata if needed
            MetadataTable metadataTable = new MetadataTable();
            metadataTable.setTableName(outputTree.getName());
            mapperComponent.getProcess().addUniqueConnectionName(outputTree.getName());
            List<IMetadataColumn> listColumns = new ArrayList<IMetadataColumn>();
            for (OutputTreeNode treeNode : outputTree.getNodes()) {
                MetadataColumn column = new MetadataColumn();
                column.setLabel(treeNode.getName());
                column.setKey(treeNode.isKey());
                column.setTalendType(treeNode.getType());
                column.setNullable(treeNode.isNullable());
                column.setPattern(treeNode.getPattern());
                listColumns.add(column);
            }
            metadataTable.setListColumns(listColumns);
            newMetadatas.add(metadataTable);
        }
    }
    mapperComponent.setMetadataList(newMetadatas);
    copyOfMetadata.removeAll(newMetadatas);
    List<IODataComponent> outputs = mapperComponent.getIODataComponents().getOuputs();
    List<String> connectionNames = new ArrayList<String>();
    for (IODataComponent output : outputs) {
        connectionNames.add(output.getUniqueName());
    }
    for (IMetadataTable leftTree : copyOfMetadata) {
        if (!connectionNames.contains(leftTree.getTableName())) {
            mapperComponent.getProcess().removeUniqueConnectionName(leftTree.getTableName());
        }
    }
}
Also used : ArrayList(java.util.ArrayList) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) IODataComponent(org.talend.core.model.components.IODataComponent)

Example 49 with OutputTreeNode

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

the class DragAndDropEditPolicy method showTargetFeedback.

@Override
public void showTargetFeedback(Request request) {
    if (request instanceof CreateNodeConnectionRequest) {
        CreateNodeConnectionRequest rq = (CreateNodeConnectionRequest) request;
        AbstractGraphicalEditPart targetEditPart = (AbstractGraphicalEditPart) rq.getTargetEditPart();
        // show feedback when insert new column
        if (rq.getNewObjectType() != null && targetEditPart != null) {
            Object model = targetEditPart.getModel();
            switch(rq.getNewObjectType()) {
                case DROP_INSERT_OUTPUT:
                case DROP_INSERT_VAR:
                    if (model instanceof OutputTreeNode || model instanceof VarNode) {
                        IFigure targetFigure = targetEditPart.getFigure();
                        if (targetFigure != null) {
                            if (indicator == null) {
                                indicator = new InsertionIndicator();
                            }
                            Rectangle copy = targetFigure.getBounds().getCopy();
                            Rectangle bounds = new Rectangle();
                            bounds.x = copy.x - 5;
                            bounds.y = copy.y - 5;
                            bounds.width = copy.width + 10;
                            bounds.height = 10;
                            indicator.setBounds(bounds);
                            getFeedbackLayer().add(indicator);
                        }
                    } else {
                        if (indicator != null && getFeedbackLayer() != null && indicator.getParent() == getFeedbackLayer()) {
                            getFeedbackLayer().remove(indicator);
                        }
                    }
                    break;
            }
        }
    }
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) CreateNodeConnectionRequest(org.talend.designer.xmlmap.dnd.CreateNodeConnectionRequest) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) Rectangle(org.eclipse.draw2d.geometry.Rectangle) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) IFigure(org.eclipse.draw2d.IFigure)

Example 50 with OutputTreeNode

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

the class SetLoopAction method findUpGroupNode.

private void findUpGroupNode(List<TreeNode> newLoopUpGroups, OutputTreeNode node) {
    if (node.eContainer() instanceof OutputTreeNode) {
        OutputTreeNode parent = (OutputTreeNode) node.eContainer();
        if (parent.isGroup()) {
            newLoopUpGroups.add(parent);
        }
        findUpGroupNode(newLoopUpGroups, parent);
    }
}
Also used : OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)

Aggregations

OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)57 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)42 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)27 ArrayList (java.util.ArrayList)16 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)16 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)15 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)15 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)11 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)11 TreeNodeEditPart (org.talend.designer.xmlmap.parts.TreeNodeEditPart)10 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)9 List (java.util.List)8 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)8 LookupConnection (org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)8 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)8 InputLoopNodesTable (org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable)7 OutputTreeNodeEditPart (org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)7 VarNodeEditPart (org.talend.designer.xmlmap.parts.VarNodeEditPart)6 FilterConnection (org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection)5 InputXmlTreeEditPart (org.talend.designer.xmlmap.parts.InputXmlTreeEditPart)5