1 11 package org.eclipse.pde.internal.ui.wizards.xhtml; 12 13 import java.lang.reflect.InvocationTargetException ; 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 e) { 42 return false; 43 } catch (InvocationTargetException e) { 44 PDEPlugin.logException(e); 45 return true; } 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 , InterruptedException { 54 try { 55 XHTMLConversionOperation op = new XHTMLConversionOperation(models, getShell()); 56 PDEPlugin.getWorkspace().run(op, monitor); 57 } catch (CoreException e) { 58 throw new InvocationTargetException (e); 59 } catch (OperationCanceledException e) { 60 throw new InterruptedException (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 |