Revision edc79e40
Added by Patrick Plitzner almost 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/e4/DefinedTermDropAdapterE4.java | ||
---|---|---|
16 | 16 |
import org.eclipse.e4.ui.di.UISynchronize; |
17 | 17 |
import org.eclipse.jface.util.LocalSelectionTransfer; |
18 | 18 |
import org.eclipse.jface.viewers.IStructuredSelection; |
19 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
20 | 19 |
import org.eclipse.jface.viewers.ViewerDropAdapter; |
21 | 20 |
import org.eclipse.swt.dnd.TransferData; |
22 | 21 |
|
... | ... | |
121 | 120 |
editor, |
122 | 121 |
currentLocation); |
123 | 122 |
AbstractUtility.executeOperation(operation, sync); |
124 |
// select the moved objects |
|
125 |
editor.getViewer().setSelection(new StructuredSelection(sourceTerms)); |
|
126 | 123 |
|
127 | 124 |
return true; |
128 | 125 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/e4/DefinedTermEditorE4.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.editor.definedterm.e4; |
10 | 10 |
|
11 |
import java.util.Collection; |
|
11 | 12 |
import java.util.HashSet; |
12 | 13 |
import java.util.Set; |
13 | 14 |
|
... | ... | |
139 | 140 |
|
140 | 141 |
@Override |
141 | 142 |
public boolean postOperation(Object objectAffectedByOperation) { |
142 |
if(objectAffectedByOperation instanceof TermVocabularyDto |
|
143 |
|| objectAffectedByOperation instanceof TermVocabulary){ |
|
144 |
input.initialiseVocabularies(); |
|
143 |
input.initialiseVocabularies(); |
|
144 |
|
|
145 |
Collection<TermDto> termsToSelect = new HashSet<>(); |
|
146 |
|
|
147 |
if(objectAffectedByOperation instanceof Collection){ |
|
148 |
for (Object o : (Collection<?>)objectAffectedByOperation) { |
|
149 |
if(o instanceof TermVocabularyDto){ |
|
150 |
viewer.refresh(o); |
|
151 |
} |
|
152 |
else if(o instanceof TermDto){ |
|
153 |
viewer.refresh(((TermDto) o).getVocabularyDto()); |
|
154 |
viewer.refresh(o); |
|
155 |
termsToSelect.add((TermDto) o); |
|
156 |
} |
|
157 |
} |
|
145 | 158 |
} |
146 | 159 |
if(objectAffectedByOperation instanceof TermDto){ |
147 |
viewer.refresh(((TermDto) objectAffectedByOperation).getVocabularyDto()); |
|
160 |
TermDto termDto = (TermDto) objectAffectedByOperation; |
|
161 |
termsToSelect.add(termDto); |
|
162 |
viewer.refresh(termDto.getVocabularyDto()); |
|
148 | 163 |
} |
149 | 164 |
else{ |
150 | 165 |
viewer.refresh(objectAffectedByOperation); |
151 | 166 |
} |
152 |
if(objectAffectedByOperation != null){
|
|
153 |
StructuredSelection selection = new StructuredSelection(objectAffectedByOperation);
|
|
167 |
if(!termsToSelect.isEmpty()){
|
|
168 |
StructuredSelection selection = new StructuredSelection(termsToSelect);
|
|
154 | 169 |
viewer.setSelection(selection); |
155 |
viewer.expandToLevel(objectAffectedByOperation, 1); |
|
170 |
for (TermDto termDto : termsToSelect) { |
|
171 |
viewer.expandToLevel(termDto, 1); |
|
172 |
} |
|
156 | 173 |
} |
157 | 174 |
return true; |
158 | 175 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/operation/MoveDefinedTermOperation.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.taxeditor.editor.definedterm.operation; |
10 | 10 |
|
11 | 11 |
import java.util.Collection; |
12 |
import java.util.HashSet; |
|
12 | 13 |
import java.util.UUID; |
13 | 14 |
|
14 | 15 |
import org.eclipse.core.commands.ExecutionException; |
... | ... | |
22 | 23 |
import eu.etaxonomy.cdm.api.service.TermServiceImpl.TermMovePosition; |
23 | 24 |
import eu.etaxonomy.cdm.persistence.dto.AbstractTermDto; |
24 | 25 |
import eu.etaxonomy.cdm.persistence.dto.TermDto; |
26 |
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto; |
|
25 | 27 |
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation; |
26 | 28 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
27 | 29 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
... | ... | |
34 | 36 |
public class MoveDefinedTermOperation extends AbstractPostTaxonOperation { |
35 | 37 |
|
36 | 38 |
private final Collection<TermDto> sourceTerms;// the actual DefinedTermBase(s) we are moving |
39 |
private final Collection<TermVocabularyDto> sourceVocabularies; |
|
37 | 40 |
private final AbstractTermDto targetTermOrVocabulary;// the target VOCABULARY or DefinedTerm we are moving these to |
38 | 41 |
private final int currentLocation; |
39 | 42 |
|
... | ... | |
55 | 58 |
this.targetTermOrVocabulary = target; |
56 | 59 |
this.sourceTerms = sourceTerms; |
57 | 60 |
this.currentLocation = currentLocation; |
61 |
sourceVocabularies = new HashSet<>(); |
|
58 | 62 |
} |
59 | 63 |
|
60 | 64 |
@Override |
61 | 65 |
public IStatus execute(IProgressMonitor monitor, IAdaptable info) |
62 | 66 |
throws ExecutionException { |
63 |
sourceTerms.forEach(term->
|
|
64 |
{
|
|
67 |
for(TermDto term:sourceTerms){
|
|
68 |
sourceVocabularies.add(term.getVocabularyDto());
|
|
65 | 69 |
UUID parentUuid = targetTermOrVocabulary.getUuid(); |
66 | 70 |
TermMovePosition termMovePosition = TermMovePosition.ON; |
67 | 71 |
if(currentLocation == ViewerDropAdapter.LOCATION_BEFORE) { |
... | ... | |
71 | 75 |
termMovePosition = TermMovePosition.AFTER; |
72 | 76 |
} |
73 | 77 |
CdmStore.getService(ITermService.class).moveTerm(term, parentUuid, termMovePosition); |
74 |
}); |
|
75 |
return postExecute(targetTermOrVocabulary); |
|
78 |
} |
|
79 |
Collection<AbstractTermDto> affectedObjects = new HashSet<>(sourceTerms); |
|
80 |
affectedObjects.addAll(sourceVocabularies); |
|
81 |
affectedObjects.add(targetTermOrVocabulary); |
|
82 |
return postExecute(affectedObjects); |
|
76 | 83 |
} |
77 | 84 |
|
78 | 85 |
@Override |
Also available in: Unified diff
ref #8263 Fix refresh of source vocabulary after moving terms