01: /*******************************************************************************
02: * Copyright (c) 2000, 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.site;
11:
12: import java.lang.reflect.InvocationTargetException;
13:
14: import org.eclipse.core.resources.IProject;
15: import org.eclipse.core.runtime.CoreException;
16: import org.eclipse.core.runtime.IConfigurationElement;
17: import org.eclipse.core.runtime.IExecutableExtension;
18: import org.eclipse.core.runtime.IPath;
19: import org.eclipse.jface.operation.IRunnableWithProgress;
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.pde.internal.ui.wizards.NewWizard;
24: import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
25:
26: public class NewSiteProjectWizard extends NewWizard implements
27: IExecutableExtension {
28:
29: public static final String DEF_PROJECT_NAME = "project-name"; //$NON-NLS-1$
30:
31: private NewSiteProjectCreationPage fMainPage;
32: private IConfigurationElement fConfig;
33:
34: public NewSiteProjectWizard() {
35: setDefaultPageImageDescriptor(PDEPluginImages.DESC_NEWSITEPRJ_WIZ);
36: setDialogSettings(PDEPlugin.getDefault().getDialogSettings());
37: setNeedsProgressMonitor(true);
38: setWindowTitle(PDEUIMessages.NewSiteWizard_wtitle);
39: }
40:
41: public void addPages() {
42: fMainPage = new NewSiteProjectCreationPage("main"); //$NON-NLS-1$
43: fMainPage.setTitle(PDEUIMessages.NewSiteWizard_MainPage_title);
44: fMainPage
45: .setDescription(PDEUIMessages.NewSiteWizard_MainPage_desc);
46: String pname = getDefaultValue(DEF_PROJECT_NAME);
47: if (pname != null)
48: fMainPage.setInitialProjectName(pname);
49: addPage(fMainPage);
50: }
51:
52: public boolean performFinish() {
53: try {
54: BasicNewProjectResourceWizard.updatePerspective(fConfig);
55: final IProject project = fMainPage.getProjectHandle();
56: final IPath location = fMainPage.getLocationPath();
57: final String webLocation = fMainPage.getWebLocation();
58: IRunnableWithProgress op = new NewSiteProjectCreationOperation(
59: getShell().getDisplay(), project, location,
60: webLocation);
61: getContainer().run(false, true, op);
62: } catch (InvocationTargetException e) {
63: PDEPlugin.logException(e);
64: return false;
65: } catch (InterruptedException e) {
66: return false;
67: }
68: return true;
69: }
70:
71: public void setInitializationData(IConfigurationElement config,
72: String property, Object data) throws CoreException {
73: this.fConfig = config;
74: }
75: }
|