Project

General

Profile

Download (1.56 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 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.event;
10

    
11
import javax.annotation.PostConstruct;
12
import javax.inject.Inject;
13
import javax.inject.Named;
14

    
15
import org.eclipse.e4.core.di.annotations.Optional;
16
import org.eclipse.e4.ui.di.UIEventTopic;
17
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
18
import org.eclipse.e4.ui.services.IServiceConstants;
19

    
20
import eu.etaxonomy.cdm.model.taxon.Taxon;
21
import eu.etaxonomy.taxeditor.editor.ITaxonEditor;
22

    
23
/**
24
 * @author pplitzner
25
 * @since Sep 4, 2017
26
 *
27
 */
28
public class EventUtility {
29

    
30
    private static ITaxonEditor editor;
31

    
32
    private static MPart activePart;
33

    
34
    @PostConstruct
35
    public void create(){
36
        //nothing
37
    }
38

    
39
    @Inject
40
    @Optional
41
    private void updateCurrentActivePart(@Named(IServiceConstants.ACTIVE_PART)MPart activePart){
42
        EventUtility.activePart = activePart;
43
    }
44

    
45
    @Inject
46
    @Optional
47
    private void updateCurrentTaxon(@UIEventTopic(WorkbenchEventConstants.CURRENT_ACTIVE_EDITOR)ITaxonEditor editor){
48
        EventUtility.editor = editor;
49
    }
50

    
51
    public static Taxon getCurrentTaxon() {
52
        if(editor!=null){
53
            return editor.getTaxon();
54
        }
55
        return null;
56
    }
57

    
58
    public static ITaxonEditor getTaxonEditor() {
59
        return editor;
60
    }
61

    
62
    public static MPart getActivePart() {
63
        return activePart;
64
    }
65

    
66
}
(1-1/2)