*/
package eu.etaxonomy.taxeditor.editor.definedterm.e4;
+import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@Override
public boolean postOperation(Object objectAffectedByOperation) {
- if(objectAffectedByOperation instanceof TermVocabularyDto
- || objectAffectedByOperation instanceof TermVocabulary){
- input.initialiseVocabularies();
+ input.initialiseVocabularies();
+
+ Collection<TermDto> termsToSelect = new HashSet<>();
+
+ if(objectAffectedByOperation instanceof Collection){
+ for (Object o : (Collection<?>)objectAffectedByOperation) {
+ if(o instanceof TermVocabularyDto){
+ viewer.refresh(o);
+ }
+ else if(o instanceof TermDto){
+ viewer.refresh(((TermDto) o).getVocabularyDto());
+ viewer.refresh(o);
+ termsToSelect.add((TermDto) o);
+ }
+ }
}
if(objectAffectedByOperation instanceof TermDto){
- viewer.refresh(((TermDto) objectAffectedByOperation).getVocabularyDto());
+ TermDto termDto = (TermDto) objectAffectedByOperation;
+ termsToSelect.add(termDto);
+ viewer.refresh(termDto.getVocabularyDto());
}
else{
viewer.refresh(objectAffectedByOperation);
}
- if(objectAffectedByOperation != null){
- StructuredSelection selection = new StructuredSelection(objectAffectedByOperation);
+ if(!termsToSelect.isEmpty()){
+ StructuredSelection selection = new StructuredSelection(termsToSelect);
viewer.setSelection(selection);
- viewer.expandToLevel(objectAffectedByOperation, 1);
+ for (TermDto termDto : termsToSelect) {
+ viewer.expandToLevel(termDto, 1);
+ }
}
return true;
}