本文整理匯總了Java中org.eclipse.swt.widgets.Widget.isDisposed方法的典型用法代碼示例。如果您正苦於以下問題:Java Widget.isDisposed方法的具體用法?Java Widget.isDisposed怎麽用?Java Widget.isDisposed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.widgets.Widget
的用法示例。
在下文中一共展示了Widget.isDisposed方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkWidget
import org.eclipse.swt.widgets.Widget; //導入方法依賴的package包/類
public static boolean checkWidget(Observer<?> observer, Widget widget) {
if (null == widget) {
observer.onError(new NullPointerException("The given widget was null"));
return false;
} else if (widget.isDisposed()) {
observer.onError(new IllegalStateException("The given widget is diposed"));
return false;
} else if (!(Thread.currentThread().equals(widget.getDisplay().getThread()))) {
observer.onError(new IllegalStateException(
"Expected to be called on the main thread but was " + Thread.currentThread().getName()));
return false;
}
return true;
}
示例2: subInvoke
import org.eclipse.swt.widgets.Widget; //導入方法依賴的package包/類
@Override
protected Object subInvoke(Object proxy, Method method, Object[] args) throws Throwable {
Display currentDisplay = Display.getCurrent();
Display widgetDisplay = null;
Widget widget = getWidget();
if (widget != null) {
if (widget.isDisposed()) {
// System.err.println("ERROR: Invoking: " + method.getName() + " on Widget: " + widget +
// " which is disposed.");
return null;
}
widgetDisplay = widget.getDisplay();
}
if (currentDisplay == null && widgetDisplay == null) {
// The current thread is not a UI thread but no widget display was provided so...
return baseInvoke(proxy, method, args);
}
else if (currentDisplay != null && (widgetDisplay == null || currentDisplay == widgetDisplay)) {
// Current thread is the widget's UI thread (or at least *a* UI thread).
return baseInvoke(proxy, method, args);
}
else {
// Current thread is not the widget's UI thread.
IBaseInvokeRunnable runnable = createBaseInvokeRunnable(proxy, method, args);
if (isAsync()) {
widgetDisplay.asyncExec(runnable);
return null;
}
widgetDisplay.syncExec(runnable);
Throwable error = runnable.getError();
if (error != null) {
throw error;
}
return runnable.getResult();
}
}
示例3: dispose
import org.eclipse.swt.widgets.Widget; //導入方法依賴的package包/類
/**
* Disposes the widget argument. Has no effect if the widget argument is either {@code null} or already
* {@link Widget#isDisposed() disposed}.
*
* @param widget
* the widget to dispose. Optional, can be {@code null}.
*/
public static void dispose(final Widget widget) {
if (null != widget && !widget.isDisposed()) {
widget.dispose();
}
}