blob: 3de397560f66ffebb4622e6bd49b301183fa012b [file] [log] [blame]
/******************************************************************************
* Copyright (c) 2010 Oracle
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* Contributors:
* Konstantin Komissarchik - initial implementation and ongoing maintenance
******************************************************************************/
package org.eclipse.wst.common.project.facet.ui.internal.util;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
/**
* @author <a href="mailto:konstantin.komissarchik@oracle.com">Konstantin Komissarchik</a>
*/
public final class SwtUtil
{
public static final int getPreferredWidth( final Control control )
{
return control.computeSize( SWT.DEFAULT, SWT.DEFAULT ).x;
}
public static void runOnDisplayThread( final Display display,
final Runnable runnable )
{
if( display.getThread() == Thread.currentThread() )
{
runnable.run();
}
else
{
display.asyncExec( runnable );
}
}
}