70 likes | 189 Views
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
E N D
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 • 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.
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
Principles for creating custom text editors • Create a document provider. • Create a document partitioner • Determine source viewer plugins to be provided • Create for all source viewer plugins the appropriate extensions for each supported content type • Build a source viewer configuration using the previously created plugins and extensions.
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.
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.