You are previewing Eclipse Plug-in Development Beginner's Guide - Second Edition.
O'Reilly logo
Eclipse Plug-in Development Beginner's Guide - Second Edition

Book Description

Develop skills to build powerful plug-ins with Eclipse IDE through examples

About This Book

  • Create useful plug-ins to make Eclipse work for you

  • Learn how to migrate Eclipse 3.x plug-ins to Eclipse 4.x

  • From automation to testing, find out how to get your IDE performing at an impressive standard

  • Who This Book Is For

    This book is for Java developers familiar with Eclipse who need more from the IDE. This book will sharpen your confidence and make you a more productive developer with a tool that supports rather than limits you.

    What You Will Learn

  • Create plug-ins for Eclipse 4.x

  • Test plug-ins automatically with JUnit

  • Display tree and table information in views

  • Upgrade Eclipse 3.x plug-ins to Eclipse 4.x

  • Find out how to build user interfaces from SWT and JFace

  • Run tasks in the background and update the user interface asynchronously

  • Automate builds of plug-ins and features

  • Automate user interface tests with SWTBot

  • In Detail

    Eclipse is used by everyone from indie devs to NASA engineers. Its popularity is underpinned by its impressive plug-in ecosystem, which allows it to be extended to meet the needs of whoever is using it. This book shows you how to take full advantage of the Eclipse IDE by building your own useful plug-ins from start to finish.

    Taking you through the complete process of plug-in development, from packaging to automated testing and deployment, this book is a direct route to quicker, cleaner Java development. It may be for beginners, but we're confident that you'll develop new skills quickly. Pretty soon you'll feel like an expert, in complete control of your IDE.

    Don't let Eclipse define you - extend it with the plug-ins you need today for smarter, happier, and more effective development.

    Style and approach

    Packed with plenty of examples so you're never stuck, or never left simply reading instructions, this book encourages you to get started immediately. This book is for developers who want to develop, not just learn.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Eclipse Plug-in Development Beginner's Guide Second Edition
      1. Table of Contents
      2. Eclipse Plug-in Development Beginner's Guide Second Edition
      3. Credits
      4. Foreword
      5. About the Author
      6. Acknowledgments
      7. About the Reviewers
      8. www.PacktPub.com
        1. eBooks, discount offers, and more
          1. Why subscribe?
      9. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Sections
        5. Time for action – heading
          1. What just happened?
          2. Pop quiz – heading
          3. Have a go hero – heading
        6. Conventions
        7. Reader feedback
        8. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      10. 1. Creating Your First Plug-in
        1. Getting started
        2. Time for action – setting up the Eclipse environment
          1. What just happened?
          2. Creating your first plug-in
        3. Time for action – creating a plug-in
          1. What just happened?
          2. Pop quiz – Eclipse workspaces and plug-ins
          3. Running plug-ins
        4. Time for action – launching Eclipse from within Eclipse
          1. What just happened?
          2. Pop quiz: launching Eclipse
          3. Have a go hero – modifying the plug-in
        5. Debugging a plug-in
        6. Time for action – debugging a plug-in
          1. What just happened?
        7. Time for action – updating code in the debugger
          1. What just happened?
          2. Debugging with step filters
        8. Time for action – setting up step filtering
          1. What just happened?
          2. Using different breakpoint types
        9. Time for action – breaking at method entry and exit
          1. What just happened?
          2. Using conditional breakpoints
        10. Time for action – setting a conditional breakpoint
          1. What just happened?
          2. Using exceptional breakpoints
        11. Time for action – catching exceptions
          1. What just happened?
        12. Time for action – inspecting and watching variables
          1. What just happened?
          2. Pop quiz: debugging
          3. Have a go hero – working with breakpoints
        13. Summary
      11. 2. Creating Views with SWT
        1. Creating views and widgets
        2. Time for action – creating a view
          1. What just happened?
            1. Manifest.mf
            2. plugin.xml
        3. Time for action – drawing a custom view
          1. What just happened?
        4. Time for action – drawing a seconds hand
          1. What just happened?
        5. Time for action – animating the second hand
          1. What just happened?
        6. Time for action – running on the UI thread
          1. What just happened?
        7. Time for action – creating a reusable widget
          1. What just happened?
        8. Time for action – using layouts
          1. What just happened?
          2. Pop quiz: understanding views
          3. Have a go hero – drawing hour and minute hands
        9. Managing resources
        10. Time for action – getting colorful
          1. What just happened?
        11. Time for action – finding the leak
          1. What just happened?
        12. Time for action – plugging the leak
          1. What just happened?
          2. Pop quiz – understanding resources
          3. Have a go hero
        13. Interacting with the user
        14. Time for action – getting in focus
          1. What just happened?
        15. Time for action – responding to input
          1. What just happened?
          2. Pop quiz: understanding widgets
          3. Have a go hero – updating the clock widget
        16. Using other SWT widgets
        17. Time for action – adding items to the tray
          1. What just happened?
        18. Time for action – responding to the user
          1. What just happened?
        19. Time for action – modal and other effects
          1. What just happened?
        20. Time for action – groups and tab folders
          1. What just happened?
          2. Pop quiz: using SWT
          3. Have a go hero: enhancing the time zones
        21. Summary
      12. 3. Creating JFace Viewers
        1. Why JFace?
        2. Creating TreeViewers
        3. Time for action – creating a tree viewer
          1. What just happened?
        4. Time for action – using Images in JFace
          1. What just happened?
        5. Time for action – styling label providers
          1. What just happened?
          2. Pop quiz – understanding JFace
          3. Have a go hero – adding images for regions
        6. Sorting and filtering
        7. Time for action – sorting items in a viewer
          1. What just happened?
        8. Time for action – filtering items in a viewer
          1. What just happened?
          2. Pop quiz – understanding sorting and filters
          3. Have a go hero – expanding and filtering
        9. Interaction
        10. Time for action – adding a double-click listener
          1. What just happened?
          2. Pop quiz – understanding interaction
        11. Tabular data
        12. Time for action – viewing time zones in tables
          1. What just happened?
          2. Pop quiz: understanding tables
        13. Selection
        14. Time for action – propagating selection
          1. What just happened?
        15. Time for action – responding to selection changes
          1. What just happened?
          2. Have a go hero – adding selection support to the table view
          3. Pop quiz – understanding selection
        16. Summary
      13. 4. Interacting with the User
        1. Creating menus, commands, and handlers
        2. Time for action – installing the E4 tools
          1. What just happened?
        3. Time for action – creating commands and handlers
          1. What just happened?
        4. Time for action – binding commands to keys
          1. What just happened?
        5. Time for action – changing contexts
          1. What just happened?
        6. Time for action – enabling and disabling menus items
          1. What just happened?
        7. Time for action – contributing commands to pop-up menus
          1. What just happened?
          2. Have a go hero – using view menus and toolbars
          3. Pop quiz – understanding menus
        8. Jobs and progress
        9. Time for action – running operations in the background
          1. What just happened?
          2. Have a go hero – using a UIJob
        10. Time for action – reporting progress
          1. What just happened?
        11. Time for action – dealing with cancellation
          1. What just happened?
        12. Time for action – using subtasks and sub-progress monitors
          1. What just happened?
        13. Time for action – using null progress monitors and sub monitors
          1. What just happened?
        14. Time for action – setting job properties
          1. What just happened?
          2. Have a go hero – displaying in the taskbar
          3. Pop quiz – understanding Jobs
        15. Reporting errors
        16. Time for action – showing errors
          1. What just happened?
          2. Pop quiz – understanding errors
        17. Summary
      14. 5. Working with Preferences
        1. Eclipse Preferences
        2. Time for action – persisting a value
          1. What just happened?
        3. Time for action – injecting preferences
          1. What just happened?
        4. Time for action – injecting individual preferences
          1. What just happened?
        5. Time for action – responding to preference changes
          1. What just happened?
        6. Preference pages
        7. Time for action – creating a preference page
          1. What just happened?
        8. Time for action – creating warning and error messages
          1. What just happened?
        9. Time for action: choosing from a list
          1. What just happened?
        10. Time for action – aligning field editors with a grid
          1. What just happened?
        11. Time for action – placing the preferences page
          1. What just happened?
        12. Time for action: using other field editors
          1. What just happened?
        13. Time for action – searching for preferences
          1. What just happened?
          2. Have a go hero – translating into different languages
          3. Pop quiz – understanding preferences
        14. Summary
      15. 6. Working with Resources
        1. Using the workspace and resources
        2. Time for action – creating an editor
          1. What just happened?
        3. Time for action – writing the markup parser
          1. What just happened?
        4. Time for action – building the builder
          1. What just happened?
        5. Time for action – iterating through resources
          1. What just happened?
        6. Time for action – creating resources
          1. What just happened?
        7. Time for action – implementing incremental builds
          1. What just happened?
        8. Time for action: handling deletion
          1. What just happened?
          2. Have a go hero – builder upgrades
        9. Using natures
        10. Time for action – creating a nature
          1. What just happened?
          2. Have a go hero – enable for selected object type
        11. Using markers
        12. Time for action – error markers if file is empty
          1. What just happened?
        13. Time for action – registering a marker type
          1. What just happened?
          2. Have a go hero – work out when the file is really empty
          3. Pop quiz – understanding resources, builders, and markers
        14. Summary
      16. 7. Creating Eclipse 4 Applications
        1. Time for action – installing E4 tooling
          1. What just happened?
        2. Time for action – creating an E4 application
          1. What just happened?
        3. Time for action – creating a part
          1. What just happened?
        4. Using services and contexts
        5. Time for action – adding logging
          1. What just happened?
        6. Time for action – getting the window
          1. What just happened?
        7. Time for action – obtaining the selection
          1. What just happened?
        8. Time for action – dealing with events
          1. What just happened?
        9. Time for action – calculating values on demand
          1. What just happened?
        10. Time for action – interacting with the UI
          1. What just happened?
        11. Using commands, handlers, and menu items
        12. Time for action – wiring a menu to a command with a handler
          1. What just happened?
        13. Time for action: passing command parameters
          1. What just happened?
        14. Time for action – creating a direct menu and keybindings
          1. What just happened?
        15. Time for action – creating a pop-up menu and a view menu
          1. What just happened?
        16. Creating custom injectable classes
        17. Time for action – creating a simple service
          1. What just happened?
        18. Time for action – injecting subtypes
          1. What just happened?
          2. Have a go hero – using the tools bridge
          3. Pop quiz – understanding E4
        19. Summary
      17. 8. Migrating to Eclipse 4.x
        1. Why Eclipse 4.x?
        2. Time for action – creating a migration component
          1. What just happened?
        3. Time for action – updating to e4view
          1. What just happened?
        4. Time for action – upgrading the actions
          1. What just happened?
        5. Time for action – creating toolbars
          1. What just happened?
          2. Have a go hero – optimising the handler lookup
        6. Time for action – adding the view menu
          1. What just happened?
        7. Time for action – adding the pop-up
          1. What just happened?
        8. Migrating to Eclipse 4.x patterns
        9. Time for action – creating a model fragment
          1. What just happened?
        10. Time for action – migrating the commands and handlers
          1. What just happened?
        11. Time for action – creating the view menu
          1. What just happened?
        12. Time for action – defining the pop-up view in the fragment
          1. What just happened?
          2. Have a go hero – invoking the handler from the hookDoubleClick action
          3. Pop quiz
        13. Summary
      18. 9. Styling Eclipse 4 Applications
        1. Styling Eclipse with CSS
        2. Time for action – styling the UI with CSS
          1. What just happened?
          2. Have a go hero – experiment with other CSS properties
        3. Time for action – using custom CSS classes
          1. What just happened?
        4. Using the Eclipse spies
        5. Time for action – using the CSS Spy
          1. What just happened?
        6. Time for action – integrating the spy into a product
          1. What just happened?
        7. Styling a custom widget
        8. Time for action – adding the clock
          1. What just happened?
        9. Time for action – using a CSS property
          1. What just happened?
          2. Themes
        10. Time for action – going to the dark side
          1. What just happened?
        11. Time for action – adding themes
          1. What just happened?
        12. Time for action – switching between themes
          1. What just happened?
          2. Have a go hero
          3. Pop quiz – styling Eclipse 4
        13. Summary
      19. 10. Creating Features, Update Sites, Applications, and Products
        1. Grouping plug-ins with features
        2. Time for action – creating a feature
          1. What just happened?
        3. Time for action – exporting a feature
          1. What just happened?
        4. Time for action – installing a feature
          1. What just happened?
        5. Time for action – categorizing the update site
          1. What just happened?
        6. Time for action – depending on other features
          1. What just happened?
        7. Time for action – branding features
          1. What just happened?
          2. Have a go hero – publishing the content remotely
        8. Building applications and products
        9. Time for action – creating a headless application
          1. What just happened?
        10. Time for action – creating a product
          1. What just happened?
          2. Have a go hero – creating a product based on features
        11. Target platforms
        12. Time for action – creating a target definition
          1. What just happened?
        13. Time for action – switching to a specific version
          1. What just happened?
          2. Have a go hero – configuring target platforms for other releases
          3. Pop quiz – understanding features, applications, and products
        14. Summary
      20. 11. Automated Testing of Plug-ins
        1. Using JUnit for automated testing
        2. Time for action – adding dependencies to the target platform
          1. What just happened?
        3. Time for action – writing a simple JUnit 4 test case
          1. What just happened?
        4. Time for action – writing a plug-in test
          1. What just happened?
        5. Using SWTBot for user interface testing
        6. Time for action – writing an SWTBot test
          1. What just happened?
        7. Time for action – working with menus
          1. What just happened?
          2. Have a go hero – using resources
        8. Working with SWTBot
        9. Time for action – hiding the welcome screen
          1. What just happened?
        10. Time for action – avoiding SWTBot runtime errors
          1. What just happened?
        11. Working with views
        12. Time for action: showing views
          1. What just happened?
        13. Time for action – interrogating views
          1. What just happened?
        14. Interacting with the UI
        15. Time for action – getting values from the UI
          1. What just happened?
        16. Time for action – waiting for a condition
          1. What just happened?
          2. Have a go hero – driving the new class wizard
          3. Pop quiz – understanding swtbot
        17. Summary
      21. 12. Automated Builds with Tycho
        1. Using Maven to build Eclipse plug-ins with Tycho
        2. Time for action – installing Maven
          1. What just happened?
        3. Time for action – building with Tycho
          1. What just happened?
        4. Building features and update sites with Tycho
        5. Time for action – creating a parent project
          1. What just happened?
        6. Time for action – building a feature
          1. What just happened?
        7. Time for action – building an update site
          1. What just happened?
        8. Time for action – building a product
          1. What just happened?
        9. Time for action – using the target platform
          1. What just happened?
          2. Have a go hero – depending on Maven components
        10. Testing and releasing
        11. Time for action – running automated tests
          1. What just happened?
        12. Time for action – changing the version numbers
          1. What just happened?
          2. Have a go hero – enabling builds for other plug-ins
        13. Signing update sites
        14. Time for action – creating a self-signed certificate
          1. What just happened?
        15. Time for action – signing the plug-ins
          1. What just happened?
        16. Time for action – serving an update site
          1. What just happened?
          2. Pop quiz – understanding automated builds and update sites
        17. Summary
      22. 13. Contributing to Eclipse
        1. Open source contributions
          1. Importing the source
        2. Time for action – installing the sources
          1. What just happened?
        3. Time for action – debugging the platform
          1. What just happened?
        4. Time for action – modifying the platform
          1. What just happened?
          2. Checking out from Git
        5. Time for action – checking out from EGit and Git
          1. What just happened?
        6. Time for action – configuring the SWT project
          1. What just happened?
        7. Contributing to Eclipse
          1. Creating bugs on Bugzilla
        8. Time for action – creating an account at Eclipse
          1. What just happened?
        9. Time for action – creating a bug
          1. What just happened?
          2. Have a go hero
          3. Submitting fixes
        10. Time for action – setting up a Gerrit profile
          1. What just happened?
        11. Time for action – committing and pushing a patch
          1. What just happened?
          2. Have a go hero
        12. Summary
      23. A. Using OSGi Services to Dynamically Wire Applications
        1. Services overview
        2. Registering a service programmatically
          1. Creating an activator
          2. Registering a service
          3. Priority of services
          4. Using the services
          5. Lazy activation of bundles
          6. Comparison of services and extension points
        3. Registering a service declaratively
          1. Declarative Services
            1. Properties and Declarative Services
            2. Service references in Declarative Services
            3. Multiple components and debugging Declarative Services
          2. Dynamic Service annotations
            1. Processing annotations at Maven build time
        4. Dynamic services
          1. Resolving services each time
          2. Using a ServiceTracker
            1. Filtering services
            2. Obtaining a BundleContext without using an activator
          3. Dependent Services
        5. Dynamic service configuration
          1. Installing Felix FileInstall
          2. Installing ConfigAdmin
          3. Configuring Declarative Services
          4. Service factories
            1. Creating the EchoService
            2. Creating an EchoServiceFactory
            3. Configuring the EchoServices
        6. Summary
      24. B. Pop Quiz Answers
        1. Chapter 1 – Creating Your First Plug-in
          1. Eclipse workspaces and plug-ins
          2. Launching Eclipse
          3. Debugging
        2. Chapter 2 – Creating Views with SWT
          1. Understanding views
          2. Understanding resources
          3. Understanding widgets
          4. Using SWT
        3. Chapter 3 – Creating JFace Viewers
          1. Understanding JFace
          2. Understanding sorting and filters
          3. Understanding interaction
          4. Understanding tables
          5. Understanding selection
        4. Chapter 4 – Interacting with the User
          1. Understanding menus
          2. Understanding jobs
          3. Understanding errors
        5. Chapter 5 – Storing Preferences and Settings
          1. Understanding preferences
        6. Chapter 6 – Working with Resources
          1. Understanding resources, builders, and markers
        7. Chapter 7 – Creating Eclipse 4 Applications
          1. Understanding E4
        8. Chapter 8 – Migrating to Eclipse 4.x
        9. Chapter 9 – Styling Eclipse 4 Applications
          1. Styling Eclipse 4
        10. Chapter 10 – Creating Features, Update Sites, Applications, and Products
          1. Understanding features, applications, and products
        11. Chapter 11 – Automated Testing of Plug-ins
          1. Understanding swtbot
        12. Chapter 12 – Automated Builds with Tycho
          1. Understanding automated builds and update sites
      25. Index