Revision f2ac0034
Added by Katja Luther almost 4 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/handler/DeleteDescriptionHandler.java | ||
---|---|---|
18 | 18 |
import org.eclipse.e4.ui.services.IServiceConstants; |
19 | 19 |
import org.eclipse.jface.viewers.IStructuredSelection; |
20 | 20 |
|
21 |
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO; |
|
21 | 22 |
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO; |
23 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
|
22 | 24 |
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet; |
23 | 25 |
import eu.etaxonomy.cdm.model.description.SpecimenDescription; |
26 |
import eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper; |
|
24 | 27 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrixPart; |
25 | 28 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
26 | 29 |
|
27 | 30 |
/** |
28 |
* @author pplitzner
|
|
29 |
* @since Sep 7, 2018
|
|
31 |
* @author k.luther
|
|
32 |
* @since May 8, 2020
|
|
30 | 33 |
* |
31 | 34 |
*/ |
32 | 35 |
public class DeleteDescriptionHandler{ |
... | ... | |
38 | 41 |
return; |
39 | 42 |
} |
40 | 43 |
DescriptiveDataSet descriptiveDataSet = matrixPart.getDescriptiveDataSet(); |
41 |
SpecimenRowWrapperDTO wrapper = (SpecimenRowWrapperDTO) matrixPart.getSelection().getFirstElement();
|
|
42 |
SpecimenDescription description = wrapper.getDescription();
|
|
44 |
RowWrapperDTO wrapper = (RowWrapperDTO) matrixPart.getSelection().getFirstElement();
|
|
45 |
DescriptionBase description = wrapper.getDescription();
|
|
43 | 46 |
|
44 | 47 |
boolean ok = matrixPart.getMatrix().getDescriptions().remove(wrapper); |
45 |
matrixPart.getMatrix().putDescriptionToDelete(description.getUuid()); |
|
48 |
matrixPart.getMatrix().addDescriptionToDelete(description.getUuid()); |
|
49 |
if (description instanceof SpecimenDescription){ |
|
50 |
SpecimenNodeWrapper nodeWrapper = new SpecimenNodeWrapper(((SpecimenRowWrapperDTO)wrapper).getSpecimen(), ((SpecimenRowWrapperDTO)wrapper).getType(), wrapper.getTaxonNode()); |
|
51 |
if (matrixPart.getMatrix().getSpecimenCache()!= null){ |
|
52 |
matrixPart.getMatrix().getSpecimenCache().add(nodeWrapper); |
|
53 |
} |
|
54 |
} |
|
46 | 55 |
matrixPart.getMatrix().update(); |
47 | 56 |
if (ok){ |
48 | 57 |
matrixPart.setDirty(); |
... | ... | |
58 | 67 |
IStructuredSelection selection = ((CharacterMatrixPart)activePart.getObject()).getSelection(); |
59 | 68 |
|
60 | 69 |
boolean canExecute = selection.size()==1 |
61 |
&& selection.getFirstElement() instanceof SpecimenRowWrapperDTO;
|
|
70 |
&& selection.getFirstElement() instanceof RowWrapperDTO; |
|
62 | 71 |
menuItem.setVisible(canExecute); |
63 | 72 |
return canExecute; |
64 | 73 |
|
Also available in: Unified diff
ref #8785: move add and delete specimen to menu and operations not saved directly but when editor is saved