KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > xhtml > XHTMLConversionWizard


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.wizards.xhtml;
12
13 import java.lang.reflect.InvocationTargetException JavaDoc;
14
15 import org.eclipse.core.runtime.CoreException;
16 import org.eclipse.core.runtime.IProgressMonitor;
17 import org.eclipse.core.runtime.OperationCanceledException;
18 import org.eclipse.jface.operation.IRunnableWithProgress;
19 import org.eclipse.jface.wizard.Wizard;
20 import org.eclipse.pde.internal.ui.PDEPlugin;
21 import org.eclipse.pde.internal.ui.PDEPluginImages;
22 import org.eclipse.pde.internal.ui.PDEUIMessages;
23 import org.eclipse.pde.internal.ui.wizards.xhtml.TocReplaceTable.TocReplaceEntry;
24
25 public class XHTMLConversionWizard extends Wizard {
26
27     private XHTMLConversionWizardPage page1;
28     private TocReplaceTable fTable;
29
30     public XHTMLConversionWizard(TocReplaceTable table) {
31         setDefaultPageImageDescriptor(PDEPluginImages.DESC_XHTML_CONVERT_WIZ);
32         setWindowTitle(PDEUIMessages.XHTMLConversionWizard_title);
33         setNeedsProgressMonitor(true);
34         fTable = table;
35     }
36     
37     public boolean performFinish() {
38         try {
39             IRunnableWithProgress op = getConversionOperation(page1.getCheckedEntries());
40             getContainer().run(true, true, op);
41         } catch (InterruptedException JavaDoc e) {
42             return false;
43         } catch (InvocationTargetException JavaDoc e) {
44             PDEPlugin.logException(e);
45             return true; // exception handled
46
}
47         return true;
48     }
49     
50     public IRunnableWithProgress getConversionOperation(final TocReplaceEntry[] models) {
51             return new IRunnableWithProgress() {
52                 public void run(IProgressMonitor monitor)
53                     throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
54                     try {
55                         XHTMLConversionOperation op = new XHTMLConversionOperation(models, getShell());
56                         PDEPlugin.getWorkspace().run(op, monitor);
57                     } catch (CoreException e) {
58                         throw new InvocationTargetException JavaDoc(e);
59                     } catch (OperationCanceledException e) {
60                         throw new InterruptedException JavaDoc(e.getMessage());
61                     } finally {
62                         monitor.done();
63                     }
64                 }
65             };
66         }
67     
68     public void addPages() {
69         page1 = new XHTMLConversionWizardPage(fTable);
70         addPage(page1);
71     }
72     
73 }
74
Popular Tags