Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Eclipse Plug-in Development Beginner's Guide - Second Edition

You're reading from  Eclipse Plug-in Development Beginner's Guide - Second Edition

Product type Book
Published in Aug 2016
Publisher
ISBN-13 9781783980697
Pages 458 pages
Edition 2nd Edition
Languages
Author (1):
Alex Blewitt Alex Blewitt
Profile icon Alex Blewitt

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
1. Creating Your First Plug-in 2. Creating Views with SWT 3. Creating JFace Viewers 4. Interacting with the User 5. Working with Preferences 6. Working with Resources 7. Creating Eclipse 4 Applications 8. Migrating to Eclipse 4.x 9. Styling Eclipse 4 Applications 10. Creating Features, Update Sites, Applications, and Products 11. Automated Testing of Plug-ins 12. Automated Builds with Tycho 13. Contributing to Eclipse Using OSGi Services to Dynamically Wire Applications Pop Quiz Answers Index

Chapter 4 – Interacting with the User


Understanding menus

1. A command can be associated with a handler to provide a menu item. Handlers are indirection mechanisms that allow the same menu (example Copy) to take on different commands based on which context they are in. It is also possible to have a default command id associated with a menu to avoid this indirection.

2. The M1 key is an alias for Cmd on macOS, and for Ctrl on other platforms. When defining standard commands like copy (M1+C) it has the expected behaviour on both platforms (Cmd + C for macOS and Ctrl + C for others).

3. Keystrokes are bound to commands via a binding, which lists the key(s) necessary to invoke and the associated command/handler.

4. A menu's locationURI is where it will contribute the entry to the UI. These are specified either as relative to an existing menu's contribution, or to its generic additions entry. It is also possible to specify custom ones which are associated with custom code.

5. A pop-up menu is created by adding a menu to the part descriptor, and then enabling contributions by registering with the EMenuService.

Understanding jobs

1. The syncExec() will block and wait for the job to complete before continuing code. The asyncExec() will continue to run after posting the job but before it completes.

2. The UISynchronize instance can be used to run jobs on UI and non-SWT UI threads.

3. The UIJob will always run on the UI thread of the runtime, and direct access of widgets will not run into a thread error. Care should be taken to minimize the amount of time spent in the UI thread so as not to block Eclipse. The Job will run on a non-UI thread, and so does not have access to acquire or modify UI-threaded objects.

4. The Status.OK_STATUS singleton is used to indicate success in general. Although it is possible to instantiate a Status object with an OK code, doing so only increases the garbage collection as the Status result is typically discarded after execution.

5. The CommandService can be injected using DI by using @Inject ICommandService into the E4 view.

6. An icon can be displayed by setting a property on the Job with the name IProgressConstants2.ICON_NAME.

7. SubMonitors are generally easier to use at the start of a method, to ensure that the monitor being passed in is correctly partitioned as appropriate for the task in hand. The SubProgressMonitor should generally not be used.

8. The cancellation should be checked as frequently as possible, so that as soon as the user clicks on cancel, the job is aborted.

Understanding errors

1. An informational dialog is shown with MessageDialog.openInformation() (and .openWarning() and .openError() as well). There is also a MessageDialog.openConfirmation(), which returns the value of a yes/no answer to the user.

2. The StatusReporter provides a means to report statuses such that they can be handled appropriately, but without a UI association.

3. Status reporting is asynchronous by default, although a BLOCK option exists to make it synchronous.

4. To combine the results of many things into one report, use a MultiStatus object.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}