|
SWT LPEX v3.0.0 | |||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
---|---|
LpexLanguageHelp | Interface LpexLanguageHelp defines a language-sensitive help (LSH) provider for LpexSourceViewer, or an editor using it. |
LpexPreload | Interface LpexPreload defines an extension point for a plug-in to extend LPEX. |
Class Summary | |
---|---|
LpexAbstractDecoratedTextEditor | A line oriented, LPEX-based abstract base implementation of an extended text editor. |
LpexAbstractTextEditor | A line oriented, LPEX-based abstract base implementation of a text editor. |
LpexAnnotationBarHoverManager | LPEX implementation of AnnotationBarHoverManager. |
LpexContextContributor | Basic LPEX contributions to the Eclipse context. |
LpexPlugin | Plug-in runtime class for LPEX. |
LpexSourceViewer | A line-oriented, LPEX-based partial implementation of org.eclipse.jface.text.source.ISourceViewer. |
LpexSourceViewerConfiguration | This class extends the configuration space defined by SourceViewerConfiguration, with LPEX's content assist for use with an LpexSourceViewer. |
LpexStatusTextEditor | A line-oriented, LPEX-based version of StatusTextEditor. |
LpexTextEditor | A line-oriented, LPEX-based version of TextEditor. |
LpexTextViewer | A line-oriented, LPEX-based partial implementation of org.eclipse.jface.text.ITextViewer. |
LpexVerticalRuler | A vertical ruler which is connected to an LpexTextViewer. |
LpexViewPreferenceNode | PreferenceNode for the view-scoped preference pages. |
This package provides advanced line-oriented editing functions for Eclipse technology plug-ins.
The organization of the LPEX Editor plug-in classes mirrors Eclipse text editing framework's:
Viewer ^ | EditorPart LpexTextViewer: new LpexView, new LpexWindow ^ ^ | | LpexAbstractTextEditor: new LpexSourceViewer ^ | LpexStatusTextEditor ^ | LpexAbstractDecoratedTextEditor ^ | LpexTextEditor |
Several functions, however, are not supported. This is mainly functionality which is already implemented in the LPEX widget. The main differences from the corresponding Eclipse classes are documented in each class.
Such low-level integration results in a strong dependency on the Eclipse implementation of these classes and its definition of the related interfaces. This in turn causes significant rewrites when new Eclipse drivers (traditionally heavily-modified) are released.
LPEX-based solution editors should subclass LpexAbstractDecoratedTextEditor, or a class lower in the hierarchy.
A minimal implementation of an LPEX-based editor plug-in could consist of one file, eclipse/plugins/com.mycompany.simplelpexeditor_1.0/plugin.xml:
<?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.0"?> <!-- ========================================= --> <!-- Simple LPEX-based editor plug-in example. --> <!-- ========================================= --> <plugin id="com.mycompany.simplelpexeditor" name="Simple LPEX Editor" version="1.0.0" provider-name="My Company"> <requires> <import plugin="com.ibm.lpex"/> </requires> <extension point="org.eclipse.ui.editors"> <editor id="com.mycompany.SimpleLpexEditor" name="Simple LPEX Editor" icon="./icons/SimpleLpexEditor.gif" class="com.ibm.lpex.alef.examples.BasicLpexEditor" extensions="app,asm,c,c++,cbl,cc,ccs,cicsc,cmd,cob,cpp,cpy,cxx,f,f90,f95,h,h++,hh,hla,hpp,htm,html,hxx,inc,inl,j,jav,java,jcl,jj,lx,lxl,lxu,mac,pli,pro,properties,rc,readme,rex,rexx,sqc,sql,sqlc,sqlj,txt,xml,xsl" contributorClass="com.ibm.lpex.alef.examples.BasicLpexEditorActionContributor" default="false"> </editor> </extension> </plugin> |
LpexAbstractTextEditor defines several new editor actions and commands, available in all the LPEX-based solution editors.
To add its contributions to the Eclipse global actions, menus, toolbar, and status line, your LPEX-based solution should extend LpexContextContributor, rather than BasicTextEditorActionContributor. This gives LPEX the opportunity to add its own basic editor contributions to Eclipse.
An LPEX-based editor plug-in that has no contributions of its own must still use this class (or a class extending it) as the contributorClass in its plugin.xml declaration of the "org.eclipse.ui.editors" extension point, in order to have the LPEX contributions appear in the workbench, and link the editor actions to the global workbench actions.
BasicTextEditorActionContributor ^ | LpexContextContributor ^ | MyTextEditorActionContributor |
Here is the relevant section of a solution plug-in's plugin.xml file:
<extension point="org.eclipse.ui.editors"> <editor . . . contributorClass="com.mycompany.MyTextEditorActionContributor"> </editor> </extension> |
AWT LPEX and SWT LPEX running outside the Eclipse workbench can load and run user-defined classes (document parsers, actions, commands, and user profiles) which are located in the CLASSPATH. Inside the Eclipse workbench, however, each plug-in has its own class loader, restricted to the class path defined in its plugin.xml or bundle (usually one or more specific jar files, and the prerequisite plug-ins).
When the LPEX Editor plug-in cannot load a class, it attempts to load it via alternate class loaders, set by default to the solution plug-in's class loader.
In order to allow the Eclipse user to add custom classes that extend the LPEX plug-in:
Any plug-in that provides document parsers, actions, commands, or user profiles for its own LPEX-based editor plug-in, can make them available to any LPEX-based editor plug-in installed in the workbench. This can be accomplished through the com.ibm.lpex.preload extension point defined in the LPEX Editor plug-in:
<!-- ======================================================================= --> <!-- Extension Point: preload. --> <!-- Define an extension point for a plug-in to extend LPEX with user --> <!-- profiles, commands, actions, and document parsers. --> <!-- --> <!-- <!ELEMENT preload> --> <!-- <!ATTLIST preload --> <!-- class CDATA #REQUIRED --> <!-- > --> <!-- where --> <!-- class - the class that registers LPEX parsers, etc. The class must --> <!-- be a public implementation of com.ibm.lpex.alef.LpexPreload, --> <!-- with a public 0-argument constructor. --> <!-- --> <!-- Example of a plug-in hooking into the "preload" extension point: --> <!-- <extension point="com.ibm.lpex.preload"> --> <!-- <preload class="com.example.LpexRegistration"/> --> <!-- </extension> --> <!-- ======================================================================= --> <extension-point id="preload" name="preload" schema="schema/preload.exsd"/> |
This extension point allows the LPEX Editor plug-in to record, upon initialization, the class loaders of all declaring client plug-ins, and use them when attempting to load document parsers, etc., that had been defined in LPEX.
The client plug-in's preload() method in the preload class specified is called. Here, the client plug-in may, for example, set default editor settings, or may choose to extend the LPEX install settings, by providing the new parsers and parser associations that it contributes. These settings will show in the LPEX Editor preference pages the first time these are displayed, even when the client plug-in has not been explicitly activated yet.
LPEX supports multiple views on the same document. In order to allow opening multiple document views and have the view-management actions added to pop-up (context) menu, explicitly enable this feature in one of the hooks that your editor application uses during initialization, for example:
public void initializeLpexView(LpexView lpexView) { // . . . // enable multiple document views lpexView.doDefaultCommand("set multipleViews on"); // . . . } |
Contributions to the pop-up menu, the actions and commands defined, and in general the functions available may be different in each view of the document, depending on your editor application.
Each view runs its own document parser instance. For information on special parser considerations when multiple document views are open, see LpexCommonParser.
Related editor parameters: documentId, multipleViews, splitWindow, splitWindow.orientation, viewId.
When multiple document views are displayed in a split window, there may be several LpexWindows and LpexViews per editor part inside the workbench. See getLpexWindow(), getFirstLpexWindow(), getLpexView(), getFirstLpexView().
The current implementation of multiple views in this package defines the first view created for a document as the primary view. When the primary view is closed, the entire document (editor part) is closed. That is, regardless of the other (secondary) views being opened and closed, the first view created is always available, its view id being 1:
boolean isPrimaryView = lpexView.queryInt("viewId") == 1; |
When window splitting is disabled or the number of open views inside a split window reaches a defined maximum, additional "Open new view" requests will open external Lpex windows. As these views are opened outside the workbench, you may want to delegate some of their actions (such as save) so they are run in the context of your application, by extending handleDelegate().
Here is a sample implementation of LSH support for C/C++ documents in an editor which subclasses LpexAbstractDecoratedTextEditor.
private LshSupport _lshSupport; /** * Registers LSH for C/C++ instances of this LPEX-based editor. */ public void updateProfile(LpexView lpexView) { // . . . LpexParser parser = lpexView.parser(); if (parser != null && parser instanceof CppParser) { // singleton LshSupport for all C/C++ LpexAbstractDecoratedTextEditor instances if (_lshSupport == null) { _lshSupport = new LshSupport(); } // register it with our LpexAbstractTextEditor setLanguageHelp(_lshSupport); } // . . . } |
Class LshSupport may be implemented as follows:
/** * One instance of this class is being registered to provide LSH support for * all the instances of LpexEditor that use an LPEX C/C++ document parser * (CppParser, or one of its extending parsers). The getHelpPage() call-back * determines the help panel to be displayed for the current editing context. * * The map of keywords to help panels (file CppLsh.properties) is packaged in * this plug-in. In other implementations it may be part of the language * documentation plug-in itself, and loaded using that plug-in's class loader. * We assume here that the C/C++ documentation plug-in is installed in the * workbench. * * LshSupport can be modified to handle LSH for several document parsers. */ public class LshSupport implements LpexLanguageHelp { // information for the current instance of this LSH provider private String _languagePluginId; private String _languageHelpMapId; private Properties _languageHelpMap; /** * Constructs an instance of this provider for C/C++ LSH. */ LshSupport() { // initialize for C/C++ LSH: C/C++ documentation plug-in, help map file name _languagePluginId = "com.ibm.etools.iseries.cpp.doc"; _languageHelpMapId = "CppLsh.properties"; } /** * Returns the fully-qualified help panel name for the current token in the * given editor view, for example: * "/com.ibm.etools.iseries.cpp.doc/help/helpitem55.html". */ public String getHelpPage(LpexView lpexView) { LpexParser parser = lpexView.parser(); if (parser == null || !(parser instanceof LpexCommonParser)) { return null; } // let parser determine the current token for LSH, // which will serve as the key into the help map lpexView.doCommand("parse"); lpexView.doCommand("screenShow view"); String token = ((LpexCommonParser)parser).getLshToken(); // keys are defined in lower case in the help map: helpful for case-sensitive // languages, so that the help may guide user to correct case syntax on errors token = (token == null)? "default_help" : token.toLowerCase(); // ensure the help map is loaded loadLanguageHelpMap(); // retrieve help page for the keyword, or default help page if none defined String helpPage = _languageHelpMap.getProperty(token); if (helpPage == null) { helpPage = _languageHelpMap.getProperty("default_help"); } // fully-qualify the documentation plug-in help page return (helpPage == null)? null : '/' + _languagePluginId + '/' + helpPage; } /** * On the first LSH request (F1), load the map of language * keywords to help panels, which is in this package in our plug-in's jar. */ private void loadLanguageHelpMap() { if (_languageHelpMap == null) { _languageHelpMap = new Properties(); try { _languageHelpMap.load(LshSupport.class.getResourceAsStream(_languageHelpMapId)); } catch (Exception x) {} // cannot load help map } } } |
|
SWT LPEX v3.0.0 | |||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |