com.teamdev.xpcom
Class Xpcom

java.lang.Object
  extended by com.teamdev.xpcom.Xpcom

public final class Xpcom
extends java.lang.Object

Main access point to the XPCOM bridge.

See Also:
DefaultLocationProvider

Nested Class Summary
static class Xpcom.Toolkit
          Deprecated. 
 
Field Summary
static Xpcom.Toolkit AWT
          Deprecated. 
 
Constructor Summary
Xpcom()
           
 
Method Summary
static void initialize()
          Initialize XPCOM embedding with default profile directory.
static void initialize(org.mozilla.xpcom.IAppFileLocProvider locProvider)
          Initialize XPCOM embedding with custom IAppFileLocProvider implementation and custom profile directory.
static void initialize(Xpcom.Toolkit toolkit)
          Deprecated. initialize instead
static void invokeAndWait(java.lang.Runnable runnable)
          Execute a runnable in the event processing thread and wait for it to finish.
static void invokeLater(java.lang.Runnable runnable)
          Schedule a runnable to run in the event processing thread at some point after the current line of code.
static void invokeLater(java.lang.Runnable runnable, AsyncHandlerFactory handlerFactory)
          Schedule a runnable to run in the event processing thread at some point after the current line of code.
static boolean isEventDispatchThread()
           
static boolean isInitialized()
          Returns whether the XPCOM embedding has been initialized.
static boolean isJDK5()
          Returns true when the current Java Runtime Environment version is 1.5, otherwise false.
static boolean isJDK6()
          Returns true when the current Java Runtime Environment version is 1.6, otherwise false.
static boolean isJVMValid()
           
static boolean isLinux()
          Check whether the application is running on a Linux platform.
static boolean isMacOSX()
          Check whether the application is running on a MacOS X platform.
static boolean isSilentMode()
           
static boolean isWindows()
          Check whether the application is running on a Windows platform.
static void lock()
          Lock current thread before call of unlock() method from another thread.
static boolean runOneMessageLoopIteration()
          Execute a platform-specific message processing loop iteration.
static AsyncHandlerFactory setGlobalAsyncHandler(AsyncHandlerFactory handlerFactory)
          Defines global asynchronous execution handler facility.
static void setNextCallAsyncHandler(AsyncHandlerFactory handlerFactory)
          Define a one-shot asynchronous execution handler.
static void setSilentMode(boolean silentMode)
          Set/unsent silent mode Silent mode is mode without popup boxes including - Java Script alerts, confirmation, prompt and authentication dialogs.
static AsyncHandlerFactory setThreadAsyncHandler(AsyncHandlerFactory handlerFactory)
          Defines asynchronous execution handler facility for this thread.
static void unlock()
          Unlock thread that was locked by lock()
Sample:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AWT

@Deprecated
public static final Xpcom.Toolkit AWT
Deprecated. 
Constructor Detail

Xpcom

public Xpcom()
Method Detail

initialize

@Deprecated
public static void initialize(Xpcom.Toolkit toolkit)
Deprecated. initialize instead

Initialize XPCOM embedding with default IAppFileLocProvider implementation and profile directory. The XPCOM system can be initialized for either AWT/Swing or SWT UI. Attempts to re-initialize the bridge for different UI toolkit will result in exception.

Parameters:
toolkit - a UI toolkit to initialize for.

initialize

public static void initialize()
Initialize XPCOM embedding with default profile directory. The XPCOM system can be initialized for either AWT/Swing or SWT UI. Attempts to re-initialize the bridge for different UI toolkit will result in exception.

If the XPCOM is already initialized than this method do nothing.

See Also:
isInitialized()

initialize

public static void initialize(org.mozilla.xpcom.IAppFileLocProvider locProvider)
Initialize XPCOM embedding with custom IAppFileLocProvider implementation and custom profile directory. The XPCOM system can be initialized for either AWT/Swing or SWT UI. Attempts to re-initialize the bridge for different UI toolkit will result in exception.

Parameters:
locProvider - custom implementation of IAppFileLocProvider

isInitialized

public static boolean isInitialized()
Returns whether the XPCOM embedding has been initialized.


