论文代写-英语日语韩语德语俄语法语
论文翻译-英语日语韩语德语俄语法语
论文修改-英语日语韩语德语俄语法语
代写作业代考试题考卷-英语日语韩语德语俄语法语
作文报告申请书文章等代写-英语日语韩语德语俄语法语
研究计划书代写-英语日语韩语德语俄语法语
西班牙语意大利语论文代写翻译修改
论文发表-英语日语韩语德语俄语法语
英语 English
日语 日本語
韩语한국의
法语 Français
德语 Deutsch
俄语 Pусский
西语 Español
意语 Italiano
·英语论文 ·日语论文
·韩语论文 ·德语论文
·法语论文 ·俄语论文

名称:智尚工作室
电话:0760-86388801
传真:0760-85885119
手机(微信):13380876598
地址:广东中山市学院路1号
网址:www.zsfy.org
E-Mail:cjpd
@vip.163.com
商务QQ:875870576
微信二维码

业务联系
隐藏文章
The Rich Client Platform (RCP) Tutorial
添加时间: 2012-12-19 12:20:32 来源: 作者: 点击数:5047


Rich Client Tutorial Part 1
The Rich Client Platform (RCP) is an exciting new way to build Java applications that can compete with native applications on any platform. This tutorial is designed to get you started building RCP applications quickly. It has been updated for Eclipse 3.1.2
By Ed Burnette, SAS
July 28, 2004
Updated for 3.1.2: February 6, 2006
________________________________________
Introduction
Try this experiment: Show Eclipse to some friends or co-workers who haven't seen it before and ask them to guess what language it is written in. Chances are, they'll guess VB, C++, or C#, because those languages are used most often for high quality client side applications. Then watch the look on their faces when you tell them it was created in Java, especially if they are Java programmers.
Because of its unique open source license, you can use the technologies that went into Eclipse to create your own commercial quality programs. Before version 3.0, this was possible but difficult, especially when you wanted to heavily customize the menus, layouts, and other user interface elements. That was because the "IDE-ness" of Eclipse was hard-wired into it. Version 3.0 introduced the Rich Client Platform (RCP), which is basically a refactoring of the fundamental parts of Eclipse's UI, allowing it to be used for non-IDE applications. Version 3.1 updated RCP with new capabilities, and, most importantly, new tooling support to make it easier to create than before.
If you want to cut to the chase and look at the code for this part you can find it in the accompanying zip file. Otherwise, let's take a look at how to construct an RCP application.
Getting started
RCP applications are based on the familiar Eclipse plug-in architecture, (if it's not familiar to you, see the references section). Therefore, you'll need to create a plug-in to be your main program. Eclipse's Plug-in Development Environment (PDE) provides a number of wizards and editors that take some of the drudgery out of the process. PDE is included with the Eclipse SDK download so that is the package you should be using. Here are the steps you should follow to get started.
First, bring up Eclipse and select File > New > Project, then expand Plug-in Development and double-click Plug-in Project to bring up the Plug-in Project wizard. On the subsequent pages, enter a Project name such as org.eclipse.ui.tutorials.rcp.part1, indicate you want a Java project, select the version of Eclipse you're targeting (at least 3.1), and enable the option to Create an OSGi bundle manifest. Then click Next >.
 Beginning in Eclipse 3.1 you will get best results by using the OSGi bundle manifest. In contrast to previous versions, this is now the default.
In the next page of the Wizard you can change the Plug-in ID and other parameters. Of particular importance is the question, "Would you like to create a rich client application?". Select Yes. The generated plug-in class is optional but for this example just leave all the other options at their default values. Click Next > to continue.
 If you get a dialog asking if Eclipse can switch to the Plug-in Development Perspective click Remember my decision and select Yes (this is optional).
Starting with Eclipse 3.1, several templates have been provided to make creating an RCP application a breeze. We'll use the simplest one available and see how it works. Make sure the option to Create a plug-in using one of the templates is enabled, then select the Hello RCP template. This is RCP's equivalent of "Hello, world". Click Finish to accept all the defaults and generate the project (see Figure 1). Eclipse will open the Plug-in Manifest Editor. The Plug-in Manifest editor puts a friendly face on the various configuration files that control your RCP application.
 
Figure 1. The Hello World RCP project was created by a PDE wizard.
Taking it for a spin
Trying out RCP applications used to be somewhat tedious. You had to create a custom launch configuration, enter the right application name, and tweak the plug-ins that were included. Thankfully the PDE keeps track of all this now. All you have to do is click on the Launch an Eclipse Application button in the Plug-in Manifest editor's Overview page. You should see a bare-bones Workbench start up (see Figure 2).
 
Figure 2. By using the templates you can be up and running an RCP application in minutes.
Making it a product
In Eclipse terms a product is everything that goes with your application, including all the other plug-ins it depends on, a command to run the application (called the native launcher), and any branding (icons, etc.) that make your application distinctive. Although as we've just seen you can run a RCP application without defining a product, having one makes it a whole lot easier to run the application outside of Eclipse. This is one of the major innovations that Eclipse 3.1 brought to RCP development.
Some of the more complicated RCP templates already come with a product defined, but the Hello RCP template does not so we'll have to make one.
In order to create a product, the easiest way is to add a product configuration file to the project. Right click on the plug-in project and select New > Product Configuration. Then enter a file name for this new configuration file, such as part1.product. Leave the other options at their default values. Then click Finish. The Product Configuration editor will open. This editor lets you control exactly what makes up your product including all its plug-ins and branding elements.
In the Overview page, select the New... button to create a new product extension. Type in or browse to the defining plug-in (org.eclipse.ui.tutorials.rcp.part1). Enter a Product ID such as product, and for the Product Application select org.eclipse.ui.tutorials.rcp.part1.application. Click Finish to define the product. Back in the Overview page, type in a new Product Name, for example RCP Tutorial 1.
 In Eclipse 3.1.0 if you create the product before filling in the Product Name you may see an error appear in the Problems view. The error will go away when you Synchronize (see below). This is a known bug that is fixed in newer versions. Always use the latest available maintenance release for the version of Eclipse you're targeting!
Now select the Configuration tab and click Add.... Select the plug-in you just created (org.eclipse.ui.tutorials.rcp.part1) and then click on Add Required Plug-ins. Then go back to the Overview page and press Ctrl+S or File > Save to save your work.
 If your application needs to reference plug-ins that cannot be determined until run time (for example the tomcat plug-in), then add them manually in the Configuration tab.
At this point you should test out the product to make sure it runs correctly. In the Testing section of the Overview page, click on Synchronize then click on Launch the product. If all goes well, the application should start up just like before.
Plug-ins vs. features
On the Overview page you may have noticed an option that says the product configuration is based on either plug-ins or features. The simplest kind of configuration is one based on plug-ins, so that's what this tutorial uses. If your product needs automatic update or Java Web Start support, then eventually you should convert it to use features. But take my advice and get it working without them first.
Running it outside of Eclipse
The whole point of all this is to be able to deploy and run stand-alone applications without the user having to know anything about the Java and Eclipse code being used under the covers. For a real application you may want to provide a self-contained executable generated by an install program like InstallShield or NSIS. That's really beyond the scope of this article though, so we'll do something simpler.
The Eclipse plug-in loader expects things to be in a certain layout so we'll need to create a simplified version of the Eclipse install directory. This directory has to contain the native launcher program, config files, and all the plug-ins required by the product. Thankfully, we've given the PDE enough information that it can put all this together for us now.
In the Exporting section of the Product Configuration editor, click the link to Use the Eclipse Product export wizard. Set the root directory to something like RcpTutorial1. Then select the option to deploy into a Directory, and enter a directory path to a temporary (scratch) area such as C:\Deploy. Check the option to Include source code if you're building an open source project. Press Finish to build and export the program.
 The compiler options for source and class compatibility in the Eclipse Product export wizard will override any options you have specified on your project or global preferences. As part of the Export process, the plug-in is code is recompiled by an Ant script using these options.
The application is now ready to run outside Eclipse. When you're done you should have a structure that looks like this in your deployment directory:
    RcpTutorial1
    |    .eclipseproduct
    |    eclipse.exe
    |    startup.jar
    +--- configuration
    |         config.ini
    +--- plugins
              org.eclipse.core.commands_3.1.0.jar
              org.eclipse.core.expressions_3.1.0.jar
              org.eclipse.core.runtime_3.1.2.jar
              org.eclipse.help_3.1.0.jar
              org.eclipse.jface_3.1.1.jar
              org.eclipse.osgi_3.1.2.jar
              org.eclipse.swt.win32.win32.x86_3.1.2.jar
              org.eclipse.swt_3.1.0.jar
              org.eclipse.ui.tutorials.rcp.part1_1.0.0.jar
              org.eclipse.ui.workbench_3.1.2.jar
              org.eclipse.ui_3.1.2.jar
 Note that all the plug-ins are deployed as jar files. This is the recommended format starting in Eclipse 3.1. Among other things this saves disk space in the deployed application.
 Previous versions of this tutorial recommended using a batch file or shell script to invoke your RCP program. It turns out this is a bad idea because you will not be able to fully brand your application later on. For example, you won't be able to add a splash screen. Besides, the export wizard does not support the batch file approach so just stick with the native launcher.
Give it a try! Execute the native launcher (eclipse or eclipse.exe by default) outside Eclipse and watch the application come up. The name of the launcher is controlled by branding options in the product configuration.
Troubleshooting
Error: Launching failed because the org.eclipse.osgi plug-in is not included...
You can get this error when testing the product if you've forgotten to list the plug-ins that make up the product. In the Product Configuration editor, select the Configuration tab, and add all your plug-ins plus all the ones they require as instructed above.
Compatibility and migration
If you are migrating a plug-in from version 2.1 to version 3.1 there are number of issues covered in the on-line documentation that you need to be aware of. If you're making the smaller step from 3.0 to 3.1, the number of differences is much smaller. See the References section for more information.
 One word of advice: be careful not to duplicate any information in both plug-in.xml and MANIFEST.MF. Typically this would not occur unless you are converting an older plug-in that did not use MANIFEST.MF into one that does, and even then only if you are editing the files by hand instead of going through the PDE.
Conclusion
In part 1 of this tutorial, we looked at what is necessary to create a bare-bones Rich Client application. The next part will delve into the classes created by the wizards such as the WorkbenchAdvisor class. All the sample code for this part may be found in the accompanying zip file.
References
RCP Tutorial Part 2
RCP Tutorial Part 3
Eclipse Rich Client Platform
RCP Browser example (project org.eclipse.ui.examples.rcp.browser)
PDE Does Plug-ins
How to Internationalize your Eclipse Plug-in
Notes on the Eclipse Plug-in Architecture
Plug-in Migration Guide: Migrating to 3.1 from 3.0
Plug-in Migration Guide: Migrating to 3.0 from 2.1
To discuss or report problems in this article see bug 104146.
IBM is trademark of International Business Machines Corporation in the United States, other countries, or both.
Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.
Microsoft and Windows are trademarks of Microsoft Corporation in the United States, other countries, or both.
Other company, product, and service names may be trademarks or service marks of others.
 
 
Rich Client Tutorial Part 2
The Rich Client Platform (RCP) allows you to build Java applications that can compete with native applications on any platform. Part 1 of the tutorial introduced you to the platform and the steps used to build the smallest possible RCP program. In part 2 we'll look at what we did in more detail and introduce some of the configuration classes that let you take control of much of the layout and functionality of an RCP application. This part has been updated for Eclipse 3.1.2
By Ed Burnette, SAS
August 9, 2004
Updated for 3.1.2: February 6, 2006
________________________________________
Introduction
In early versions of Eclipse, many functions of the IDE were hard-wired into the code. These included the name and location of the File menu, the title of the Workbench Window, and the existence of the status bar. This was fine for the IDE but when people started to use Eclipse as a basis for non-IDE programs, sometimes these things didn't make sense. Although all the source code was provided, it was inconvenient to find the right places that had to be changed.
So, beginning in Eclipse 3.0, the designers refactored the API to make these and other hard-wired aspects of the user interface controllable through public API. Subsequent releases have fine tuned that API and provided tooling in the Plug-in Development Environment (PDE) to lower the barriers to getting started using it. However, you'll eventually need to look behind the PDE wizards and editors to really understand what is going on.
In this part we'll examine the code and configuration files created in Part 1 of the tutorial. To keep the parts separate I've recreated the examples for each part under a different name. All the sample code for Part 2 may be found in the part2.zip archive file.
 If you're following along with this tutorial in Eclipse and you're thinking of just renaming your old project, I don't recommend it. In Eclipse 3.1, Refactor > Rename does not work well on plug-in projects due to all the internal references in XML files and strings that don't participate. Hopefully this will be fixed in a future release.
Before we go any further let's clear up some possible confusion about the relationship between Applications, Workbenches, and Workbench Windows.
Applications, Workbenches, and Workbench Windows
The Application is a class you create that acts as your RCP program's main routine. You can think of it as the controller for the program. Just like the controller in a Model2 architecture, it is short and sweet and doesn't change significantly for different projects. All it does is create a Workbench and attach another class called a Workbench Advisor to it (Workbench Advisors will be covered more later).
The Workbench is declared and maintained for you as part of the RCP framework. There is only one Workbench but it can have more than one visible top-level Workbench Window. For example, in the Eclipse IDE, when you first start Eclipse you will see one Workbench Window, but if you select Window > New Window a second window pops up -- two Workbench Windows, but only one Workbench.
Ok, now that that's out of the way, let's see what those PDE wizards did for us, starting with the plug-in manifest.
Plug-in manifest
The plug-in manifest ties all the code and resources together. When you first create a plug-in, Eclipse will create and open the manifest for you automatically. The manifest is split into two files: MANIFEST.MF and plugin.xml. PDE provides a fancy editor to modify the options stored in these files (see Figure 1) but also allows you to edit the source directly.
 
Figure 1. The plug-in manifest editor provides a single interface for editing the manifest and related files. The tabs along the bottom of the editor access all the different sections in the GUI or the raw text files.
MANIFEST.MF
The OSGi bundle manifest is stored in MANIFEST.MF. OSGi is the name of a standard that Eclipse uses for dynamically loading plug-ins (see refererences). Listing 1 shows the OSGi bundle manifest generated by the plug-in wizard. Everything in this file can be edited by the Manifest editor, so there should be no need to edit it by hand. However if you need to, just double-click it in the Package Explorer to bring up the Manifest editor, then click on the MANIFEST.MF tab in the editor to see and modify the source.
 For backwards compatability with Eclipse 2.1, Eclipse will recognize and load plug-ins that do not use MANIFEST.MF. However, this incurs a small performance penalty and is not recommended for plug-ins targeting Eclipse 3.0 and later.
Listing 1. MANIFEST.MF
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Part2 Plug-in
Bundle-SymbolicName: org.eclipse.ui.tutorials.rcp.part2; singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: org.eclipse.ui.tutorials.rcp.part2.Part2Plugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime
Eclipse-AutoStart: true
plugin.xml
The Eclipse extension manifest is called plugin.xml. It's used for defining and using Eclipse extension points, so if you're not using extension points then this file may be omitted. Extension points are the fundamental way that Eclipse plug-ins are tied together so if you're not familiar with them see one of the articles in the Reference section. Listing 2 shows the plugin.xml file created by the PDE wizard.
Listing 2. plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>

   <extension
         id="application"
         point="org.eclipse.core.runtime.applications">
      <application>
         <run
               class="org.eclipse.ui.tutorials.rcp.part2.Application">
         </run>
      </application>
   </extension>
   <extension
         point="org.eclipse.ui.perspectives">
      <perspective
            name="Part2 Perspective"
            class="org.eclipse.ui.tutorials.rcp.part2.Perspective"
            id="org.eclipse.ui.tutorials.rcp.part2.perspective">
      </perspective>
   </extension>
   <extension
         id="product"
         point="org.eclipse.core.runtime.products">
      <product
            application="org.eclipse.ui.tutorials.rcp.part2.application"
            name="RCP Tutorial 2"/>
   </extension>

</plugin>
The class name of the main program is defined with the org.eclipse.core.runtime.applications extension.
 Although it's not an absolute requirement, I recommend keeping your id's and your class names the same except possibly for case. For historical reasons, Eclipse prepends the plug-in's id to the id of your top level plug-in elements (like extension). For example, even though the plugin.xml in listing 2 says id="application", the fully qualified id for that extension is org.eclipse.ui.tutorials.rcp.part2.application. Since the perspective's id is written on a sub-element (perspective) it has to be spelled out completely in the manifest (org.eclipse.ui.tutorials.rcp.part2.perspective). By convention only, package names and ids are lower case and class names are Pascal Case.
The main program
The org.eclipse.core.runtime.applications extension tells the Eclipse runtime the name of your main program. This is a class that implements IPlatformRunnable and a run() method. Listing 3 shows the simple implementation supplied by the plug-in wizard.
Listing 3. Application.java
package org.eclipse.ui.tutorials.rcp.part2;

import org.eclipse.core.runtime.IPlatformRunnable;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;

/**
* This class controls all aspects of the application's execution
*/
public class Application implements IPlatformRunnable {

  /* (non-Javadoc)
   * @see org.eclipse.core.runtime.IPlatformRunnable#run(java.lang.Object)
   */
  public Object run(Object args) throws Exception {
    Display display = PlatformUI.createDisplay();
    try {
      int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
      if (returnCode == PlatformUI.RETURN_RESTART) {
        return IPlatformRunnable.EXIT_RESTART;
      }
      return IPlatformRunnable.EXIT_OK;
    } finally {
      display.dispose();
    }
  }
}
The default perspective
A Perspective is a set of visible views, editors, and menus including their positions and sizes. In an RCP program you must define at least one perspective and make it the default. Perspectives are created by implementing IPerspectiveFactory using the class name referred to by the org.eclipse.ui.perspectives extension. See Listing 4 for the implementation provided by the plug-in wizard. The important part of this interface is the createInitialLayout() method where you position and open any views and/or editors you'd like the user to start with. So far in this example we haven't created any views so it's a pretty boring perspective.
Listing 4. Perspective.java
package org.eclipse.ui.tutorials.rcp.part2;

import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;

public class Perspective implements IPerspectiveFactory {

  public void createInitialLayout(IPageLayout layout) {
  }
}
The Advisor classes
The main program referenced a class called ApplicationWorkbenchAdvisor. This is one of three Advisor classes that you use to configure all aspects of the Workbench such as the title, menu bars, and so on. These are the most important classes for an RCP developer to understand. You extend the base version of the class, for example WorkbenchAdvisor, in your RCP application and override one or more of the methods to set whatever options you want. Let's examine these classes now in more detail.
Workbench Advisor
Methods in this class are called from the platform to notify you at every point in the lifecycle of the Workbench. They also provide a way to handle exceptions in the event loop, and provide important parameters to the Workbench such as the default perspective. With the exception of createWorkbenchWindowAdvisor() and getInitialWindowPerspectiveId(), the methods on WorkbenchAdvisor do not have to be overridden. Listing 5 shows the implementation that was provided by the plug-in wizard.
Listing 5. ApplicationWorkbenchAdvisor.java
package org.eclipse.ui.tutorials.rcp.part2;

import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;

public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {

  private static final String PERSPECTIVE_ID = "org.eclipse.ui.tutorials.rcp.part2.perspective";

    public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
        return new ApplicationWorkbenchWindowAdvisor(configurer);
    }

  public String getInitialWindowPerspectiveId() {
    return PERSPECTIVE_ID;
  }
}
 Why not an interface? You'll notice that WorkbenchAdvisor is an abstract class. For the most part, Eclipse APIs shun abstract classes in favor of interfaces and base classes that implement those interfaces. In this case, the designers intend for WorkbenchAdvisor to always be implemented by the RCP application, and the base class doesn't contain any significant functionality. Also it is very likely that new methods will need to be added to the base class in the future (something that is difficult using interfaces). So this was a deliberate design choice. See the article on evolving Java APIs in the reference section for more tips.
