本文整理汇总了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();
}
}