Project

General

Profile

Download (2.27 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2016 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.handler.defaultHandler.e4;
10

    
11
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
12
import org.eclipse.e4.ui.workbench.modeling.EPartService;
13
import org.eclipse.jface.viewers.IStructuredSelection;
14
import org.eclipse.jface.wizard.WizardDialog;
15
import org.eclipse.swt.widgets.Shell;
16

    
17
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
18
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
19
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
20
import eu.etaxonomy.taxeditor.event.EventUtility;
21
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
22
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
23
import eu.etaxonomy.taxeditor.store.CdmStore;
24
import eu.etaxonomy.taxeditor.ui.section.classification.EditTaxonNodeWizard;
25

    
26
/**
27
 * @author k.luther
28
 * @date 22.03.2016
29
 *
30
 */
31
public class DefaultOpenTaxonNodeWizardHandlerE4 extends DefaultOpenHandlerBaseE4<TaxonNodeDto> {
32

    
33
//    @Override
34
//    protected TaxonNode getEntity(UUID uuid) {
35
//        return CdmStore.getService(ITaxonNodeService.class).load(uuid);
36
//    }
37

    
38
    @Override
39
    protected void open(TaxonNodeDto entity, Shell shell, EPartService partService) {
40
        EditTaxonNodeWizard taxonNodeWizard = ContextInjectionFactory.make(EditTaxonNodeWizard.class, context);
41
        taxonNodeWizard.init(null, null);
42
        taxonNodeWizard.setEntity(CdmStore.getService(ITaxonNodeService.class).load(entity.getUuid()));
43
        WizardDialog dialog = new WizardDialog(shell, taxonNodeWizard);
44
        dialog.open();
45
        EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, entity);
46

    
47
    }
48

    
49
    @Override
50
    public boolean canExecute(Object selection) {
51
        if (((IStructuredSelection)selection).getFirstElement() instanceof TaxonNodeDto && ((IStructuredSelection)selection).size() == 1){
52
            return ((TaxonNodeDto)((IStructuredSelection)selection).getFirstElement()).getTaxonUuid()!=null && PreferencesUtil.getBooleanValue(PreferencePredicate.ShowTaxonNodeWizard.getKey());
53
        }
54
        return false;
55
    }
56

    
57
}
(4-4/4)