01: /*******************************************************************************
02: * Copyright (c) 2005, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.wizards.toc;
11:
12: import java.lang.reflect.InvocationTargetException;
13:
14: import org.eclipse.core.runtime.IPath;
15: import org.eclipse.jface.viewers.IStructuredSelection;
16: import org.eclipse.pde.internal.ui.PDEPlugin;
17: import org.eclipse.pde.internal.ui.PDEPluginImages;
18: import org.eclipse.pde.internal.ui.PDEUIMessages;
19: import org.eclipse.ui.IWorkbench;
20:
21: public class NewTocFileWizard extends TocHTMLWizard {
22:
23: private TocWizardPage fPage;
24: private IPath fInitialPath = null;
25:
26: public void addPages() {
27: fPage = new TocWizardPage("tocfile", getSelection()); //$NON-NLS-1$
28: if (fInitialPath != null)
29: fPage.setContainerFullPath(fInitialPath);
30: addPage(fPage);
31: }
32:
33: public void init(IWorkbench workbench,
34: IStructuredSelection currentSelection) {
35: super .init(workbench, currentSelection);
36: setWindowTitle(PDEUIMessages.NewTocFileWizard_title);
37: setNeedsProgressMonitor(true);
38: }
39:
40: protected void initializeDefaultPageImageDescriptor() {
41: setDefaultPageImageDescriptor(PDEPluginImages.DESC_TARGET_WIZ);
42: }
43:
44: public boolean performFinish() {
45: try {
46: fNewFile = fPage.createNewFile();
47: getContainer().run(false, true, getOperation());
48: } catch (InvocationTargetException e) {
49: PDEPlugin.logException(e);
50: fNewFile = null;
51: return false;
52: } catch (InterruptedException e) {
53: fNewFile = null;
54: return false;
55: }
56: return true;
57: }
58:
59: private TocOperation getOperation() {
60: return new TocOperation(fPage.createNewFile(), fPage
61: .getTocName());
62: }
63:
64: public void setInitialPath(IPath path) {
65: fInitialPath = path;
66: }
67:
68: }
|