Skip to content
JunLeeTerry edited this page May 28, 2014 · 5 revisions

RCP Editor tutorials

by Jun Lee
What we need to do

If you want to create an editor on RCP you must do four things first.

1.Make the editor area visible in your perspective 2.Create an IEditorInput class 3.Define an extension for the "org.eclipse.ui.editors" extension point 4.Implement the class for the editor, this class must implement IEditorPart

How we realize the editor

1.We will add three dependencies in Dependencise.

org.eclipse.jface.text: Provides text-processing libraries org.eclipse.ui.editors: The general editor support org.eclipse.ui.workbench.texteditor: The general text editor

2.We will add an extension.

org.eclipse.ui.editor then we add an editor in this extension,set the editor ID ,editor name and the class where wo need to add code.

3.The class editor extends the class TextEditor.In class TextEditor,a DocumentProvider has setted.Every editor need a DocumentProvider which synchronizes the content of the document with any other open editors. (This allows Eclipse to open multiple editors on the same file and still show the same changes in both.)

  1. layout.setFixed(true); You need to add this code in the Perspective.java. Now you can make the editor area visible in your perspective.

5.If you want to show the editor you need next code. try { getViewSite().getWorkbenchWindow().getActivePage() .openEditor(input, ASMEditor.ID); } catch (PartInitException e1) { e1.printStackTrace(); }

You can add this in postWindowOpen() method in the class ApplicationWorkbenchWindowAdvisor.Or you can add this into a listener in a button.

Clone this wiki locally