1 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 33 public class JavaPackagePage extends ModelPackagePage 34 { 35 public JavaPackagePage(ModelImporter modelImporter, String 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 () 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 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 exception) 96 { 97 JavaImporterPlugin.INSTANCE.log(exception); 98 } 99 } 100 101 protected void computeEPackages(IProgressMonitor progressMonitor) throws Exception 102 { 103 IStatus status = getJavaImporter().computeEPackages(progressMonitor); 104 getJavaImporter().adjustEPackages(progressMonitor); 105 106 String message = JavaImporterPlugin.INSTANCE.getString("_UI_ProblemsEncounteredProcessingJava_message"); 107 handleStatus(status, message, JavaImporterPlugin.INSTANCE.getString("_UI_LoadProblem_title"), message); 108 } 109 } 110 | Popular Tags |