16 |
16 |
import org.eclipse.core.runtime.IAdaptable;
|
17 |
17 |
import org.eclipse.core.runtime.IProgressMonitor;
|
18 |
18 |
import org.eclipse.core.runtime.IStatus;
|
|
19 |
import org.eclipse.jface.viewers.ViewerDropAdapter;
|
19 |
20 |
|
20 |
21 |
import eu.etaxonomy.cdm.api.service.ITermService;
|
|
22 |
import eu.etaxonomy.cdm.api.service.TermServiceImpl.TermMovePosition;
|
21 |
23 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
|
22 |
24 |
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
23 |
25 |
import eu.etaxonomy.cdm.persistence.dto.AbstractTermDto;
|
... | ... | |
57 |
59 |
{
|
58 |
60 |
UUID parentUuid = targetTermOrVocabulary.getUuid();
|
59 |
61 |
boolean isKindOf = term.getKindOfUuid()!=null && term.getKindOfUuid().equals(parentUuid);
|
60 |
|
CdmStore.getService(ITermService.class).moveTerm(term.getUuid(), parentUuid, isKindOf);
|
61 |
|
//FIXME: implement moving for ordered terms
|
|
62 |
TermMovePosition termMovePosition = TermMovePosition.ON;
|
|
63 |
if(currentLocation == ViewerDropAdapter.LOCATION_BEFORE) {
|
|
64 |
termMovePosition = TermMovePosition.BEFORE;
|
|
65 |
}
|
|
66 |
else if(currentLocation == ViewerDropAdapter.LOCATION_AFTER) {
|
|
67 |
termMovePosition = TermMovePosition.AFTER;
|
|
68 |
}
|
|
69 |
CdmStore.getService(ITermService.class).moveTerm(term.getUuid(), parentUuid, isKindOf, termMovePosition);
|
62 |
70 |
});
|
63 |
|
// // need to make the moved DefinedTerm part of another DefinedTerm or Vocabulary (target)
|
64 |
|
// // and remove it from old associations
|
65 |
|
//
|
66 |
|
//
|
67 |
|
// for (DefinedTermBase term : sourceTerms) {
|
68 |
|
// // do nothing when moving it on itself
|
69 |
|
// if(targetTermOrVocabulary.equals(term)){
|
70 |
|
// Status status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), "Term can not be added to itself");
|
71 |
|
// MessagingUtils.informationDialog("", status);
|
72 |
|
// return status;
|
73 |
|
// }
|
74 |
|
//
|
75 |
|
// if (targetTermOrVocabulary instanceof TermVocabulary) {
|
76 |
|
// TermVocabulary termVocabulary = (TermVocabulary)targetTermOrVocabulary;
|
77 |
|
//
|
78 |
|
// // do nothing when term is top level and gets added to the same vocabulary
|
79 |
|
// if(term.getPartOf() == null && termVocabulary.equals(term.getVocabulary())){
|
80 |
|
// Status status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), "Term is already in this vocabulary");
|
81 |
|
// MessagingUtils.informationDialog("", status);
|
82 |
|
// return status;
|
83 |
|
// }
|
84 |
|
//
|
85 |
|
// cleanTerm(term);
|
86 |
|
// termVocabulary.addTerm(term);
|
87 |
|
//
|
88 |
|
// } else if (targetTermOrVocabulary instanceof DefinedTermBase) {
|
89 |
|
// cleanTerm(term);
|
90 |
|
// DefinedTermBase targetDefinedTerm = (DefinedTermBase) targetTermOrVocabulary;
|
91 |
|
//
|
92 |
|
// if(targetDefinedTerm instanceof OrderedTermBase && term instanceof OrderedTermBase) {
|
93 |
|
// OrderedTermBase targetOrderedDefinedTerm = (OrderedTermBase)targetDefinedTerm;
|
94 |
|
// TermVocabulary tVoc = targetOrderedDefinedTerm.getVocabulary();
|
95 |
|
// if(tVoc instanceof OrderedTermVocabulary) {
|
96 |
|
// OrderedTermVocabulary otVoc = (OrderedTermVocabulary)tVoc;
|
97 |
|
// // the link between the location and the add term (below / above)
|
98 |
|
// // method is determined by the compare method in the
|
99 |
|
// // DefinedTermEditor's ViewerSorter (DefinedTermSorter) class
|
100 |
|
// if(currentLocation == ViewerDropAdapter.LOCATION_BEFORE) {
|
101 |
|
// otVoc.addTermAbove((OrderedTermBase)term, (OrderedTermBase)targetTermOrVocabulary);
|
102 |
|
// if (targetOrderedDefinedTerm.getPartOf() != null){
|
103 |
|
// targetOrderedDefinedTerm.getPartOf().addIncludes(term);
|
104 |
|
// }
|
105 |
|
// }
|
106 |
|
//
|
107 |
|
// if(currentLocation == ViewerDropAdapter.LOCATION_AFTER) {
|
108 |
|
// otVoc.addTermBelow((OrderedTermBase)term, (OrderedTermBase)targetTermOrVocabulary);
|
109 |
|
// if (targetOrderedDefinedTerm.getPartOf() != null){
|
110 |
|
// targetOrderedDefinedTerm.getPartOf().addIncludes(term);
|
111 |
|
// }
|
112 |
|
// }
|
113 |
|
// if(currentLocation == ViewerDropAdapter.LOCATION_ON) {
|
114 |
|
// targetOrderedDefinedTerm.addIncludes(term);
|
115 |
|
// targetOrderedDefinedTerm.getVocabulary().addTerm(term);
|
116 |
|
// }
|
117 |
|
// }
|
118 |
|
// } else{
|
119 |
|
// targetDefinedTerm.addIncludes(term);
|
120 |
|
// targetDefinedTerm.getVocabulary().addTerm(term);
|
121 |
|
// }
|
122 |
|
//
|
123 |
|
// }
|
124 |
|
//
|
125 |
|
// }
|
126 |
71 |
return postExecute(targetTermOrVocabulary);
|
127 |
72 |
}
|
128 |
73 |
|
129 |
|
private DefinedTermBase cleanTerm(DefinedTermBase term){
|
130 |
|
|
131 |
|
DefinedTermBase partOf = term.getPartOf();
|
132 |
|
if(partOf != null){
|
133 |
|
partOf.removeIncludes(term);
|
134 |
|
}
|
135 |
|
DefinedTermBase kindOf = term.getKindOf();
|
136 |
|
if(kindOf!=null){
|
137 |
|
kindOf.removeGeneralization(term);
|
138 |
|
}
|
139 |
|
|
140 |
|
|
141 |
|
TermVocabulary vocabulary = term.getVocabulary();
|
142 |
|
if(vocabulary != null){
|
143 |
|
vocabulary.removeTerm(term);
|
144 |
|
}
|
145 |
|
|
146 |
|
return term;
|
147 |
|
}
|
148 |
|
|
149 |
74 |
@Override
|
150 |
75 |
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
151 |
76 |
throws ExecutionException {
|
ref #7887 Implement moving terms for ordered terms