3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.printpublisher
.handler
;
13 import java
.util
.UUID
;
15 import org
.eclipse
.core
.commands
.AbstractHandler
;
16 import org
.eclipse
.core
.commands
.ExecutionEvent
;
17 import org
.eclipse
.core
.commands
.ExecutionException
;
18 import org
.eclipse
.jface
.wizard
.WizardDialog
;
19 import org
.eclipse
.ui
.IEditorInput
;
20 import org
.eclipse
.ui
.IEditorPart
;
21 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
22 import org
.jdom
.Element
;
24 import eu
.etaxonomy
.cdm
.api
.application
.ICdmApplicationConfiguration
;
25 import eu
.etaxonomy
.cdm
.print
.IXMLEntityFactory
;
26 import eu
.etaxonomy
.cdm
.print
.PublishConfigurator
;
27 import eu
.etaxonomy
.cdm
.print
.out
.pdf
.PdfOutputModule
;
28 import eu
.etaxonomy
.cdm
.print
.out
.xml
.XMLOutputModule
;
29 import eu
.etaxonomy
.taxeditor
.editor
.TaxonEditorInput
;
30 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
31 import eu
.etaxonomy
.taxeditor
.printpublisher
.PrintUtil
;
32 import eu
.etaxonomy
.taxeditor
.printpublisher
.wizard
.DirectPublishingWizard
;
33 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
36 * <p>GeneratePdfHandler class.</p>
39 * @created Jul 20, 2010
42 public class GeneratePdfHandler
extends AbstractHandler
{
44 private PublishConfigurator configurator
;
47 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
48 // make the editors taxon the selected taxon to export
49 IEditorPart editor
= HandlerUtil
.getActiveEditor(event
);
51 IEditorInput input
= editor
.getEditorInput();
53 if(!(input
instanceof TaxonEditorInput
)){
54 MessagingUtils
.warningDialog("PDF generation not supported for selected input", this, "Generating PDF output is not supported for the current active editor");
59 configurator
= PublishConfigurator
.NewLocalInstance((ICdmApplicationConfiguration
) CdmStore
.getCurrentApplicationConfiguration());
61 Element taxonNodeElement
= getTaxonNodeElement((TaxonEditorInput
) input
);
62 configurator
.addSelectedTaxonNodeElements(taxonNodeElement
);
64 configurator
.setDoPublishEntireBranches(false);
66 configurator
.addOutputModule(new PdfOutputModule());
67 configurator
.addOutputModule(new XMLOutputModule());
69 DirectPublishingWizard wizard
= new DirectPublishingWizard(configurator
);
70 WizardDialog dialog
= new WizardDialog(HandlerUtil
.getActiveShell(event
), wizard
);
77 private Element
getTaxonNodeElement(TaxonEditorInput input
){
79 UUID taxonNodeUuid
= input
.getTaxonNode().getUuid();
81 IXMLEntityFactory factory
= configurator
.getFactory();
83 Element taxonNodeElement
= factory
.getTaxonNode(taxonNodeUuid
);
85 return taxonNodeElement
;