Workbench lifecycle hooks
The Workbench Advisor class has several methods that are called at defined points in the Workbench's lifecycle (see Table 1). By overriding these you can run whatever code you want at these points.
Table 1. Workbench lifecycle hooks provided by WorkbenchAdvisor.
Method Description Parameter(s)
initialize Called first to perform any setup such as parsing the command line, registering adapters, declaring images, etc.. IWorkbenchConfigurer
preStartup Called after initialization but before the first window is opened. May be used to set options affecting which editors and views are initially opened. 
postStartup Called after all windows have been opened or restored, but before the event loop starts. It can be used to start automatic processes and to open tips or other windows. 
preShutdown Called after the event loop has terminated but before any windows have been closed. 
postShutdown Called after all windows are closed during Workbench shutdown. This can be used to save the current application state and clean up anything created by initialize. 
Event loop hooks
The event loop is the code that is running most of the time during the life of the Workbench. It handles all user inputs and dispatches them to the right listeners. RCP provides a couple of hooks to handle crashes and perform work during idle time (see Table 2). Note however that the Jobs interface (see References) is a better way of performing long running work than this idle hook.
Table 2. Event loop hooks provided by WorkbenchAdvisor.
Method Description Parameter(s)
eventLoopException Called if there is an unhandled exception in the event loop. The default implementation will log the error. Throwable
eventLoopIdle Called when the event loop has nothing to do. Display
Information getting hooks
Next, there are few methods you can implement that the platform will call to get information about your application (see Table 3). The most important one (and the only one that is not optional) is getInitialWindowPerspectiveId. We used this in Listing 5 to return the id of the starting perspective.
Table 3. Information request methods you can override in WorkbenchAdvisor.
Method Description Parameter(s)
getDefaultPageInput Return the default input for new workbench pages. Defaults to null. 
getInitialWindowPerspectiveId Return the initial perspective used for new workbench windows. This is a required function that has no default. 
getMainPreferencePageId Return the preference page that should be displayed first. Defaults to null, meaning the pages should be arranged alphabetically.  
Advanced configuration
The WorkbenchAdvisor events above should be sufficient for most applications, but just in case, RCP provides another method to take complete control of how your application windows and controls are created. It's listed in Table 4 for completeness but I don't expect many programs will need it.
Table 4. Advanced methods in org.eclipse.ui.application.WorkbenchAdvisor.
Method Description Parameter(s)
openWindows Open all Workbench windows on startup. The default implementation tries to restore the previously saved workbench state. 
Workbench Window Advisor
This class is used to control the status line, toolbar, title, window size, and other things you'll almost certainly want to customize. You can also use it to hook into all the various lifecycle events of the Workbench Windows. Listing 6 shows the implementation provided by the plug-in wizard.
Listing 6. ApplicationWorkbenchWindowAdvisor.java
package org.eclipse.ui.tutorials.rcp.part2;

