Project

General

Profile

Download (2.12 KB) Statistics
| Branch: | Tag: | Revision:
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.view.descriptive.e4.handler;
10

    
11
import javax.inject.Named;
12

    
13
import org.eclipse.e4.core.di.annotations.Execute;
14
import org.eclipse.e4.ui.di.UISynchronize;
15
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
16
import org.eclipse.e4.ui.model.application.ui.menu.MMenuItem;
17
import org.eclipse.e4.ui.services.IServiceConstants;
18
import org.eclipse.swt.widgets.Shell;
19

    
20
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
21
import eu.etaxonomy.cdm.model.common.OriginalSourceType;
22
import eu.etaxonomy.cdm.model.reference.Reference;
23
import eu.etaxonomy.cdm.model.taxon.Taxon;
24
import eu.etaxonomy.taxeditor.editor.EditorUtil;
25
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateTaxonDescriptionOperation;
26
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
27
import eu.etaxonomy.taxeditor.ui.dialog.selection.ReferenceSelectionDialog;
28

    
29
/**
30
 * @author pplitzner
31
 * @since Sep 20, 2018
32
 *
33
 */
34
public class CreateDescriptionWithSourceHandler extends CreateDescriptionHandlerE4 {
35

    
36
    private Shell shell;
37

    
38
    @Execute
39
    public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart, MMenuItem menuItem,
40
            UISynchronize sync, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell) {
41
        this.shell = shell;
42
        super.execute(activePart, menuItem, sync);
43
    }
44

    
45
    @Override
46
    protected CreateTaxonDescriptionOperation createTaxonOperation(String eventLabel, Taxon taxon, IPostOperationEnabled postOperationEnabled) {
47
        Reference reference = ReferenceSelectionDialog.select(shell, null);
48
        if(reference==null){
49
            return null;
50
        }
51
        IdentifiableSource source = IdentifiableSource.NewInstance(OriginalSourceType.Unknown, null, null, reference, null);
52
        return new CreateTaxonDescriptionOperation(eventLabel, EditorUtil.getUndoContext(), taxon, source, postOperationEnabled);
53
    }
54
}
(3-3/9)