KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > cheatsheet > RegisterCSWizard


1 /*******************************************************************************
2  * Copyright (c) 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
12 package org.eclipse.pde.internal.ui.wizards.cheatsheet;
13
14 import java.lang.reflect.InvocationTargetException JavaDoc;
15
16 import org.eclipse.jface.operation.IRunnableWithProgress;
17 import org.eclipse.jface.viewers.IStructuredSelection;
18 import org.eclipse.jface.wizard.Wizard;
19 import org.eclipse.pde.core.IModel;
20 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSModel;
21 import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSModel;
22 import org.eclipse.pde.internal.ui.PDEPlugin;
23 import org.eclipse.pde.internal.ui.PDEPluginImages;
24 import org.eclipse.pde.internal.ui.PDEUIMessages;
25 import org.eclipse.ui.INewWizard;
26 import org.eclipse.ui.IWorkbench;
27
28 /**
29  * NewRegisterCSWizard
30  *
31  */

32 public class RegisterCSWizard extends Wizard implements INewWizard {
33
34     private RegisterCSWizardPage fMainPage;
35     
36     private IModel fModel;
37     
38     /**
39      *
40      */

41     public RegisterCSWizard(IModel model) {
42         fModel = model;
43     }
44
45     /* (non-Javadoc)
46      * @see org.eclipse.jface.wizard.Wizard#addPages()
47      */

48     public void addPages() {
49         if (fModel instanceof ICompCSModel) {
50             fMainPage = new RegisterCompCSWizardPage((ICompCSModel)fModel);
51         } else if (fModel instanceof ISimpleCSModel) {
52             fMainPage = new RegisterSimpleCSWizardPage((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 JavaDoc e) {
65             PDEPlugin.logException(e);
66             return false;
67         } catch (InterruptedException JavaDoc 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, IStructuredSelection selection) {
84         setWindowTitle(PDEUIMessages.RegisterCSWizard_registerCheatSheet);
85         // TODO: MP: LOW: CompCS: New register cheat sheet wizard image
86
setDefaultPageImageDescriptor(PDEPluginImages.DESC_CHEATSHEET_WIZ);
87         setNeedsProgressMonitor(true);
88     }
89     
90 }
91
Popular Tags