import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;

public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {

    public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
        super(configurer);
    }

    public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
        return new ApplicationActionBarAdvisor(configurer);
    }
   
    public void preWindowOpen() {
        IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
        configurer.setInitialSize(new Point(400, 300));
        configurer.setShowCoolBar(false);
        configurer.setShowStatusLine(false);
        configurer.setTitle("Hello RCP");
    }
}
Methods on WorkbenchWindowAdvisor (see Table 5 and Table 6) will all need access to a Configurer interface (in this case, IWorkbenchWindowConfigurer) in order to do anything so they're expected to call getWindowConfigurer() to fetch it. You call methods on the Configurer interfaces to actually change the options. These interfaces are not covered in any detail in this tutorial but you can refer to their Javadoc for more information.
Table 5. Workbench window lifecycle hooks provided by WorkbenchWindowAdvisor.
Method Description Parameter(s)
preWindowOpen Called in the constructor of the Workbench Window. Use this method to set options such as whether or not the window will have a menu bar. However none of the window's widgets have been created yet so they can't be referenced in this method. 
postWindowRestore Optionally called for cases when a window has been restored from saved state but before it is opened. 
postWindowCreate Called after a window has been restored from saved state or created from scratch but before it is opened. 
openIntro Called immediately before a window is opened in order to create the Intro component (if any). 
postWindowOpen Called right after the Workbench window is opened. Can be used to tweak any of the window's widgets, for example to set a title or change its size. 
preWindowShellClose Called before the Workbench window is closed (technically, before its shell is closed). This is the only function that can veto the close, so it's a good place for an "Are you sure" kind of dialog. 
postWindowClose Called after the Workbench window is closed. Can be used to clean up anything created by preWindowOpen. 
Table 6. Advanced methods in WorkbenchWindowAdvisor.
Method Description Parameter(s)
createWindowContents Creates the contents of one window. Override this method to define custom contents and layout. Shell
createEmptyWindowContents Like createWindowContents, but used when the window has no open pages. Override this method to show something other than the default window background. Composite
ActionBar Advisor
In Eclipse jargon, "action bar" is a catch-all term for menus, toolbars, and status bars. The ActionBar Advisor handles creating Actions within these locations. A plug-in can also contribute actions dynamically with its plugin.xml file. See Listing 7 for the implementation provided by the plug-in wizard and Table 7 for the methods.
 The whole action, command and keybinding system is a bit of a mess in Eclipse 3.1. For example you can't add combo boxes to action bars, and plugin.xml can't contribute actions to the status bar. Getting key bindings to work involves multiple steps. Hopefully this will be cleaned up in a future release.
