Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[e4-dev] Feedback about E4 Tools OrionEditor

Hi E4 guys,

I have noticed that you provide an OrionEditor based on 3x EditorPart + OrionEditorControl : 

http://git.eclipse.org/c/e4/org.eclipse.e4.tools.git/tree/bundles/org.eclipse.e4.tools.orion.text.editor/src/org/eclipse/e4/tools/orion/text/editor/OrionEditor.java

At first why OrionEditor is not based on E4 part?

I would like to share with you my skill about an OrionEditor like. Indeed I have do the same thing than Orion with CodeMirror in my project https://github.com/angelozerr/CodeMirror-Eclipse.

I have a CMControl (like OrionEditorControl) and a CMEditorPart https://github.com/angelozerr/CodeMirror-Eclipse/blob/master/core/codemirror.eclipse.ui/src/codemirror/eclipse/ui/editors/CMEditorPart.java and an implemetation per mode (css, js, etc).

An interesting feature that I have done I think is that the editor like _javascript_Editor declared in https://github.com/angelozerr/CodeMirror-Eclipse/blob/master/mode/_javascript_/codemirror.eclipse.ui._javascript_/plugin.xml

works in several context : 

 * RCP
 * RAP
 * IDE

In your case, your OrionEditor is linked to IFile and so you can just use it on IDE context and not for RCP and RAP context.

To support any context, in my case I have delegate the load and save to an extension point called cmOperations, so I can work with IFile (see https://github.com/angelozerr/CodeMirror-Eclipse/blob/master/core/codemirror.eclipse.ui.ide/plugin.xml), Java File (see https://github.com/angelozerr/CodeMirror-Eclipse/blob/master/core/codemirror.eclipse.ui/plugin.xml) , other context.

To load/save my CodeMirror Editor from IFile, I use this cmOperations https://github.com/angelozerr/CodeMirror-Eclipse/blob/master/core/codemirror.eclipse.ui.ide/src/codemirror/eclipse/ui/ide/operations/CMFileOperation.java

In this code, we will see that I use file.getCharset() to load the content of IFile. As you are linked to commons io, I suggest you to do the same thing than me : 

-------------------------------------------------------------------------------
InputStream in = file.getContents();
try {
return IOUtils.toString(in, file.getCharset());
} finally {
if (in != null) {
in.close();
}
}
-------------------------------------------------------------------------------

I don't know if Orion has the same problem than CodeMirror, but with CodeMorrir when you want to retrieve the text value of the editor, you must pass the lineSeparator char (otherwise it uses a default value).

So I had to the getLineSeparator which comes from the Eclipse preferences to fix this problem.

Hope my feedback will be useful for you.

Regards Angelo

Back to the top