1
|
/**
|
2
|
* Copyright (C) 2018 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.handler;
|
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;
|
19
|
import eu.etaxonomy.cdm.model.description.DescriptionType;
|
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;
|
25
|
|
26
|
/**
|
27
|
* @author pplitzner
|
28
|
* @since Sep 7, 2018
|
29
|
*
|
30
|
*/
|
31
|
public class CreateDefaultTaxonDescriptionHandler extends CreateTaxonDescriptionHandler{
|
32
|
|
33
|
@Override
|
34
|
protected DescriptionType getDescriptionType() {
|
35
|
return DescriptionType.DEFAULT_VALUES_FOR_AGGREGATION;
|
36
|
}
|
37
|
|
38
|
@Override
|
39
|
public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
|
40
|
MHandledMenuItem menuItem){
|
41
|
boolean canExecute = super.canExecute(activePart, menuItem);
|
42
|
if(canExecute){
|
43
|
CharacterMatrixPart matrixPart = (CharacterMatrixPart) activePart.getObject();
|
44
|
DescriptiveDataSet descriptiveDataSet = matrixPart.getDescriptiveDataSet();
|
45
|
IStructuredSelection selection = ((CharacterMatrixPart)activePart.getObject()).getSelection();
|
46
|
TaxonNodeDto taxonNodeDto = (TaxonNodeDto) selection.getFirstElement();
|
47
|
|
48
|
TaxonDescription defaultTaxonDescription = CdmStore.getService(IDescriptiveDataSetService.class)
|
49
|
.findTaxonDescriptionByDescriptionType(descriptiveDataSet.getUuid(), taxonNodeDto.getUuid(), getDescriptionType());
|
50
|
canExecute = defaultTaxonDescription==null;
|
51
|
menuItem.setVisible(canExecute);
|
52
|
}
|
53
|
|
54
|
return canExecute;
|
55
|
}
|
56
|
}
|