1 17 package org.eclipse.emf.importer.ui; 18 19 import java.util.List ; 20 21 import org.eclipse.core.runtime.IPath; 22 import org.eclipse.core.runtime.Platform; 23 import org.eclipse.jface.resource.ImageDescriptor; 24 import org.eclipse.ui.dialogs.WizardNewProjectCreationPage; 25 26 import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry; 27 import org.eclipse.emf.importer.ImporterPlugin; 28 import org.eclipse.emf.importer.ui.contribution.IModelImporterWizard; 29 import org.eclipse.emf.importer.ui.contribution.ModelImporterDescriptor; 30 import org.eclipse.emf.importer.ui.contribution.ModelImporterUtil; 31 32 33 36 public class EMFProjectWizard extends EMFModelWizard 37 { 38 protected IPath projectLocation; 39 protected IPath projectPath; 40 41 public EMFProjectWizard() 42 { 43 super(); 44 setWindowTitle(ImporterPlugin.INSTANCE.getString("_UI_EMFProjectWizard_title")); 45 } 46 47 protected ImageDescriptor getDefaultImageDescriptor() 48 { 49 return ExtendedImageRegistry.INSTANCE.getImageDescriptor(ImporterPlugin.INSTANCE.getImage("full/wizban/NewEMFProject")); 50 } 51 52 public void addPages() 53 { 54 WizardNewProjectCreationPage newProjectCreationPage = new WizardNewProjectCreationPage("NewProjectCreationPage") 55 { 56 protected boolean validatePage() 57 { 58 if (super.validatePage()) 59 { 60 IPath locationPath = getLocationPath(); 61 projectLocation = Platform.getLocation().equals(locationPath) ? null : locationPath; 62 projectPath = getProjectHandle().getFullPath(); 63 return true; 64 } 65 else 66 { 67 return false; 68 } 69 } 70 }; 71 newProjectCreationPage.setTitle(ImporterPlugin.INSTANCE.getString("_UI_EMFProjectWizard_name")); 72 newProjectCreationPage.setDescription(ImporterPlugin.INSTANCE.getString("_UI_CreateEMFProject_label")); 73 addPage(newProjectCreationPage); 74 75 SelectionPage selectionPage = new SelectionPage("ModelImporterDescriptorSelectionPage"); 76 selectionPage.setTitle(ImporterPlugin.INSTANCE.getString("_UI_SelectModelImporters_title")); 77 addPage(selectionPage); 78 } 79 80 protected List getModelImporterDescriptors() 81 { 82 return ModelImporterUtil.filterModelImporterDescriptors(ModelImporterDescriptor.TYPE_PROJECT); 83 } 84 85 protected void adjustModelImporterWizard(IModelImporterWizard modelImporterWizard, ModelImporterDescriptor modelImporterDescriptor) 86 { 87 super.adjustModelImporterWizard(modelImporterWizard, modelImporterDescriptor); 88 89 if (isValidNewValue(projectLocation, modelImporterWizard.getGenModelProjectLocation())) 90 { 91 modelImporterWizard.setGenModelProjectLocation(projectLocation); 92 } 93 if (isValidNewValue(projectPath, modelImporterWizard.getGenModelProjectPath())) 94 { 95 modelImporterWizard.setGenModelProjectPath(projectPath); 96 } 97 } 98 } 99 | Popular Tags |