Listing 7. ApplicationActionBarAdvisor.java
package org.eclipse.ui.tutorials.rcp.part2;

import org.eclipse.jface.action.IMenuManager;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

    public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
        super(configurer);
    }

    protected void makeActions(IWorkbenchWindow window) {
    }

    protected void fillMenuBar(IMenuManager menuBar) {
    }
   
}
Table 7. Methods you can override in ActionBarAdvisor.
Method Description Parameter(s)
makeActions Called to create the actions used in the fill methods. IWorkbenchWindow
fillMenuBar Called to fill the menu bar with the main menus for the window. IMenuManager
fillCoolBar Called to fill the cool bar with the main toolbars for the window. ICoolBarManager
fillStatusLine Called to fill the status line with the main status line contributions for the window. IStatusLineManager
isApplicationMenu Return true if the menu is one of yours. OLE specific; see Javadoc for details. String
Plug-in class
The plug-in class is an optional singleton class that can be used to store global information for the plug-in. It's also a convenient place to put a few static utility functions used by other classes in the plug-in. See Listing 8 for the plug-in class that was created for us by the plug-in wizard.
Listing 8. Part2Plugin.java
package org.eclipse.ui.tutorials.rcp.part2;

import org.eclipse.ui.plugin.*;
import org.eclipse.jface.resource.ImageDescriptor;
import org.osgi.framework.BundleContext;