isWindows

public static boolean isWindows()
Check whether the application is running on a Windows platform.


isMacOSX

public static boolean isMacOSX()
Check whether the application is running on a MacOS X platform.


isLinux

public static boolean isLinux()
Check whether the application is running on a Linux platform.


isJDK5

public static boolean isJDK5()
Returns true when the current Java Runtime Environment version is 1.5, otherwise false.

Returns:
true when the current Java Runtime Environment version is 1.5, otherwise false
See Also:
isJDK6()

isJDK6

public static boolean isJDK6()
Returns true when the current Java Runtime Environment version is 1.6, otherwise false.

Returns:
true when the current Java Runtime Environment version is 1.6, otherwise false
See Also:
isJDK5()

isJVMValid

public static boolean isJVMValid()

invokeLater

public static void invokeLater(java.lang.Runnable runnable)
Schedule a runnable to run in the event processing thread at some point after the current line of code. The calling code is not notified of the result of execution.

Parameters:
runnable - the Runnable whose run method should be executed asynchronously in the event processing thread

invokeLater

public static void invokeLater(java.lang.Runnable runnable,
                               AsyncHandlerFactory handlerFactory)
Schedule a runnable to run in the event processing thread at some point after the current line of code. Asynchronous execution handler will be used to monitor execution.

Parameters:
runnable - the Runnable whose run method should be executed asynchronously in the event processing thread
handlerFactory - a handler to wrap execution of the runnable

setGlobalAsyncHandler

public static AsyncHandlerFactory setGlobalAsyncHandler(AsyncHandlerFactory handlerFactory)
Defines global asynchronous execution handler facility.

Parameters:
handlerFactory - new factory
Returns:
old factory

setThreadAsyncHandler

public static AsyncHandlerFactory setThreadAsyncHandler(AsyncHandlerFactory handlerFactory)
Defines asynchronous execution handler facility for this thread.

Parameters:
handlerFactory - new factory
Returns:
old factory

setNextCallAsyncHandler

public static void setNextCallAsyncHandler(AsyncHandlerFactory handlerFactory)
Define a one-shot asynchronous execution handler. This handler will be used for the very first case of Xpcom.invokeLater() in the current thread. This may lead to unexpected results if the code, that follows this method changes.

Parameters:
handlerFactory - one-shot handler factory

invokeAndWait

public static void invokeAndWait(java.lang.Runnable runnable)
Execute a runnable in the event processing thread and wait for it to finish. The calling code does not continue execution until the runnable completes. If a call to this method is performed in the event processing thread the runnable is simply run withing this function.

Parameters:
runnable - the Runnable whose run method should be executed synchronously in the event processing thread

runOneMessageLoopIteration

public static boolean runOneMessageLoopIteration()
Execute a platform-specific message processing loop iteration. WARING: Mac implementation alway returns true

Returns:
true if there is potentially more work to do, false if the caller can sleep upon return from this method

isEventDispatchThread

public static boolean isEventDispatchThread()

lock

public static void lock()
Lock current thread before call of unlock() method from another thread.
Sample
 volatile boolean canUnlock = false;
 Xpcom.invokeLater(new Runnable() {
     public void run()
     {
         canUnlock = true;
         Xpcom.unlock();
     }
 });
 while (!canUnlock)
 {
     Xpcom.unlock();
 }
 


unlock

public static void unlock()
Unlock thread that was locked by lock()
Sample:
 volatile boolean canUnlock = false;
 Xpcom.invokeLater(new Runnable() {
     public void run()
     {
         canUnlock = true;
         Xpcom.unlock();
     }
 });
 while (!canUnlock)
 {
     Xpcom.unlock();
 }
 


setSilentMode

public static void setSilentMode(boolean silentMode)
Set/unsent silent mode Silent mode is mode without popup boxes including - Java Script alerts, confirmation, prompt and authentication dialogs. By default silent mode not used.

Parameters:
silentMode - whether silent mode should be used

isSilentMode

public static boolean isSilentMode()
Returns:
silent mode state
See Also:
setSilentMode(boolean)