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


Eclipse 4 Plug-in Development by Example Beginner's Guide
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
$22.94
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
$44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Create plug-ins to extend the Eclipse runtime covering Eclipse 3.x and the changes required for Eclipse 4.x
  • Plug-ins from design to distribution — wide coverage of the entire process
  • No prior OSGi or Eclipse plug-in development experience necessary

Book Details

Language : English
Paperback : 348 pages [ 235mm x 191mm ]
Release Date : June 2013
ISBN : 1782160329
ISBN 13 : 9781782160328
Author(s) : Dr Alex Blewitt
Topics and Technologies : All Books, Application Development, Beginner's Guides, Java, Open Source

Table of Contents

Preface
Chapter 1: Creating Your First Plug-in
Chapter 2: Creating Views with SWT
Chapter 3: Creating JFace Viewers
Chapter 4: Interacting with the User
Chapter 5: Storing Preferences and Settings
Chapter 6: Working with Resources
Chapter 7: Understanding the Eclipse 4 Model
Chapter 8: Creating Features, Update Sites, Applications, and Products
Chapter 9: Automated Testing of Plug-ins
Chapter 10: Automated Builds with Tycho
Appendix: Pop Quiz Answers
Index
  • Chapter 1: Creating Your First Plug-in
    • Getting started
    • Time for action – setting up the Eclipse SDK environment
    • Creating your first plug-in
    • Time for action – creating a plug-in
    • Running plug-ins
    • Time for action – launching Eclipse from within Eclipse
    • Debugging a plug-in
    • Time for action – debugging a plug-in
    • Time for action – updating code in debugger
    • Debugging with step filters
    • Time for action – setting up step filtering
    • Using different breakpoint types
    • Time for action – breaking at method entry and exit
    • Using conditional breakpoints
    • Time for action – setting a conditional breakpoint
    • Using exceptional breakpoints
    • Time for action – catching exceptions
    • Time for action – using watch variables and expressions
    • Summary
    • Chapter 2: Creating Views with SWT
      • Creating views and widgets
      • Time for action – creating a view
      • Time for action – drawing a custom view
      • Time for action – drawing a second hand
      • Time for action – animating the second hand
      • Time for action – running on the UI thread
      • Time for action – creating a reusable widget
      • Time for action – using layouts
      • Managing resources
      • Time for action – getting colorful
      • Time for action – finding the leak
      • Time for action – plugging the leak
      • Interacting with the user
      • Time for action – getting in focus
      • Time for action – responding to input
      • Using other SWT widgets
      • Time for action – adding items to the tray
      • Time for action – responding to the user
      • Time for action – modal and other effects
      • Time for action – groups and tab folders
      • Summary
      • Chapter 3: Creating JFace Viewers
        • Why JFace?
        • Creating TreeViewers
        • Time for action – creating a TreeViewer
        • Time for action – using Images in JFace
        • Time for action – styling label providers
        • Sorting and filtering
        • Time for action – sorting items in a viewer
        • Time for action – filtering items in a viewer
        • Interaction and properties
        • Time for action – adding a double-click listener
        • Time for action – showing properties
        • Tabular data
        • Time for action – viewing time zones in tables
        • Time for action – syncing selection
        • Summary
        • Chapter 4: Interacting with the User
          • Creating actions, commands, and handlers
          • Time for action – adding context menus
          • Time for action – creating commands and handlers
          • Time for action – binding commands to keys
          • Time for action – changing contexts
          • Time for action – enabling and disabling the menu's items
          • Time for action – reusing expressions
          • Time for action – contributing commands to pop-up menus
          • Jobs and progress
          • Time for action – running operations in the background
          • Time for action – reporting progress
          • Time for action – dealing with cancellation
          • Time for action – using subtasks and subprogress monitors
          • Time for action – using null progress monitors and submonitors
          • Time for action – setting job properties
          • Reporting errors
          • Time for action – showing errors
          • Summary
          • Chapter 5: Storing Preferences and Settings
            • Storing preferences
            • Time for action – persisting a value
            • Time for action – creating a preference page
            • Time for action – creating warning and error messages
            • Time for action – choosing from a list
            • Time for action – using a grid
            • Time for action – placing the preferences page
            • Time for action – using other field editors
            • Time for action – adding keywords
            • Time for action: using IEclipsePreferences
            • Using IMemento and DialogSettings
            • Time for action – adding a memento for the Time Zone View
            • Time for action – using DialogSettings
            • Summary
            • Chapter 6: Working with Resources
              • Using the workspace and resources
              • Time for action – creating an editor
              • Time for action – writing the markup parser
              • Time for action – building the builder
              • Time for action – iterating through resources
              • Time for action – creating resources
              • Time for action – implementing incremental builds
              • Time for action – handling deletion
              • Using natures
              • Time for action – creating a nature
              • Using markers
              • Time for action – error markers if the file is empty
              • Time for action – registering a marker type
              • Summary
              • Chapter 7: Understanding the Eclipse 4 Model
                • Working with the Eclipse 4 model
                • Time for action – installing E4 tooling
                • Time for action – creating an E4 application
                • Time for action – creating a part
                • Time for action – styling the UI with CSS
                • Using services and contexts
                • Time for action – adding logging
                • Time for action – getting the window
                • Time for action – obtaining the selection
                • Time for action – dealing with events
                • Time for action – calculating values on demand
                • Time for action – using preferences
                • Time for action – interacting with the UI
                • Using Commands, Handlers, and MenuItems
                • Time for action – wiring a menu to a command with a handler
                • Time for action – passing command parameters
                • Time for action – creating a direct menu and keybindings
                • Time for action – creating a pop-up menu and a view menu
                • Creating custom injectable classes
                • Time for action – creating a simple service
                • Time for action – injecting subtypes
                • Summary
                • Chapter 8: Creating Features, Update Sites, Applications, and Products
                  • Grouping plug-ins with features
                  • Time for action – creating a feature
                  • Time for action – exporting a feature
                  • Time for action – installing a feature
                  • Time for action – categorizing the update site
                  • Time for action – depending on other features
                  • Time for action – branding features
                  • Building applications and products
                  • Time for action – creating a headless application
                  • Time for action – creating a product
                  • Summary
                  • Chapter 9: Automated Testing of Plug-ins
                    • Using JUnit for automated testing
                    • Time for action – writing a simple JUnit test case
                    • Time for action – writing a plug-in test
                    • Using SWTBot for user interface testing
                    • Time for action – writing an SWTBot test
                    • Time for action – working with menus
                    • Working with SWTBot
                    • Time for action – hiding the welcome screen
                    • Time for action – avoiding SWTBot runtime errors
                    • Working with views
                    • Time for action – showing views
                    • Time for action – interrogating views
                    • Interacting with the UI
                    • Time for action – getting values from the UI
                    • Time for action – waiting for a condition
                    • Summary
                    • Chapter 10: Automated Builds with Tycho
                      • Using Maven to build Eclipse plug-ins with Tycho
                      • Time for action – installing Maven
                      • Time for action – building with Tycho
                      • Building features and update sites with Tycho
                      • Time for action – creating a parent project
                      • Time for action – building a feature
                      • Time for action – building an update site
                      • Time for action – building a product
                      • Testing and releasing
                      • Time for action – running automated tests
                      • Time for action – changing the version numbers
                      • Signing update sites
                      • Time for action – creating a self-signed certificate
                      • Time for action – signing the plug-ins
                      • Time for action – serving an update site
                      • Summary
                      • Appendix: Pop Quiz Answers
                        • Chapter 1, Creating Your First Plug-in
                        • Chapter 2, Creating Views with SWT
                        • Chapter 3, Creating JFace Viewers
                        • Chapter 4, Interacting with the User
                        • Chapter 5, Storing Preferences and Settings
                        • Chapter 6, Working with Resources
                        • Chapter 7, Understanding the Eclipse 4 Model
                        • Chapter 8, Creating Features, Update Sites, Applications, and Products
                        • Chapter 9, Automated Testing of Plug-ins
                        • Chapter 10, Automated Builds with Tycho

                        Dr Alex Blewitt

                        Dr Alex Blewitt has been developing Java applications since Version 1.0 was released in 1996, and has been using the Eclipse platform since its first release as part of the IBM WebSphere Studio product suite. He even migrated some plugins from Visual Age for Java to WebSphere Studio/Eclipse as part of his PhD on Automated Verification of Design Patterns. He got involved in the open source community as a tester when Eclipse 2.1 was being released for Mac OS X, and then subsequently as an editor for EclipseZone, including being a finalist for Eclipse Ambassador in 2007. More recently, Alex has been writing for InfoQ, covering generic Java and specifically, Eclipse and OSGi subjects. He keynoted the 2011 OSGi Community Event on the past, present, and future of OSGi. The coverage of both new releases of the Eclipse platform and its projects, as well as video interviews with some of the Eclipse project leads can be found via the InfoQ home page, for which he was nominated and won the Eclipse Top Contributor 2012 award. Alex currently works for an investment bank in London. He also has a number of apps on the Apple AppStore through Bandlem Limited. When he's not working on technology, and if the weather is nice, he likes to go flying from the nearby Cranfield airport. Alex writes regularly at his blog, http://alblue.bandlem.com, as well as tweets regularly from Twitter and App.Net as @alblue.
                        Sorry, we don't have any reviews for this title yet.

                        Code Downloads

                        Download the code and support files for this book.


                        Submit Errata

                        Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                        Errata

                        - 31 submitted: last submission 10 Feb 2014

                        Errata Type: Code | Page number: 57

                        It is : timezones = new Combo(parent, SWT.SIMPLE);

                        It should be: timezones = new Combo(parent, SWT.DROP_DOWN);

                        Errata Type: Code | Page number: : 110

                        It is: MenuManager manager = new MenuManager("#PopupMenu");

                        It should be: MenuManager manager = new MenuManager(null, "#PopupMenu");

                        Errata Type: Typo | Page number: 12

                        It is: Care should be taken while installing Eclipse for RCP and RAP developers, as this will cause the applications created in Chapter 7 ,  Understanding the Eclipse 4 Model and Chapter 8 ,  Creating Features, Update Sites, Applications, and Products.

                        It should be: Care should be taken if installing Eclipse for RCP and RAP developers, as this will cause problems for applications created in Chapter 7 ,  Understanding the Eclipse 4 Model and Chapter 8 ,  Creating Features, Update Sites, Applications, and Products.

                         

                         

                        Errata Type: Typo | Page Number: 32

                        It is:

                        11. Click on the  Add new expression option in the bottom of the  Variables  view.

                        It should be:

                        11. Click on the  Add new expression option in the bottom of the Expressions  view.

                         

                         

                        Errata Type: Typo | Page Number: 32

                        It is:

                        12. Add new  java.util.Date() and the right-hand side will show the current time.

                        It should be:

                        12. Add new  java.util.Date() and the right-hand side will show the current time.

                         

                        The term "new" should also be included in the code.

                        Errata type: Code | Page Number: 80

                        It is:  15. ... the createPartControl() method of TimeZoneTreeViewer, ...

                        It should be: 15. ... the createPartControl() method of TimeZoneTreeView, ...

                        Errata type: Code | Page Number: 89

                        It is : Modify the TimeZoneTreeViewer  class at the bottom of the  createPartControl() method:

                        It should be:  Modify the TimeZoneTreeView  class at the bottom of the  createPartControl() method:

                        Errata Type: Typo | Page Number: 94

                        It is : The  IStructuredSelection is the most commanly used interface in dealing with selection types.


                        It should be: The  IStructuredSelection is the most commonly used interface in dealing with selection types.

                        Errata Type: Code | Page Number: 99

                        It is : It's quite common to have a class (such as TimeZonePropertySupport ) whose sole job is to implement the desired interface,...


                        It should be: It's quite common to have a class (such as TimeZonePropertySource) whose sole job is to implement the desired interface,...

                        Errata Type: Code | Page Number: 99

                        It is : The  IPropertySupport interface  provides a basic means to acquire properties from the object, and to do so it uses an identifier for each property.


                        It should be: The  IPropertySource interface  provides a basic means to acquire properties from the object, and to do so it uses an identifier for each property.

                        Errata Type: Typo | Page Number: 138

                        It is : Introduce an error into the run() method of  HelloHandler, whch will generate a NullPointerException. 


                        It should be: Introduce an error into the run() method of  HelloHandler, which will generate aNullPointerException. 

                        Errata Type: Typo | Page Number: 196

                        It is : Ensure To Be  Rendered is selected


                        It should be: Ensure To Be  Rendered is selected

                        Errata Type: Code | Page Number: 167

                        It is :  new FileReader("in.txt"),
                                 new FileWriter("out.txt"));


                        It should be: new FileReader("input.txt"),
                                           new FileWriter("output.txt"));

                        Errata Type: Code | Page Number: 167

                        It is : The file out.txt should  be shown,  and opening it should show an HTML file like the one at the start of this section.


                        It should be: The file output.txt should  be shown, and opening it should show an HTML file like the one at the start of this section.

                        Errata Type: Code | Page Number: 215

                        It is: These are supplied via an interface IContextFuction.

                        It should be:  These are supplied via an interface IContextFunction.

                        Errata Type: Code | Page Number: 122

                        It is: In the TimeZoneTreeView class, at the end of the createPartControl() method, call hookContextMenu(tableViewer).


                        It should be: In the TimeZoneTreeView class, at the end of the  createPartControl() method, call hookContextMenu(treeViewer).

                        Errata Type: Code | Page Number: 126

                        It is: MessageDialog.openInformation(null, "Hello", "World");
                                Display.getDefault().asyncExec(new Runnable() {
                                  public void run() {
                                    MessageDialog.openInformation(null, "Hello", "World");
                                  }
                                });


                        It should be: MessageDialog.openInformation(null, "Hello", "World");
                                           Display.getDefault().asyncExec(new Runnable() {
                                             public void run() {
                                               MessageDialog.openInformation(null, "Hello", "World");
                                             }
                                           });

                        Errata Type: Code | Page Number: 105

                        It is: IStructuredSelection selected = ((IStructuredSelection)sel).getFirstElement();


                        It should be: Object selected = ((IStructuredSelection)sel).getFirstElement();

                        Errata Type: Typo| Page Number: 316

                        It is: The job will run on a non-UI thread, and so it does not have access to acquire or modify UI threaded objects.

                        It should be: The Job will run on a non-UI thread, and so it does not have access to acquire or modify UI threaded objects.

                        Errata Type: Typo | Page Number: 160

                        It is: In addition, we created a separate group of settings to create a nested namespace with  settings.addNewSection("name") and with settings.getSection("name").

                        It should be: In addition, to create a separate group of settings (instead of using string prefixes), the settings to create a nested namespace, with settings.addNewSection("name") and with settings.getSection("name").

                        Errata Type: Typo | Page Number: 132

                        It is: The  NullProgressMonitor was replaced with a  SubProgressMonitor  with a SubMonitor.


                        It should be: The  NullProgressMonitor was replaced with a SubMonitor.

                        Errata Type: Typo | Page Number: 133

                        It is: In situations where there will be lots of recursive tasks, the  SubProgessMonitor will handle nesting better than instantiating a  SubProgressMonitor  each time.

                        It should be: In situations where there will be lots of recursive tasks, the  SubMonitor will handle nesting better than instantiating a  SubProgressMonitor  each time.

                        Errata Type: Typo | Page Number: 133

                        It is:  Time for action – setting job properties

                        It should be: Time for action – setting the Job properties

                        Errata Type: Code | Page number: 18

                        It is : Switch the action icon to a different graphic (note that if you use a different filename, remember to update  build.properties).

                        It should be: Switch the action icon to a different graphic (note that if you use a different filename, remember to update it in plugin.xml, and if necessary, build.properties as well).

                        Errata type: Technical | Page Number: 13

                        It is:  The Java package name, which defaults to the project's name

                        It should be: The Java package name, which defaults to the project's name followed by .handlers

                        Errata Type: Code | Page number: 49

                        It is :  RowLayout will set the component's sizes to their default size as calculated by  computeSize(0,0).

                        It should be: RowLayout will set the component's sizes to their default size as calculated by  computeSize(SWT.DEFAULT,SWT.DEFAULT).

                         

                         

                         

                        Errata Type: Code | Page number: 78

                        It is :  This requires the implementation of three methods:

                        It should be:  This requires the implementation of three out of the six methods, leaving others empty:

                         

                        Errata Type: Code | Page number: 87

                        It is : if (o1 instanceof TimeZone && o2 instanceof TimeZone) {
                            compare=((TimeZone)o2).getOffset(System.currentTimeMillis())
                            - ((TimeZone)o1).getOffset(System.currentTimeMillis());
                          }

                         

                        It should be:
                        if (o1 instanceof TimeZone && o2 instanceof TimeZone) {

                        long time= System.currentTimeMillis();
                            compare=((TimeZone)o2).getOffset(time)
                            - ((TimeZone)o1).getOffset(time);
                          }

                        Errata Type: Typo | Page Number: 79

                        It is: Since a TreeViewer can have multiple roots, there is a method to get the array of roots from the input element object.

                        It should be:  Since a TreeViewer can have multiple roots, there is a method to get the array of roots from the input element object.

                        The sentence should be removed.

                        Errata Type: Technical | Page Number: 96

                        It is: The accessors are called with an identifier; while the latter returns an array of PropertyDescriptors combining pairs of identifiers and a displayable name.

                        It should be: The getPropertyValue and isPropertySet methods are called with an identifier, while getPropertyDescriptors returns an array of PropertyDescriptors combining pairs of identifiers and a displayable name.

                        Errata Type: Technical | Page Number: 90    

                        It is: To remove the expandable nodes next to the tree items, the TreeViewer can be configured to expand nodes automatically

                        It should be: To remove the expand icon next to tree items with no children, the TreeViewer can be configured to check for children against each element automatically:

                        Sample chapters

                        You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                        Frequently bought together

                        Eclipse 4 Plug-in Development by Example Beginner's Guide +    GeoServer Beginner’s Guide =
                        50% Off
                        the second eBook
                        Price for both: $39.00

                        Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                        What you will learn from this book

                        • How to create plug-ins for Eclipse 3.x and 4.x and automatically test plug-ins with JUnit
                        • 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
                        • How to run tasks in the background and update the user interface asynchronously
                        • How to build plug-ins, features and update sites with Maven Tycho and automate user interface tests with SWTBot
                        • How to store and obtain preferences, and how to integrate with the Preferences panel
                        • How to work with the Eclipse resources model for creating and updating files and reporting errors to the user

                        In Detail

                        As a highly extensible platform, Eclipse is used by everyone from independent software developers to NASA. Key to this is Eclipse’s plug-in ecosystem, which allows applications to be developed in a modular architecture and extended through its use of plug-ins and features.

                        "Eclipse 4 Plug-in Development by Example Beginner's Guide" takes the reader through the full journey of plug-in development, starting with an introduction to Eclipse plug-ins, continued through packaging and culminating in automated testing and deployment. The example code provides simple snippets which can be developed and extended to get you going quickly.

                        This book covers basics of plug-in development, creating user interfaces with both SWT and JFace, and interacting with the user and execution of long-running tasks in the background.

                        Example-based tasks such as creating and working with preferences and advanced tasks such as well as working with Eclipse’s files and resources. A specific chapter on the differences between Eclipse 3.x and Eclipse 4.x presents a detailed view of the changes needed by applications and plug-ins upgrading to the new model. Finally, the book concludes on how to package plug-ins into update sites, and build and test them automatically.

                        Approach

                        A Beginner's Guide following the "by Example" approach. There will be 5-8 major examples that will be used in the book to develop advanced plugins with the Eclipse IDE.

                        Who this book is for

                        This book is for Java developers who are familiar with Eclipse as a Java IDE and are interested in learning how to develop plug-ins for Eclipse. No prior knowledge of Eclipse plug-in development or OSGi is necessary, although you are expected to know how to create, run, and debug Java programs in Eclipse.

                        Code Download and Errata
                        Packt Anytime, Anywhere
                        Register Books
                        Print Upgrades
                        eBook Downloads
                        Video Support
                        Contact Us
                        Awards Voting Nominations Previous Winners
                        Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                        Resources
                        Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software