01: package org.eclipse.pde.internal.ui.wizards.toc;
02:
03: import java.lang.reflect.InvocationTargetException;
04:
05: import org.eclipse.core.resources.IFile;
06: import org.eclipse.jface.wizard.IWizardPage;
07: import org.eclipse.pde.internal.ui.PDEPlugin;
08: import org.eclipse.pde.internal.ui.PDEUIMessages;
09: import org.eclipse.ui.actions.WorkspaceModifyOperation;
10: import org.eclipse.ui.wizards.newresource.BasicNewFileResourceWizard;
11:
12: public class TocHTMLWizard extends BasicNewFileResourceWizard {
13: protected IFile fNewFile;
14:
15: /* (non-Javadoc)
16: * @see org.eclipse.ui.wizards.newresource.BasicNewFileResourceWizard#addPages()
17: */
18: public void addPages() {
19: IWizardPage mainPage = new TocHTMLWizardPage(
20: "newHTMLPage1", getSelection());//$NON-NLS-1$
21: mainPage.setTitle(PDEUIMessages.TocHTMLWizard_title);
22: mainPage.setDescription(PDEUIMessages.TocHTMLWizard_desc);
23: addPage(mainPage);
24: }
25:
26: /* (non-Javadoc)
27: * @see org.eclipse.ui.wizards.newresource.BasicNewFileResourceWizard#performFinish()
28: */
29: public boolean performFinish() {
30: IWizardPage mainPage = getPage("newHTMLPage1"); //$NON-NLS-1$
31: if (!(mainPage instanceof TocHTMLWizardPage)) {
32: return false;
33: }
34:
35: fNewFile = ((TocHTMLWizardPage) mainPage).createNewFile();
36: if (fNewFile == null) {
37: return false;
38: }
39:
40: try {
41: getContainer().run(false, true, getOperation());
42: selectAndReveal(fNewFile);
43: } catch (InvocationTargetException e) {
44: PDEPlugin.logException(e);
45: fNewFile = null;
46: return false;
47: } catch (InterruptedException e) {
48: fNewFile = null;
49: return false;
50: }
51:
52: return true;
53: }
54:
55: private WorkspaceModifyOperation getOperation() {
56: return new TocHTMLOperation(fNewFile);
57: }
58:
59: public IFile getNewResource() {
60: return fNewFile;
61: }
62: }
|