Every Eclipse plugin developer has to deal with Shell and Window, but
sometimes doesn't understand the difference between these two. In this
tip, I'm trying to explain the basic things: Display, Shell, Window,
Dialog, Workbench, WorkbenchPart, WorkbenchSite and WorkbenchPage.
Yeah, I know, its probably the boring post you can read in this blog,
if you are little bit experienced in these areas.
This
class is the link between SWT and the underlying OS. It manages the
interaction between widgets and the OS. The primary task for this class
is to maintain the event loop (readAndDispatch()
).
Unless you are writing a plain SWT app, you won't be using that. The
most common methods you would be using in this class are asyncExec()
, syncExec()
and timerExec()
, which allows you to run a piece of code in the UI thread. (aka user interface thread or display thread)
Shell
is the "window" that you see in your desktop. The one that has a title,
maximize, minimize, restore and close buttons. A shell can be either a
top-level shell (no parent shell) or can be a secondary shell (will
have a parent shell). The style that is passed in the constructor
defines which of the above mentioned buttons are displayed and also
whether the Shell is modal or not. If you are on a pure SWT app, then
you should be create a Shell; create controls in it; open it; run the
event loop; and dispose it. Speaking in code:
Shell shell = new Shell(display);
// set layout and create widgets
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
If you are developing plugins/JFace applications, its better to use
Window rather than Shells directly, because it manages the above things
for you. It is not, but think it of as a wrapper for Shell. When you
use a Window, a Shell is not created until the open() method is called.
Since the Shell is not created till the Window is open and windows can
be reopened (yes, you can reopen it), configuration of the Shell should
be done in the configureShell() method. Remember, this is an abstract
class and so you cannot directly use it. You must either use Dialog or
ApplicationWindow or your own concrete class.
When you need a specialized communication with the user, you should
be using Dialogs. In all other cases, you will be using
ApplicationWindow. Dialog are more of helper windows that are attached
to another main window. PreferenceDialog, PropertyDialog, ErrorDialog,
InputDialog & WizardDialog are some frequently used dialogs.
Window + menu support + toolbar support + coolbar support + status line support = ApplicationWindow :-)
WorkbenchWindow is Eclipse specific ApplicationWindow, which adds
few services and a set of IWorkbenchPages to the ApplicationWindow.
Although the javadoc says "Each workbench window has a collection of 0
or more pages", in reality it has only one page. I believe this is due
to backward compatibility with Eclipse 1.0.
The area that lies between the toolbar and the status line of the
WorkbenchWindow is known as WorkbenchPage. Simply put, this is the body
of the WorkbenchWindow, where all the editors and views are showed.
IWorkbenchPage contains IWorkbenchParts, which are the the visual
representation of the Views and Editors. Both IViewPart and IEditorPart
derive from IWorkbenchPart
IWorkbenchPart resides inside the IWorkbenchPage. So it has no direct
access to the workbench itself. So when it needs to interact with the
workbench, then it needs the IWorkbenchSite. For example to get the
shell inside a view, you call getSite().getShell().
分享到:
相关推荐
Luis.Royo-Conceptions_I(概念1)
Different views are presented on some fundamental conceptions and view-points in the paper "A preliminary theoretical analysis on lowering breakdown voltage in gas laser tubes"[1].
(Ed.) Psychology and the Process of Schooling in the Next Decade: Alternative Conceptions. Minneapolis: University of Minnesota, 1971, 256p., [dollar]3.50 B O O K R E V I E W S ~~~~ ~ ~ ~ ~ ~ ...
We have a new idea to infer the refractive index for the extraordinary ray (the Poynting vector) in double refraction crystals at any... Some ambiguous conceptions on the ray are clarified in this paper.
An investigation of the (mis) conceptions of pre- and inservice teachers as to the manifestation of anxiety in upper elmentary school children from different racial-socioeconomic backgrounds ...
Demonstration programs shows some features of AlphaControls and can help you in understanding of main conceptions of AlphaControls. Page with demo programs: http://www.alphaskins.com/ademos.php ...
Demonstration programs shows some features of AlphaControls and can help you in understanding of main conceptions of AlphaControls. Page with demo programs: http://www.alphaskins.com/ademos.php ...
Demonstration programs shows some features of AlphaControls and can help you in understanding of main conceptions of AlphaControls. Page with demo programs: http://www.alphaskins.com/ademos.php ...
Demonstration programs shows some features of AlphaControls and can help you in understanding of main conceptions of AlphaControls. Page with demo programs: http://www.alphaskins.com/ademos.php ...
Demonstration programs shows some features of AlphaControls and can help you in understanding of main conceptions of AlphaControls. Page with demo programs: http://www.alphaskins.com/ademos.php ...
(Ed.) Psychology and the Process of Schooling in the Next Decade: Alternative Conceptions. Minneapolis: University of Minnesota, 1971, 256p., [dollar]3.50 B O O K R E V I E W S ~~~~ ~ ~ ~ ~ ~ ...
Parental interest and children’s self-conceptions. Sociometry, 26, 35-49. ROSENBERG, M. (1965). Society and adolescent self image. Princeton, NJ: Princeton University Press. TERRELL, F., TAYLOR, J...
Parental interest and children’s self-conceptions. Sociometry, 26, 35-49. ROSENBERG, M. (1965). Society and adolescent self image. Princeton, NJ: Princeton University Press. TERRELL, F., TAYLOR, J...
In this paper, we introduced the conceptions of differential metrics and differential metric spaces of discrete functions. The convergence of differential motrics of discrete functions have all ...
but it would only intimidate the beginners by including so many confused conceptions, which are not used at most of the time, in a single huge book. It's too lengthy, more than 1500 pages.You can ...
Altin业务流程管理-使用Conceptions在Java中开发业务逻辑(域逻辑)的简单内核。 基于JPA&Java EE。 概念指的是域逻辑中的概念,因为开发业务逻辑变得更加简单,快捷,并导致开发可重用的业务概念库。
An investigation of the (mis) conceptions of pre- and inservice teachers as to the manifestation of anxiety in upper elmentary school children from different racial-socioeconomic backgrounds ...