Contributing to Eclipse

Report
Contributing to Eclipse:
Understanding and Writing Plug-ins
Tutorial Outline
• Understanding the Contribution Cycle
•
•
•
•
Introducing the technical side of Eclipse
Using Eclipse to explore Eclipse
Becoming an Extender
Becoming an Enabler
Eclipse is an IDE framework
• Is more than a Java IDE
– ƒEclipse + JDT = Java IDE
– Eclipse + CDT = C/C++ IDE
– Eclipse + PHP = PHP IDE
• Language Editor/Debugger/Refractor
Eclipse is a Tools Framework
• Tools extend the Eclipse platform using plugins
– Business Intelligence and Reporting Tools (BIRT)
– Eclipse Communications Framework (ECF)
– Web Tools Project (WTP)
– Eclipse Modelling Framework (EMF)
– Graphical Editing Framework (GEF)
– Test and Performance Tooling Project (TPTP)
Eclipse is a Rich Client Platform
Platform vs. Extensible Application
Platform Implications
• Everybody can contribute plug-ins
– Every programmer can be a tool smith
• Creating opportunities for further extension
makes it possible for the tool smith to benefit
from the work of others
• It has to be easy to install and manage plugins
Eclipse Involvements
Eclipse Involvements
• Users
– Users of Eclipse
• Extenders
– Providers of extensions to existing extension
points
• Enablers
– Providers of extension points others provide
extensions for
As an eclipse user
• common user interface paradigm
–
–
–
–
–
Workbench
Views – navigation support, properties
Editors – edit files, e.g. Java Editor
Perspectives – arrangement of views and editors
Preference / Property – Global/Local settings
• Hot Keys for Java developer
–
–
–
–
Ctrl+Shift T
Ctrl+Shift M
Ctrl+Shift F
Ctrl 1
Find Type
Find Import
Format
Quick Fix
Tutorial Outline
• Understanding the Contribution Cycle
• Introducing the technical side of Eclipse
• Using Eclipse to explore Eclipse
• Becoming an Extender
• Becoming an Enabler
Eclipse Plug-in Architecture
• Plug-in – set of contributions
– ƒSmallest unit of Eclipse functionality
– ƒ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
Contribution Rule
• Everything is a contribution.
• Each plug-in
–
–
–
–
–
–
Contributes to 1 or more extension points
Optionally declares new extension points
Depends on a set of other plug-ins
Optionally contains Java code libraries and other files
May export Java-based APIs for downstream plug-ins
Lives in its own plug-in subdirectory
• Theoretically unbound number of plug-ins
Eclipse Plug-in Architecture
• Allow for loading on demand by separating
declaration and implementation:
– Declaration of plug-in contributions
•
•
•
•
Describes plug-in functionality
Describes UI elements to present plug-in functionality
Used by the platform to render parts of the plug-in’s UI
Specifies implementation classes
– Implementation of plug-in contributions
• Implemented in Java and provided as Java archive
• ƒIs loaded on demand
Tip of the Iceberg
• Startup time: O(#used plug-ins), not O(# installed plug-ins)
Eclipse Plug-in Architecture
• Plug-in 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
Plug-in Manifest
Eclipse Platform
• Eclipse Platform is the common base
• Consists of several key components
Strata Rule
• Separate core functionality from UI
functionality.
– Workspace Component
– Workbench Component
Workspace Component
• Project – Folder – Files termed resources
• ƒMeta data management:
– Natures (e.g., Web, Java)
– Markers
• Incremental builders
• Local history
Workbench Component
• SWT – generic low-level graphics and widget toolkit
• JFace – UI frameworks for common UI tasks
• Workbench – UI personality of Eclipse Platform
SWT
• A portable widget set
– OS-independent API
– Uses native widgets where available
– Emulates widgets where unavailable
• Supported platforms
–
–
–
–
Win32, WinCE
Linux/Motif, Solaris/Motif, AIX/Motif, HP-UX/Motif,…
QNX/Photon, Linux/GTK,
Mac OS X/Carbon
JFace
• UI framework built on top of SWT
– Viewers
• Model aware adapters for SWT widgets
• Trees, tables, lists, styled text, ..
– Dialog, Preference and Wizard frameworks
– Actions
• Location-independent user commands
• Contribute action to menu, tool bar, or status line
Workbench
• Defines common user interface paradigm
– Workbench
– Views – navigation support, properties
– Editors – edit files, e.g. Java Editor
– Perspectives – arrangement of views and editors
• Extended by contributing
– Views, editors, preference pages, wizards, …
Tutorial Outline
• Understanding the Contribution Cycle
• Introducing the technical side of Eclipse
• Using Eclipse to explore Eclipse
• Becoming an Extender
• Becoming an Enabler
Explore Eclipse with Eclipse
• The Plug-in Development Environment
• Explore a running Eclipse installation
• Create a self-hosting workspace
Plug-in Development Support
Plug-in Development Environment
•
•
•
•
•
Extenders use PDE to implement plug-ins
PDE = Plug-in development environment
Specialized tools for developing Eclipse plug-ins
Built atop Eclipse Platform and JDT
Features
– Specialized views to explore a running Eclipse
installation
– Specialized PDE editor for plug-in manifest files
– Templates for new plug-ins
– PDE runs and debugs another Eclipse workbench
Available and Activated Plug-ins
Self-hosting Workspace
• PDE allows to
import the plugins of a running
Eclipse installation
into an Eclipse
workspace
• Locate
implementation
class using plugin
spy
Self-hosting Workspace
• P
ƒ lug-ins correspond to Java projects
• Source projects “projects you are working on”
• Binary projects “projects you are browsing
only”
– Source can be inspected
Tutorial Outline
• Understanding the Contribution Cycle
• Introducing the technical side of Eclipse
• Using Eclipse to explore Eclipse
• Becoming an Extender
• Becoming an Enabler
Becoming an Extender
• Contributions do not
– Override existing behavior
– Remove or replace existing components
– Harm existing or future contributions
Becoming an Extender
• Create the Course Explorer plug-in
• Import the business layer source to workspace
• Declare and sketch the implementation of the
Course Explorer View
• Create a PDE launch configuration
• Run the Course Explorer
• Finalize the implementation
Create a PDE launch configuration
Viewer Details
• Adapt domain model to a Viewer
View Details
Becoming an Extender
• Another example:
– Popup qualified Java class file Name and show java structure
view
• Step:
–
–
–
–
Create an eclipse plug-in project
Add dependencies(org.eclipse.jdt.core, org.eclipse.jdt.ui)
Copy qualified name of (org.eclipse.jdt.core.ICompilationUnit)
Add a popup extension.
• Name with ~ShowJavaTreeViewAction~Test the action
– Create a tree view
– Reuse JavaElementLabelProvider and
StandardJavaContentProvier
Tutorial Outline
•
•
•
•
Understanding the Contribution Cycle
Introducing the technical side of Eclipse
Using Eclipse to explore Eclipse
Becoming an Extender
• Becoming an Enabler
Tutorial Outline
• Identify the scope of contributions to your
plug-in
• Declare the extension points
• Implement the extension points
• Consume the new extension points
作业
• 自行实现课堂上讲解的拼写检查的示例
– 提示:三个主要的类型:
• SpellChecker/IDictionary/IWordIterator
• 利用上述的组件,实现一个具有以下功能的
Eclipse 插件:
– 在PackageExplorer视图中选取一个文件,在右键菜
单中增加OOADSpell Check菜单项。
– 选中后,根据选中文件的类型,选取适当的拼写检
查器进行检查,并将检查的结果以表格的形式显示
在一个名为Spell Check Result的视图中。表格包括
两栏:错误单词和错误次数。
作业
• 需要支持对文本文件(.txt)和(.xml)文件的检查,XML
文件检查时需要简单地忽略掉’<‘和’>’之间的内容
(不必考虑特殊情况,如xml文件的格式错误)。
• 可选:
– 对于有能力的同学,可以考虑定义扩展点,使得第三
方开发者能够提供对其它文件格式的拼写检查的支持。
• 可参考的资料:
– 示例
– Platform Plug-in Developer Guide(Eclipse Help)
– The Official Eclipse FAQs:
http://wiki.eclipse.org/The_Official_Eclipse_FAQs
作业讲解
主要问题
• 包含统计的概念
• 有些过度设计的内容
– 如包含了Project/Schedule
• 依然有将用例和概念模型混杂在一起的情
况
– 如包含执行任务/登录系统的概念

similar documents