2 * Copyright (c) 2002 Team in a Box Ltd. All rights reserved. This file is made available under the terms and conditions of the
3 * Common Public License v 1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/cpl-v1.0.html
5 * Contributors: Team in a Box Ltd http://www.teaminabox.co.uk/
8 package net.sourceforge.phpeclipse.wiki.export.pdf;
11 import java.lang.reflect.InvocationTargetException;
13 import net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin;
15 import org.eclipse.core.resources.IProject;
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.QualifiedName;
18 import org.eclipse.jface.dialogs.MessageDialog;
19 import org.eclipse.jface.operation.IRunnableWithProgress;
20 import org.eclipse.jface.viewers.IStructuredSelection;
21 import org.eclipse.jface.wizard.Wizard;
22 import org.eclipse.ui.INewWizard;
23 import org.eclipse.ui.IWorkbench;
25 public final class WikiPDFExportWizard extends Wizard implements INewWizard {
26 static final QualifiedName DIRECTORY_QUALIFIED_NAME = new QualifiedName(WikiEditorPlugin.PLUGIN_ID, "exportDirectory");
28 private WikiPDFExportWizardPage page;
30 private IStructuredSelection selection;
32 public WikiPDFExportWizard() {
34 setNeedsProgressMonitor(true);
37 public void addPages() {
38 page = new WikiPDFExportWizardPage(selection);
42 public boolean performFinish() {
46 private boolean runOperationForContainer(IRunnableWithProgress op) {
48 getContainer().run(true, true, op);
49 } catch (InterruptedException e) {
51 } catch (InvocationTargetException e) {
52 WikiEditorPlugin.getDefault().log("", e);
53 MessageDialog.openError(getShell(), "Error", e.getTargetException().getMessage());
60 private void persistExportProperties() {
61 IProject project = page.getFolder().getProject();
63 project.setPersistentProperty(WikiPDFExportWizard.DIRECTORY_QUALIFIED_NAME, new File(page.getExportDirectoryPath())
65 } catch (CoreException cex) {
70 private void noteException(CoreException cex) {
71 WikiEditorPlugin.getDefault().log("Export Error", cex);
72 throw new RuntimeException("An error occurred. Please see the log for details.");
75 public void init(IWorkbench workbench, IStructuredSelection selection) {
76 this.selection = selection;