KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > InitializeAfterLoadJob


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 JavaDoc name) {
30             super(name);
31         }
32         protected IStatus run(IProgressMonitor monitor) {
33             monitor.beginTask("", 10); //$NON-NLS-1$
34
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); //$NON-NLS-1$
42
}
43         public boolean belongsTo(Object JavaDoc 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); //$NON-NLS-1$
57
}
58 }
Popular Tags