KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > site > NewSiteProjectWizard


1 /*******************************************************************************
2  * Copyright (c) 2000, 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 package org.eclipse.pde.internal.ui.wizards.site;
12
13 import java.lang.reflect.InvocationTargetException JavaDoc;
14
15 import org.eclipse.core.resources.IProject;
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.IConfigurationElement;
18 import org.eclipse.core.runtime.IExecutableExtension;
19 import org.eclipse.core.runtime.IPath;
20 import org.eclipse.jface.operation.IRunnableWithProgress;
21 import org.eclipse.pde.internal.ui.PDEPlugin;
22 import org.eclipse.pde.internal.ui.PDEPluginImages;
23 import org.eclipse.pde.internal.ui.PDEUIMessages;
24 import org.eclipse.pde.internal.ui.wizards.NewWizard;
25 import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
26
27 public class NewSiteProjectWizard extends NewWizard implements IExecutableExtension {
28
29     public static final String JavaDoc DEF_PROJECT_NAME = "project-name"; //$NON-NLS-1$
30

31     private NewSiteProjectCreationPage fMainPage;
32     private IConfigurationElement fConfig;
33     
34
35     public NewSiteProjectWizard() {
36         setDefaultPageImageDescriptor(PDEPluginImages.DESC_NEWSITEPRJ_WIZ);
37         setDialogSettings(PDEPlugin.getDefault().getDialogSettings());
38         setNeedsProgressMonitor(true);
39         setWindowTitle(PDEUIMessages.NewSiteWizard_wtitle);
40     }
41     
42     public void addPages() {
43         fMainPage = new NewSiteProjectCreationPage("main"); //$NON-NLS-1$
44
fMainPage.setTitle(PDEUIMessages.NewSiteWizard_MainPage_title);
45         fMainPage.setDescription(PDEUIMessages.NewSiteWizard_MainPage_desc);
46         String JavaDoc pname = getDefaultValue(DEF_PROJECT_NAME);
47         if (pname!=null)
48             fMainPage.setInitialProjectName(pname);
49         addPage(fMainPage);
50     }
51
52     
53     public boolean performFinish() {
54         try {
55             BasicNewProjectResourceWizard.updatePerspective(fConfig);
56             final IProject project = fMainPage.getProjectHandle();
57             final IPath location = fMainPage.getLocationPath();
58             final String JavaDoc webLocation = fMainPage.getWebLocation();
59             IRunnableWithProgress op = new NewSiteProjectCreationOperation(getShell().getDisplay(), project, location, webLocation);
60             getContainer().run(false, true, op);
61         } catch (InvocationTargetException JavaDoc e) {
62             PDEPlugin.logException(e);
63             return false;
64         } catch (InterruptedException JavaDoc e) {
65             return false;
66         }
67         return true;
68     }
69
70     public void setInitializationData(
71         IConfigurationElement config,
72         String JavaDoc property,
73         Object JavaDoc data)
74         throws CoreException {
75         this.fConfig = config;
76     }
77 }
78
Popular Tags