Revision eaff1338
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.printpublisher/src/main/java/eu/etaxonomy/taxeditor/printpublisher/handler/GeneratePdfHandler.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
20 | 20 |
import org.eclipse.ui.handlers.HandlerUtil; |
21 | 21 |
import org.jdom.Element; |
22 | 22 |
|
23 |
import eu.etaxonomy.cdm.api.application.ICdmRepository; |
|
24 | 23 |
import eu.etaxonomy.cdm.print.IXMLEntityFactory; |
25 | 24 |
import eu.etaxonomy.cdm.print.PublishConfigurator; |
26 | 25 |
import eu.etaxonomy.cdm.print.out.pdf.PdfOutputModule; |
27 | 26 |
import eu.etaxonomy.cdm.print.out.xml.XMLOutputModule; |
28 |
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
|
|
27 |
import eu.etaxonomy.taxeditor.editor.e4.TaxonEditorInputE4;
|
|
29 | 28 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
30 |
import eu.etaxonomy.taxeditor.printpublisher.PrintUtil; |
|
31 | 29 |
import eu.etaxonomy.taxeditor.printpublisher.wizard.DirectPublishingWizard; |
32 | 30 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
33 | 31 |
|
... | ... | |
39 | 37 |
* @version 1.0 |
40 | 38 |
*/ |
41 | 39 |
public class GeneratePdfHandler extends AbstractHandler { |
42 |
|
|
40 |
|
|
43 | 41 |
private PublishConfigurator configurator; |
44 | 42 |
|
45 | 43 |
/** {@inheritDoc} */ |
46 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
44 |
@Override |
|
45 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
47 | 46 |
// make the editors taxon the selected taxon to export |
48 |
IEditorPart editor = HandlerUtil.getActiveEditor(event);
|
|
47 |
IEditorPart editor = HandlerUtil.getActiveEditor(event); |
|
49 | 48 |
|
50 | 49 |
IEditorInput input = editor.getEditorInput(); |
51 |
|
|
52 |
if(!(input instanceof TaxonEditorInput)){ |
|
50 |
|
|
51 |
if(!(input instanceof TaxonEditorInputE4)){
|
|
53 | 52 |
MessagingUtils.warningDialog("PDF generation not supported for selected input", this, "Generating PDF output is not supported for the current active editor"); |
54 |
|
|
53 |
|
|
55 | 54 |
return null; |
56 | 55 |
} |
57 |
|
|
58 |
configurator = PublishConfigurator.NewLocalInstance((ICdmRepository) CdmStore.getCurrentApplicationConfiguration());
|
|
59 |
|
|
60 |
Element taxonNodeElement = getTaxonNodeElement((TaxonEditorInput) input); |
|
56 |
|
|
57 |
configurator = PublishConfigurator.NewLocalInstance(CdmStore.getCurrentApplicationConfiguration()); |
|
58 |
|
|
59 |
Element taxonNodeElement = getTaxonNodeElement((TaxonEditorInputE4) input);
|
|
61 | 60 |
configurator.addSelectedTaxonNodeElements(taxonNodeElement); |
62 |
|
|
61 |
|
|
63 | 62 |
configurator.setDoPublishEntireBranches(false); |
64 |
|
|
63 |
|
|
65 | 64 |
configurator.addOutputModule(new PdfOutputModule()); |
66 | 65 |
configurator.addOutputModule(new XMLOutputModule()); |
67 |
|
|
66 |
|
|
68 | 67 |
DirectPublishingWizard wizard = new DirectPublishingWizard(configurator); |
69 | 68 |
WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard); |
70 |
|
|
69 |
|
|
71 | 70 |
dialog.open(); |
72 |
|
|
71 |
|
|
73 | 72 |
return null; |
74 | 73 |
} |
75 |
|
|
76 |
private Element getTaxonNodeElement(TaxonEditorInput input){ |
|
77 |
|
|
74 |
|
|
75 |
private Element getTaxonNodeElement(TaxonEditorInputE4 input){
|
|
76 |
|
|
78 | 77 |
UUID taxonNodeUuid = input.getTaxonNode().getUuid(); |
79 |
|
|
78 |
|
|
80 | 79 |
IXMLEntityFactory factory = configurator.getFactory(); |
81 |
|
|
80 |
|
|
82 | 81 |
Element taxonNodeElement = factory.getTaxonNode(taxonNodeUuid); |
83 |
|
|
82 |
|
|
84 | 83 |
return taxonNodeElement; |
85 | 84 |
} |
86 | 85 |
} |
Also available in: Unified diff
ref #6595 refactor selection handling to migrated name editor