1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
package eu.etaxonomy.taxeditor.editor.name.e4.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.e4.container.AbstractGroupedContainerE4;
|
14
|
import eu.etaxonomy.taxeditor.editor.name.e4.container.ConceptContainer;
|
15
|
|
16
|
/**
|
17
|
* @author pplitzner
|
18
|
* @date 04.09.2017
|
19
|
*/
|
20
|
public class NameEditorDragListenerE4 extends DragSourceAdapter {
|
21
|
|
22
|
private AbstractGroupedContainerE4<?> container;
|
23
|
|
24
|
public NameEditorDragListenerE4(AbstractGroupedContainerE4 container){
|
25
|
this.container = container;
|
26
|
}
|
27
|
|
28
|
@Override
|
29
|
public void dragFinished(DragSourceEvent event) {
|
30
|
if(!event.doit) {
|
31
|
return;
|
32
|
}
|
33
|
if(event.detail == DND.DROP_MOVE){
|
34
|
ManagedForm managedForm = container.getGroup().getEditor().getManagedForm();
|
35
|
container.getGroup().remove(container);
|
36
|
managedForm.reflow(true);
|
37
|
}
|
38
|
|
39
|
}
|
40
|
|
41
|
@Override
|
42
|
public void dragSetData(DragSourceEvent event) {
|
43
|
ICdmBase[] cdmBaseObjects = new ICdmBase[]{container.getData()};
|
44
|
if(CdmDataTransfer.getInstance().isSupportedType(event.dataType)){
|
45
|
event.data = cdmBaseObjects;
|
46
|
}
|
47
|
}
|
48
|
|
49
|
@Override
|
50
|
public void dragStart(DragSourceEvent event) {
|
51
|
event.doit = (container.getData() != null) && !(container instanceof ConceptContainer);
|
52
|
}
|
53
|
}
|