Component-Based Development
Total Page:16
File Type:pdf, Size:1020Kb
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 <plugin id = “com.example.tool" Plug-in identification name = “Example Plug-in Tool" class = "com.example.tool.ToolPlugin"> <requires> Other plug-ins needed <import plugin = "org.eclipse.core.resources"/> <import plugin = "org.eclipse.ui"/> </requires> <runtime> Location of plug-in’s code <library name = “tool.jar"/> </runtime> <extension point = "org.eclipse.ui.preferencepages"> Declare <page id = "com.example.tool.preferences" contribution icon = "icons/knob.gif" this plug-in makes title = “Tool Knobs" class = "com.example.tool.ToolPreferenceWizard“/> </extension> Declare new extension <extension-point point open to contributions name = “Frob Providers“ id = "com.example.tool.frobProvider"/> from other plug-ins </plugin> 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