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
|
private void updateCurrentActivePart(@Named(IServiceConstants.ACTIVE_PART)MPart activePart){
|
41
|
if(activePart!=null){
|
42
|
EventUtility.activePart = activePart;
|
43
|
}
|
44
|
}
|
45
|
|
46
|
@Inject
|
47
|
@Optional
|
48
|
private void updateCurrentTaxon(@UIEventTopic(WorkbenchEventConstants.CURRENT_ACTIVE_EDITOR)ITaxonEditor editor){
|
49
|
EventUtility.editor = editor;
|
50
|
}
|
51
|
|
52
|
public static Taxon getCurrentTaxon() {
|
53
|
if(editor!=null){
|
54
|
return editor.getTaxon();
|
55
|
}
|
56
|
return null;
|
57
|
}
|
58
|
|
59
|
public static ITaxonEditor getTaxonEditor() {
|
60
|
return editor;
|
61
|
}
|
62
|
|
63
|
public static MPart getActivePart() {
|
64
|
return activePart;
|
65
|
}
|
66
|
|
67
|
}
|