Component-Based Development
2004-2005 Marco Scotto ([email protected])
Component-Based Development Outline
¾Introduction to Eclipse • Plug-in Architecture •Platform •JDT •PDE ¾HelloWorld Example ¾PDE Views
Component-Based Development 2 Eclipse Project Aims
¾ Provide open platform for application development tools • Run on a wide range of operating systems • GUI and non-GUI ¾ Language-neutral • Permit unrestricted content types • HTML, Java, C, JSP, EJB, XML, GIF, … ¾ Facilitate seamless tool integration • At UI and deeper • Add new tools to existing installed products ¾ Attract community of tool developers • Including independent software vendors (ISVs) • Capitalize on popularity of Java for writing tools
Component-Based Development 3 Eclipse Overview
Another Eclipse Platform Tool
Java Workbench Help Development Tools JFace (JDT) SWT Team Your Tool
Plug-in Workspace Development Debug Environment (PDE)
Their Platform Runtime Tool Eclipse Project
Component-Based Development 4 Eclipse Origins
¾ Eclipse created by OTI and IBM teams responsible for IDE products • IBM VisualAge/Smalltalk (Smalltalk IDE) • IBM VisualAge/Java (Java IDE) • IBM VisualAge/Micro Edition (Java IDE) ¾ Initially staffed with 40 full-time developers ¾ Geographically dispersed development teams • OTI Ottawa, OTI Minneapolis, OTI Zurich, IBM Toronto, OTI Raleigh, IBM RTP, IBM St. Nazaire (France) ¾ Effort transitioned into open source project • IBM donated initial Eclipse code base Platform, JDT, PDE
Component-Based Development 5 Brief History of Eclipse
1999 April - Work begins on Eclipse inside OTI/IBM 2000 June - Eclipse Tech Preview ships 2001 March - http://www.eclipsecorner.org/ opens June - Eclipse 0.9 ships October - Eclipse 1.0 ships November - IBM donates Eclipse source base - eclipse.org board announced - http://www.eclipse.org/ opens 2002 June - Eclipse 2.0 ships September - Eclipse 2.0.1 ships November - Eclipse 2.0.2 ships 2003 March - Eclipse 2.1 ships
Component-Based Development 6 What is Eclipse? ¾ Eclipse is a universal platform for integrating development tools ¾ Open, extensible architecture based on plug-ins
Plug-in development PDE environment
Java development JDT tools
Eclipse Platform Platform
Standard Java2 Java VM Virtual Machine
Component-Based Development 7 Eclipse Plug-in Architecture
¾ Plug-in - smallest unit of Eclipse function • Big example: HTML editor • Small example: Action to create zip files
¾ Extension point - named entity for collecting “contributions” • Example: extension point for workbench preference UI
¾ Extension - a contribution • Example: specific HTML editor preferences
Component-Based Development 8 Eclipse Plug-in Architecture
¾ Each plug-in • Contributes to 1 or more extension points • Optionally declares new extension points • Depends on a set of other plug-ins • Contains Java code libraries and other files • May export Java-based APIs for downstream plug-ins • Lives in its own plug-in subdirectory
¾ Details spelled out in the plug-in manifest • Manifest declares contributions • Code implements contributions and provides API • plugin.xml file in root of plug-in subdirectory
Component-Based Development 9 plugin.xml Plug-in Manifest
Component-Based Development 10 Eclipse Plug-in Architecture ¾ Typical arrangement plug-in A plug-in B extension contributes extension point P
implements interface I class C
¾ Plug-in A creates, calls • Declares extension point P • Declares interface I to go with P ¾ Plug-in B • Implements interface I with its own class C • Contributes class C to extension point P ¾ Plug-in A instantiates C and calls its I methods Component-Based Development 11 Eclipse Platform Architecture
¾Eclipse Platform Runtime is micro-kernel • All functionality supplied by plug-ins
¾Eclipse Platform Runtime handles start up • Discovers plug-ins installed on disk • Matches up extensions with extension points • Builds global plug-in registry • Caches registry on disk for next time
Component-Based Development 12 Plug-in Activation
¾ Each plug-in gets its own Java class loader • Delegates to required plug-ins • Restricts class visibility to exported APIs
¾ Contributions processed without plug-in activation • Example: Menu constructed from manifest info for contributed items
¾ Plug-ins are activated only as needed • Example: Plug-in activated only when user selects its menu item • Scalable for large base of installed plug-ins • Helps avoid long start up times
Component-Based Development 13 Plug-in Fragments
¾ Plug-in fragments holds some of plug-in’s files • Separately installable ¾ Each fragment has separate subdirectory • Separate manifest file ¾ Logical plug-in = Base plug-in + fragments ¾ Plug-in fragments used for • Isolation of OS dependencies • Internalization – fragments hold translations
Component-Based Development 14 Plug-in Install
¾ Features group plug-ins into installable chunks • Feature manifest file ¾ Plug-ins and features bear version identifiers • major . minor . service • Multiple versions may co-exist on disk ¾ Features downloadable from web site • Using Eclipse Platform update manager • Obtain and install new plug-ins • Obtain and install updates to existing plug-ins
Component-Based Development 15 Plug-in Architecture - Summary
¾ All functionality provided by plug-ins • Includes all aspects of Eclipse Platform itself ¾ Communication via extension points • Contributing does not require plug-in activation ¾ Packaged into separately installable features • Downloadable
Eclipse has open, extensible architecture based on plug-ins
Component-Based Development 16 Eclipse Platform ¾Eclipse Platform is the common base ¾Consists of several key components
Eclipse Platform
Workbench
“UI” JFace SWT Team Help Debug
“Core” Workspace Ant
Platform Runtime Component-Based Development 17 Workspace Component
¾ Tools operate on files in user’s workspace ¾ Workspace holds 1 or more top-level projects ¾ Projects map to directories in file system ¾ Tree of folders and files ¾ {Files, Folders, Projects} termed resources
¾ Tools read, create, modify, and delete resources in workspace ¾ Plug-ins access via workspace and resource APIs
Component-Based Development 18 Workspace and Resource API
¾ Allows fast navigation of workspace resource tree ¾ Resource change listener for monitoring activity • Resource deltas describe batches of changes ¾ Maintains limited history of changed/deleted files ¾ Several kinds of extensible resource metadata • Persistent resource properties • Session resource properties •Markers • Project natures ¾ Workspace session lifecycle • Workspace save, exit, restore ¾ Incremental project builders Component-Based Development 19 Incremental Project Builders
¾ Problem: coordinated analysis and transformation of thousands of files • Compiling all source code files in project • Checking for broken links in HTML files ¾ Scalable solution requires incremental reanalysis ¾ Incremental project builder API/framework • Builders are passed resource delta • Delta describes all changes since previous build • Basis for incremental tools ¾ Extensible – plug-ins define new types of builders • JDT defines Java builder ¾ Configurable – any number of builders per project Component-Based Development 20 Workbench Component
Workbench
JFace SWT
¾ SWT – generic low-level graphics and widget set ¾ JFace – UI frameworks for common UI tasks ¾ Workbench – UI personality of Eclipse Platform
Component-Based Development 21 SWT ¾ SWT = Standard Widget Toolkit ¾ Generic graphics and GUI widget set • buttons, lists, text, menus, trees, styled text...
¾ Simple ¾ Small ¾ Fast ¾ OS-independent API ¾ Uses native widgets where available ¾ Emulates widgets where unavailable
Component-Based Development 22 Why SWT?
¾ Consensus: hard to produce professional looking shrink- wrapped products using Swing and AWT
¾ SWT provides • Tight integration with native window system • Authentic native look and feel • Good performance • Good portability • Good base for robust GUIs
¾ The proof of the pudding is in the eating…
Component-Based Development 23 Why SWT?
¾Eclipse Platform on Windows XP
Component-Based Development 24 Why SWT? ¾Eclipse Platform on Windows XP (skinned)
Component-Based Development 25 Why SWT? ¾Eclipse Platform on Linux - GTK 2.0
Component-Based Development 26 Why SWT? ¾Eclipse Platform on Linux - Motif
Component-Based Development 27 Why SWT? ¾Eclipse Platform on Mac OS X - Carbon
Component-Based Development 28 JFace
¾JFace is set of UI frameworks for common UI tasks ¾Designed to be used in conjunction with SWT ¾Classes for handling common UI tasks ¾API and implementation are window- system independent
Component-Based Development 29 JFace APIs
¾ Image and font registries ¾ Dialog, preference, and wizard frameworks ¾ Structured viewers • Model-aware adapters for SWT tree, table, list widgets ¾ Text infrastructure • Document model for SWT styled text widget • Coloring, formatting, partitioning, completion ¾ Actions • Location-independent user commands • Contribute action to menu, tool bar, or button
Component-Based Development 30 Workbench Component
¾ Workbench is UI personality of Eclipse Platform
¾ UI paradigm centered around •Editors •Views • Perspectives
Component-Based Development 31 Workbench Terminology
Menu bar Text Tool bar editor
Perspective and Fast View bar Outline view Resource Navigator view
Bookmarks Properties view view
Message Editor area Status area Stacked Tasks views view Component-Based Development 32 Editors
¾ Editors appear in workbench editor area ¾ Contribute actions to workbench menu and tool bars ¾ Open, edit, save, close lifecycle ¾ Open editors are stacked
¾ Extension point for contributing new types of editors ¾ Example: JDT provides Java source file editor ¾ Eclipse Platform includes simple text file editor ¾ Windows only: embed any document as editor ¾ Extensive text editor API and framework
Component-Based Development 33 Views ¾ Views provide information on some object ¾ Views augment editors • Example: Outline view summarizes content ¾ Views augment other views • Example: Properties view describes selection
¾ Extension point for new types of views ¾ Eclipse Platform includes many standard views • Resource Navigator, Outline, Properties, Tasks, Bookmarks, Search, … ¾ View API and framework • Views can be implemented with JFace viewers
Component-Based Development 34 Perspectives ¾ Perspectives are arrangements of views and editors ¾ Different perspectives suited for different user tasks ¾ Users can quickly switch between perspectives ¾ Task orientation limits visible views, actions • Scales to large numbers of installed tools ¾ Perspectives control • View visibility • View and editor layout • Action visibility ¾ Extension point for new perspectives ¾ Eclipse Platform includes standard perspectives • Resource, Debug, … ¾ Perspective API
Component-Based Development 35 Other Workbench Features
¾ Tools may also • Add global actions • Add actions to existing views and editors • Add views, action sets to existing perspectives
¾ Eclipse Platform is accessible (Section 508) ¾ Accessibility mechanisms available to all plug-ins
Component-Based Development 36 Workbench Responsibilities
¾ Eclipse Platform manages windows and perspectives ¾ Eclipse Platform creates menu and tool bars • Labels and icons listed in plug-in manifest • Contributing plug-ins not activated ¾ Eclipse Platform creates views and editors • Instantiated only as needed ¾ Scalable to large numbers of installed tools
Component-Based Development 37 Team Component
¾ Version and configuration management (VCM) ¾ Share resources with team via a repository ¾ Repository associated at project level ¾ Extension point for new types of repositories ¾ Repository provider API and framework ¾ Eclipse Platform includes CVS repository provider ¾ Available repository providers* • ChangeMan (Serena) - AllFusion Harvest (CA) • ClearCase (Rational) - Perforce • CM Synergy (Telelogic) - Source Integrity (MKS) • PVCS (Merant) - TeamCode (Interwoven) • Microsoft Visual Source Safe * March 2003 Component-Based Development 38 Team Component ¾Repository providers have wide latitude • Provide actions suited to repository • No built-in process model ¾Integrate into workbench UI via • Share project configuration wizard • Actions on Team menu • Resource decorators • Repository-specific preferences • Specialized views for repository browsing, …
Component-Based Development 39 Debug Component ¾Common debug UI and underlying debug model
Component-Based Development 40 Debug Component ¾ Launch configurations • How to run a program (debug mode option) ¾ Generic debug model • Standard debug events: suspended, exit, … • Standard debug actions: resume, terminate, step, … •Breakpoints •Expressions • Source code locator ¾ Generic debug UI • Debug perspective • Debug views: stack frames, breakpoints, … ¾ Example: JDT supplies Java launcher and debugger • Java debugger based on JPDA ¾ Debug mechanisms available to other plug-ins Component-Based Development 41 Ant Component ¾ Eclipse incorporates Apache Ant ¾ Ant is Java-based build tool • “Kind of like Make…without Make's wrinkles” ¾ XML-based build files instead of makefiles ¾ Available from workbench External Tools menu ¾ Run Ant targets in build files inside or outside workspace ¾ PDE uses Ant for building deployed form of plug- in
Component-Based Development 42 Help Component ¾Help is presented in a standard web browser
Component-Based Development 43 Help Component
¾ Help books are HTML webs ¾ Extension points for contributing • entire books • sections to existing books • F1-help pop ups ¾ Eclipse Platform contributes • “Workbench User Guide” • “Platform Plug-in Developer Guide” (APIs) • F1-help for views, editors, dialogs, … ¾ JDT and PDE contribute their own help ¾ Help mechanisms available to all plug-ins • Help search engine based on Apache Lucene • Headless help server based on Apache Tomcat
Component-Based Development 44 Internationalization
¾ Eclipse Platform is internationalized ¾ 2.0 translations available for following languages English German Spanish Italian French Portugese (Brazil) Japanese Korean Chinese (Traditional) Chinese (Simplified)
¾ Translations live in plug-in fragments • Separately shippable ¾ Internalization mechanisms available to all plug-ins
Component-Based Development 45 Product Information
Window image
Welcome pages Splash screen
About product info About feature info
Component-Based Development 46 Product Information
¾ Primary feature controls product information • Splash screen • Window image • About product info • Initial welcome page • Default perspective • Preference default overrides
¾ All features can provide • Welcome page • About feature info
Component-Based Development 47 Eclipse Platform - Summary
¾ Eclipse Platform is the nucleus of IDE products ¾ Plug-ins, extension points, extensions • Open, extensible architecture ¾ Workspace, projects, files, folders • Common place to organize & store development artifacts ¾ Workbench, editors, views, perspectives • Common user presentation and UI paradigm ¾ Key building blocks and facilities • Help, team support, internationalization, … Eclipse is a universal platform for integrating development tools
Component-Based Development 48 Java Development Tools
¾ JDT = Java development tools ¾ State of the art Java development environment
¾ Built atop Eclipse Platform • Implemented as Eclipse plug-ins • Using Eclipse Platform APIs and extension points
¾ Included in Eclipse Project releases • Available as separately installable feature • Part of Eclipse SDK drops
Component-Based Development 49 JDT Goals
¾Goal: To be #1 Java IDE ¾Goal: To make Java programmers smile
Component-Based Development 50 Java Perspective ¾Java-centric view of files in Java projects • Java elements meaningful for Java programmers
Java project
package
class
field method
Java editor Component-Based Development 51 Java Perspective ¾Browse type hierarchies • “Up” hierarchy to supertypes • “Down” hierarchy to subtypes
Type hierarchy
Selected type’s members
Component-Based Development 52 Java Perspective ¾Search for Java elements • Declarations or references • Including libraries and other projects Hits flagged in margin of editor
All search results
Component-Based Development 53 Java Editor
¾Hovering over identifier shows Javadoc spec
Component-Based Development 54 Java Editor ¾Method completion in Java editor
List of plausible methods Doc for method
Component-Based Development 55 Java Editor
¾On-the-fly spell check catches errors early
Click to see fixes
Problem Preview Quick fixes
Component-Based Development 56 Java Editor
¾Code templates help with drudgery
Statement template Preview
Component-Based Development 57 Java Editor
¾Java editor creates stub methods
Method stub insertion for anonymous inner types
Method stub insertion for inherited methods
Component-Based Development 58 Java Editor ¾Java editor helps programmers write good Java code Variable name suggestion JavaDoc code assist
Argument hints and proposed argument names
Component-Based Development 59 Java Editor
¾Other features of Java editor include • Local method history •Code formatter • Source code for binary libraries • Built-in refactoring
Component-Based Development 60 Refactoring
¾JDT has actions for refactoring Java code
Component-Based Development 61 Refactoring
¾ Refactoring actions rewrite source code • Within a single Java source file • Across multiple interrelated Java source files ¾ Refactoring actions preserve program semantics • Does not alter what program does • Just affects the way it does it
¾ Encourages exploratory programming ¾ Encourages higher code quality • Makes it easier to rewrite poor code
Component-Based Development 62 Refactoring ¾Full preview of all ensuing code changes • Programmer can veto individual changes
List of changes
“before” vs. “after”
Component-Based Development 63 Refactoring ¾Growing catalog of refactoring actions • Organize imports • Rename {field, method, class, package} • Move {field, method, class} • Extract {method, local variable, interface} • Inline {method, local variable} • Reorder method parameters • Push members down …
Component-Based Development 64 Eclipse Java Compiler ¾ Eclipse Java compiler • JCK-compliant Java compiler (selectable 1.3 and 1.4) • Helpful error messages • Generates runnable code even in presence of errors • Fully-automatic incremental recompilation • High performance • Scales to large projects ¾ Multiple other uses besides the obvious • Syntax and spell checking • Analyze structure inside Java source file • Name resolution • Content assist •Refactoring • Searches
Component-Based Development 65 Eclipse Java Debugger
¾Run or debug Java programs Local variables
Threads and stack frames
Editor with breakpoint marks
Console I/O Component-Based Development 66 Eclipse Java Debugger ¾ Run Java programs • In separate target JVM (user selectable) • Console provides stdout, stdin, stderr • Scrapbook pages for executing Java code snippets ¾ Debug Java programs • Full source code debugging • Any JPDA-compliant JVM ¾ Debugger features include • Method and exception breakpoints • Conditional breakpoints •Watchpoints • Step over, into, return; run to line • Inspect and modify fields and local variables • Evaluate snippets in context of method • Hot swap (if target JVM supports) Component-Based Development 67 JDT APIs
¾ JDT APIs export functionality to other plug-ins
¾ Java model • Java-centric analog of workspace • Tree of Java elements (down to individual methods) • Java element deltas •Type hierarchies • Model accurate independent of builds ¾ Building blocks • Java scanner • Java class file reader • Java abstract syntax trees (down to expressions) ¾ Many others…
Component-Based Development 68 Eclipse JDT - Summary ¾ JDT is a state of the art Java IDE ¾ Java views, editor, refactoring • Helps programmer write and maintain Java code ¾ Java compiler • Takes care of translating Java sources to binaries ¾ Java debugger • Allows programmer to get inside the running program
Eclipse Java programmers
Component-Based Development 69 Plug-in Development Environment ¾ PDE = Plug-in development environment ¾ Specialized tools for developing Eclipse plug-ins
¾ Built atop Eclipse Platform and JDT • Implemented as Eclipse plug-ins • Using Eclipse Platform and JDT APIs and extension points
¾ Included in Eclipse Project releases • Separately installable feature • Part of Eclipse SDK drops
Component-Based Development 70 PDE Goals
¾Goals • To make it easier to develop Eclipse plug-ins • Support self-hosted Eclipse development
Component-Based Development 71 PDE ¾PDE templates for creating simple plug-in projects
Component-Based Development 72 PDE ¾Specialized PDE editor for plug-in manifest files
Component-Based Development 73 PDE ¾PDE runs and debugs another Eclipse workbench
1. Workbench running PDE (host)
2. Run-time workbench (target)
Component-Based Development 74 PDE - Summary
¾PDE makes it easier to develop Eclipse plug-ins ¾PDE also generates Ant build scripts • Compile and create deployed form of plug-in
PDE is basis for self-hosted Eclipse development
Component-Based Development 75 Eclipse Operating Environments
¾ Eclipse Platform currently* runs on •Microsoft® Windows® XP, 2000, NT, ME, 98SE • Linux® on Intel x86 - Motif, GTK RedHat Linux 8.0 x86 SuSE Linux 8.1 x86 • Sun Solaris 8 SPARC – Motif • HP-UX 11i hp9000 – Motif •IBM® AIX 5.1 on PowerPC – Motif • Apple Mac OS® X 10.2 on PowerPC – Carbon • QNX® Neutrino® RTOS 6.2.1 - Photon®
* Eclipse 2.1 - March 2003 Component-Based Development 76 Other Operating Environments
¾ Most Eclipse plug-ins are 100% pure Java • Freely port to new operating environment • Java2 and Eclipse APIs insulate plug-in from OS and window system
¾ Gating factor: porting SWT to native window system ¾ Just added in 2.1* • Mac OS X PowerPC – Carbon window system • QNX Neutrino RTOS Intel x86 - Photon window system
¾ Eclipse Platform also runs “headless” • Example: help engine running on server
* March 2003 Component-Based Development 77 Who’s on Board? ¾ Wide range of software vendors on Eclipse board ¾ Represent various development tool markets
*As of August 2002
Component-Based Development 78 Who’s on Board? ¾New members joined Sept.-Dec. 2002
Component-Based Development 79 Who’s Shipping on Eclipse?
¾Commercial products* ¾ 10 Technology – Visual PAD ¾ Assisi – V4ALL Assisi GUI-Builder ¾ Bocaloco – XMLBuddy ¾ Borland – Together Edition for WebSphere Studio ¾ Catalyst Systems – Openmake ¾ Computer Associates – AllFusion Harvest Change Manager VCM ¾ Ensemble Systems – Glider for Eclipse ¾ Fujitsu – Interstage ¾ Genuitec – EASIE Plug-ins ¾ HP – OpenCall Media Platform OClet Development Environment ¾ James Holmes – Struts Console ¾ Instantiations – CodePro Studio * As of March 2003 Component-Based Development 80 Who’s Shipping on Eclipse?
¾ IBM uses Eclipse for • WebSphere® Studio Family WebSphere Studio Homepage Builder WebSphere Studio Site Developer (WSSD) WebSphere Studio Application Developer (WSAD) WebSphere Studio Application Developer Integration Edition (WSADIE) WebSphere Studio Enterprise Developer (WSED) WebSphere Studio Device Developer (WSDD) WebSphere Development Studio for iSeries • Rational® XDE Professional: Java Platform Edition
• Tivoli Monitoring Workbench * As of March 2003 Component-Based Development 81 Who’s Shipping on Eclipse? ¾Commercial products*
¾ Interwoven – TeamSite repository ¾ Intland – CodeBeamer ¾ LegacyJ – PERCobol ¾ Merant – PVCS Version Manager ¾ MKS – Source Integrity Enterprise plug-in ¾ Mobile Media – Grand-Rapid Browser ¾ mvmsoft – Slime UML ¾ No Magic Inc. – MagicDraw UML ¾ Object Edge – Weblogic Plug-in ¾ ObjectLearn – Lomboz ¾ Omondo – EclipseUML ¾ Ontogenics – hyperModel * As of March 2003 Component-Based Development 82 Who’s Shipping on Eclipse? ¾Commercial products* ¾ Parasoft – Jtest ¾ ProSyst – Eclipse OSGi Plug-in ¾ QNX – QNX Momentics ¾ Quest Software – JProbe integration ¾ Serena Software – ChangeMan DS ¾ SlickEdit – Visual SlickEdit Plug-in ¾ Systinet – WASP Developer ¾ THOUGHT – CocoBase Enterprise O/R ¾ TimeSys – TimeStorm 2.0 ¾ xored – WebStudio IDE for PHP * As of March 2003 Component-Based Development 83 Who’s Building on Eclipse?
¾Plus more than 40* other open source projects based on Eclipse ¾See http://eclipse.org/community/plugins.html
* As of March 2003 Component-Based Development 84 HelloWorld example
¾ Creating a plug-in project ¾ Reviewing the generated code ¾ Building a product ¾ Installing and running the product
Component-Based Development 85 Hello Button
¾We want to contribute a button to Eclipse ¾First, we have to create a project ¾Eclipse has wizards to automate tedious work
Component-Based Development 86 Hello Button
¾Open the new wizard
Component-Based Development 87 Hello Button
¾ Select Plug-in Project
Component-Based Development 88 Hello Button
¾ Define the name of the plug-in project
Component-Based Development 89 Hello Button
¾ Define the settings related to the plug-in structure
Component-Based Development 90 Hello Button
¾ This wizard has a number of different code generation options for creating sample plug-in code such as views, editors, and actions ¾ Create a blank plug-in project without using any of the code generation wizards
Component-Based Development 91 Hello Button
¾Now we have a plug-in, but it does not do anything ¾Clicking Run As > Eclipse Application will bring up another instance of Eclipse, but this one has our new plug-in loaded
Component-Based Development 92 Hello Button
¾ Next we need to contribute a button. Here’s how we specify or button appearance:
Component-Based Development 93 Hello Button
¾ We can see our action set in Window > Customize Perspective…
Component-Based Development 94 Hello Button
Our button
Component-Based Development 95 Saying “Hello”
¾We have finished the user visible appearance of our plug-in ¾Now it is time to fill-in the implementation size ¾According to the Lazy Loading Rule, contributions are only loaded when they are first invoked • Eclipse waits until the button is clicked, then looks for code to invoke
Component-Based Development 96 Saying “Hello”
¾ The code is represented as a Java Class, so the name of the class has to be part of the definition of the action ¾ Each action has the name of a Java class associated with it:
Component-Based Development 97 Saying “Hello”
¾When we start the run-time workbench and click our button, the console in the host workbench tells us that the class cannot be found:
Could not create action delegate for id: it.unibz.contribution.hello.HelloAction Reason: Executable extension definition for "class" not found.
Component-Based Development 98 Saying “Hello”
¾To make the action work, we need to create a class called it.unibz.contribution.hello.HelloAction ¾How will the action be invoked? • Eclipse needs a protocol common to all actions • This protocol is defined in the interface IWorkbenchWindowActionDelegate
Component-Based Development 99 Saying “Hello”
¾Before we can define an implementor of IWorkbenchWindowActionDelegate we have to help Eclipse find it within our plug-in ¾Eclipse does not use the usual classpath mechanism of Java to find classes • Each plug-in has its own class lookup path
Component-Based Development 100 Saying “Hello”
¾The interface we want to implement is defined in the org.eclipse.ui plugin, so our plug-in needs to depend on it ¾We add the following to our manifest:
Component-Based Development 101 Saying “Hello”
¾ Now we can define our HelloActionClass 1. Create a package it.unibz.contribution.hello in the source folder src of our project 2. Create a class HelloAction implementing the interface IWorkbenchWindowActionDelegate
Component-Based Development 102 Saying “Hello”
¾Eclipse fills in default implementation for the four methods in the signature of the interface:
public void dispose() { } public void init(IWorkbenchWindow window) { } public void run(IAction action) { } public void selectionChanged(IAction action, ISelection selection) {}
Component-Based Development 103 Saying “Hello”
¾We replace the implementation of HelloAction.run() with the following:
public void run(IAction action) { MessageDialog.openInformation(null, null, "Hello, Eclipse world");
}
Component-Based Development 104 Saying “Hello”
¾Now when we start the run-time workbench and click the button, we see the message we have been expecting:
Component-Based Development 105 Building a product
¾ Building a product involves packaging up only those elements to be delivered to the customer in a form that the customer can install into their environment ¾ You can build the product in several different ways including manually, using a Windows batch script, a Unix shell script, or using an Ant script ¾ You can deliver the end product as a single compressed file or as a stand-alone executable
Component-Based Development 106 Building manually
¾Building the product manually involves launching an Eclipse export wizard, filling out a few fields, and clicking the Finish button
Component-Based Development 107 Building manually
¾ Select the File > Export command to launch the desired export wizard. On the first wizard page select Deployable plug-ins and fragments and click the Next button
Component-Based Development 108 Building manually
¾ On the second page of the export wizard select the plug-ins to be exported and enter the name of the zip file to contain the result
Component-Based Development 109 Building manually
¾The created zip file contains the plug-in and its source code as specified in the export wizard: • plugins/it.unibz.contribution.hello_1.0.0/hello.jar • plugins/it.unibz.contribution.hello_1.0.0/plugin.xml
Component-Based Development 110 Building with Apache Ant
¾An Apache Ant script provides a reliable, flexible and repeatable process for building a commercial plug-in project ¾There is a little more up-front work to setup an Ant script, but it is much less error prone over time than building the product manually
Component-Based Development 111 Building with Apache Ant ¾ For the Favorites plug-in, create a build.xml file in the it.unibz.contribution.hello project and enter the following script:
Component-Based Development 112 Building with Apache Ant
Component-Based Development 113 Building with Apache Ant
¾ To execute the Ant script, select the build.xml file in the navigator view, and then from the popup context menu, select Run Ant…
Component-Based Development 114 Building with Apache Ant
¾ Once the Ant wizard appears, click the Run button to build the product
Component-Based Development 115 Installing and running the product
¾To install the Favorites plug-in, shutdown Eclipse, unzip the hello_v1.0.0.zip the Ant script generated, and restart Eclipse
Component-Based Development 116 PDE Views
¾The Plug-in Development Environment (PDE) provides several views for inspecting various aspects of plug-ins ¾To open the various PDE views, select Window > Show View > Other…, and in the Show View dialog, expand both the PDE category and the PDE Runtime category
Component-Based Development 117 The Plug-in Registry view
¾ The Plug-in Registry view displays a tree view of all plug- ins discovered in the current workspace ¾ Expanding the plug-in in the tree shows its components such as extension points, extensions, prerequisites, and runtime libraries ¾ Right-click and select Properties to display additional information about each element in the tree
Component-Based Development 118 The Plug-in view ¾ The Plug-ins view shows a tree list of external plug-ins and plug-in projects in the current workspace and provides a quick way to review plug-ins that already exist (see Figure 2-28) ¾ You can expand each external plug-in in the tree to browse the files located in the plug-in directory ¾ Similar to the Plug-in Registry view, selecting an element in the tree displays additional information about that element in the Properties view ¾ Double-clicking on a file element opens that file in an editor for viewing Component-Based Development 119 The Plug-in Dependency view
¾ The Plug-in Dependency view shows a hierarchy of which plug-ins are dependent upon which other plug-ins, which in turn are dependent upon other plug-ins, etc. ¾ When the view opens, first right-click and select Focus On… ¾ Double clicking on an element in the tree opens the plug-in manifest editor for the corresponding plug-in
Component-Based Development 120