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 – injecting individual preferences


Although it is possible to inject an entire preference node, sometimes it is more convenient to inject just a single preference value. This can reduce the amount of code needed to extract and use a preference value. In addition, this can remove the runtime dependency on IEclipsePreferences, which can make the code more portable.

  1. Replace the injected IEclipsePreferences node with an int launchCount field, and append value = "launchCount" to the @Preferences annotation:

    @Preference(nodePath = "com.packtpub.e4.clock.ui",
     value = "launchCount")
    @Inject
    // IEclipsePreferences preferences;
    int launchCount;
  2. Update the print message to use the launchCount value directly:

    System.out.println("Launch count is: " + launchCount);
  3. Run the target Eclipse instance, and open the Time Zone Tree View. In the Console view, there should be a Launch count is: message with the same value as before.

What just happened?

Instead of injecting the entire preferences node...