Search in sources :

Example 11 with TableEntityPart

use of org.talend.designer.gefabstractmap.part.TableEntityPart in project tdi-studio-se by Talend.

the class MapperSelectEditPartTracker method canAppend.

private boolean canAppend() {
    if (getSourceEditPart() instanceof TableEntityPart) {
        EditPart lastPart = lastSelectedShiftPart;
        List selectedEditParts = getCurrentViewer().getSelectedEditParts();
        if (lastPart == null && !selectedEditParts.isEmpty()) {
            lastPart = (EditPart) selectedEditParts.get(selectedEditParts.size() - 1);
        }
        if (lastPart == null) {
            return true;
        } else if (lastPart instanceof TableEntityPart) {
            MapperTablePart lastContaier = MapperUtils.getMapperTablePart((TableEntityPart) lastPart);
            MapperTablePart toAppendContaier = MapperUtils.getMapperTablePart((TableEntityPart) getSourceEditPart());
            if (lastContaier == toAppendContaier) {
                return true;
            }
        }
    }
    lastSelectedShiftPart = null;
    return false;
}
Also used : TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) EditPart(org.eclipse.gef.EditPart) List(java.util.List) ArrayList(java.util.ArrayList) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart)

Example 12 with TableEntityPart

use of org.talend.designer.gefabstractmap.part.TableEntityPart in project tdi-studio-se by Talend.

the class MapperUtils method getFlatChildrenPartList.

public static List<TableEntityPart> getFlatChildrenPartList(MapperTablePart treePart) {
    List<TableEntityPart> partList = new ArrayList<TableEntityPart>();
    List children = treePart.getChildren();
    for (int i = 0; i < children.size(); i++) {
        partList.add((TableEntityPart) children.get(i));
        partList.addAll(getFlatChildrenPartList((TableEntityPart) children.get(i)));
    }
    return partList;
}
Also used : TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 13 with TableEntityPart

use of org.talend.designer.gefabstractmap.part.TableEntityPart in project tdi-studio-se by Talend.

the class MapperUtils method getFlatChildrenPartList.

private static List<TableEntityPart> getFlatChildrenPartList(TableEntityPart treeNode) {
    List<TableEntityPart> list = new ArrayList<TableEntityPart>();
    List children = treeNode.getChildren();
    for (int i = 0; i < children.size(); i++) {
        if (children.get(i) instanceof TableEntityPart) {
            TableEntityPart child = (TableEntityPart) children.get(i);
            list.add(child);
            if (!child.getChildren().isEmpty()) {
                list.addAll(getFlatChildrenPartList(child));
            }
        }
    }
    return list;
}
Also used : TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 14 with TableEntityPart

use of org.talend.designer.gefabstractmap.part.TableEntityPart in project tdi-studio-se by Talend.

the class XmlDragSourceListener method getTemplate.

/**
     * 
     * DOC talend Comment method "getTemplate".
     * 
     * @param event
     * @return the validate drag able node list
     */
