Eclipse Example Guide

7
Eclipse Example Guide Example : Java Editor

description

Eclipse Example Guide. Example : Java Editor. Introduction. The Java Editor example : demonstrates the standard features available for custom text editors.  shows how  to register an editor for a file extension (in this case .jav) and - PowerPoint PPT Presentation

Transcript of Eclipse Example Guide

Page 1: Eclipse Example Guide

1

Eclipse Example Guide

Example : Java Editor

Page 2: Eclipse Example Guide

2

Introduction The Java Editor example :

» demonstrates the standard features available for custom text editors. 

» shows how  to register an editor for a file extension (in this case .jav) and

» how to define a custom Document provider for use by that editor.

» only for demonstration purposes. Java editing support is provided by the  Eclipse Java Tooling.

Page 3: Eclipse Example Guide

3

Features demonstrated syntax highlighting content type sensitive content assist (JavaDoc and Java

code) communication between content outliner and editor,

» i.e. content outliner selection feeds the highlight range of the editor

two different presentation modes» marking the highlight range using a visual range

indicator » confining the editor to show only text within the highlight

range (e.g. show a single method of a Java class) marker handling document sharing

Page 4: Eclipse Example Guide

4

How to run the editor

Page 5: Eclipse Example Guide

5

Principles for creating custom text editors

1. Create a document provider.

2. Create a document partitioner

3. Determine source viewer plugins to be provided

4. Create for all source viewer plugins the appropriate extensions for each supported content type

5. Build a source viewer configuration using the previously created plugins and extensions.

Page 6: Eclipse Example Guide

6

6. Customize the class TextEditor or AbstractTextEditor with the developed document partitioner and source viewer configuration. » Add or replace actions and adapt the construction of

the editor's context menu. In the actual version, this customization must be done in a subclass. See JavaEditor in the example editor.

7. Set up an appropriate action bar contributor who contributes editor-related actions to the desktop's toolbar and menus. See JavaActionContributor in the example editor.

8. Extend the XML configuration file of the editor's plugin, so that the editor registers at the predefined editor extension point for a specific set of file extensions. Also set up the action bar contributor in the XML file. See plugin.xml of this example.

Page 7: Eclipse Example Guide

7

Code organization four packages: org.eclipse.ui.examples.javaeditor

» contains all the editor specific classes. org.eclipse.ui.examples.javaeditor.java

» contains all Java specific source viewer plugins such as the JavaDamagerRepairer as well as the Java specific document partitioner.

org.eclipse.ui.examples.javaeditor.javadoc » contains all JavaDoc specific source viewer plugins

such as the JavaDocDamagerRepairer. org.eclipse.ui.examples.javaeditor.util

» contains convenience classes shared by the three other packages.