Book Image

Eclipse Plug-in Development Beginner's Guide - Second Edition

By : Alex Blewitt
Book Image

Eclipse Plug-in Development Beginner's Guide - Second Edition

By: Alex Blewitt

Overview of this book

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.
Table of Contents (24 chapters)
Eclipse Plug-in Development Beginner's Guide Second Edition
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – responding to preference changes


In order to react when preferences are changed, it is necessary to inject the preference value as part of a method call. When the preference value is changed, the method will be invoked again with the new value.

  1. Remove the annotations associated with the launchCount instance field.

  2. Create a setLaunchCount method that takes an int argument and assigns it to the launchCount instance field.

    Tip

    Type setL and press Ctrl + space to suggest creating this method automatically.

  3. Add the @Inject annotation to the setLaunchCount method.

  4. Add the @Preference(nodePath = "com.packtpub.e4.clock.ui", value = "launchCount") annotation to the method argument. The resulting method will look like this:

    int launchCount;
    
    @Inject
    public void setLaunchCount(
     @Preference(nodePath = "com.packtpub.e4.clock.ui",
       value = "launchCount") int launchCount) {
      this.launchCount = launchCount;
    }
  5. Run the target Eclipse instance, and open the Time Zone Tree View. In the Console...