1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
package eu.etaxonomy.taxeditor.printpublisher.wizard;
|
5
|
|
6
|
import org.eclipse.core.runtime.IProgressMonitor;
|
7
|
import org.eclipse.core.runtime.IStatus;
|
8
|
import org.eclipse.core.runtime.Status;
|
9
|
import org.eclipse.core.runtime.jobs.Job;
|
10
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
11
|
import org.eclipse.jface.wizard.Wizard;
|
12
|
import org.eclipse.ui.IExportWizard;
|
13
|
import org.eclipse.ui.IWorkbench;
|
14
|
|
15
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
16
|
import eu.etaxonomy.cdm.print.PublishConfigurator;
|
17
|
import eu.etaxonomy.cdm.print.Publisher;
|
18
|
import eu.etaxonomy.cdm.print.out.IPublishOutputModule;
|
19
|
import eu.etaxonomy.taxeditor.model.CdmProgressMonitorAdapter;
|
20
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
21
|
|
22
|
/**
|
23
|
* <p>AbstractPublishWizard class.</p>
|
24
|
*
|
25
|
* @author n.hoffmann
|
26
|
* @created Apr 1, 2010
|
27
|
* @version 1.0
|
28
|
*/
|
29
|
public class AbstractPublishWizard extends Wizard implements IExportWizard{
|
30
|
|
31
|
/** Constant <code>PAGE_SERVICE="PAGE_SERVICE"</code> */
|
32
|
public static final String PAGE_SERVICE = "PAGE_SERVICE";
|
33
|
/** Constant <code>PAGE_TAXA="PAGE_TAXA"</code> */
|
34
|
public static final String PAGE_TAXA = "PAGE_TAXA";
|
35
|
/** Constant <code>PAGE_OPTIONS="PAGE_OPTIONS"</code> */
|
36
|
public static final String PAGE_OPTIONS = "PAGE_OPTIONS";
|
37
|
/** Constant <code>PAGE_FOLDER="PAGE_FOLDER"</code> */
|
38
|
public static final String PAGE_FOLDER = "PAGE_FOLDER";
|
39
|
/** Constant <code>PAGE_OVERVIEW="PAGE_OVERVIEW"</code> */
|
40
|
public static final String PAGE_OVERVIEW = "PAGE_OVERVIEW";
|
41
|
/** Constant <code>PAGE_FEATURETREE="PAGE_FEATURETREE"</code> */
|
42
|
public static final String PAGE_FEATURETREE = "PAGE_FEATURETREE";
|
43
|
|
44
|
protected SelectServiceWizardPage pageService;
|
45
|
protected SelectTaxaWizardPage pageTaxa;
|
46
|
protected OptionsWizardPage pageOptions;
|
47
|
protected SelectFeatureTreeWizardPage pageFeatureTree;
|
48
|
protected SelectFolderWizardPage pageFolder;
|
49
|
protected OverviewWizardPage pageOverview;
|
50
|
|
51
|
private PublishConfigurator configurator;
|
52
|
|
53
|
private IPublishOutputModule outputModule;
|
54
|
|
55
|
/**
|
56
|
* <p>Constructor for AbstractPublishWizard.</p>
|
57
|
*/
|
58
|
public AbstractPublishWizard(){
|
59
|
setNeedsProgressMonitor(true);
|
60
|
}
|
61
|
|
62
|
/* (non-Javadoc)
|
63
|
* @see org.eclipse.jface.wizard.Wizard#performFinish()
|
64
|
*/
|
65
|
/** {@inheritDoc} */
|
66
|
@Override
|
67
|
public boolean performFinish() {
|
68
|
|
69
|
Job job = new Job("Running Print Publisher") {
|
70
|
|
71
|
@Override
|
72
|
protected IStatus run(IProgressMonitor monitor) {
|
73
|
monitor.beginTask("Print Publisher", getConfigurator().calculateNumberOfNodes() + 1);
|
74
|
ConversationHolder conversation = null;
|
75
|
try{
|
76
|
getConfigurator().setProgressMonitor(CdmProgressMonitorAdapter.CreateMonitor(monitor));
|
77
|
|
78
|
if(getConfigurator().isLocal()){
|
79
|
conversation= CdmStore.createConversation();
|
80
|
}
|
81
|
|
82
|
Publisher.publish(getConfigurator());
|
83
|
|
84
|
}finally{
|
85
|
monitor.done();
|
86
|
if(conversation != null) conversation.close();
|
87
|
}
|
88
|
return Status.OK_STATUS;
|
89
|
}
|
90
|
|
91
|
};
|
92
|
|
93
|
job.setPriority(Job.BUILD);
|
94
|
job.schedule();
|
95
|
|
96
|
return true;
|
97
|
}
|
98
|
|
99
|
/** {@inheritDoc} */
|
100
|
@Override
|
101
|
public void addPages() {
|
102
|
super.addPages();
|
103
|
|
104
|
pageService = new SelectServiceWizardPage(PAGE_SERVICE);
|
105
|
addPage(pageService);
|
106
|
|
107
|
pageTaxa = new SelectTaxaWizardPage(PAGE_TAXA);
|
108
|
addPage(pageTaxa);
|
109
|
|
110
|
pageOptions = new OptionsWizardPage(PAGE_OPTIONS);
|
111
|
addPage(pageOptions);
|
112
|
|
113
|
pageFeatureTree = new SelectFeatureTreeWizardPage(PAGE_FEATURETREE);
|
114
|
addPage(pageFeatureTree);
|
115
|
|
116
|
pageFolder = new SelectFolderWizardPage(PAGE_FOLDER);
|
117
|
addPage(pageFolder);
|
118
|
|
119
|
pageOverview = new OverviewWizardPage(PAGE_OVERVIEW);
|
120
|
addPage(pageOverview);
|
121
|
}
|
122
|
|
123
|
/* (non-Javadoc)
|
124
|
* @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
|
125
|
*/
|
126
|
/** {@inheritDoc} */
|
127
|
public void init(IWorkbench workbench, IStructuredSelection selection) {
|
128
|
PrintUtil.info("Instantiating wizard: " + this.getClass().getSimpleName());
|
129
|
}
|
130
|
|
131
|
|
132
|
|
133
|
/** {@inheritDoc} */
|
134
|
@Override
|
135
|
public boolean canFinish() {
|
136
|
return pageService.isPageComplete() &&
|
137
|
pageTaxa.isPageComplete() &&
|
138
|
pageFeatureTree.isPageComplete() &&
|
139
|
pageFolder.isPageComplete();
|
140
|
}
|
141
|
|
142
|
/**
|
143
|
* <p>Getter for the field <code>configurator</code>.</p>
|
144
|
*
|
145
|
* @return a {@link eu.etaxonomy.cdm.print.PublishConfigurator} object.
|
146
|
*/
|
147
|
protected PublishConfigurator getConfigurator() {
|
148
|
return configurator;
|
149
|
}
|
150
|
|
151
|
/**
|
152
|
* <p>Setter for the field <code>configurator</code>.</p>
|
153
|
*
|
154
|
* @param configurator a {@link eu.etaxonomy.cdm.print.PublishConfigurator} object.
|
155
|
*/
|
156
|
protected void setConfigurator(PublishConfigurator configurator){
|
157
|
this.configurator = configurator;
|
158
|
}
|
159
|
|
160
|
/**
|
161
|
* <p>Setter for the field <code>outputModule</code>.</p>
|
162
|
*
|
163
|
* @param outputModule a {@link eu.etaxonomy.cdm.print.out.IPublishOutputModule} object.
|
164
|
*/
|
165
|
protected void setOutputModule(IPublishOutputModule outputModule){
|
166
|
this.outputModule = outputModule;
|
167
|
}
|
168
|
|
169
|
/**
|
170
|
* <p>Getter for the field <code>outputModule</code>.</p>
|
171
|
*
|
172
|
* @return a {@link eu.etaxonomy.cdm.print.out.IPublishOutputModule} object.
|
173
|
*/
|
174
|
public IPublishOutputModule getOutputModule(){
|
175
|
return outputModule;
|
176
|
}
|
177
|
}
|