blob: 0ca6924fbbd943a38ae983c8723c03d869f3ddb9 [file] [log] [blame]
//------------------------------------------------------------------------------
// Copyright (c) 2005, 2006 IBM Corporation and others.
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// Contributors:
// IBM Corporation - initial implementation
//------------------------------------------------------------------------------
package org.eclipse.epf.authoring.ui.wizards;
import org.eclipse.epf.authoring.ui.AuthoringUIPlugin;
import org.eclipse.epf.authoring.ui.AuthoringUIResources;
import org.eclipse.epf.library.LibraryService;
import org.eclipse.epf.uma.MethodConfiguration;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
/**
* A wizard that guides the user to create a new Method Configuration.
*
* @author Kelvin Low
* @author Bingxue Xu
* @since 1.0
*/
public class NewConfigurationWizard extends Wizard implements INewWizard {
/**
* The wizard ID.
*/
public static final String WIZARD_ID = NewConfigurationWizard.class
.getName();
private NewConfigurationMainPage mainPage;
/**
* Creates a new instance.
*/
public NewConfigurationWizard() {
super();
}
/**
* @see org.eclipse.ui.IWorkbenchWizard#init(IWorkbench,
* IStructuredSelection)
*/
public void init(IWorkbench workbench, IStructuredSelection selection) {
setWindowTitle(AuthoringUIResources.AuthoringUIPlugin_newConfigurationWizard_title); //$NON-NLS-1$
}
/**
* @see org.eclipse.jface.wizard.Wizard#addPages()
*/
public void addPages() {
mainPage = new NewConfigurationMainPage();
addPage(mainPage);
}
/**
* @see org.eclipse.jface.wizard.Wizard#createPageControls(Composite)
*/
public void createPageControls(Composite pageContainer) {
super.createPageControls(pageContainer);
pageContainer.getShell().setImage(
AuthoringUIPlugin.getDefault().getSharedImage(
"full/obj16/MethodConfiguration.gif")); //$NON-NLS-1$
}
/**
* @see org.eclipse.jface.wizard.IWizard#canFinish()
*/
public boolean canFinish() {
if (LibraryService.getInstance().getCurrentMethodLibrary() == null) {
return false;
}
return super.canFinish();
}
/**
* @see org.eclipse.jface.wizard.IWizard#performFinish()
*/
public boolean performFinish() {
String configName = mainPage.getConfigurationName();
if (configName != null) {
try {
MethodConfiguration config = LibraryService.getInstance()
.createMethodConfiguration(
configName,
LibraryService.getInstance()
.getCurrentMethodLibrary());
String briefDescription = mainPage
.getConfigurationBriefDescription();
if (briefDescription != null) {
config.setBriefDescription(briefDescription);
}
} catch (Exception e) {
AuthoringUIPlugin
.getDefault()
.getMsgDialog()
.displayError(
AuthoringUIResources.AuthoringUIPlugin_newConfigurationWizard_title,
AuthoringUIResources.internalError_msg, e);
}
}
return true;
}
}