Chapter 4. Interacting with the User

In the previous chapter, we looked at some of the basic JFace viewers, which provide a representation of data. However, we need to interact with the user and we can do this in multiple ways, from responding to mouse clicks to processing data-intensive operations in the background.

In this chapter we will cover:

  • Creating a menu in response to a user pop up
  • Adding a command and a handler in a menu
  • Using progress managers to report work
  • Adding actions to the progress manager
  • Showing errors and dealing with failure

Creating actions, commands, and handlers

The first few releases of the Eclipse framework provided Action as a means of contributing to menu items. These were defined declaratively via actionSets in the plugin.xml file, and many tutorials still reference those today. At the programming level, when creating views, Actions are still used to provide context menus programmatically.

They were replaced with commands in Eclipse 3, as a more abstract way of decoupling the operation of a command with its representation of the menu. To connect these two together, a handler is used.

Note

Creating actions, commands, and handlers E4: Eclipse 4.x uses the command's model, and decouples it further using the @Execute annotation on the handler class. Commands and views are hooked up with entries on the application's model. The basic ideas covered in this chapter will translate into examples in the E4 in Chapter 7.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset