Introduction to Eclipse plugin development - PowerPoint PPT Presentation

About This Presentation
Title:

Introduction to Eclipse plugin development

Description:

SWT - Standard Widget Toolkit. JFace Framework providing higher-level UI ... concept of annotations, annotations painter, hovers. concept of content assist ... – PowerPoint PPT presentation

Number of Views:503
Avg rating:3.0/5.0
Slides: 24
Provided by: jingso
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Eclipse plugin development


1
Introduction to Eclipse plugin development
  • for CSU 670 course project,
  • Selector language (Xaspect) editor plugin
    implementation

2
What is Eclipse?
  • - Eclipse is a universal platformfor
    integrating development tools.
  • - Open, extensible architecture based on
    plug-ins

3
UI Components
  • SWT - Standard Widget Toolkit
  • JFace Framework providing higher-level UI
    abstractions
  • Workbench Provides reusable and extensible UI
    metaphors
  • Text - Framework(s) for building high-function
    text editors
  • UI Forms - Framework for building forms-based
    views and editors
  • GEF - Framework for building rich graphical
    editors

4
SWT - Standard Widget Toolkit
  • ? Platform-independent native widget toolkit

5
JFace
  • ? Framework on top of SWT providing higher-level
    UI abstractions
  • Application window menu bar, tool bar, content
    area status line
  • Viewers (MVC pattern)
  • Actions, action bars (abstracts menu items, tool
    items)
  • Preference and wizard framework

6
Workbench
  • ? Defines reusable and extensible UI metaphors
  • Leverages extension point mechanism and JFace
    abstractions.
  • Provides
  • Views
  • Editors
  • Action sets
  • Perspectives combination of Views and
  • Editors
  • -Wizards
  • Preference pages
  • -Commands and Key Bindings
  • -Undo/Redo support
  • -Presentations and Themes
  • -Activities (aka Capabilities)
  • -
  • Is Dynamic-aware responds to registry changes
    and adds/removes views, action sets, etc.
    accordingly

7
Text Editor
? Framework(s) for building high-function text
editors
  • document infrastructure
  • text manipulation through text edits
  • positions and linked position manager
  • template support
  • projection (aka folding) support
  • source viewer framework
  • provides Text-, SourceViewer and
    SourceViewerConfiguration
  • concept of annotations, annotations painter,
    hovers
  • concept of content assist
  • incremental syntax coloring (presentation
    reconciler)
  • incremental outline update (model reconciler)
  • formatter infrastructure
  • text editor framework
  • leverages source viewer framework for use in
    workbench editors
  • provides AbstractTextEditor

8
UI Forms
  • Form consisting of multiple FormParts
  • Extra widgets
  • FormText (marked-up text)
  • ScrolledForm
  • Section
  • MasterDetailsBlock
  • Extra layouts
  • TableWrapLayout (HTML-like)
  • ColumnLayout (newspaper-like)
  • Flat look, lightweight borders
  • Forms-based multi-page editor
  • Used extensively in PDE

9
GEF (Graphical Editor Framework)
? Framework for building rich graphical editors
  • Draw2D - structured graphics drawing framework
  • Graphical editor framework
  • MVC architecture
  • Undo/Redo support
  • Palette and common tools for manipulating
    objects
  • Integration with Properties and Outline view

10
User Assistance Components
  • Eclipse Help Help UI on top of an extensible
    help content model
  • Intro support Provides the welcome experience
    for your product
  • Cheat sheets Provides guidance through complex
    tasks

11
Eclipse Help
? Help UI on top of an extensible help content
model
  • HTML and XML based system
  • Context-sensitive (F1) help
  • Dynamic content generation
  • Search engine
  • Dynamic-aware
  • Highly scalable (used on ibm.com)

Help UI User interface and dialogs
Help Core API to access the documents
guide.xml
lttoc label"Go wild user Guide"gt lttopic
label"Getting Started"gt ltanchor
id"gettingstarted"/gt lt/topicgt lttopic
label"Commands" href"doc/cmds.html"/gt
lt/tocgt
plugin.xml
ltextension point"org.eclipse.help.toc"gt lttoc
primarytrue" file"doc/guide.xml"/gt
lttoc file"doc/tipsAndTricks.xml"/gt lt/extensiongt
12
Eclipse Help
13
Intro support
  • Provides the welcome experience for your
    product

