KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > internal > base > DisplayUtils


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.help.internal.base;
12
13 import java.lang.reflect.*;
14
15 import org.eclipse.core.runtime.*;
16 import org.osgi.framework.*;
17
18 /**
19  * Utility class to control SWT Display and event loop run in
20  * org.eclipse.help.ui plug-in
21  */

22 public class DisplayUtils {
23     private static final String JavaDoc HELP_UI_PLUGIN_ID = "org.eclipse.help.ui"; //$NON-NLS-1$
24
private static final String JavaDoc LOOP_CLASS_NAME = "org.eclipse.help.ui.internal.HelpUIEventLoop"; //$NON-NLS-1$
25

26     static void runUI() {
27         invoke("run"); //$NON-NLS-1$
28
}
29     static void wakeupUI() {
30         invoke("wakeup"); //$NON-NLS-1$
31
}
32
33     static void waitForDisplay() {
34         invoke("waitFor"); //$NON-NLS-1$
35
}
36
37     private static void invoke(String JavaDoc method) {
38         try {
39             Bundle bundle = Platform.getBundle(HELP_UI_PLUGIN_ID);
40             if (bundle == null) {
41                 return;
42             }
43             Class JavaDoc c = bundle.loadClass(LOOP_CLASS_NAME);
44             Method m = c.getMethod(method, new Class JavaDoc[]{});
45             m.invoke(null, new Object JavaDoc[]{});
46         } catch (Exception JavaDoc e) {
47         }
48     }
49 }
50
Popular Tags