KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > importer > ui > EMFProjectWizard


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2005 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: EMFProjectWizard.java,v 1.6 2005/06/09 21:39:37 marcelop Exp $
16  */

17 package org.eclipse.emf.importer.ui;
18
19 import java.util.List JavaDoc;
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 /**
34  * @since 2.1.0
35  */

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 JavaDoc 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