Full mode
Standby mode
  • HTML / CSS or SWT / Forms based
  • Can run actions todrive the UI

14
Cheat sheets
  • Guides the user through a series of complex
    tasks to achieve a goal
  • Content written in XML
  • Can run actions to drive the UI

15
Eclipse Plug-in Architecture
  • Plug-in - smallest unit of Eclipse function
  • Example the editor of our course project.
  • Extension point - named entity for collecting
    contributions
  • Example extension point for workbench text
    editor.
  • Extension - a contribution
  • Example extending the text editor to edit
    selector language with syntax highlighting and
    semantics checking.

16
Eclipse Plug-in Architecture
  • Typical arrangement

plug-in B
plug-in A
contributes
extensionpoint P
extension
implements
interface I
class C
  • Plug-in A
  • 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

creates, calls
17
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

18
Runtime Extension / extension point model
? Declarative extensibility mechanism
The extension-point defines the contract (markup
and code) for the extensions
Extension point declaration plugin.xml
ltextension-point idviews
nameViews schema"schema/view
s.exsd/gt
Metaphor disc spindle
Extension declaration plugin.xml
ltextension idcatalogView"
pointorg.eclipse.ui.viewsgt ltview
nameCatalog iconicons/catview.gif
classcom.acme.CatalogView/gt lt/extension
gt
19
A typical Plug-in Manifest
plugin.xml
ltplugin id com.example.tool" name
Example Plug-in Tool" class
"com.example.tool.ToolPlugin"gt ltrequiresgt
ltimport plugin "org.eclipse.core.resources"/gt
ltimport plugin "org.eclipse.ui"/gt
lt/requiresgt ltruntimegt ltlibrary name
tool.jar"/gt lt/runtimegt ltextension
point "org.eclipse.ui.preferencepages"gt
ltpage id "com.example.tool.preferences"
icon "icons/knob.gif" title Tool
Knobs" class "com.example.tool.ToolPrefe
renceWizard/gt lt/extensiongt ltextension-point
name Frob Providers id
"com.example.tool.frobProvider"/gt lt/plugingt
20
The Text Editor Framework
  • The text editor framework provides a
    model-independent editor that supports the
    following features
  • presentation and user modification of text
  • standard text editing operations such as
    cut/copy/paste, find/replace
  • support for context and pull-down menus
  • visual presentation of text annotations in
    rulers
  • automatic update of annotations as the user
    edits text
  • presentation of additional information such as
    line numbers
  • syntax highlighting
  • content assist
  • text outlining pages that show the hierarchical
    structure of the text
  • context sensitive behavior
  • hover support over rulers and text
  • key binding contexts
  • preference handling

21
Syntax coloring in Text Editor
  • Syntax coloring is provided in the platform
    text framework using a model of
  • Damage,
  • Repair
  • reconciling. 

22
Damage, repair, and reconciling
  • Damage As the user modifies text in an editor,
    parts of the editor must be redisplayed to show
    the changes. 
  • Repair A repairer must be able to derive all of
    the information it needs from a damage region in
    order to successfully describe the repairs that
    are needed for a particular content type.
  • Reconciling describes the overall process of
    maintaining the presentation of a document as
    changes are made in the editor. 

23
Rule Based Reconciling
  • public class MyRuleScanner extends
    RuleBasedScanner
  • .
  • public MyRuleScanner()
  • IToken tagToken new Token(new
    TextAttribute(TAG_COLOR))
  • IToken commentToken new Token(new

  • TextAttribute(COMMENT_COLOR))
  • IRule rules new IRule2
  • rules0 new SingleLineRule("ltmyTag",
    "myTaggt", tagToken)
  • rules1 (new EndOfLineRule("//",
    commentToken))
  • setRules(rules)
  • ////// in subclass of SourceViewerConfiguration
  • public IPresentationReconciler getPresentationReco
    nciler(ISourceViewer sourceViewer)
  • PresentationReconciler reconciler new
    PresentationReconciler()
  • DefaultDamagerRepairer dr new
    DefaultDamagerRepairer(getTagScanner())
  • reconciler.setDamager(dr, Document.DEFAULT_CONTEN
    T_TYPE)
  • reconciler.setRepairer(dr, IDocument.DEFAULT_CONT
    ENT_TYPE)
Write a Comment
User Comments (0)
About PowerShow.com