Project

General

Profile

Revision e9fa67ee

IDe9fa67ee1ead81a33b4f6e0960920b87d2af03b8
Parent 7f6ce378
Child fb85fe2e

Added by Patrick Plitzner almost 3 years ago

ref #6595, #6925 Use EventBroker to keep track of active taxon editor

View differences:

eu.etaxonomy.taxeditor.editor/META-INF/MANIFEST.MF
35 35
 org.eclipse.e4.core.di,
36 36
 org.eclipse.e4.ui.model.workbench,
37 37
 org.eclipse.e4.ui.di,
38
 org.eclipse.e4.core.commands
38
 org.eclipse.e4.core.commands,
39
 org.eclipse.e4.core.services
39 40
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
40 41
Bundle-ActivationPolicy: lazy
41 42
Import-Package: javax.annotation;version="1.0.0";resolution:=optional,
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/TaxonNameEditorE4.java
23 23
import org.eclipse.core.commands.operations.UndoContext;
24 24
import org.eclipse.core.runtime.IProgressMonitor;
25 25
import org.eclipse.core.runtime.OperationCanceledException;
26
import org.eclipse.e4.core.services.events.IEventBroker;
26 27
import org.eclipse.e4.ui.di.Focus;
27 28
import org.eclipse.e4.ui.di.Persist;
28 29
import org.eclipse.e4.ui.model.application.ui.MDirtyable;
......
56 57
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
57 58
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
58 59
import eu.etaxonomy.taxeditor.editor.ISecuredEditor;
60
import eu.etaxonomy.taxeditor.editor.ITaxonEditor;
59 61
import eu.etaxonomy.taxeditor.editor.e4.TaxonEditorInputE4;
60 62
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
61 63
import eu.etaxonomy.taxeditor.editor.name.e4.container.AbstractGroupE4;
......
65 67
import eu.etaxonomy.taxeditor.editor.name.e4.container.ContainerFactoryE4;
66 68
import eu.etaxonomy.taxeditor.editor.name.e4.container.HomotypicalSynonymGroupE4;
67 69
import eu.etaxonomy.taxeditor.editor.name.e4.container.MisappliedGroupE4;
70
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
68 71
import eu.etaxonomy.taxeditor.model.AbstractUtility;
69 72
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
70 73
import eu.etaxonomy.taxeditor.model.IPartChangeListener;
......
87 90
 */
88 91
public class TaxonNameEditorE4 implements IConversationEnabled, IDirtyMarkable, IPartContentHasDetails,
89 92
        IPartContentHasSupplementalData, IPartContentHasMedia, IPartContentHasFactualData, IPartChangeListener,
90
        ISelectionListener, ISecuredEditor, IPostOperationEnabled, IE4SavablePart {
93
        ISelectionListener, ISecuredEditor, IPostOperationEnabled, IE4SavablePart, ITaxonEditor {
91 94

  
92 95
	private Taxon taxon;
93 96

  
......
124 127

  
125 128
    private UndoContext undoContext;
126 129

  
130
    @Inject
131
    private IEventBroker eventBroker;
132

  
127 133
	@Inject
128 134
	public TaxonNameEditorE4() {
129 135
	    undoContext = new UndoContext();
......
204 210
		managedForm.refresh();
205 211
	}
206 212

  
207
	public Taxon getTaxon() {
213
	@Override
214
    public Taxon getTaxon() {
208 215
		return HibernateProxyHelper.deproxy(taxon);
209 216
	}
210 217

  
......
230 237
	        boolean doEnable = permissionsSatisfied();
231 238
	        managedForm.getForm().setEnabled(doEnable);
232 239
	    }
240
        eventBroker.post(WorkbenchEventConstants.CURRENT_ACTIVE_EDITOR, this);
233 241
	}
234 242

  
235 243
	@Override
eu.etaxonomy.taxeditor.store/META-INF/MANIFEST.MF
14 14
 eu.etaxonomy.taxeditor.editor,
15 15
 eu.etaxonomy.taxeditor.editor.definedterm,
16 16
 eu.etaxonomy.taxeditor.editor.definedterm.input,
17
 eu.etaxonomy.taxeditor.event,
17 18
 eu.etaxonomy.taxeditor.featuretree,
18 19
 eu.etaxonomy.taxeditor.featuretree.e4,
19 20
 eu.etaxonomy.taxeditor.handler,
eu.etaxonomy.taxeditor.store/fragment.e4xmi
1 1
<?xml version="1.0" encoding="ASCII"?>
2
<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/descriptor/basic" xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmlns:ui="http://www.eclipse.org/ui/2010/UIModel/application/ui" xmi:id="_OhwnQCTfEeeiN5lBIuqN3g">
2
<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/descriptor/basic" xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmlns:ui="http://www.eclipse.org/ui/2010/UIModel/application/ui" xmi:id="_OhwnQCTfEeeiN5lBIuqN3g">
3 3
  <imports xsi:type="commands:Command" xmi:id="_bnVKsCZxEeeQLpuomSmVoQ" elementId="eu.etaxonomy.taxeditor.command.openPart"/>
4 4
  <imports xsi:type="commands:Command" xmi:id="_LlbAMEq2EeeN-dEYnw7m3g" elementId="org.eclipse.ui.file.save"/>
5 5
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_xVa1wCXXEeex9MwMOgUeWw" featurename="descriptors" parentElementId="xpath:/">
......
108 108
      </children>
109 109
    </elements>
110 110
  </fragments>
111
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_pVVyEJFJEeeDJpjGQES7gw" featurename="addons" parentElementId="org.eclipse.e4.legacy.ide.application">
112
    <elements xsi:type="application:Addon" xmi:id="_q4JBkJFJEeeDJpjGQES7gw" elementId="eu.etaxonomy.taxeditor.event.EventUtility" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.event.EventUtility"/>
113
  </fragments>
111 114
</fragment:ModelFragments>
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/event/EventUtility.java
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

  
14
import org.eclipse.e4.core.di.annotations.Optional;
15
import org.eclipse.e4.ui.di.UIEventTopic;
16

  
17
import eu.etaxonomy.cdm.model.taxon.Taxon;
18
import eu.etaxonomy.taxeditor.editor.ITaxonEditor;
19

  
20
/**
21
 * @author pplitzner
22
 * @since Sep 4, 2017
23
 *
24
 */
25
public class EventUtility {
26

  
27
    private static ITaxonEditor editor;
28

  
29
    @PostConstruct
30
    public void create(){
31
        //nothing
32
    }
33

  
34
    @Inject
35
    @Optional
36
    private void updateCurrentTaxon(@UIEventTopic(WorkbenchEventConstants.CURRENT_ACTIVE_EDITOR)ITaxonEditor editor){
37
        EventUtility.editor = editor;
38
    }
39

  
40
    public static Taxon getCurrentTaxon() {
41
        if(editor!=null){
42
            return editor.getTaxon();
43
        }
44
        return null;
45
    }
46

  
47
    public static ITaxonEditor getEditor() {
48
        return editor;
49
    }
50

  
51
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/event/WorkbenchEventConstants.java
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
/**
12
 * @author pplitzner
13
 * @since Sep 4, 2017
14
 *
15
 */
16
public interface WorkbenchEventConstants {
17

  
18
    public static final String CURRENT_ACTIVE_EDITOR = "CURRENT/ACTIVE_EDITOR";
19

  
20
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)