1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
package eu.etaxonomy.taxeditor.editor.name.dnd;
|
5
|
|
6
|
import org.eclipse.swt.dnd.DND;
|
7
|
import org.eclipse.swt.dnd.DragSourceAdapter;
|
8
|
import org.eclipse.swt.dnd.DragSourceEvent;
|
9
|
import org.eclipse.ui.forms.ManagedForm;
|
10
|
|
11
|
import eu.etaxonomy.cdm.model.common.ICdmBase;
|
12
|
import eu.etaxonomy.taxeditor.editor.CdmDataTransfer;
|
13
|
import eu.etaxonomy.taxeditor.editor.name.container.AbstractGroupedContainer;
|
14
|
|
15
|
/**
|
16
|
* <p>NameEditorDragListener class.</p>
|
17
|
*
|
18
|
* @author n.hoffmann
|
19
|
* @version $Id: $
|
20
|
*/
|
21
|
public class NameEditorDragListener extends DragSourceAdapter {
|
22
|
|
23
|
private AbstractGroupedContainer container;
|
24
|
|
25
|
/**
|
26
|
* <p>Constructor for NameEditorDragListener.</p>
|
27
|
*
|
28
|
* @param container a {@link eu.etaxonomy.taxeditor.editor.name.container.AbstractGroupedContainer} object.
|
29
|
*/
|
30
|
public NameEditorDragListener(AbstractGroupedContainer container){
|
31
|
this.container = container;
|
32
|
}
|
33
|
|
34
|
/** {@inheritDoc} */
|
35
|
public void dragFinished(DragSourceEvent event) {
|
36
|
if(!event.doit)
|
37
|
return;
|
38
|
if(event.detail == DND.DROP_MOVE){
|
39
|
ManagedForm managedForm = container.getGroup().getEditor().getManagedForm();
|
40
|
container.getGroup().remove(container);
|
41
|
managedForm.reflow(true);
|
42
|
}
|
43
|
|
44
|
};
|
45
|
|
46
|
/** {@inheritDoc} */
|
47
|
@Override
|
48
|
public void dragSetData(DragSourceEvent event) {
|
49
|
ICdmBase[] cdmBaseObjects = new ICdmBase[]{(ICdmBase) container.getData()};
|
50
|
if(CdmDataTransfer.getInstance().isSupportedType(event.dataType)){
|
51
|
event.data = cdmBaseObjects;
|
52
|
}
|
53
|
}
|
54
|
|
55
|
/** {@inheritDoc} */
|
56
|
@Override
|
57
|
public void dragStart(DragSourceEvent event) {
|
58
|
event.doit = container.getData() != null;
|
59
|
}
|
60
|
}
|