summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/event/dd/acceptCriteria/IsSameSourceAndTarget.java
blob: 73609e592b867e9c0367670a435e4a43aed70183 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
@ITMillApache2LicenseForJavaFiles@
 */
/**
 * 
 */
package com.vaadin.event.dd.acceptCriteria;

import com.vaadin.event.TransferableImpl;
import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.DropTarget;
import com.vaadin.terminal.gwt.client.ui.dd.VSourceIsSameAsTarget;
import com.vaadin.ui.Component;

/**
 * TODO Javadoc
 * 
 * @since 6.3
 * 
 */
@ClientCriterion(VSourceIsSameAsTarget.class)
public class IsSameSourceAndTarget extends ClientSideCriterion {

    public boolean accepts(DragAndDropEvent dragEvent) {
        if (dragEvent.getTransferable() instanceof TransferableImpl) {
            Component sourceComponent = ((TransferableImpl) dragEvent
                    .getTransferable()).getSourceComponent();
            DropTarget target = dragEvent.getDropTargetDetails().getTarget();
            return sourceComponent == target;
        }

        return false;
    }

}