📄 rich client platform part2.mht
字号:
<TH>Method=20
<TH>Description=20
<TH>Parameter(s)=20
<TR>
<TD>initialize=20
<TD>Called first to perform any setup such as parsing the command =
line,=20
registering adapters, declaring images, etc..=20
<TD><CODE>IWorkbenchConfigurer<CODE> </CODE></CODE>
<TR>
<TD>preStartup=20
<TD>Called after initialization but before the first window is =
opened. May=20
be used to set options affecting which editors and views are =
initially=20
opened.=20
<TD> =20
<TR>
<TD>postStartup=20
<TD>Called after all windows have been opened or restored, but =
before the=20
event loop starts. It can be used to start automatic processes and =
to open=20
tips or other windows.=20
<TD> =20
<TR>
<TD>preShutdown=20
<TD>Called after the event loop has terminated but before any =
windows have=20
been closed.=20
<TD> =20
<TR>
<TD>postShutdown=20
<TD>Called after all windows are closed during Workbench shutdown. =
This=20
can be used to save the current application state and clean up =
anything=20
created by <CODE>initialize</CODE>.=20
<TD> </TR></TBODY></TABLE>
<P><B>Table 2. Workbench window lifecycle hooks provided by=20
<CODE>org.eclipse.ui.application.WorkbenchAdvisor</CODE>. </B></P>
<TABLE border=3D1>
<TBODY>
<TR>
<TH>Method=20
<TH>Description=20
<TH>Parameter(s)=20
<TR>
<TD>preWindowOpen=20
<TD>Called in the constructor of the Workbench Window. Use this =
method to=20
set options such as whether or not the window will have a menu =
bar.=20
However none of the window's widgets have been created yet so they =
can't=20
be referenced in this method.=20
<TD><CODE>IWorkbenchWindowConfigurer</CODE>=20
<TR>
<TD>fillActionBars=20
<TD>Called right after <CODE>preWindowOpen</CODE>. This is where you =
set=20
up any hard-wired menus and toolbars. This is probably the most=20
complicated method here because of the flags it is passed. Note: =
takes a=20
Workbench window, not a configurer.=20
<TD><CODE>IWorkbenchWindow</CODE>, =
<CODE>IActionBarConfigurer</CODE>,=20
flags=20
<TR>
<TD>postWindowRestore=20
<TD>Optionally called for cases when a window has been restored from =
saved=20
state but before it is opened.=20
<TD><CODE>IWorkbenchWindowConfigurer</CODE>=20
<TR>
<TD>postWindowCreate=20
<TD>Called after a window has been restored from saved state or =
created=20
from scratch but before it is opened.=20
<TD><CODE>IWorkbenchWindowConfigurer</CODE>=20
<TR>
<TD>openIntro=20
<TD>Called immediately before a window is opened in order to create =
the=20
Intro component (if any).=20
<TD><CODE>IWorkbenchWindowConfigurer</CODE>=20
<TR>
<TD>postWindowOpen=20
<TD>Called right after the Workbench window is opened. Can be used =
to=20
tweak any of the window's widgets, for example to set a title or =
change=20
its size.=20
<TD><CODE>IWorkbenchWindowConfigurer</CODE>=20
<TR>
<TD>preWindowShellClose=20
<TD>Called before the Workbench window is closed (technically, =
before its=20
shell is closed). This is the only function that can veto the =
close, so=20
it's a good place for an "Are you sure" kind of dialog.=20
<TD><CODE>IWorkbenchWindowConfigurer</CODE>=20
<TR>
<TD>postWindowClose=20
<TD>Called after the Workbench window is closed Can be used to clean =
up=20
anything created by <CODE>preWindowOpen</CODE>.=20
<TD><CODE>IWorkbenchWindowConfigurer</CODE> </TR></TBODY></TABLE>
<H3>Event loop hooks</H3>
<P>The event loop is the code that is running most of the time during =
the life=20
of the Workbench. It handles all user inputs and dispatches them to the =
right=20
listeners. RCP provides a couple of hooks to handle crashes and perform =
work=20
during idle time (see table 3). </P>
<P><B>Table 3. Event loop hooks provided by=20
<CODE>org.eclipse.ui.application.WorkbenchAdvisor</CODE>. </B></P>
<TABLE border=3D1>
<TBODY>
<TR>
<TH>Method=20
<TH>Description=20
<TH>Parameter(s)=20
<TR>
<TD>eventLoopException=20
<TD>Called if there is an unhandled exception in the event loop. The =
default implementation will log the error.=20
<TD><CODE>Throwable</CODE>=20
<TR>
<TD>eventLoopIdle=20
<TD>Called when the event loop has nothing to do.=20
<TD><CODE>Display</CODE> </TR></TBODY></TABLE>
<H3>Information getting hooks</H3>
<P>Next, there are few methods you can implement that the platform will =
call to=20
get information about your application (see table 4). The most important =
one=20
(and the only one that is not optional) is=20
<CODE>getInitialWindowPerspectiveId</CODE>. We used this in part 1 to =
return the=20
id of the starting (and only) perspective in RcpTest. </P>
<P><B>Table 4. Information requests provided by=20
<CODE>org.eclipse.ui.application.WorkbenchAdvisor</CODE>. </B></P>
<TABLE border=3D1>
<TBODY>
<TR>
<TH>Method=20
<TH>Description=20
<TH>Parameter(s)=20
<TR>
<TD>getDefaultPageInput=20
<TD>Return the default input for new workbench pages. Defaults to =
null.=20
<TD> =20
<TR>
<TD>getInitialWindowPerspectiveId=20
<TD>Return the initial perspective used for new workbench windows. =
This is=20
a required function that has no default.=20
<TD> =20
<TR>
<TD>getMainPreferencePageId=20
<TD>Return the preference page that should be displayed first. =
Defaults to=20
null, meaning the pages should be arranged alphabetically.=20
<TD> =20
<TR>
<TD>isApplicationMenu=20
<TD>Return true if the menu is one of yours. OLE specific; see =
Javadoc for=20
details.=20
<TD><CODE>IWorkbenchWindowConfigurer</CODE>, <CODE>String</CODE>=20
</TR></TBODY></TABLE>
<H3>Advanced configuration</H3>
<P>The <CODE>WorkbenchAdvisor</CODE> events above should be sufficient =
for most=20
applications, but just in case, RCP provides two more methods to take =
complete=20
control of how your application windows and controls are created. =
They're listed=20
in table 5 for completeness but I don't expect many programs will need =
them.=20
</P>
<P><B>Table 5. Advanced methods in=20
<CODE>org.eclipse.ui.application.WorkbenchAdvisor</CODE>. </B></P>
<TABLE border=3D1>
<TBODY>
<TR>
<TH>Method=20
<TH>Description=20
<TH>Parameter(s)=20
<TR>
<TD>createWindowContents=20
<TD>Creates the contents of one window. Override this method to =
define=20
custom contents and layout.=20
<TD><CODE>IWorkbenchWindowConfigurer</CODE>, <CODE>Shell</CODE>=20
<TR>
<TD>openWindows=20
<TD>Open all Workbench windows on startup. The default =
implementation=20
tries to restore the previously saved workbench state.=20
<TD> </TR></TBODY></TABLE>
<H2>Preparing for internationalization</H2>
<P>Internationalization (i18n for short) opens up your application to a =
much=20
wider market. The first step is simply to pull all your human readable =
text=20
messages out of your code and into a standard format properties file. =
Even if=20
you are not planning to make your code available in multiple languages,=20
separating the messages makes it much easier for you to spell check them =
and=20
check them for consistent grammar and word usage. </P>
<P>There's nothing magic about messages in Eclipse - you just use the =
plain old=20
Java resource bundle mechanism that you may already be familiar with. =
The=20
Eclipse IDE provides a nice Externalization wizard to make this less of =
a chore.=20
See the references section below for a link to an article that describes =
how to=20
use it in detail. </P>
<P>Briefly, when you're writing a new section of code you will often =
hard-code=20
strings just to get something going. For example, in listing 1 we used: =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -