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();
}
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;
}
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();
}
Aggregations