Revision 257a82c2
Added by Katja Luther almost 3 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/termtree/e4/TermTreeDtoDropAdapter.java | ||
---|---|---|
11 | 11 |
import java.util.Arrays; |
12 | 12 |
import java.util.Collection; |
13 | 13 |
import java.util.Collections; |
14 |
import java.util.List; |
|
14 | 15 |
import java.util.UUID; |
16 |
import java.util.stream.Collectors; |
|
15 | 17 |
|
16 | 18 |
import org.eclipse.e4.ui.di.UISynchronize; |
19 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
20 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
|
17 | 21 |
import org.eclipse.jface.util.LocalSelectionTransfer; |
18 | 22 |
import org.eclipse.jface.viewers.IStructuredSelection; |
19 | 23 |
import org.eclipse.jface.viewers.TreeViewer; |
... | ... | |
32 | 36 |
import eu.etaxonomy.cdm.persistence.dto.TermTreeDto; |
33 | 37 |
import eu.etaxonomy.taxeditor.editor.definedterm.TermTransfer; |
34 | 38 |
import eu.etaxonomy.taxeditor.editor.definedterm.e4.DefinedTermDropAdapterE4; |
39 |
import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput; |
|
35 | 40 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
36 | 41 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
42 |
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin; |
|
37 | 43 |
import eu.etaxonomy.taxeditor.termtree.TermNodeDtoTransfer; |
38 | 44 |
import eu.etaxonomy.taxeditor.termtree.e4.operation.AddFeatureOperation; |
39 | 45 |
import eu.etaxonomy.taxeditor.termtree.e4.operation.AddOntologyTermOperation; |
... | ... | |
125 | 131 |
return false; |
126 | 132 |
} |
127 | 133 |
TermNodeDto droppedNode = editor.getNodeDtoForUuid(((TermNodeDto) droppedObject).getUuid()); |
128 |
TermNodeDto oldParent = editor.getNodeDtoForUuid(droppedNode.getParentUuid()); |
|
134 |
ITermTreeEditor sourceEditor = editor; |
|
135 |
if (droppedNode == null){ |
|
136 |
//the node does not come from the same editor, need to find the source editor |
|
137 |
TermType type = ((TermNodeDto) droppedObject).getType(); |
|
138 |
TermEditorInput termEditorInput = new TermEditorInput(type); |
|
139 |
|
|
140 |
EPartService partService = TaxeditorStorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class); |
|
141 |
List<MPart> alreadyOpenedEditors = partService.getParts().stream() |
|
142 |
.filter(part->part.getObject()!=null && part.getObject() instanceof ITermTreeEditor) |
|
143 |
.filter(part->((ITermTreeEditor)part.getObject()).getTermType().equals(type)) |
|
144 |
.collect(Collectors.toList()); |
|
145 |
|
|
146 |
if(!alreadyOpenedEditors.isEmpty()){ |
|
147 |
//there should never be more than one already opened editor |
|
148 |
//so we just open the first |
|
149 |
sourceEditor = (ITermTreeEditor)alreadyOpenedEditors.iterator().next().getObject(); |
|
150 |
droppedNode = sourceEditor.getNodeDtoForUuid(((TermNodeDto) droppedObject).getUuid()); |
|
151 |
} |
|
152 |
} |
|
153 |
if (droppedNode == null){ |
|
154 |
return false; |
|
155 |
} |
|
156 |
|
|
157 |
TermNodeDto oldParent = sourceEditor.getNodeDtoForUuid(droppedNode.getParentUuid()); |
|
129 | 158 |
boolean isCircle = checkCircle(droppedNode, target); |
130 | 159 |
if (isCircle || droppedNode.equals(target)){ |
131 | 160 |
return false; |
Also available in: Unified diff
ref #9337: allow d&d from character voc -> tree and add tree image