introduction to eclipse plugin development

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

Upload: vladimir-hughes

Post on 03-Jan-2016

49 views

Category:

Documents


4 download

DESCRIPTION

Introduction to Eclipse plugin development. for CSU 670 course project, Selector language (Xaspect) editor plugin implementation. Plug-in development environment. Java development tools. Java VM. JDT. PDE. Platform. Eclipse Platform. Standard Java2 Virtual Machine. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Introduction to  Eclipse plugin development

Introduction to Eclipse plugin development

for CSU 670 course project,

Selector language (Xaspect) editor plugin implementation

Page 2: Introduction to  Eclipse plugin development

What is Eclipse?

Java VMStandard Java2Virtual Machine

PlatformEclipse Platform

Java development tools

JDT

PDEPlug-in developmentenvironment

- Eclipse is a universal platformfor integrating development tools.

- Open, extensible architecture based on plug-ins

Page 3: Introduction to  Eclipse plugin development

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

Page 4: Introduction to  Eclipse plugin development

SWT - Standard Widget Toolkit

Platform-independent native widget toolkit

Page 5: Introduction to  Eclipse plugin development

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

Page 6: Introduction to  Eclipse plugin development

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

Page 7: Introduction to  Eclipse plugin development

– 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

Text Editor Framework(s) for building high-function text editors

Page 8: Introduction to  Eclipse plugin development

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

Page 9: Introduction to  Eclipse plugin development

GEF (Graphical Editor Framework)

– 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

Framework for building rich graphical editors

Page 10: Introduction to  Eclipse plugin development

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

Page 11: Introduction to  Eclipse plugin development

Eclipse Help

• HTML and XML based system

• Context-sensitive (F1) help

• Dynamic content generation

• Search engine

• Dynamic-aware

• Highly scalable (used on ibm.com)

<extension point="org.eclipse.help.toc"> <toc primary=“true" file="doc/guide.xml"/> <toc file="doc/tipsAndTricks.xml"/></extension>

<toc label="Go wild user Guide"> <topic label="Getting Started"> <anchor id="gettingstarted"/> </topic> <topic label="Commands" href="doc/cmds.html"/></toc>

plugin.xml

guide.xml

Help UIUser interface and dialogs

Help CoreAPI to access the documents

Help UI on top of an extensible help content model

Page 12: Introduction to  Eclipse plugin development

Eclipse Help

Page 13: Introduction to  Eclipse plugin development

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

Page 14: Introduction to  Eclipse plugin development

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

Page 15: Introduction to  Eclipse plugin development

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.

Page 16: Introduction to  Eclipse plugin development

Eclipse Plug-in Architecture

• 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

plug-in A plug-in B

class Cinterface I

extensionpoint P

extension

• Typical arrangement

contributes

creates, calls

implements

Page 17: Introduction to  Eclipse plugin development

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

Page 18: Introduction to  Eclipse plugin development

<extension-point id=“views” name=“Views” schema="schema/views.exsd”/>

<extension id=“catalogView" point=“org.eclipse.ui.views”> <view name=“Catalog” icon=“icons/catview.gif” class=“com.acme.CatalogView”/></extension>

Runtime: Extension / extension point model

Extension point declaration – plugin.xml

Extension declaration – plugin.xml

Declarative extensibility mechanism

The extension-point defines the contract (markup and code) for the extensions

Metaphor: disc spindle

Page 19: Introduction to  Eclipse plugin development

A typical Plug-in Manifest

<plugin id = “com.example.tool" name = “Example Plug-in Tool" class = "com.example.tool.ToolPlugin"> <requires> <import plugin = "org.eclipse.core.resources"/> <import plugin = "org.eclipse.ui"/> </requires> <runtime> <library name = “tool.jar"/> </runtime> <extension point = "org.eclipse.ui.preferencepages"> <page id = "com.example.tool.preferences" icon = "icons/knob.gif" title = “Tool Knobs" class = "com.example.tool.ToolPreferenceWizard“/> </extension> <extension-point name = “Frob Providers“ id = "com.example.tool.frobProvider"/></plugin>

Declare contributionthis plug-in makes

Declare new extension point open to contributions from other plug-ins

Location of plug-in’s code

Other plug-ins needed

Plug-in identification

plugin.xml

Page 20: Introduction to  Eclipse plugin development

The Text Editor FrameworkThe 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

Page 21: Introduction to  Eclipse plugin development

Syntax coloring in Text Editor

Syntax coloring is provided in the platform text framework using a model of :

• Damage, • Repair• reconciling. 

Page 22: Introduction to  Eclipse plugin development

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. 

Page 23: Introduction to  Eclipse plugin development

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 IRule[2];• rules[0] = new SingleLineRule("<myTag", "myTag>", tagToken);• rules[1] = (new EndOfLineRule("//", commentToken));• setRules(rules);• }• }• ////// in subclass of SourceViewerConfiguration: • public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {• PresentationReconciler reconciler = new PresentationReconciler();• DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getTagScanner());• reconciler.setDamager(dr, Document.DEFAULT_CONTENT_TYPE);• reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);• return reconciler;• }