gt: 			catch (PartInitException exception) {
context: /**
   * JBoss, Home of Professional Open Source.
   * Copyright 2012, Red Hat Middleware LLC, and individual contributors
   * as indicated by the @author tags. See the copyright.txt file in the
   * distribution for a full listing of individual contributors.
   * 
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   * 
   * This software is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   * Lesser General Public License for more details.
   * 
   * You should have received a copy of the GNU Lesser General Public
   * License along with this software; if not, write to the Free
   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
   * 
   */
  package org.jboss.jca.adapters.sap.spi.presentation;
  
  
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Collection;
  import java.util.Collections;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  import java.util.MissingResourceException;
  import java.util.StringTokenizer;
  
  import org.eclipse.emf.common.CommonPlugin;
  
  import org.eclipse.emf.common.util.URI;
  
  import org.eclipse.emf.ecore.EClass;
  import org.eclipse.emf.ecore.EClassifier;
  
  import org.eclipse.emf.ecore.resource.Resource;
  import org.eclipse.emf.ecore.resource.ResourceSet;
  
  import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
  
  import org.eclipse.emf.ecore.EObject;
  
  import org.eclipse.emf.ecore.xmi.XMLResource;
  
  import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
  
  import org.eclipse.core.resources.IContainer;
  import org.eclipse.core.resources.IFile;
  import org.eclipse.core.resources.IFolder;
  import org.eclipse.core.resources.IProject;
  import org.eclipse.core.resources.IResource;
  import org.eclipse.core.resources.ResourcesPlugin;
  
  import org.eclipse.core.runtime.IProgressMonitor;
  
  import org.eclipse.jface.dialogs.MessageDialog;
  
  import org.eclipse.jface.viewers.IStructuredSelection;
  
  import org.eclipse.jface.wizard.Wizard;
  import org.eclipse.jface.wizard.WizardPage;
  
  import org.eclipse.swt.SWT;
  
  import org.eclipse.swt.events.ModifyListener;
  import org.eclipse.swt.events.ModifyEvent;
  
  import org.eclipse.swt.layout.GridData;
  import org.eclipse.swt.layout.GridLayout;
  
  import org.eclipse.swt.widgets.Combo;
  import org.eclipse.swt.widgets.Composite;
  import org.eclipse.swt.widgets.Label;
  
  import org.eclipse.ui.INewWizard;
  import org.eclipse.ui.IWorkbench;
  
  import org.eclipse.ui.actions.WorkspaceModifyOperation;
  
  import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
  
  import org.eclipse.ui.part.FileEditorInput;
  import org.eclipse.ui.part.ISetSelectionTarget;
  
  import org.jboss.jca.adapters.sap.spi.impl.SpiPackageImpl;
  import org.jboss.jca.adapters.sap.edit.JBossSapJcaEditPlugin;
  
  
  import org.eclipse.core.runtime.Path;
  
  import org.eclipse.emf.ecore.EFactory;
  import org.eclipse.emf.ecore.EPackage;
  
  import org.eclipse.jface.viewers.ISelection;
  import org.eclipse.jface.viewers.StructuredSelection;
  
  import org.eclipse.ui.IWorkbenchPage;
  import org.eclipse.ui.IWorkbenchPart;
  import org.eclipse.ui.IWorkbenchWindow;
  import org.eclipse.ui.PartInitException;
  
  import org.jboss.jca.adapters.sap.editor.JBossSapJcaEditorPlugin;
  
  
  /**
   * This is a simple wizard for creating a new model file.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public class SpiModelWizard extends Wizard implements INewWizard {
  	/**
  	 * The supported extensions for created files.
  	 * <!-- begin-user-doc -->
  	 * <!-- end-user-doc -->
  	 * @generated
  	 */
  	public static final List<String> FILE_EXTENSIONS =
  		Collections.unmodifiableList(Arrays.asList(JBossSapJcaEditorPlugin.INSTANCE.getString("_UI_SpiEditorFilenameExtensions").split("\\s*,\\s*")));
  
  	/**
  	 * A formatted list of supported file extensions, suitable for display.
  	 * <!-- begin-user-doc -->
  	 * <!-- end-user-doc -->
  	 * @generated
  	 */
  	public static final String FORMATTED_FILE_EXTENSIONS =
  		JBossSapJcaEditorPlugin.INSTANCE.getString("_UI_SpiEditorFilenameExtensions").replaceAll("\\s*,\\s*", ", ");
  
  	/**
  	 * This caches an instance of the model package.
  	 * <!-- begin-user-doc -->
  	 * <!-- end-user-doc -->
  	 * @generated
  	 */
  	protected EPackage spiPackage = SpiPackageImpl.eINSTANCE;
  
  	/**
  	 * This caches an instance of the model factory.
  	 * <!-- begin-user-doc -->
  	 * <!-- end-user-doc -->
  	 * @generated
  	 */
  	protected EFactory spiFactory = spiPackage.getEFactoryInstance();
  
  	/**
  	 * This is the file creation page.
  	 * <!-- begin-user-doc -->
  	 * <!-- end-user-doc -->
  	 * @generated
  	 */
  	protected SpiModelWizardNewFileCreationPage newFileCreationPage;
  
  	/**
  	 * This is the initial object creation page.
  	 * <!-- begin-user-doc -->
  	 * <!-- end-user-doc -->
  	 * @generated
  	 */
  	protected SpiModelWizardInitialObjectCreationPage initialObjectCreationPage;
  
  	/**
  	 * Remember the selection during initialization for populating the default container.
  	 * <!-- begin-user-doc -->
  	 * <!-- end-user-doc -->
  	 * @generated
  	 */
  	protected IStructuredSelection selection;
  
  	/**
  	 * Remember the workbench during initialization.
  	 * <!-- begin-user-doc -->
  	 * <!-- end-user-doc -->
  	 * @generated
  	 */
  	protected IWorkbench workbench;
  
  	/**
  	 * Caches the names of the types that can be created as the root object.
  	 * <!-- begin-user-doc -->
  	 * <!-- end-user-doc -->
  	 * @generated
  	 */
  	protected List<String> initialObjectNames;
  
  	/**
  	 * This just records the information.
  	 * <!-- begin-user-doc -->
  	 * <!-- end-user-doc -->
  	 * @generated
  	 */
  	public void init(IWorkbench workbench, IStructuredSelection selection) {
  		this.workbench = workbench;
  		this.selection = selection;
  		setWindowTitle(JBossSapJcaEditorPlugin.INSTANCE.getString("_UI_Wizard_label"));
  		setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE.getImageDescriptor(JBossSapJcaEditorPlugin.INSTANCE.getImage("full/wizban/NewSpi")));
  	}
  
  	/**
  	 * Returns the names of the types that can be created as the root object.
  	 * <!-- begin-user-doc -->
  	 * <!-- end-user-doc -->
  	 * @generated
  	 */
  	protected Collection<String> getInitialObjectNames() {
  		if (initialObjectNames == null) {
  			initialObjectNames = new ArrayList<String>();
  			for (EClassifier eClassifier : spiPackage.getEClassifiers()) {
  				if (eClassifier instanceof EClass) {
  					EClass eClass = (EClass)eClassifier;
  					if (!eClass.isAbstract()) {
  						initialObjectNames.add(eClass.getName());
  					}
  				}
  			}
  			Collections.sort(initialObjectNames, CommonPlugin.INSTANCE.getComparator());
  		}
  		return initialObjectNames;
  	}
  
  	/**
  	 * Create a new model.
  	 * <!-- begin-user-doc -->
  	 * <!-- end-user-doc -->
  	 * @generated
  	 */
  	protected EObject createInitialModel() {
  		EClass eClass = (EClass)spiPackage.getEClassifier(initialObjectCreationPage.getInitialObjectName());
  		EObject rootObject = spiFactory.create(eClass);
  		return rootObject;
  	}
  
  	/**
  	 * Do the work after everything is specified.
  	 * <!-- begin-user-doc -->
  	 * <!-- end-user-doc -->
  	 * @generated
  	 */
  	@Override
  	public boolean performFinish() {
  		try {
  			// Remember the file.
  			//
  			final IFile modelFile = getModelFile();
  
  			// Do the work within an operation.
  			//
  			WorkspaceModifyOperation operation =
  				new WorkspaceModifyOperation() {
  					@Override
  					protected void execute(IProgressMonitor progressMonitor) {
  						try {
  							// Create a resource set
  							//
  							ResourceSet resourceSet = new ResourceSetImpl();
  
  							// Get the URI of the model file.
  							//
  							URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true);
  
  							// Create a resource for this file.
  							//
  							Resource resource = resourceSet.createResource(fileURI);
  
  							// Add the initial model object to the contents.
  							//
  							EObject rootObject = createInitialModel();
  							if (rootObject != null) {
  								resource.getContents().add(rootObject);
  							}
  
  							// Save the contents of the resource to the file system.
  							//
  							Map<Object, Object> options = new HashMap<Object, Object>();
  							options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding());
  							resource.save(options);
  						}
  						catch (Exception exception) {
  							JBossSapJcaEditorPlugin.INSTANCE.log(exception);
  						}
  						finally {
  							progressMonitor.done();
  						}
  					}
  				};
  
  			getContainer().run(false, false, operation);
  
  			// Select the new file resource in the current view.
  			//
  			IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
  			IWorkbenchPage page = workbenchWindow.getActivePage();
  			final IWorkbenchPart activePart = page.getActivePart();
  			if (activePart instanceof ISetSelectionTarget) {
  				final ISelection targetSelection = new StructuredSelection(modelFile);
  				getShell().getDisplay().asyncExec
  					(new Runnable() {
  						 public void run() {
  							 ((ISetSelectionTarget)activePart).selectReveal(targetSelection);
  						 }
  					 });
  			}
  
  			// Open an editor on the new file.
  			//
  			try {
  				page.openEditor
  					(new FileEditorInput(modelFile),
  					 workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId());					 	 
  			}
  