`
子衿青青
  • 浏览: 106128 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Eclipse的Display

阅读更多

org.eclipse.swt.widgets
    Class Display extends Device

   DIsplay提供足够的方法去访问有关操作系统的信息,还全面管理SWT占用的操作系统资源。

   start()方法

	public Object start(IApplicationContext context) throws Exception {
		Display display = PlatformUI.createDisplay();
		try {
			int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
			if (returnCode == PlatformUI.RETURN_RESTART)
				return IApplication.EXIT_RESTART;
			else
				return IApplication.EXIT_OK;
		} finally {
			display.dispose();
		}
	}

   

   stop()方法

	public void stop() {
		final IWorkbench workbench = PlatformUI.getWorkbench();
		if (workbench == null)
			return;
		final Display display = workbench.getDisplay();
		display.syncExec(new Runnable() {
			public void run() {
				if (!display.isDisposed())
					workbench.close();
			}
		});
	}

 

该类的实例[Instance]负责管理SWT与底层操作系统之间的连接[connection]。它最重要的功能是根据底层平台的事件模型[event model]实现SWT的事件循环机制[the SWT enevt loop]。

 

基于SWT的应用程序几乎总是只需要单一一个display对象。特别的,有些SWT支持的平台[platform],不允许多于一个的DIsplay对象存在。换句话说,如果一个Display对象存在,并且没有收到 dispose() 消息,这些平台不支持创建一个新的Display对象。

 

在SWT里,创建一个Display实例的线程[thread ],被称为这个实例的user-interface thread 。

display的user-interface thread 有以下特殊的属性:

1 display的事件循环必须从这个 thread 运行。
2 一些SWT API方法(Widget及其子类的大部分方法),只可以被这个thread调用。为了支持多线程用户接口应用程序,display类提供了内部类交互方法,允许包括用户接口线程在内的线程来请求他们要执行得操作。(为了支持multi-threaded user-interface 的应用程序,class Display provides inter-thread communication methods which allow threads other than the user-interface thread to request that it perform operations on their behalf.)
3 在display被dispose之前,thread不允许创建其他的display。(Note that, this is in addition to the restriction mentioned above concerning platform support for multiple displays. Thus, the only way to have multiple simultaneously active displays, even on platforms which support it, is to have multiple threads.)

强制这些属性,允许SWT可以直接由底层操作系统的事件模型实现。这样有很多好处,包括更小的footprint,更优化的资源利用,更安全的内存管理,更清晰的层需逻辑,更优的性能,和需要更少的操作系统线程。The down side however, is that care must be taken (only) when constructing multi-threaded applications to use the inter-thread communication mechanisms which this class provides when required.

 

所有只可以从 user-interface thread 被调用的SWT API方法,在文档里很有名,因为他们指出他们会抛出"ERROR_THREAD_INVALID_ACCESS" SWT 异常。

分享到:
评论

相关推荐

    jd-eclipse-site-1.0.0-RC2.zip、jd-eclipse-2.0.0.zip

    It allows you to display all the Java sources during your debugging process, even if you do not have them all. Installation Download JD-Eclipse ZIP file, Launch Eclipse, Click on "Help > Install New ...

    org.eclipse.swt.win32

    org.eclipse.swt.SWT.class org.eclipse.swt.SWTError.class org.eclipse.swt.SWTException.class org.eclipse.swt.accessibility.ACC.class org.eclipse.swt.accessibility.Accessible.class org.eclipse.swt....

    Eclipse 4 Plug-in Development by Example: Beginner's Guide

    How to display tree and table information in views What are the specific differences between the Eclipse 3.x model and the Eclipse 4.x model How and when to build user interfaces from SWT and JFace...

    m2maven is a plugin for maven

    This should display the "Install" dialog. Paste the Update Site URL into the field named "Work with:" and press Enter. Pressing Enter should cause Eclipse to update list of available plugins and ...

    java反编译工具JD-Eclipse+JD-GUI

    It allows you to display all the Java sources during your debugging process, even if you do not have them all. JD-Eclipse is free for non-commercial use. This means that JD-Eclipse shall not be ...

    displaytag的使用 eclipse工程

    displaytag官方实例,改装成一个eclipse工程 适合初学者

    Eclipse RCP Plugin 开发自学入门指南(CEC首发)

    Eclipse Rich Client Application 开发自学教程 For The Eclipser salever 2011-3-28 根据最新版本的Eclipse 3.6 重新编写,每章都可独立于其他章节,内附的代码均可直接运行, 适合Eclipse 开发者参考。 声明...

    Eclipse RCP详细教程

    16.3.获得display 122 16.4.使用eclipse的“保存”action 123 16.5.装载模型 127 16.6.向你的程序添加错误日志视口 127 17.制造一个产品 129 17.1.概述 129 17.2.创建一个工程 130 17.3.测试你的产品...

    System Variables Display Eclipse Plugin-开源

    Eclipse插件3.0,允许将视图添加到“环境变量”和“ Java属性”列表中。

    Eclipse_Swt_Jface_核心应用_部分19

    1.3 Eclipse的诞生 3 1.4 Eclipse贡献SWT工具包 5 1.4.1 SWT的结构 6 1.4.2 SWT所支持的操作系统 6 1.5 Sun AWT/Swing与Eclipse SWT 7 1.5.1 Swing与SWT的比较 7 1.5.2 SWT的优势和不足 8 1.6 SWT与...

    Eclipse RCP Plug-in开发自学教程(Eclipse3.6)

    本教程素材来源于网络,经过本人的整理、添加以及部分的重写,将原有的Eclipse3.3版本的一些内容完全迁移到Eclipse3.6版本上来。基于开源以及分享的精神,特地将教程分享到网络上,希望所有需要的朋友因此而受益,也...

    arcgis for android 100.2 库文件 可在eclipse下导入使用

    arcgis for android 100.2 库文件 可在eclipse下导入使用,包含三维图层

    m2maven 插件

    This should display the "Install" dialog. Paste the Update Site URL into the field named "Work with:" and press Enter. Pressing Enter should cause Eclipse to update list of available plugins and ...

    eclipse-testng 离线包下载

    eclipse-testng 离线包 xmlns:math="http://exslt.org/math" xmlns:testng="http://testng.org"> indent="yes" omit-xml-declaration="yes" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" ...

    jd-gui-windows-1.6.6

    JD-GUI是一款反编译软件,JD分为JD-GUI、... It allows you to display all the Java sources during your debugging process, even if you do not have them all. JD-Core is a library that reconstructs Java sourc

    wso2esb-tooling-composite-p2-5.0.0.zip

    官网下载,Eclipse插件:WSO2 ESB tooling,适配WSO2 ESB 5.0.0。 仅 Eclipse Mars.2 Release (4.5.2) 版本可使用(我用的是...WSO2官网教程:https://docs.wso2.com/display/ESB500/Installing+WSO2+ESB+Tooling

    j2me手机程序eclipse开发基---snake

    这个是一个贪吃蛇的源代码。... display = Display.getDisplay(this); // 获得Displayable Displayable current = display.getCurrent(); if (current == null) { // 装载logo图象 Image logo = null;

    开发项目用SWING与RCP与SWT.JFACE的分析

    首先要在Eclipse安装文件中找到SWT包,Eclipse组织并不提供单独的SWT包下载,必须下载完整的Eclipse开发环境才能得到SWT包。SWT是作为Eclipse开发环境的一个插件形式存在,可以在${你的eclipse安装路径}\plugins...

    J2ME移动开发环境配置教程

    eclipse-SDK-3.1 或 eclipse-SDK-3.0.x eclipseme.feature_0.9.2_site 2.安装jdk并配置环境变量 按照JDK的提示来安装,安装完之后设置环境变量 假设我们的jdk安装在d:\jdk-1_5_0_04 JAVA_HOME =d:\jdk-1_5_0_04 ...

Global site tag (gtag.js) - Google Analytics