KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > importer > java > ui > JavaPackagePage


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: JavaPackagePage.java,v 1.7 2005/06/09 14:52:31 davidms Exp $
16  */

17 package org.eclipse.emf.importer.java.ui;
18
19 import org.eclipse.core.runtime.CoreException;
20 import org.eclipse.core.runtime.IProgressMonitor;
21 import org.eclipse.core.runtime.IStatus;
22 import org.eclipse.ui.actions.WorkspaceModifyOperation;
23
24 import org.eclipse.emf.importer.ModelImporter;
25 import org.eclipse.emf.importer.java.JavaImporter;
26 import org.eclipse.emf.importer.java.JavaImporterPlugin;
27 import org.eclipse.emf.importer.ui.contribution.base.ModelPackagePage;
28
29
30 /**
31  * @since 2.1.0
32  */

33 public class JavaPackagePage extends ModelPackagePage
34 {
35   public JavaPackagePage(ModelImporter modelImporter, String JavaDoc pageName)
36   {
37     super(modelImporter, pageName);
38
39     setDescription(JavaImporterPlugin.INSTANCE.getString("_UI_PackageSelection_description"));
40
41   }
42
43   public JavaImporter getJavaImporter()
44   {
45     return (JavaImporter)getModelImporter();
46   }
47
48   protected void pageActivated(final boolean firstTime, int cause)
49   {
50     if (getJavaImporter().canImport())
51     {
52       setErrorMessage(null);
53       getControl().getDisplay().asyncExec(new Runnable JavaDoc()
54         {
55           public void run()
56           {
57             computeEPackages();
58             filterPackagesTable(firstTime);
59             getContainer().updateButtons();
60           }
61         });
62     }
63     else
64     {
65       setErrorMessage(JavaImporterPlugin.INSTANCE.getString("_UI_JavaProjectRequired_message"));
66       setPageComplete(false);
67     }
68   }
69
70   protected void computeEPackages()
71   {
72     WorkspaceModifyOperation initializeOperation = new WorkspaceModifyOperation()
73       {
74         protected void execute(IProgressMonitor progressMonitor) throws CoreException
75         {
76           try
77           {
78             computeEPackages(progressMonitor);
79           }
80           catch (Exception JavaDoc e)
81           {
82             JavaImporterPlugin.INSTANCE.log(e);
83           }
84           finally
85           {
86             progressMonitor.done();
87           }
88         }
89       };
90
91     try
92     {
93       getContainer().run(false, false, initializeOperation);
94     }
95     catch (Exception JavaDoc exception)
96     {
97       JavaImporterPlugin.INSTANCE.log(exception);
98     }
99   }
100
101   protected void computeEPackages(IProgressMonitor progressMonitor) throws Exception JavaDoc
102   {
103     IStatus status = getJavaImporter().computeEPackages(progressMonitor);
104     getJavaImporter().adjustEPackages(progressMonitor);
105     
106     String JavaDoc message = JavaImporterPlugin.INSTANCE.getString("_UI_ProblemsEncounteredProcessingJava_message");
107     handleStatus(status, message, JavaImporterPlugin.INSTANCE.getString("_UI_LoadProblem_title"), message);
108   }
109 }
110
Popular Tags