Revision 81783422
Added by Katja Luther about 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptionElementDropAdapter.java | ||
---|---|---|
12 | 12 |
import java.util.ArrayList; |
13 | 13 |
import java.util.Collection; |
14 | 14 |
|
15 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
15 | 16 |
import org.eclipse.jface.viewers.Viewer; |
16 | 17 |
import org.eclipse.swt.dnd.DND; |
17 | 18 |
import org.eclipse.swt.dnd.TransferData; |
18 | 19 |
|
20 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
|
19 | 21 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
20 | 22 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
21 | 23 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
22 | 24 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
25 |
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4; |
|
26 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4; |
|
23 | 27 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.MoveDescriptionElementsOperation; |
24 | 28 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
25 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
|
29 |
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
|
|
26 | 30 |
import eu.etaxonomy.taxeditor.ui.EditViewerDropAdapter; |
27 | 31 |
|
28 | 32 |
/** |
... | ... | |
34 | 38 |
|
35 | 39 |
private static final String OPERATION_NOT_SUPPORTED_YET = Messages.DescriptionElementDropAdapter_NOT_SUPPORTED; |
36 | 40 |
|
41 |
|
|
42 |
|
|
37 | 43 |
/** |
38 | 44 |
* @param viewer |
39 | 45 |
*/ |
... | ... | |
68 | 74 |
if (descriptionElement.getInDescription().equals(target)) { |
69 | 75 |
return false; |
70 | 76 |
} |
77 |
DescriptionBase<?> description = descriptionElement.getInDescription(); |
|
78 |
description.removeElement(descriptionElement); |
|
79 |
target.addElement(descriptionElement); |
|
71 | 80 |
|
81 |
if (description.getElements().isEmpty()){ |
|
82 |
((TaxonDescription)description).getTaxon().removeDescription((TaxonDescription)description, false); |
|
83 |
} |
|
72 | 84 |
descriptionElements.add(descriptionElement); |
73 | 85 |
} |
74 | 86 |
} |
87 |
TaxonNameEditorE4 editor = null; |
|
88 |
Object activePart = EditorUtil.getActivePart(); |
|
89 |
if (activePart instanceof FactualDataPartE4){ |
|
90 |
MPart selectionProvidingPart =(MPart) ((FactualDataPartE4)activePart).getSelectionProvidingPart(); |
|
91 |
Object obj = selectionProvidingPart.getObject(); |
|
92 |
if (obj instanceof TaxonNameEditorE4){ |
|
93 |
editor = (TaxonNameEditorE4) obj; |
|
94 |
} |
|
95 |
} |
|
96 |
AbstractPostTaxonOperation operation = new MoveDescriptionElementsOperation(Messages.DescriptionElementDropAdapter_MOVE_DESC, EditorUtil.getUndoContext(), target, descriptionElements, isCopy, null, sync); |
|
75 | 97 |
|
76 |
AbstractPostOperation operation = new MoveDescriptionElementsOperation(Messages.DescriptionElementDropAdapter_MOVE_DESC, EditorUtil.getUndoContext(), target, descriptionElements, isCopy, null);
|
|
77 |
|
|
78 |
EditorUtil.executeOperation(operation, sync); |
|
98 |
editor.getEditorInput().addOperation(operation);
|
|
99 |
editor.setDirty(); |
|
100 |
// EditorUtil.executeOperation(operation, sync);
|
|
79 | 101 |
return true; |
80 | 102 |
} |
81 | 103 |
MessagingUtils.warningDialog(OPERATION_NOT_SUPPORTED_YET, this, Messages.DescriptionElementDropAdapter_NOT_SUPPORTED_EMPTY_ELEMENT); |
Also available in: Unified diff
some smaller changes for drag & drop of factual data