Search in sources :

Example 1 with ISash

use of org.talend.designer.gefabstractmap.figures.sash.ISash in project tdi-studio-se by Talend.

the class MapperDropTargetListener method handleDragOver.

@Override
public void handleDragOver() {
    getCurrentEvent().detail = DND.DROP_NONE;
    getCurrentEvent().feedback = DND.FEEDBACK_NONE;
    updateTargetRequest();
    updateTargetEditPart();
    DropTargetEvent event = getCurrentEvent();
    Object object = TemplateTransfer.getInstance().getObject();
    if (object == null) {
        event.detail = DND.DROP_NONE;
        return;
    }
    // dnd the sash
    if (object instanceof ISash) {
        handleSashDrag(event, (ISash) object);
        return;
    }
    // dnd the tree node
    if (!(object instanceof TransferedObject)) {
        event.detail = DND.DROP_NONE;
        return;
    }
    showTargetFeedback();
}
Also used : ISash(org.talend.designer.gefabstractmap.figures.sash.ISash) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent)

Example 2 with ISash

use of org.talend.designer.gefabstractmap.figures.sash.ISash 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 3 with ISash

use of org.talend.designer.gefabstractmap.figures.sash.ISash in project tdi-studio-se by Talend.

the class XmlDropTargetListener method handleDragOver.

@Override
public void handleDragOver() {
    getCurrentEvent().detail = DND.DROP_NONE;
    getCurrentEvent().feedback = DND.FEEDBACK_NONE;
    updateTargetRequest();
    updateTargetEditPart();
    DropTargetEvent event = getCurrentEvent();
    Object object = TemplateTransfer.getInstance().getObject();
    if (object == null) {
        event.detail = DND.DROP_NONE;
        return;
    }
    // dnd the sash
    if (object instanceof ISash) {
        handleSashDrag(event, (ISash) object);
        return;
    }
    // dnd the tree node
    if (!(object instanceof TransferedObject)) {
        event.detail = DND.DROP_NONE;
        return;
    }
    DropContextAnalyzer analyzer = new DropContextAnalyzer((TransferedObject) object, (AbstractGraphicalEditPart) getTargetEditPart(), getDropLocation());
    if (analyzer.isDropValid()) {
        event.detail = analyzer.getDetail();
        NewNodeCreationFactory factory = new NewNodeCreationFactory(analyzer.getDropType(), null);
        getCreateRequest().setFactory(factory);
    }
    showTargetFeedback();
}
Also used : ISash(org.talend.designer.gefabstractmap.figures.sash.ISash) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject)

Aggregations

ISash (org.talend.designer.gefabstractmap.figures.sash.ISash)3 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)2 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 IFigure (org.eclipse.draw2d.IFigure)1 Point (org.eclipse.draw2d.geometry.Point)1 EditPart (org.eclipse.gef.EditPart)1 RootEditPart (org.eclipse.gef.RootEditPart)1 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)1 TransferdType (org.talend.designer.gefabstractmap.dnd.TransferdType)1 MapperTablePart (org.talend.designer.gefabstractmap.part.MapperTablePart)1 TableEntityPart (org.talend.designer.gefabstractmap.part.TableEntityPart)1 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)1 OutputTreeNodeEditPart (org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)1 TreeNodeEditPart (org.talend.designer.xmlmap.parts.TreeNodeEditPart)1 VarNodeEditPart (org.talend.designer.xmlmap.parts.VarNodeEditPart)1