@Override
protected Object getTemplate(DragSourceEvent event) {
    final RootEditPart rootEditPart = getViewer().getRootEditPart();
    if (rootEditPart instanceof AbstractGraphicalEditPart) {
        AbstractGraphicalEditPart graphicPart = (AbstractGraphicalEditPart) rootEditPart;
        final IFigure figure = graphicPart.getFigure();
        final IFigure findFigureAt = figure.findFigureAt(new Point(event.x, event.y));
        if (findFigureAt instanceof ISash) {
            return findFigureAt;
        }
    }
    List<EditPart> filtedSelection = new ArrayList<EditPart>();
    for (Object part : getViewer().getSelectedEditParts()) {
        if (part instanceof TreeNodeEditPart || part instanceof VarNodeEditPart) {
            filtedSelection.add((EditPart) part);
        }
    }
    if (filtedSelection == null || filtedSelection.isEmpty()) {
        return null;
    }
    List toTransfer = new ArrayList();
    TransferdType type = null;
    List<TableEntityPart> partList = new ArrayList<TableEntityPart>();
    EditPart lastSelection = filtedSelection.get(filtedSelection.size() - 1);
    if (lastSelection instanceof TreeNodeEditPart && !(lastSelection instanceof OutputTreeNodeEditPart)) {
        type = TransferdType.INPUT;
    } else if (lastSelection instanceof VarNodeEditPart) {
        type = TransferdType.VAR;
    }
    if (type != null) {
        if (filtedSelection.size() > 1) {
            partList.addAll(lastSelection.getParent().getChildren());
            Map<EditPart, Integer> partAndIndex = new HashMap<EditPart, Integer>();
            if (type == TransferdType.INPUT) {
                for (EditPart treePart : filtedSelection) {
                    if (!XmlMapUtil.isDragable((TreeNode) treePart.getModel())) {
                        return null;
                    }
                }
                MapperTablePart abstractInOutTreePart = MapperUtils.getMapperTablePart((TableEntityPart) lastSelection);
                if (abstractInOutTreePart != null) {
                    partList = MapperUtils.getFlatChildrenPartList(abstractInOutTreePart);
                }
            } else {
                partList.addAll(lastSelection.getParent().getChildren());
            }
            for (EditPart selected : filtedSelection) {
                int indexOf = partList.indexOf(selected);
                if (indexOf != -1) {
                    partAndIndex.put(selected, indexOf);
                    int index = 0;
                    for (int i = 0; i < toTransfer.size(); i++) {
                        if (indexOf > partAndIndex.get(toTransfer.get(i))) {
                            index = i + 1;
                        }
                    }
                    toTransfer.add(index, selected);
                }
            }
        } else {
            if (lastSelection.getModel() instanceof TreeNode && !XmlMapUtil.isDragable((TreeNode) lastSelection.getModel())) {
                return null;
            }
            toTransfer.add(lastSelection);
        }
        return new TransferedObject(toTransfer, type);
    }
    return null;
}
Also used : VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) HashMap(java.util.HashMap) ISash(org.talend.designer.gefabstractmap.figures.sash.ISash) ArrayList(java.util.ArrayList) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) RootEditPart(org.eclipse.gef.RootEditPart) EditPart(org.eclipse.gef.EditPart) Point(org.eclipse.draw2d.geometry.Point) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) Point(org.eclipse.draw2d.geometry.Point) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) ArrayList(java.util.ArrayList) List(java.util.List) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) RootEditPart(org.eclipse.gef.RootEditPart) IFigure(org.eclipse.draw2d.IFigure) TransferdType(org.talend.designer.gefabstractmap.dnd.TransferdType)

Example 15 with TableEntityPart

use of org.talend.designer.gefabstractmap.part.TableEntityPart in project tdi-studio-se by Talend.

the class FiguresManager method selectionChanged.

