1 package org.simantics.document.linking.wizard;
3 import org.eclipse.jface.resource.JFaceResources;
4 import org.eclipse.jface.resource.LocalResourceManager;
5 import org.eclipse.jface.viewers.IStructuredSelection;
6 import org.eclipse.jface.wizard.IWizardPage;
7 import org.eclipse.jface.wizard.Wizard;
8 import org.eclipse.ui.IExportWizard;
9 import org.eclipse.ui.IWorkbench;
10 import org.simantics.db.Resource;
11 import org.simantics.utils.ui.AdaptionUtils;
14 * Wizard for exporting reports.
16 * @author Marko Luukkainen <marko.luukkainen@vtt.fi>
19 public class ReportWizard extends Wizard implements IExportWizard{
21 Resource selectedResource;
22 ReportSelectionPage reportSelectionPage;
23 ReportCustomizationPage reportCustomizationPage;
24 ReportGeneratePage reportGeneratePage;
26 LocalResourceManager manager = new LocalResourceManager(JFaceResources.getResources());
28 public ReportWizard() {
29 setNeedsProgressMonitor(true);
33 public void addPages() {
34 reportSelectionPage = new ReportSelectionPage("Select report parameters");
35 reportCustomizationPage = new ReportCustomizationPage("Customize report");
36 reportGeneratePage = new ReportGeneratePage("Run Report");
37 addPage(reportSelectionPage);
38 addPage(reportCustomizationPage);
39 addPage(reportGeneratePage);
40 if (selectedResource != null)
41 reportSelectionPage.setInput(selectedResource);
45 public IWizardPage getNextPage(IWizardPage page) {
46 if (page == reportSelectionPage) {
47 reportCustomizationPage.setReportWriter(reportSelectionPage.getSelectedWriter());
48 reportCustomizationPage.setModel(reportSelectionPage.getSelectedModel());
49 reportGeneratePage.setFilename(reportSelectionPage.getFilename());
50 reportGeneratePage.setModel(reportSelectionPage.getSelectedModel());
51 reportGeneratePage.setReportWriter(reportSelectionPage.getSelectedWriter());
53 return super.getNextPage(page);
57 public boolean performFinish() {
58 return reportGeneratePage.isGenerated();
62 public boolean canFinish() {
63 if (!reportGeneratePage.isGenerated())
65 return super.canFinish();
69 public void init(IWorkbench workbench, IStructuredSelection selection) {
70 selectedResource = AdaptionUtils.adaptToSingle(selection, Resource.class);
71 if (reportSelectionPage != null)
72 reportSelectionPage.setInput(selectedResource);
76 public void dispose() {