當前位置: 首頁>>代碼示例>>Java>>正文


Java Display.syncExec方法代碼示例

本文整理匯總了Java中org.eclipse.swt.widgets.Display.syncExec方法的典型用法代碼示例。如果您正苦於以下問題:Java Display.syncExec方法的具體用法?Java Display.syncExec怎麽用?Java Display.syncExec使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.swt.widgets.Display的用法示例。


在下文中一共展示了Display.syncExec方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: stop

import org.eclipse.swt.widgets.Display; //導入方法依賴的package包/類
@Override
public void stop ()
{
    if ( !PlatformUI.isWorkbenchRunning () )
    {
        return;
    }
    final IWorkbench workbench = PlatformUI.getWorkbench ();
    final Display display = workbench.getDisplay ();
    display.syncExec ( new Runnable () {
        @Override
        public void run ()
        {
            if ( !display.isDisposed () )
            {
                workbench.close ();
            }
        }
    } );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:21,代碼來源:Application.java

示例2: messageBoxWithoutReturnCode

import org.eclipse.swt.widgets.Display; //導入方法依賴的package包/類
private static void messageBoxWithoutReturnCode(final String message, int options) {
	final Display display = getDisplay();
	
	Runnable runnable = new Runnable() {
		public void run() {
			try {
				messageBox(null, message, SWT.OK | SWT.ICON_INFORMATION);
			}
			catch (Exception e){
				ConvertigoPlugin.logException(e, "Error while trying to open message box");
			}
		};
	};
	
	if (display.getThread() != Thread.currentThread()) {
		display.asyncExec(runnable);		
	} else {
		display.syncExec(runnable);
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:21,代碼來源:ConvertigoPlugin.java

示例3: stop

import org.eclipse.swt.widgets.Display; //導入方法依賴的package包/類
@Override
public void stop() {
	final IWorkbench workbench = PlatformUI.getWorkbench();
	if (workbench == null)
		return;
	final Display display = workbench.getDisplay();
	display.syncExec(new Runnable() {
		@Override
		public void run() {
			if (!display.isDisposed())
				workbench.close();
		}
	});
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:15,代碼來源:N4JSApplication.java

示例4: stop

import org.eclipse.swt.widgets.Display; //導入方法依賴的package包/類
public void stop() {
	if (!PlatformUI.isWorkbenchRunning())
		return;
	final IWorkbench workbench = PlatformUI.getWorkbench();
	final Display display = workbench.getDisplay();
	display.syncExec(new Runnable() {
		public void run() {
			if (!display.isDisposed())
				workbench.close();
		}
	});
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:13,代碼來源:Application.java

示例5: loadAncestor

import org.eclipse.swt.widgets.Display; //導入方法依賴的package包/類
private void loadAncestor(IFile file) {
	Display display = Display.getCurrent();
	Runnable longJob = new Runnable() {
		public void run() {
			display.syncExec(new Runnable() {
				public void run() {
					ancestors = JDTManager.findAvailableExecutionContextAncestors(file);
				}
			});
			display.wake();
		}
	};
	BusyIndicator.showWhile(display, longJob);

}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:16,代碼來源:ExecutionContextSelectionUIPage.java

示例6: loadVertices

import org.eclipse.swt.widgets.Display; //導入方法依賴的package包/類
/**
 * 
 */
private void loadVertices() {
	Display display = Display.getCurrent();
	Runnable longJob = new Runnable() {
		public void run() {
			display.syncExec(new Runnable() {
				public void run() {
					IFile ifile = ResourceManager.toIFile(selection);
					String modelFileName = null;

					try {
						modelFileName = ResourceManager.getAbsolutePath(ifile);
						context = GraphWalkerFacade.getContext(modelFileName);
						updateUI();
					} catch (Exception e) {
						ResourceManager.logException(e);
						JUnitGW4ETestUIPage.this.setErrorMessage(
								"Unable to load the graph model. See error logs in the Error View.");
						return;
					}

					comboReachedVertexViewer.setInput(_loadVertices(context));
				}
			});
			display.wake();
		}
	};
	BusyIndicator.showWhile(display, longJob);
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:32,代碼來源:JUnitGW4ETestUIPage.java

示例7: loadAncestor

import org.eclipse.swt.widgets.Display; //導入方法依賴的package包/類
private void loadAncestor(IFile file) {
	Display display = Display.getCurrent();
	Runnable longJob = new Runnable() {
		public void run() {
			display.syncExec(new Runnable() {
				public void run() {
					ancestors = JDTManager.findAvailableExecutionContextAncestors(file);
				}
			});
			display.wake();
		}
	};
	BusyIndicator.showWhile(display, longJob);
	 
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:16,代碼來源:GeneratorChoiceComposite.java

示例8: loadBuildPolicies

import org.eclipse.swt.widgets.Display; //導入方法依賴的package包/類
/**
 * 
 */
public void loadBuildPolicies() {
	Display display = Display.getCurrent();
	Runnable longJob = new Runnable() {
		public void run() {
			display.syncExec(new Runnable() {
				public void run() {
					List<BuildPolicy> policies;
					try {
						if (file!=null) {
							policies = BuildPolicyManager.getBuildPolicies(file, false);
						} else {
							policies = new ArrayList<BuildPolicy>();
						}
					} catch (Exception e) {
						// DialogManager.displayErrorMessage(MessageUtil.getString("error"), e.getMessage(),e);
						// throw new RuntimeException(e);
						policies = new ArrayList<BuildPolicy>();
					}
					BuildPolicy[] input = policies.stream().filter(item -> !item.hasTimeDuratioStopCondition())
							.toArray(BuildPolicy[]::new);
					setInput(input);
				}
			});
			display.wake();
		}
	};
	BusyIndicator.showWhile(display, longJob);
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:32,代碼來源:BuildPoliciesCheckboxTableViewer.java

示例9: getSWTImage

import org.eclipse.swt.widgets.Display; //導入方法依賴的package包/類
private Image getSWTImage() {
	Shell shell = getShell();
	final Display display;
	if (shell == null || shell.isDisposed()) {
		shell = getParentShell();
	}
	if (shell == null || shell.isDisposed()) {
		display = Display.getCurrent();
		// The dialog should be always instantiated in UI thread.
		// However it was possible to instantiate it in other threads
		// (the code worked in most cases) so the assertion covers
		// only the failing scenario. See bug 107082 for details.
		Assert.isNotNull(display,
				"The dialog should be created in UI thread"); //$NON-NLS-1$
	} else {
		display = shell.getDisplay();
	}

	final Image[] image = new Image[1];
	display.syncExec(new Runnable() {
		public void run() {
			image[0] = display.getSystemImage(SWT.ICON_QUESTION);
		}
	});

	return image[0];

}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:29,代碼來源:SaveJobFileBeforeRunDialog.java

示例10: subInvoke

import org.eclipse.swt.widgets.Display; //導入方法依賴的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();
    }
}
 
開發者ID:baloise,項目名稱:eZooKeeper,代碼行數:43,代碼來源:SwtThreadSafeDelegatingInvocationHandler.java

示例11: sync

import org.eclipse.swt.widgets.Display; //導入方法依賴的package包/類
public static void sync(@Nullable Display display, Runnable task) {
	if(display == null) display = getDisplay(); display.syncExec(task);
}
 
開發者ID:nextopcn,項目名稱:xcalendar,代碼行數:4,代碼來源:SwtUtils.java

示例12: ShellSlider

import org.eclipse.swt.widgets.Display; //導入方法依賴的package包/類
/**
 * Slide In
 *
 * @param shell
 * @param direction
 * @param endBounds
 */
public ShellSlider(final Shell shell, int direction, final Rectangle endBounds) {
	this.shell = shell;
	this.endBounds = endBounds;
	this.slideIn = true;
	this.direction = direction;

	if (shell == null || shell.isDisposed())
		return;

	Display display = shell.getDisplay();
	display.syncExec(new Runnable() {
		@Override
		public void run() {
			if (shell.isDisposed())
				return;

			switch (ShellSlider.this.direction) {
				case SWT.UP:
				default:
					shell.setLocation(endBounds.x, endBounds.y);
					Rectangle displayBounds = null;
					try {
						boolean ok = false;
						Monitor[] monitors = shell.getDisplay().getMonitors();
						for (int i = 0; i < monitors.length; i++) {
							Monitor monitor = monitors[i];
							displayBounds = monitor.getBounds();
							if (displayBounds.contains(endBounds.x, endBounds.y)) {
								ok = true;
								break;
							}
						}
						if (!ok) {
							displayBounds = shell.getMonitor().getBounds();
						}
					} catch (Throwable t) {
						displayBounds = shell.getDisplay().getBounds();
					}

					shellBounds = new Rectangle(endBounds.x, displayBounds.y
							+ displayBounds.height, endBounds.width, 0);
					break;
			}
			shell.setBounds(shellBounds);
			shell.setVisible(true);

			if (DEBUG)
				System.out.println("Slide In: " + shell.getText());
		}
	});
}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:59,代碼來源:ShellSlider.java


注:本文中的org.eclipse.swt.widgets.Display.syncExec方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。