javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/common_j2se/org/eclipse/swt/internal/qt/UIThreadHandOverManager.java
author hgs
Fri, 15 Oct 2010 12:29:39 +0300
changeset 80 d6dafc5d983f
permissions -rw-r--r--
v2.2.19_1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
80
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
     1
/*******************************************************************************
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
     2
 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
     3
 * All rights reserved. This program and the accompanying materials
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
     4
 * are made available under the terms of the Eclipse Public License v1.0
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
     5
 * which accompanies this distribution, and is available at
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
     6
 * http://www.eclipse.org/legal/epl-v10.html
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
     7
 *
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
     8
 * Contributors:
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
     9
 *     Nokia Corporation - initial implementation
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    10
 *******************************************************************************/
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    11
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    12
package org.eclipse.swt.internal.qt;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    13
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    14
import org.eclipse.swt.internal.qt.midp.UIThreadLauncher;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    15
import org.eclipse.swt.widgets.Display;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    16
import org.eclipse.swt.widgets.Internal_PackageSupport;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    17
import org.eclipse.swt.widgets.Shell;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    18
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    19
/**
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    20
 * A class that manages the UI thread hand-over from the internal UI event 
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    21
 * loop to the application. 
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    22
 */
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    23
public final class UIThreadHandOverManager {
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    24
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    25
    /**
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    26
     * Called indirectly by the application when it's requesting the UI thread. 
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    27
     * Application will pass a Runnable as a parameter and expects it to get called
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    28
     * in the UI thread. 
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    29
     * 
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    30
     * @param runnable
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    31
     *            The Runnable to call in the UI thread.
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    32
     * @return True if obtaining the UI thread was successful and the runnable
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    33
     *         will be called.
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    34
     */
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    35
    public static boolean startInUIThread(Runnable runnable) {
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    36
        if(!UIThreadLauncher.startInUIThread(runnable)) {
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    37
            return false;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    38
        }
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    39
        
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    40
        return true;
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    41
    }
d6dafc5d983f v2.2.19_1
hgs
parents:
diff changeset
    42
}