4 package eu
.etaxonomy
.printpublisher
.wizard
;
6 import java
.lang
.reflect
.InvocationTargetException
;
8 import org
.apache
.log4j
.Logger
;
9 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
10 import org
.eclipse
.jface
.operation
.IRunnableWithProgress
;
11 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
12 import org
.eclipse
.jface
.wizard
.Wizard
;
13 import org
.eclipse
.ui
.IExportWizard
;
14 import org
.eclipse
.ui
.IWorkbench
;
16 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
17 import eu
.etaxonomy
.printpublisher
.IHarvestObserver
;
18 import eu
.etaxonomy
.printpublisher
.PublishConfigurator
;
19 import eu
.etaxonomy
.printpublisher
.Publisher
;
20 import eu
.etaxonomy
.printpublisher
.out
.IPublishOutputModule
;
21 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
26 * @created Apr 1, 2010
29 public class AbstractPublishWizard
extends Wizard
implements IExportWizard
{
30 private static final Logger logger
= Logger
31 .getLogger(AbstractPublishWizard
.class);
33 public static final String PAGE_SERVICE
= "PAGE_SERVICE";
34 public static final String PAGE_TAXA
= "PAGE_TAXA";
35 public static final String PAGE_OPTIONS
= "PAGE_OPTIONS";
36 public static final String PAGE_FOLDER
= "PAGE_FOLDER";
37 public static final String PAGE_OVERVIEW
= "PAGE_OVERVIEW";
38 public static final String PAGE_FEATURETREE
= "PAGE_FEATURETREE";
40 protected SelectServiceWizardPage pageService
;
41 protected SelectTaxaWizardPage pageTaxa
;
42 protected OptionsWizardPage pageOptions
;
43 protected SelectFeatureTreeWizardPage pageFeatureTree
;
44 protected SelectFolderWizardPage pageFolder
;
45 protected OverviewWizardPage pageOverview
;
47 private PublishConfigurator configurator
;
49 private IPublishOutputModule outputModule
;
51 public AbstractPublishWizard(){
52 setNeedsProgressMonitor(true);
56 * @see org.eclipse.jface.wizard.Wizard#performFinish()
59 public boolean performFinish() {
61 IRunnableWithProgress runnable
= new IRunnableWithProgress() {
63 public void run(final IProgressMonitor monitor
)
64 throws InvocationTargetException
, InterruptedException
{
65 monitor
.beginTask("Exporting Printable Output", getConfigurator().calculateNumberOfNodes() + 1);
67 IHarvestObserver observer
= new IHarvestObserver() {
69 public void update(String taskName
) {
70 monitor
.setTaskName(taskName
);
75 getConfigurator().addObserver(observer
);
77 Publisher
.publish(configurator
);
85 ConversationHolder conversation
= null;
88 if(getConfigurator().isLocal()){
89 conversation
= CdmStore
.createConversation();
91 getContainer().run(false, true, runnable
);
93 } catch (InvocationTargetException e
) {
94 // TODO Auto-generated catch block
96 } catch (InterruptedException e
) {
97 // TODO Auto-generated catch block
100 if(conversation
!= null) conversation
.close();
107 public void addPages() {
110 pageService
= new SelectServiceWizardPage(PAGE_SERVICE
);
111 addPage(pageService
);
113 pageTaxa
= new SelectTaxaWizardPage(PAGE_TAXA
);
116 pageOptions
= new OptionsWizardPage(PAGE_OPTIONS
);
117 addPage(pageOptions
);
119 pageFeatureTree
= new SelectFeatureTreeWizardPage(PAGE_FEATURETREE
);
120 addPage(pageFeatureTree
);
122 pageFolder
= new SelectFolderWizardPage(PAGE_FOLDER
);
125 pageOverview
= new OverviewWizardPage(PAGE_OVERVIEW
);
126 addPage(pageOverview
);
130 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
132 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
133 logger
.warn("Instantiating wizard: " + this.getClass().getSimpleName());
139 public boolean canFinish() {
140 return pageService
.isPageComplete() &&
141 pageTaxa
.isPageComplete() &&
142 pageFeatureTree
.isPageComplete() &&
143 pageFolder
.isPageComplete();
146 protected PublishConfigurator
getConfigurator() {
150 protected void setConfigurator(PublishConfigurator configurator
){
151 this.configurator
= configurator
;
154 protected void setOutputModule(IPublishOutputModule outputModule
){
155 this.outputModule
= outputModule
;
158 public IPublishOutputModule
getOutputModule(){