/**
* The main plugin class to be used in the desktop.
*/
public class Part2Plugin extends AbstractUIPlugin {

  //The shared instance.
  private static Part2Plugin plugin;
 
  /**
   * The constructor.
   */
  public Part2Plugin() {
    plugin = this;
  }

  /**
   * This method is called upon plug-in activation
   */
  public void start(BundleContext context) throws Exception {
    super.start(context);
  }

  /**
   * This method is called when the plug-in is stopped
   */
  public void stop(BundleContext context) throws Exception {
    super.stop(context);
    plugin = null;
  }

  /**
   * Returns the shared instance.
   */
  public static Part2Plugin getDefault() {
    return plugin;
  }

  /**
   * Returns an image descriptor for the image file at the given
   * plug-in relative path.
   *
   * @param path the path
   * @return the image descriptor
   */
  public static ImageDescriptor getImageDescriptor(String path) {
    return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.ui.tutorials.rcp.part2", path);
  }
}
Build properties
The build.properties file (see Listing 9) will be needed when exporting the application for others to use. In particular if your application needs any resources like icons they should be listed here in the bin.includes section. The Plug-in Manifest editor provides a convenient interface to modify this file that is less error-prone than modifying it by hand.
Listing 9. build.properties
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
               META-INF/,\
               .
Conclusion
In part 2 of this tutorial, we looked at some of the API of the Rich Client Platform that allows you to develop customized native-looking client-side Java programs. The next part will delve into branding and deploying your application so others can use it. All the sample code for this part is included in the part2.zip archive file that accompanies this document.
References
RCP Tutorial Part 1
RCP Tutorial Part 3
Eclipse Rich Client Platform
The Equinox project (OSGi in Eclipse)
How to Internationalize your Eclipse Plug-in
PDE Does Plug-ins
Notes on the Eclipse Plug-in Architecture
On the Job: The Eclipse Jobs API
Almost All Java Web Apps Need Model 2 (introduction to the Model 2 architecture)
Evolving Java-based APIs
To discuss or report problems in this article see bug 104170.
IBM is trademark of International Business Machines Corporation in the United States, other countries, or both.
Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.
Microsoft and Windows are trademarks of Microsoft Corporation in the United States, other countries, or both.
Other company, product, and service names may be trademarks or service marks of others.

 

