1 11 package org.eclipse.jdt.internal.ui; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.core.runtime.IProgressMonitor; 15 import org.eclipse.core.runtime.IStatus; 16 import org.eclipse.core.runtime.Status; 17 import org.eclipse.core.runtime.SubProgressMonitor; 18 import org.eclipse.core.runtime.jobs.Job; 19 20 import org.eclipse.ui.progress.UIJob; 21 22 import org.eclipse.jdt.core.JavaCore; 23 24 import org.eclipse.jdt.ui.JavaUI; 25 26 public class InitializeAfterLoadJob extends UIJob { 27 28 private final class RealJob extends Job { 29 public RealJob(String name) { 30 super(name); 31 } 32 protected IStatus run(IProgressMonitor monitor) { 33 monitor.beginTask("", 10); try { 35 JavaCore.initializeAfterLoad(new SubProgressMonitor(monitor, 6)); 36 JavaPlugin.initializeAfterLoad(new SubProgressMonitor(monitor, 4)); 37 } catch (CoreException e) { 38 JavaPlugin.log(e); 39 return e.getStatus(); 40 } 41 return new Status(IStatus.OK, JavaPlugin.getPluginId(), IStatus.OK, "", null); } 43 public boolean belongsTo(Object family) { 44 return JavaUI.ID_PLUGIN.equals(family); 45 } 46 } 47 48 public InitializeAfterLoadJob() { 49 super(JavaUIMessages.InitializeAfterLoadJob_starter_job_name); 50 setSystem(true); 51 } 52 public IStatus runInUIThread(IProgressMonitor monitor) { 53 Job job = new RealJob(JavaUIMessages.JavaPlugin_initializing_ui); 54 job.setPriority(Job.SHORT); 55 job.schedule(); 56 return new Status(IStatus.OK, JavaPlugin.getPluginId(), IStatus.OK, "", null); } 58 } | Popular Tags |