001: /*
002: * JBoss, Home of Professional Open Source
003: * Copyright 2005, JBoss Inc., and individual contributors as indicated
004: * by the @authors tag. See the copyright.txt in the distribution for a
005: * full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package com.bostechcorp.cbesb.ui.ide.wizards;
023:
024: import java.lang.reflect.InvocationTargetException;
025:
026: import org.eclipse.core.runtime.CoreException;
027: import org.eclipse.core.runtime.IConfigurationElement;
028: import org.eclipse.core.runtime.IExecutableExtension;
029: import org.eclipse.core.runtime.IProgressMonitor;
030: import org.eclipse.jdt.internal.ui.JavaPlugin;
031: import org.eclipse.jdt.internal.ui.JavaPluginImages;
032: import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
033: import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
034: import org.eclipse.swt.widgets.Shell;
035: import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
036:
037: /**
038: * Base class for project wizards. Derived from
039: * org.eclipse.jdt.internal.ui.wizards.NewProjectCreationWizard
040: *
041: * @version $Revision: 1.3 $
042: */
043: public abstract class ProjectWizard extends BaseWizard implements
044: IExecutableExtension {
045: /** Description of the Field */
046: protected IConfigurationElement fConfigElement;
047:
048: /** Description of the Field */
049: protected ProjectWizardPage fJavaPage;
050:
051: /** Description of the Field */
052: protected WizardNewProjectCreationPage fMainPage;
053:
054: /** Constructor for the ProjectWizard object */
055: public ProjectWizard() {
056: super ();
057: this
058: .setDefaultPageImageDescriptor(JavaPluginImages.DESC_WIZBAN_NEWJPRJ);
059: this .setDialogSettings(JavaPlugin.getDefault()
060: .getDialogSettings());
061: this .setWindowTitle(NewWizardMessages.JavaProjectWizard_title);//$NON-NLS-1$
062: }
063:
064: /** Adds a feature to the Pages attribute of the ProjectWizard object */
065: public void addPages() {
066: super .addPages();
067: this .fMainPage = new WizardNewProjectCreationPage(
068: "NewProjectCreationWizard");//$NON-NLS-1$
069: this .fMainPage
070: .setTitle(NewWizardMessages.JavaProjectWizardFirstPage_page_title);//$NON-NLS-1$
071: this .fMainPage
072: .setDescription(NewWizardMessages.JavaProjectWizardFirstPage_page_description);//$NON-NLS-1$
073: this .addPage(fMainPage);
074:
075: this .fJavaPage = createProjectWizardPage(fMainPage);
076: this .addPage(fJavaPage);
077: }
078:
079: /**
080: * Description of the Method
081: *
082: * @return Description of the Return Value
083: */
084: public boolean performCancel() {
085: this .fJavaPage.performCancel();
086: return super .performCancel();
087: }
088:
089: /**
090: * Sets the initializationData attribute of the ProjectWizard object
091: *
092: * @param cfig
093: * The new initializationData value
094: * @param propertyName
095: * The new initializationData value
096: * @param data
097: * The new initializationData value
098: */
099: public void setInitializationData(IConfigurationElement cfig,
100: String propertyName, Object data) {
101: this .fConfigElement = cfig;
102: }
103:
104: /**
105: * Description of the Method
106: *
107: * @param mainPage
108: * Description of the Parameter
109: * @return Description of the Return Value
110: */
111: protected abstract ProjectWizardPage createProjectWizardPage(
112: WizardNewProjectCreationPage mainPage);
113:
114: /**
115: * Description of the Method
116: *
117: * @param monitor
118: * Description of the Parameter
119: * @exception InterruptedException
120: * Description of the Exception
121: * @exception CoreException
122: * Description of the Exception
123: */
124: protected void finishPage(IProgressMonitor monitor)
125: throws InterruptedException, CoreException {
126: fJavaPage.performFinish(monitor);// use the full progress monitor
127: BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
128: this .selectAndReveal(fJavaPage.getJavaProject().getProject());
129: }
130:
131: /**
132: * Description of the Method
133: *
134: * @param shell
135: * Description of the Parameter
136: * @param e
137: * Description of the Parameter
138: */
139: protected void handleFinishException(Shell shell,
140: InvocationTargetException e) {
141: String title = NewWizardMessages.JavaProjectWizard_op_error_title;//$NON-NLS-1$
142: String message = NewWizardMessages.JavaProjectWizard_op_error_create_message;//$NON-NLS-1$
143: ExceptionHandler.handle(e, getShell(), title, message);
144: }
145: }
|