Eclipse icon

In the Building a Custom Text Editor with JFace Text lecture you walked through an example of building a custom text editor. The completed implementation of a SQL editor is contained on the CD-ROM in the project com.ibm.lab.soln.sqltexteditor.

Running the Solution

  1. In the PDE perspective, launch and run a runtime workbench (Run > Run As > Run-time Workbench).
  2. Create a new project in the workspace of the run-time workbench..
  3. Copy the test.sql file from the host/build-time workspace into the new project in the runtime-workspace.
  4. Open the test.sql file.
  5. Use the the content assist; type in part of the select, type the letters, "s e l", and then CTL+Space bar, and the content proposals will appear.
  6. Type in the word where in lower case. Notice the color syntax highlighting.
  7. Select Edit > Content Format and notice that "where" is turned to upper case "WHERE".

Roadmap of the Solution

The SQL Editor implements three editor customizations:
1. SQL keywords are available using content assist.
2. Using syntax highlighting, SQL keywords are colorized.
3. The formatter folds all SQL keywords to upper case.

Explore the steps required to implement this editor in four phases. A basic source editor is delivered in phase one. Phase two delivers content assist. Phase three adds syntax-color highlighting. Finally, phase 4 delivers content formatting

Phase 1

The implementaion phases begins with the creation of an editor with only the basic text editing functions. Here are the highlights of the basic text editing implementation.

Phase 2

In this phase, a content assistant is implemented that provides completion proposals for SQL keywords. Here are the highlights of the contents assist implementation.

Phase 3

This phase adds the syntax highlighting of SQL keywords. Here are the highlights of this phase of development.

SQL Plugin Utilities

Class (All) Description
ColorProvider Colors used in the SQL editor.
SQLWhiteSpaceDetector A class that determines if character is a SQL white space character.
SQLWordDetector Determines whether a given character is valid as part of a SQL keywords in the current context.
WordPartDetector Scans aand detects parts of a word.

Phase 4

This phase adds the content formatting of SQL keywords. Here are the highlights of this phase of development.

 

Formatting Specific Implementation

Class (All) Description
SQLWordStrategy The formatting strategy that converts SQL keywords to upper case.

Class Diagrams

The classes involved in the solution and their relationships are shown in the figure below. Only the key methods are illustrated.