Project

General

Profile

Revision 7b1abbc3

ID7b1abbc3dfc350ea2c3e21bfc5b3989d1b51963a
Parent fe4a6e83
Child 65b3a18d

Added by Patrick Plitzner over 1 year ago

Fix term type check for feature drop adapter

View differences:

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.description.Feature;
24
import eu.etaxonomy.cdm.model.term.FeatureNode;
25
import eu.etaxonomy.cdm.model.term.FeatureTree;
23 26
import eu.etaxonomy.cdm.model.term.IHasTermType;
24 27
import eu.etaxonomy.cdm.model.term.OrderedTermVocabulary;
25 28
import eu.etaxonomy.cdm.model.term.TermType;
26 29
import eu.etaxonomy.cdm.model.term.TermVocabulary;
27
import eu.etaxonomy.cdm.model.description.Feature;
28
import eu.etaxonomy.cdm.model.term.FeatureNode;
29
import eu.etaxonomy.cdm.model.term.FeatureTree;
30 30
import eu.etaxonomy.cdm.persistence.dto.TermDto;
31 31
import eu.etaxonomy.taxeditor.editor.definedterm.TermTransfer;
32 32
import eu.etaxonomy.taxeditor.editor.definedterm.e4.DefinedTermDropAdapterE4;
......
110 110
		for (Object droppedObject : droppedObjects) {
111 111
		    //check term type compatibility
112 112
		    TermType targetType = target.getTermType();
113
		    TermType droppedType = null;
113 114
		    if(droppedObject instanceof IHasTermType){
114
		        TermType droppedType = ((IHasTermType)droppedObject).getTermType();
115
		        if(!droppedType.equals(targetType)){
116
                    MessagingUtils.warningDialog(DefinedTermDropAdapterE4.TERM_TYPE_ERROR_TITLE, this, DefinedTermDropAdapterE4.TERM_TYPE_ERROR_MESSAGE);
117
		            continue;
118
		        }
115
		        droppedType = ((IHasTermType)droppedObject).getTermType();
116
		    }
117
		    else if(droppedObject instanceof TermDto){
118
		        droppedType = ((TermDto)droppedObject).getTermType();
119
		    }
120
		    if(droppedType!=null && !droppedType.equals(targetType)){
121
		        MessagingUtils.warningDialog(DefinedTermDropAdapterE4.TERM_TYPE_ERROR_TITLE, this, DefinedTermDropAdapterE4.TERM_TYPE_ERROR_MESSAGE);
122
		        continue;
119 123
		    }
120 124
		    if(droppedObject instanceof FeatureNode){
121 125
		        FeatureNode droppedNode = (FeatureNode) droppedObject;
......
134 138
		        AbstractUtility.executeOperation(operation, sync);
135 139
		    }
136 140
		    else if(droppedObject instanceof TermDto){
137
		            TermDto termDto = (TermDto) droppedObject;
138
		            // check if a feature or sub type is dropped
139
		            if(termDto.getTermType().equals(TermType.Feature) || termDto.getTermType().isKindOf(TermType.Feature)){
140
		                // check if target feature tree has the same type as the dropped term
141
		                if(!termDto.getTermType().equals(targetType)){
142
		                    MessagingUtils.warningDialog(DefinedTermDropAdapterE4.TERM_TYPE_ERROR_TITLE, this, DefinedTermDropAdapterE4.TERM_TYPE_ERROR_MESSAGE);
143
		                    continue;
144
		                }
145
		                AddFeatureOperation operation = new AddFeatureOperation(
146
		                        termDto.getUuid(),
147
		                        target, position, editor, editor);
148
		                AbstractUtility.executeOperation(operation, sync);
149
		            }
150
		            else{
151
		                MessagingUtils.warningDialog(DefinedTermDropAdapterE4.MOVE_FAILED, this, Messages.FeatureTreeDropAdapter_ONLY_MOVE_FEATURES);
152
		            }
141
		        TermDto termDto = (TermDto) droppedObject;
142
		        // check if target feature tree has the same type as the dropped term
143
		        if(!termDto.getTermType().equals(targetType)){
144
		            MessagingUtils.warningDialog(DefinedTermDropAdapterE4.TERM_TYPE_ERROR_TITLE, this, DefinedTermDropAdapterE4.TERM_TYPE_ERROR_MESSAGE);
145
		            continue;
146
		        }
147
		        AddFeatureOperation operation = new AddFeatureOperation(
148
		                termDto.getUuid(),
149
		                target, position, editor, editor);
150
		        AbstractUtility.executeOperation(operation, sync);
153 151
		    }
154 152
		    else if(droppedObject instanceof OntologyTermWrapper){
155 153
		        OntologyTermWrapper wrapper = (OntologyTermWrapper)droppedObject;

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)