1 |
d9fbbe86
|
Patrick Plitzner
|
/**
|
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 |
6ed7a1a7
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
|
22 |
872fe921
|
Katja Luther
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
23 |
d9fbbe86
|
Patrick Plitzner
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
24 |
|
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
25 |
|
|
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
26 |
0e1842fc
|
Katja Luther
|
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateTaxonNameDescriptionOperation;
|
27 |
d9fbbe86
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateTaxonDescriptionOperation;
|
28 |
95116a15
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
29 |
d9fbbe86
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.ui.dialog.selection.ReferenceSelectionDialog;
|
30 |
|
|
|
31 |
|
|
/**
|
32 |
|
|
* @author pplitzner
|
33 |
|
|
* @since Sep 20, 2018
|
34 |
|
|
*
|
35 |
|
|
*/
|
36 |
95116a15
|
Patrick Plitzner
|
public class CreateDescriptionWithSourceHandler extends CreateDescriptionHandlerE4 {
|
37 |
|
|
|
38 |
|
|
private Shell shell;
|
39 |
|
|
|
40 |
d9fbbe86
|
Patrick Plitzner
|
@Execute
|
41 |
|
|
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart, MMenuItem menuItem,
|
42 |
|
|
UISynchronize sync, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell) {
|
43 |
95116a15
|
Patrick Plitzner
|
this.shell = shell;
|
44 |
|
|
super.execute(activePart, menuItem, sync);
|
45 |
|
|
}
|
46 |
d9fbbe86
|
Patrick Plitzner
|
|
47 |
95116a15
|
Patrick Plitzner
|
@Override
|
48 |
|
|
protected CreateTaxonDescriptionOperation createTaxonOperation(String eventLabel, Taxon taxon, IPostOperationEnabled postOperationEnabled) {
|
49 |
d9fbbe86
|
Patrick Plitzner
|
Reference reference = ReferenceSelectionDialog.select(shell, null);
|
50 |
a347d48a
|
Patrick Plitzner
|
if(reference==null){
|
51 |
|
|
return null;
|
52 |
|
|
}
|
53 |
95116a15
|
Patrick Plitzner
|
IdentifiableSource source = IdentifiableSource.NewInstance(OriginalSourceType.Unknown, null, null, reference, null);
|
54 |
|
|
return new CreateTaxonDescriptionOperation(eventLabel, EditorUtil.getUndoContext(), taxon, source, postOperationEnabled);
|
55 |
d9fbbe86
|
Patrick Plitzner
|
}
|
56 |
872fe921
|
Katja Luther
|
|
57 |
|
|
@Override
|
58 |
0e1842fc
|
Katja Luther
|
protected CreateTaxonNameDescriptionOperation createTaxonNameOperation(String eventLabel, TaxonName taxonName, IPostOperationEnabled postOperationEnabled) {
|
59 |
872fe921
|
Katja Luther
|
Reference reference = ReferenceSelectionDialog.select(shell, null);
|
60 |
|
|
if(reference==null){
|
61 |
|
|
return null;
|
62 |
|
|
}
|
63 |
|
|
IdentifiableSource source = IdentifiableSource.NewInstance(OriginalSourceType.Unknown, null, null, reference, null);
|
64 |
0e1842fc
|
Katja Luther
|
return new CreateTaxonNameDescriptionOperation(eventLabel, EditorUtil.getUndoContext(), taxonName, source, postOperationEnabled);
|
65 |
872fe921
|
Katja Luther
|
}
|
66 |
d9fbbe86
|
Patrick Plitzner
|
}
|