Revision e4f5a8e2
Added by Patrick Plitzner over 5 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/handler/CreateDefaultTaxonDescriptionHandler.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.handler; |
10 | 10 |
|
11 |
import javax.inject.Named; |
|
12 |
|
|
13 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
14 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
|
15 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
16 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
17 |
|
|
18 |
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService; |
|
11 | 19 |
import eu.etaxonomy.cdm.model.common.MarkerType; |
20 |
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet; |
|
21 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
|
22 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto; |
|
23 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrixPart; |
|
24 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
12 | 25 |
|
13 | 26 |
/** |
14 | 27 |
* @author pplitzner |
... | ... | |
24 | 37 |
|
25 | 38 |
@Override |
26 | 39 |
protected MarkerType getMarkerType() { |
27 |
return MarkerType.USE(); |
|
40 |
//FIXME #7957 Use actual marker type when implemented |
|
41 |
return MarkerType.TO_BE_CHECKED(); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
46 |
MHandledMenuItem menuItem){ |
|
47 |
boolean canExecute = super.canExecute(activePart, menuItem); |
|
48 |
if(canExecute){ |
|
49 |
CharacterMatrixPart matrixPart = (CharacterMatrixPart) activePart.getObject(); |
|
50 |
DescriptiveDataSet descriptiveDataSet = matrixPart.getDescriptiveDataSet(); |
|
51 |
IStructuredSelection selection = ((CharacterMatrixPart)activePart.getObject()).getSelection(); |
|
52 |
TaxonNodeDto taxonNodeDto = (TaxonNodeDto) selection.getFirstElement(); |
|
53 |
|
|
54 |
TaxonDescription defaultTaxonDescription = CdmStore.getService(IDescriptiveDataSetService.class) |
|
55 |
.findTaxonDescriptionByMarkerType(descriptiveDataSet.getUuid(), taxonNodeDto.getUuid(), getMarkerType()); |
|
56 |
canExecute = defaultTaxonDescription==null; |
|
57 |
menuItem.setVisible(canExecute); |
|
58 |
} |
|
59 |
|
|
60 |
return canExecute; |
|
28 | 61 |
} |
29 | 62 |
} |
Also available in: Unified diff
ref #7589 Only allow one single default taxon description per taxon