@Override
public void selectionChanged(SelectionChangedEvent event) {
    mapDataEditPart = (MapperRootEditPart) graphicViewer.getContents();
    if (getRootEditPart() == null) {
        return;
    }
    List selectedEditParts = graphicViewer.getSelectedEditParts();
    if (selectedEditParts.isEmpty()) {
        return;
    }
    boolean outputRemoveEnable = false;
    boolean outputMoveUp = false;
    boolean outputMoveDown = false;
    boolean inputMoveUp = false;
    boolean inputMoveDown = false;
    List<MapperTable> outputTrees = getOutputTables();
    List<MapperTable> inputTrees = getInputTables();
    OutputZoneToolBar outputToolBar = mapDataEditPart.getOutputZoneToolBar();
    InputZoneToolBar inputToolBar = mapDataEditPart.getInputZoneToolBar();
    boolean selectNode = false;
    Object lastSelection = selectedEditParts.get(selectedEditParts.size() - 1);
    if (lastSelection instanceof TableEntityPart) {
        selectNode = true;
        MapperTablePart findTreePart = MapperUtils.getMapperTablePart((TableEntityPart) lastSelection);
        if (findTreePart instanceof InputTablePart) {
            currentSelectedInputTable = (InputTablePart) findTreePart;
        } else if (findTreePart instanceof OutputTablePart) {
            currentSelectedOutputTable = (OutputTablePart) findTreePart;
        }
        // only change connection figures for nodes in the same tree as the lastSelection
        List<TableEntityPart> nodes = new ArrayList<TableEntityPart>();
        for (int i = 0; i < selectedEditParts.size() - 1; i++) {
            Object obj = selectedEditParts.get(i);
            if (obj instanceof TableEntityPart) {
                MapperTablePart findOtherTreePart = MapperUtils.getMapperTablePart((TableEntityPart) obj);
                if (findOtherTreePart == findTreePart) {
                    nodes.add((TableEntityPart) obj);
                }
            }
        }
        nodes.add((TableEntityPart) lastSelection);
        onTreeSelected(nodes, findTreePart);
    // change color for other unselected node in the tree;
    } else if (lastSelection instanceof OutputTablePart) {
        currentSelectedOutputTable = (OutputTablePart) lastSelection;
        onTreeSelected(currentSelectedOutputTable.getChildren(), currentSelectedOutputTable);
    } else if (lastSelection instanceof InputTablePart) {
        currentSelectedInputTable = (InputTablePart) lastSelection;
        onTreeSelected(currentSelectedInputTable.getChildren(), currentSelectedInputTable);
    }
    if (currentSelectedOutputTable != null) {
        MapperTable model = (MapperTable) currentSelectedOutputTable.getModel();
        if (!isErrorRejectTable(model)) {
            outputRemoveEnable = true;
        }
        int index = outputTrees.indexOf(model);
        if (index != -1 && index != 0) {
            if (index != 1 || !isErrorRejectTable(outputTrees.get(0))) {
                outputMoveUp = true;
            }
        }
        if (index != -1 && index != outputTrees.size() - 1) {
            if (!isErrorRejectTable(model)) {
                outputMoveDown = true;
            }
        }
    }
    outputToolBar.setRemoveButtonEnable(outputRemoveEnable);
    outputToolBar.setMoveUpEnable(outputMoveUp);
    outputToolBar.setMoveDownEnable(outputMoveDown);
    if (currentSelectedInputTable != null) {
        MapperTable tree = (MapperTable) currentSelectedInputTable.getModel();
        if (!isLookup(tree)) {
            inputMoveUp = false;
            inputMoveDown = false;
        } else {
            int indexOf = inputTrees.indexOf(tree);
            if (indexOf != -1 && indexOf > 1) {
                inputMoveUp = true;
            }
            if (indexOf > 0 && indexOf != inputTrees.size() - 1) {
                inputMoveDown = true;
            }
        }
    }
    inputToolBar.setMoveDownEnable(inputMoveDown);
    inputToolBar.setMoveUpEnable(inputMoveUp);
}
Also used : OutputTablePart(org.talend.designer.gefabstractmap.part.OutputTablePart) OutputZoneToolBar(org.talend.designer.gefabstractmap.figures.treetools.zone.OutputZoneToolBar) TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) ArrayList(java.util.ArrayList) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) InputTablePart(org.talend.designer.gefabstractmap.part.InputTablePart) InputZoneToolBar(org.talend.designer.gefabstractmap.figures.treetools.zone.InputZoneToolBar) MapperTable(org.talend.designer.gefabstractmap.model.abstractmap.MapperTable) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

TableEntityPart (org.talend.designer.gefabstractmap.part.TableEntityPart)15 List (java.util.List)8 ArrayList (java.util.ArrayList)7 MapperTablePart (org.talend.designer.gefabstractmap.part.MapperTablePart)7 EditPart (org.eclipse.gef.EditPart)5 IFigure (org.eclipse.draw2d.IFigure)3 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)3 TableEntityFigure (org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure)3 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)3 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)3 OutputTreeNodeEditPart (org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)3 HashMap (java.util.HashMap)2 Figure (org.eclipse.draw2d.Figure)2 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)2 ExpandCollapseFigure (org.talend.designer.gefabstractmap.figures.table.entity.ExpandCollapseFigure)2 TableTreeEntityFigure (org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure)2 VarEntityFigure (org.talend.designer.gefabstractmap.figures.var.VarEntityFigure)2 InputTablePart (org.talend.designer.gefabstractmap.part.InputTablePart)2 OutputTablePart (org.talend.designer.gefabstractmap.part.OutputTablePart)2 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)2