ECLIPSE RICH CLIENT PLATFORM DESIGNING, CODING, AND PACKAGING JAVA TM APPLICATIONS Jeff McAffer Jean-Michel Lemieux v:addison-wesley Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich Paris Madrid Capetown Sydney Tokyo Singapore Mexico City
Contents Foreword by John Wiegand xix Foreword by Jeff Norris xxi Acknowledgments xxv Preface xxvii Part 1 0 Introduction 1 Chapter 1 Eclipse as a Rich Client Platform 3 1.1 Eclipse 4 1.2 The Eclipse Rich Client Platform 5 1.3 Eclipse RCP Over the Years 6 1.4 Uses of RCP 7 1.4.1 IBM Workplace Client TechnologyTM7 1.4.2 NASA and Eclipse RCP 9 1.5 Summary 12 Chapter 2 Eclipse RCP Concepts 13 2.1 A Community of Plug-ins 13 2.2 Inside Plug-ins 16 2.3 Putting a System Together 17 2.4 OSGi Framework 18 2.5 The Runtime 19 2.5.1 Applications 20 2.5.2 Products 20 2.5.3 Extension Registry 21 2.6 SWT 22 2.7 JFace 23 vii
viii Contents 2.8 UI Workbench 2.8.1 Contribution-based Extensibility 2.8.2 Perspectives, Views, and Editors 2.9 Summary Part II 0 RCP by Example 23 23 24 25 27 Chapter 3 Tutorial Introduction 29 3.1 What Is Hyperbola? 29 3.2 The Evolution of Hyperbola 31 3.3 Development Environment Installation 32 3.4 Target Setup 33 3.5 Checkpoint 35 3.6 Sample Code 36 3.6.1 Moving from Chapter to Chapter 36 3.6.2 Comparing 38 3.7 Learning by Example 39 3.8 Summary 40 Chapter 4 The Hyperbola Application 4 I 4.1 Hyperbola Hello World 41 4.2 Tour of the Code 48 4.2.1 Application 48 4.2.2 WorkbenchAdvisor 49 4.2.3 Perspective 50 4.2.4 WorkbenchWindowAdvisor 50 4.2.5 ActionBarAdvisor 51 4.2.6 Summary 52 4.3 Running and Debugging 52 4.3.1 Debugging 53 4.3.2 Launch Configurations 56 4.4 Summary 59 Chapter 5 Starting the Hyperbola Prototype 6 I 5.1 Continuing from the Shell 62 5.1.1 Saving Window Location and Size 63 5.2 Adding a Contacts View 63 5.2.1 Adding the Contacts. View to a Perspective 65 5.3 The Chat Model 68
Contents ix 5.4 Filling in the Contacts View 70 5.4.1 The ContactsView 70 5.4.2 Content Providers Overview 72 5.4.3 The Label Provider 76 5.5 Adding Images 77 5.6 Summary 80 5.7 Pointers 80 Chapter 6 Adding Actions 81 6.1 Adding to the Menus and Toolbar 82 6.1.1 Create Top-Level Menu 82 6.1.2 Menu Managers 85 6.1.3 The Add Contact Action 86 6.1.4 Adding the "Add Contact" Action 89 6.1.5 Customizable Toolbars 91 6.2 Adding to the Status Line 92 6.2.1 Status Line A Shared Resource 93 6.3 System Tray Integration 94 6.3.1 Obtaining a Display 95 6.3.2 Creating the Tray Item 96 6.4 Summary 98 6.5 Pointers 99 Chapter 7 Adding a Chat Editor 101 7.1 Views and Editors 102 7.2 Defining the Chat Editor 103 7.2.1 Editor Input 107 7.2.2 The Chat Action 109 7.3 Checkpoint 111 7.4 Summary 112 7.5 Pointers 112 Chapter 8 Branding Hyperbola 113 8.1 Defining the Hyperbola Product 113 8.2 Window Images 118 8.3 Customizing the Launcher 119 8.4 Splash Screen 120 8.5 About Information 122 8.5.1 Product About Information 122 8.5.2 Plug-in About Information 125 8.6 Summary 125
xii Contents 15.4 ActionBarAdvisor 227 15.4.1 IActionBarConfigurer 228 15.5 Workbench Overview 228 15.5.1 Workbench Extension Point Reference 230 15.5.2 Actions 231 15.5.3 Scalability 232 15.5.4 Contributions 232 15.5.5 Perspectives 233 15.5.6 Startup 234 15.6 Summary 234 Chapter 16 Perspectives, Views, and Editors 235 16.1 Perspectives 236 16.1.1 Adding Perspectives 237 16.1.2 Adding the Debug Perspective and Console View 238 16.1.3 IPageLayout Reference 240 16.1.4 Perspective Bar 243 16.1.5 Perspective Menu 244 16.1.6 Programmatic Perspective Control 245 16.2 Views and Editors 247 16.2.1 Multiple Instances of the Same View 247 16.2.2 Sticky Views 249 16.2.3 Showing Contributed Views 250 16.2.4 View Registry 251 16.2.5 Connecting Parts Together 251 16.3 Multiple Workbench Windows 254 16.3.1 Window Navigation Menu 255 16.4 Drag and Drop with Editors 255 16.5 Summary 259 Chapter 17 Actions 261 17.1 Overview 261 17.2 Declarative Actions in Hyperbola 263 17.2.1 Declarative Actions 264 17.2.2 Allowing Contribution 265 17.2.3 Declaring Actions 267 17.2.4 Context Menus 270 17.3 Standard Workbench Actions 272 17.4 Retargetable Actions 274 17.5 Consolidating Declarative Actions 276
Contents xiii 17.6 Toolbar Action Tricks 277 17.6.1 Showing Images and Text 277 17.6.2 Adding Controls to the Toolbar 279 17.7 Adding Contributions to the Status Line 280 17.8 Reporting Progress 281 17.8.1 Non-modal Progress 283 17.8.2 Progress View 285 17.8.3 Customizing Progress 286 17.8.4 Writing a ProgressProvider 287 17.9 Summary 289 Chapter 18 Customizing Workbench Windows 291 18.1 Customization Defined 291 18.2 Customizing a Workbench Window 292 18.2.1 Example: Hide and Show 295 18.2.2 FormLayout 295 18.2.3 Hiding the Toolbar 297 18.2.4 Adding the Toggle Actions 297 18.2.5 Quick Search Panel 299 18.2.6 Checkpoint 300 18.3 Custom Window Shapes 301 18.3.1 Creating the Shape 302 18.3.2 Creating the Window 304 18.3.3 Defining the Window Contents 305 18.4 Summary 306 Chapter 19 Customizing the Presentation ofviews and Editors 307 19.1 Presentations 307 19.2 Sample Presentations 308 19.2.1 The R21 Presentation 309 19.2.2 Example Presentations 310 19.3 Writing a Presentation 310 19.3.1 Widget Hierarchy 312 19.3.2 StackPresentation 313 19.4 Example Presentation 314 19.4.1 The Presentation Factory 315 19.4.2 The Stack Presentation 316 19.4.3 Size and Position 319 19.4.4 Adding, Selecting, and Removing Parts 319 19.4.5 Menus 322 19.5 Summary 322
xvi Contents 24.8 Tweaking the Build 24.8.1 Managing the Base 24.8.2 Fetching from CVS 24.8.3 Fetching the Maps 24.8.4 Auto-substitution of Version Numbers 24.8.5 Qualifying Version Numbers 24.8.6 Controlling the Output Names 24.9 Summary Chapter 25 The Last Mile 25.1 Archives 25.2 Native Installers 25.3 Java Web Start (JNLP) 25.3.1 How Java Web Start Works 25.3.2 Hyperbola and Java Web Start 25.3.3 JAR Signing 25.3.4 Exporting for Java Web Start 25.3.5 Building JNLP Manifests 25.3.6 Java Web Start and Update 25.4 Update Sites 25.5 Initializing the Install 25.6 Pre-initialized Configurations 25.7 Multi-user Install Scenarios 25.7.1 Shared Installs 25.7.2 Shared Configurations 25.7.3 Multiple Configurations 25.8 Summary 25.9 Pointers Part V 0 Reference 421 421 421 423 424 424 425 426 427 427 428 429 429 430 432 433 434 435 435 436 436 437 438 439 440 443 443 445 Chapter 26 26.1 26.2 26.3 26.4 26.5 26.6 26.7 OSGi Essentials OSGi and the Eclipse Runtime The Shape of Plug-ins Fragments Version Numbering Services Singletons Bundle Lifecycle 26.7.1 BundleActivator (Plugin Class) 447 448 450 452 456 457 458 459 460
Contents xvii 26.7.2 The Downside of Activators 461 26.7.3 Uses for Activators 462 26.8 Early Activation 464 26.8.1 Early Activation Extensions 464 26.8.2 osgi.bundles 465 26.8.3 Start Levels 465 26.9 Auto-activation 466 26.10 Classloading 468 26.10.1 Class Lookup Algorithm 468 26.10.2 Declaring Imports and Exports 469 26.10.3 Importing versus Requiring 470 26.10.4 Optionality 471 26.10.5 Re-exporting 471 26.10.6 x-internal and x-friends 471 26.11 Data Areas 472 26.12 Putting It All Together 475 26.13 Summary 477 Chapter 27 Eclipse.org Plug-ins 479 27.1 Where to Find Plug-ins 479 27.2 Eclipse Platform Plug-ins 481 27.3 Product Introduction 481 27.4 Resources 482 27.4.1 Overview of Resources Key Features 483 27.4.2 Getting Started with Resources 484 27.4.3 Resources in the Workbench 485 27.5 Text Editing 485 27.5.1 Text Plug-ins 485 27.5.2 Editing versus Editor 486 27.5.3 Text and StyledText 487 27.5.4 IDocument 488 27.5.5 TextViewers and TextEditors 488 27.5.6 What Is Missing? 489 27.6 Consoles 489 27.7 Variables 490 27.8 Outline and Property Views 491 27.9 Forms 491 27.10 Browser 492 27.11 Summary 492 Index 495