智尚简介  |  诚聘英才  |  联系我们  |  友情链接
版权所有:@2007-2009 智尚 电话:0760-86388801 客服QQ:875870576
地址:广东中山市学院路1号 邮编:528402 皖ICP备10002124号
  • 境外将美元汇入中国方法渠道方式
  • 财产、厂房和设备按照IAS16审计
  • IFRS:國際財務報告準則
  • IFRS:國際財務報告準則
  • 德国酒店中德两国文化的交融和冲突
  • 工业翻译中译英考试题目
  • Introduction to en
  • 从汉法主要颜色词汇的文化内涵看两国文
  • Un problème chez &
  • INTERNATIONAL AND
  • IHRM Individual re
  • НАЦИОНАЛЬНО-КУЛЬТУ
  • ТЕОРЕТИЧЕСКИЕ ОСНО
  • SPE会议论文翻译
  • Project Proposal 地
  • 中国意大利家用电器领域合作的可能性和
  • Career Goal与Career
  • Caractéristiques e
  • L'influence de l'S
  • 英语口语教学改革途径测试与分析
  • 语用学理论与高校英语阅读教学
  • 日本语研究计划书写作申请
  • To Whom it May Con
  • 译文中英对照葡萄酒产品介绍
  • 韩国传统用餐礼节
  • 日本語の暧昧語婉曲暧昧性省略表現以心
  • 研究计划书写作要求
  • Outline Impact of
  • 计算机工程与网络技术国际学术会议EI
  • 微软的人脸3D建模技术 Kinect
  • Qualitative resear
  • 新闻的感想
  • 与老师对话的测验
  • 韩语论文修改意见教授老师
  • 华南师范大学外国语言文化学院英语专业
  • APA论文写作格式
  • the surrounding en
  • Современное состоя
  • CHIN30005 Advanced
  • The APA Harvard Sy
  • Annotated Bibiolgr
  • Acker Merrall & Co
  • 资生堂进入中国市场的经营策略
  • Introduction to Pu
  • 软件测试Introduction t
  • Pro Ajax and java
  • 用户体验The user exper
  • AJAX Design Patter
  • The Rich Client Pl
  • Keyframer Chunks
  • 3D-Studio File For
  • Mathematics for Co
  • The Linux MTD, JFF
  • 中日体态语的表现形式及其差异
  • CB 202 System Anal
  • 论日本恐怖电影与好莱坞恐怖片的异同
  • 俄语论文修改
  • 古典诗歌翻译英语论文资料
  • <한중
  • 公司治理(Corporate Gov
  • 英语习语翻译中的移植与转换
  • 日语(上) 期末复习题
  • ACTIVIDAD CORRESPO
  • 리더&#
  • 购物小票翻译
  • 论文摘要翻译英文
  • Bedeutung der Prod
  • ELABORACIÓN
  • 英语考卷代写代做
  • 日本語の感情形容詞の使用特徴——ドラ
  • 未来創造学部卒業研究要領
  • 光之明(国际)低碳产品交易中心介绍
  • 中国の茶文化と日本茶道との比較—精神
  • 목차
  • Final Project Grad
  • 東京学芸大学>センターなど教員許 夏
  • 東京学芸大学 大学院教育学研究科(修
  • 白澤論
  • ポスト社会主義モンゴルにおけるカザフ
  • 言語と色彩現象—史的テクストをもとに
  • 渡来人伝説の研究
  • 中日企业文化差异的比较
  • Modellierung des B
  • 日本大学奖学金申请
  • 大学日语教师尉老师
  • 석사&#
  • Chemical Shift of
  • 中韩生日习俗文化比较
  • Measure of Attachm
  • 酒店韩国客人满意度影响因素研究
  • 要旨部分の訂正版をお送りします
  • Writing and textua
  • 日本企業文化が中国企業にもたらす啓示
  • 日本情报信息专业考试题
  • 雅丽姿毛绒时装有限公司网站文案(中文
  • 語用論の関連性理論「carston」
  • 組織行動と情報セキュリティ.レポート
  • Bedarf
  • 中日企业文化差异的比较
  • 从语形的角度对比中日“手”语义派生的
  • 中国明朝汉籍东传日本及其对日本文化的
  • 《中日茶道文化比较》
  • 从中日两国电视剧看中日文化之差异
  • FOM Hochschule für
  • Die Rolle der Bank
  • A Penny for Your T
  • 也谈ガ行鼻浊音的语音教学问题
  • On the Difference
  • 衣装は苗族の伝統文化の主な表現形式
  • 日语语言文学硕士论文:日本の义务教育
  • 日本的茶文化
  • Samsung Electronic
  • Synthesis and char
  • The traveling mark
  • The Japanese Democ
  • 四季の歌
  • CapitoloI La situa
  • The Effects of Aff
  • WEB服务安全保障分析
  • 音译汉语和英语的相互渗透引用
  • 中日两国服装贸易日语论文写作要求
  • 日语论文修改意见
  • 英语作文题目
  • 申请留学社会经验心得体会
  • BE951 Coursework O
  • Overview township
  • 日本の長寿社会考察
  • 日语老师教师电话联系方式
  • 「依頼」に対する中上級者の「断り」に
  • 日本語序論
  • component formatti
  • 日文文献资料的查阅方法
  • 日文文献资料的查阅方法
  • 日语文献检索日文文献搜索网站
  • 日本留学硕士及研究生的区别硕士申请条
  • Adult attachment s
  • レベルが向上する中国の日本学研究修士
  • 日本留学硕士(修士)与研究生的区别
  • Nontraditional Man
  • Engine Lathes
  • Automatic Screw M
  • Chain Drives
  • V-belt
  • Bestimmung der rut
  • 中山LED生产厂家企业黄页大全
  • 活用神话的文化背景来看韩国语教育方案
  • MLA論文格式
  • 旅游中介
  • MLA论文格式代写MLA论文
  • 小論文參考資料寫作格式範例(採APA
  • clothing model; fi
  • 共同利用者支援システムへのユーザー登
  • 太陽風を利用した次世代宇宙推進システ
  • RAO-SS:疎行列ソルバにおける実
  • 井伏鱒二の作品における小動物について
  • 從“老祖宗的典籍”到“現代科學的証
  • “A great Pecking D
  • 净月法师简历
  • 科技论文中日对照
  • 翻译的科技论文节选
  •  IPY-4へ向ける準備の進み具合
  • 論文誌のJ-STAGE投稿ʍ
  • Journal of Compute
  • 学会誌 (Journal of Co
  • 学会誌JCCJ特集号への投稿締切日の
  • 「化学レポート:現状と将来」
  • 韩语翻译个人简历
  • 九三会所
  • 事態情報附加連体節の中国語表現につい
  • International Bacc
  • HL introduction do
  • コーパスを利用した日本語の複合動詞の
  • 日语分词技术在日语教材开发中的应用构
  • 北極圏環境研究センター活動報告
  • 语用学在翻译中的运用
  • 日汉交替传译小议——从两篇口译试题谈
  • 総合科学専攻における卒業論文(ミニ卒
  • Heroes in August W
  • 玛雅文明-西班牙语论文
  • 西班牙语论文-西班牙旅游美食建筑
  • 八戸工業大学工学部環境建設工学科卒業
  • 親の連れ子として離島の旧家にやって来
  • 「米ソ協定」下の引揚げにおいて
  • タイトル:少子化対策の国際比較
  • メインタイトル:ここに入力。欧数字は
  • 東洋大学工学部環境建設学科卒業論文要
  • IPCar:自動車プローブ情報システ
  • Abrupt Climate Cha
  • Recognition of Eco
  • Complexities of Ch
  • Statistical Analys
  • Dangerous Level o
  • 中日对照新闻稿
  • 俄汉语外来词使用的主要领域对比分析
  • 两种形式的主谓一致
  • 韩语论文大纲修改
  • 중국&#
  • 俄语外来词的同化问题
  • 北海道方言中自发助动词らさる的用法与
  • 论高职英语教育基础性与实用性的有机结
  • 论高职幼师双语口语技能的培养
  • 论高职幼师英语口语技能的培养
  •     自分・この眼&
  • 成蹊大学大学院 経済経営研究科
  • アクア・マイクロ
  • 公共経営研究科修士論文(政策提言論文
  • 基于学习风格的英语学习多媒体课件包
  • 后殖民时期印度英语诗歌管窥
  • 汉语互动致使句的句法生成
  • 笔译价格
  • 携帯TV電話の活用
  • 英語学習におけるノートテイキング方略
  • 強化学習と決定木によるエージェント
  • エージェントの行動様式の学習法
  • 学習エージェントとは
  • 強化学習と決定木学習による汎用エージ
  • 講演概要の書き方
  • 对学生英语上下义语言知识与写作技能的
  • 英汉词汇文化内涵及其翻译
  • 论大学英语教学改革之建构主义理论指导
  • 国内影片片名翻译研究综观及现状
  • 平成13年度経済情報学科特殊研究
  • Comparison of curr
  • 英文论文任务书
  • This project is to
  • the comparison of
  • デジタルペンとRFIDタグを活用した
  • 無資格者無免許・対策関
  • 創刊の辞―医療社会学の通常科学化をめ
  • gastric cancer:ade
  • 揭示政治语篇蕴涵的意识形态
  • 试论专业英语课程项目化改革的可行性
  • 多媒体环境下的英语教学交际化
  • 翻译认知论
  • 读高桥多佳子的《相似形》
  • 以英若诚对“Death of A S
  • 论沈宝基的翻译理论与实践
  • 论语域与文学作品中人物会话的翻译
  • 浅析翻译活动中的文化失衡
  • 谈《傲慢与偏见》的语言艺术
  • 论语言结构差异对翻译实效性的影响
  • 英语传递小句的认知诠释
  • 英语阅读输入的四大误区
  • 在语言选择中构建社会身份
  • 私たちが見た、障害者雇用の今。
  • 震災復興の経済分析
  • 研究面からみた大学の生産性
  • 喫煙行動の経済分析
  • 起業の経済分析
  • 高圧力の科学と技術の最近の進歩
  • 「観光立国」の実現に向けて
  • 資源としてのマグロと日本の動向
  • 揚湯試験結果の概要温泉水の水質の概要
  • 計量史研究執筆要綱 
  • 日中友好中国大学生日本語科卒業論文
  • 제 7 장
  • 전자&
  • 現代國民論、現代皇室論
  • 記紀批判—官人述作論、天皇宗家論
  • 津田的中國觀與亞洲觀
  • 津田思想的形成
  • 反思台灣與中國的津田左右吉研究
  • 遠隔講義 e-learning
  • 和文タイトルは17ポイント,センタリ
  • Design And Impleme
  • Near-surface mount
  • 중국 &
  • 韩国泡菜文化和中国的咸菜文化
  • 무한&#
  • 수시 2
  • 韩流流向世界
  • 무설&#
  • 要想学好韩语首先得学好汉语
  • 사망&#
  • Expression and Bio
  • Increased Nuclear
  • 论女性主义翻译观
  • 健康食品の有効性
  • 日语的敬语表现与日本人的敬语意识
  • 日语拒否的特点及表达
  • Solve World’s Prob
  • 韩汉反身代词“??”和“自己”的对比
  • 韩汉量词句法语义功能对比
  • 浅析日语中的省略现象
  • 浅谈日语中片假名的应用
  • 土木学会論文集の完全版下印刷用和文原
  • 英语语调重音研究综述
  • 英汉语言结构的差异与翻译
  • 平等化政策の現状と課題
  • 日本陸軍航空史航空特攻
  • 商务日语专业毕业生毕业论文选题范围
  • 家庭内暴力の現象について
  • 敬语使用中的禁忌
  • Treatment of high
  • On product quality
  • Functional safety
  • TIDEBROOK MARITIME
  • 日文键盘的输入方法
  • 高职高专英语课堂中的提问策略
  • 对高校学生英语口语流利性和正确性的思
  • 二语习得中的文化错误分析及对策探讨
  • 高职英语专业阅读课堂教学氛围的优化对
  • 趣谈英语中的比喻
  • 浅析提高日语国际能力考试听力成绩的对
  • 外语语音偏误认知心理分析
  • 读格林童话《小精灵》有感
  • “新世纪”版高中英语新课教学导入方法
  • 初探大学英语口语测试模式与教学的实证
  • 中加大学生拒绝言语行为的实证研究
  • 目的论与翻译失误研究—珠海市旅游景点
  • 对学生英语上下义语言知识与写作技能的
  • 英语水平对非英语专业研究生语言学习策
  • 英语教学中的文化渗透
  • 中学教师自主学习角色的一项实证研究
  • 叶维廉后期比较文学思想和中诗英译的传
  • 钟玲中诗英译的传递研究和传递实践述评
  • 建构主义和高校德育
  • 论习语的词法地位
  • 广告英语中的修辞欣赏
  • 从奢侈品消费看王尔德及其唯美主义
  • 论隐喻的逆向性
  • 企盼和谐的两性关系——以劳伦斯小说《
  • 论高等教育大众化进程中的大学英语教学
  • 试论《三四郎》的三维世界
  • 李渔的小说批评与曲亭马琴的读本作品
  • 浅谈中国英语的表现特征及存在意义
  • 湖南常德农村中学英语教师师资发展状况
  • 海明威的《向瑞士致敬》和菲茨杰拉德
  • 围绕课文综合训练,培养学生的写作能力
  • 指称晦暗性现象透析
  • 西部地区中学生英语阅读习惯调查
  • 论隐喻的逆向性
  • 认知体验与翻译
  • 试析英诗汉译中的创造性
  • 言语交际中模糊语浅议
  • 认知体验与翻译
  • 关于翻译中的词汇空缺现象及翻译对策
  • 从互文性视角解读《红楼梦》两译本宗教
  • 从目的论看中英动物文化词喻体意象的翻
  • 高校英语语法教学的几点思考
  • 高校体艺类学生外语学习兴趣与动机的研
  • 大学英语自主学习存在的问题及“指导性
  • 从接受美学看文学翻译的纯语言观
  • 《红楼梦》两种英译本中服饰内容的翻译
  • 法语对英语的影响
  • 影响中美抱怨实施策略的情景因素分析
  • 代写需求表
  • 跨文化交际中称赞语的特点及语言表达模
  • 实现文化教育主导外语教育之研究
  • 试论读者变量对英语阅读的影响
  • 从文化的角度看英语词汇中的性别歧视现
  • 合作原则在外贸函电翻译中的运用
  • Default 词义探悉
  • 从图示理论看英汉翻译中的误译
  • 许国璋等外语界老前辈所接受的双语教学
  • “provide” 和 “suppl
  • 由英汉句法对比看长句翻译中的词序处理
  • 1000名富翁的13条致富秘诀中英对
  • 英语中18大激励人心的谚语中英对照
  • 反省女性自身 寻求两性和谐---评
  • 浅析翻译中的“信”
  • 集体迫害范式解读《阿里》
  • 横看成岭侧成峰-从美学批评角度解读《
  • 福柯的话语权及规范化理论解读《最蓝的
  • 播客技术在大学英语教学中的应用
  • 如何在山区中等专业学校英语课堂实施分
  • 奈达与格特翻译理论比较研究
  • 语篇内外的衔接与连贯
  • Economic globaliza
  • 用概念整合理论分析翻译中不同思维模式
  • 英语新闻语篇汉译过程中衔接手段的转换
  • 对易卜生戏剧创作转向的阐释
  • 动词GO语义延伸的认知研究
  • 反思型教师—我国外语教师发展的有效途
  • 输入与输出在词汇学习中的动态统一关系
  • 教育实践指导双方身份认同批判性分析
  • 中英商务文本翻译异化和归化的抉择理据
  • 从艺术结构看《呼啸山庄》
  • 从儒家术语“仁”的翻译论意义的播撒
  • 论隐喻与明喻的异同及其在教学中的启示
  • 话语标记语的语用信息在英汉学习型词典
  • 论森欧外的历史小说
  • 翻译认知论 ——翻译行为本质管窥
  • 中美语文教材设计思路的比较
  • 美国写作训练的特点及思考
  • UP语义伸延的认知视角
  • 成功的关键-The Key to S
  • 杨利伟-Yang Liwei
  • 武汉一个美丽的城市
  • 对儿童来说互联网是危险的?
  • 跨文化交际教学策略与法语教学
  • 试论专业英语课程项目化改革的可行性-
  • 论沈宝基的翻译理论与实践
  • 翻译认知论——翻译行为本质管窥
  • 母爱的虚像 ——读高桥多佳子的《相似
  • 浅析英语广告语言的特点
  • 中国の株価動向分析
  • 日语拒否的特点及表达
  • 日语的敬语表现与日本人的敬语意识
  • 浅析日语中的省略现象
  • 浅谈日语中片假名的应用
  • 浅谈日语敬语的运用法
  • 浅谈日语会话能力的提高
  • ^论日语中的年轻人用语
  • 敬语使用中的禁忌
  • 关于日语中的简略化表达
  • 关于日语的委婉表达
  • The Wonderful Stru
  • Of Love(论爱情)
  • SONY Computer/Notb
  • 从加拿大汉语教学现状看海外汉语教学
  • MLA格式简要规范
  • 浅析翻译类学生理解下的招聘广告
  • 日本大学排名
  • 虎头虎脑
  • 杰克逊涉嫌猥亵男童案首次庭审
  • Throughout his car
  • June 19,1997: Vict
  • 今天你睡了“美容觉”吗?
  • [双语]荷兰橙色统治看台 荷兰球员统
  • Father's Day(异趣父亲节
  • 百佳电影台词排行前25名
  • June 9,1983: Thatc
  • June 8, 1968: Robe
  • 60 players mark bi
  • June 6, 1984: Indi
  • 日本の専門家が漁業資源を警告するのは
  • オーストリア巴馬は模範的な公民に日本
  • 日本のメディアは朝鮮があるいは核実験
  • 世界のバレーボールの日本の32年の始
  • 日本の国債は滑り降りて、取引員と短い
  • 广州紧急“清剿”果子狸
  • 美国“勇气”号登陆火星
  • 第30届冰灯节哈尔滨开幕
  • 美国士兵成为时代周刊2003年度人物
  • BIRD flu fears hav
  • 中国チベット文化週間はマドリードで開
  • 中国チベット文化週間はマドリードで開
  • 中国の重陽の文化の発祥地──河南省西
  • シティバンク:日本の国債は中国の中央
  • イギリスは間もなく中国にブタ肉を輸出
  • 古いものと新しい中国センター姚明の失
  • 中国の陝西は旅行して推薦ӥ
  • 中国の電子は再度元手を割って中国の有