01: /*******************************************************************************
02: * Copyright (c) 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.cheatsheet;
11:
12: import java.lang.reflect.InvocationTargetException;
13:
14: import org.eclipse.jface.operation.IRunnableWithProgress;
15: import org.eclipse.jface.viewers.IStructuredSelection;
16: import org.eclipse.jface.wizard.Wizard;
17: import org.eclipse.pde.core.IModel;
18: import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSModel;
19: import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSModel;
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.ui.INewWizard;
24: import org.eclipse.ui.IWorkbench;
25:
26: /**
27: * NewRegisterCSWizard
28: *
29: */
30: public class RegisterCSWizard extends Wizard implements INewWizard {
31:
32: private RegisterCSWizardPage fMainPage;
33:
34: private IModel fModel;
35:
36: /**
37: *
38: */
39: public RegisterCSWizard(IModel model) {
40: fModel = model;
41: }
42:
43: /* (non-Javadoc)
44: * @see org.eclipse.jface.wizard.Wizard#addPages()
45: */
46: public void addPages() {
47: if (fModel instanceof ICompCSModel) {
48: fMainPage = new RegisterCompCSWizardPage(
49: (ICompCSModel) fModel);
50: } else if (fModel instanceof ISimpleCSModel) {
51: fMainPage = new RegisterSimpleCSWizardPage(
52: (ISimpleCSModel) fModel);
53: }
54:
55: addPage(fMainPage);
56: }
57:
58: /* (non-Javadoc)
59: * @see org.eclipse.jface.wizard.Wizard#performFinish()
60: */
61: public boolean performFinish() {
62: try {
63: getContainer().run(false, true, getOperation());
64: } catch (InvocationTargetException e) {
65: PDEPlugin.logException(e);
66: return false;
67: } catch (InterruptedException e) {
68: return false;
69: }
70: return true;
71: }
72:
73: /**
74: * @return
75: */
76: private IRunnableWithProgress getOperation() {
77: return new RegisterCSOperation(fMainPage, getShell());
78: }
79:
80: /* (non-Javadoc)
81: * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
82: */
83: public void init(IWorkbench workbench,
84: IStructuredSelection selection) {
85: setWindowTitle(PDEUIMessages.RegisterCSWizard_registerCheatSheet);
86: // TODO: MP: LOW: CompCS: New register cheat sheet wizard image
87: setDefaultPageImageDescriptor(PDEPluginImages.DESC_CHEATSHEET_WIZ);
88: setNeedsProgressMonitor(true);
89: }
90:
91: }
|