javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/graphics/Utils.java
changeset 21 2a9601315dfc
child 35 85266cc22c7f
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     1 /*******************************************************************************
       
     2  * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     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  *     Nokia Corporation - initial implementation
       
    10  *******************************************************************************/
       
    11 package org.eclipse.swt.internal.qt.graphics;
       
    12 
       
    13 import org.eclipse.swt.widgets.Display;
       
    14 
       
    15 /** 
       
    16  * Class for general utilities for common graphics
       
    17  */
       
    18 final class Utils {
       
    19 	
       
    20 	/**
       
    21 	 * Validates that ui thread is created and execution is 
       
    22 	 * currently in ui thread.
       
    23 	 * 
       
    24 	 * @throws java.lang.Error if ui thread is not initialized or 
       
    25 	 * this method is not called within ui thread.
       
    26 	 */
       
    27 	static void validateUiThread() {
       
    28 		if (!Config.ENABLE_UI_THREAD_VALIDATION) {
       
    29 			return;
       
    30 		}
       
    31 		if (Display.getCurrent() == null) {
       
    32 			throw new Error("Ui thread not initialized or call was made outside ui thread");
       
    33 		} else {
       
    34 			Display display = Display.getCurrent();
       
    35 			if (Thread.currentThread() != display.getThread()) {
       
    36 				throw new Error("Call to common graphics object occured outside ui thread");
       
    37 			}
       
    38 		}
       
    39 	}
       
    40 
       
    41 }