Revision 899c5dee
Added by Patrick Plitzner about 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/FeatureTreeDropAdapter.java | ||
---|---|---|
20 | 20 |
import org.eclipse.jface.viewers.ViewerDropAdapter; |
21 | 21 |
import org.eclipse.swt.dnd.TransferData; |
22 | 22 |
|
23 |
import eu.etaxonomy.cdm.model.common.IHasTermType; |
|
23 | 24 |
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary; |
24 | 25 |
import eu.etaxonomy.cdm.model.common.TermType; |
25 | 26 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
... | ... | |
107 | 108 |
} |
108 | 109 |
} |
109 | 110 |
for (Object droppedObject : droppedObjects) { |
111 |
//check term type compatibility |
|
112 |
String title = "Term types do not match"; |
|
113 |
String message = "The term type of the dropped term does not match the target term type."; |
|
114 |
TermType targetType = target.getTermType(); |
|
115 |
if(droppedObject instanceof IHasTermType){ |
|
116 |
TermType droppedType = ((IHasTermType)droppedObject).getTermType(); |
|
117 |
if(!droppedType.equals(targetType)){ |
|
118 |
MessagingUtils.warningDialog(title, this, message); |
|
119 |
continue; |
|
120 |
} |
|
121 |
} |
|
110 | 122 |
if(droppedObject instanceof FeatureNode){ |
111 | 123 |
FeatureNode droppedNode = (FeatureNode) droppedObject; |
112 | 124 |
int currentPosition = target.getIndex(droppedNode); |
... | ... | |
125 | 137 |
} |
126 | 138 |
else if(droppedObject instanceof TermDto){ |
127 | 139 |
TermDto termDto = (TermDto) droppedObject; |
128 |
if(termDto.getTermType().equals(TermType.Feature)){ |
|
140 |
// check if a feature or sub type is dropped |
|
141 |
if(termDto.getTermType().equals(TermType.Feature) || termDto.getTermType().isKindOf(TermType.Feature)){ |
|
142 |
// check if target feature tree has the same type as the dropped term |
|
143 |
if(!termDto.getTermType().equals(targetType)){ |
|
144 |
MessagingUtils.warningDialog(title, this, message); |
|
145 |
continue; |
|
146 |
} |
|
129 | 147 |
AddFeatureOperation operation = new AddFeatureOperation( |
130 | 148 |
termDto.getUuid(), |
131 | 149 |
target, position, editor, editor); |
Also available in: Unified diff
ref #8146 Check term type compatibility for drag and drop