Embedding a text editor within another Eclipse editor - eclipse

Is it possible to embed a text editor (with syntax coloring and content assist) within my own custom Eclipse editor? I am under the impression that a text editor (with features like syntax coloring) needs to extend IEditorPart or one of its subclasses, but am I correct in thinking that an IEditorPart subclass can't be embedded because it's not part of Eclipse SWT? And if that's true, is there another way to get that functionality?
To expand on this "custom Eclipse editor": I'm referring to an editor with multiple tabs, and in one of the tabs I want to embed a text editor with syntax coloring, and possibly content assist.

Yes, using a MultiPageEditorPart, where every page is either an IEditorPart or an SWT control. Keep in mind that the text editor you're embedding has to have been written to still function correctly in that situation.

Right, you cannot embed IEditorPart, instead you could inherit your editor from a concrete IEditorPart implementor and override custom aspects thereof.

You can add your editor to MultiPageEditPArt.
final IEditorPart = new YourEditor();
int editorIndex = addPage(formJSEditor, editorInput);
setPageText(editorIndex, "Your Editor");

Related

How to add a macro to an umbraco page when using the markdown editor

EDIT:
What I really need is an editor that'll allow me to write html directly and allow inserting macros.
I'm using WMD editor in umbraco 7 and need to add a partial view macro to the page.
The editor does not have an insert macro button and if I pasted the following code in the editor, it is not shown in the page. I think the markdown processor removes it from the page ; <umbraco:Macro Alias="YourMacroAlias" \>
How can I add the macro to the page ?
Out of the box, the WMD editor does not support embedding Macros in the same way as the Richtext Editor does. You could raise a feature request at http://issues.umbraco.org and see if they'll add it, or you could take the source of the WMD from the Umbraco source at https://github.com/umbraco/Umbraco-CMS and create your own version of the markdown editor based on it.
The way the Richtext editor does it is that it stores the macro details as a specially formatted bit of markup, and there's some code in the front end that looks for that markup and replaces it with the output of the Macro.
Go to the developer section. Open the Macros.
In your macro there is a checkbox "Use in rich text editor and the grid" and "Render in rich text editor and the grid" check this.
For Using in Rich Text the option must be checked in the Data Type.
In the Developer section there is below Data Types, the Richtext editor data type check umbmacro.
In the Rich Text editor there is a "Insert Macro" Button, the 2 gears icon.
But for a markdown datatype there is no button, no support, An option is invent a tag a replace you tag in the template with somethings else. To come a bit near a macro functionality.
Instead of using Markdown editor for less options, you can disable excess commands for the tinyMce too. Extra tags added by tinyMce can also be disabled, see at end
Firstly there is file in config folder named tinyMceConfig.config. It handles the options in all datatypes using tinyMce. Below is entry for macro
<command>
<umbracoAlias>umbracomacro</umbracoAlias>
<icon>images/editor/insMacro.gif</icon>
<tinyMceCommand value="" userInterface="true" frontendCommand="umbmacro">umbracomacro</tinyMceCommand>
<priority>62</priority>
</command>
Go to
Developer -> DataTypes -> Rich Text Editor
There will be toolbar checkbox list. Select umbmacro from the list and save the data type. You will see the macro on the WYSIWYG editor. Uncheck all unwanted options. Also you can create new datatype say "RTE Lite" using property editor "Rich Text Editor" and use this "RTE Lite" where less options are needed.
Edit: Okay, if you do not like extra p tag added by tinyMce, go to "tiny_mce_src.js" file from your umbraco solution, search for forced_root_block : 'p' and change it to forced_root_block : ''

In an eclipse plugin: How can I programmatically highlight lines of codes in the java editor?

I am trying to develop an eclipse plugin that does some documentation check on java code and highlights some lines of code in the editor.
To achieve my goal, I DON'T want to create a new editor in eclipse, I simply want to extend the default java editor to draw a line under (or highlight) the methods that do not satisfy some set of predetermined requirements.
Do I need to create a PresentationReconciler? If yes, how do I make the JDT or workbench use my reconciler.
I have never done plugin development and this is my first attempt.
Several starting points for you:
Annotations are an UI feature of JFace's text editor that allows you to visually mark some places in an open editor.
Markers are a Workbench feature, more high-level. They are generic "objects that may be associated with Workbench resources", and they can display in several places: in text editors (as annotations) or in the Problems view, for example.
Depending on what you want to do, you would plug in your plug-in into extension points related to either of those.
The Eclipse Java editor is located in the org.eclipse.jdt.internal.ui.javaeditor.JavaEditor package.
The "internal" in the package name means that the Eclipse development team can change how the Java editor works with new revisions.
Try this help page: Juno Help on syntax highlighting
At the end of the page, it describes how to dynamically add a PresentationReconciler, which is used for syntax highlighting. See if that fits the problem that you want to solve.
I assume you already have a plugin project.
In your plugin.xml, open the tab Extensions, click Add..., search for org.eclipse.ui.editors, then you should see a template named Editor, which will produce a simple xml editor to experiment and play with. Also, you will be able to see the needed structure to define a custom editor.
Hope this helps...
I don't know if you still have a need for this, but you are going to want to use Annotations to keep track of what parts of the editor you need to highlight.
For actually doing the graphical effect of highlighting, you could do syntax highlighting via a PresentationReconciler, but I have no experience with that.
We used a technique we borrowed from http://editbox.sourceforge.net/, replacing the background image of the editor Shell. Its open source, so check it out. (Our code might also help -- its at https://github.com/IDE4edu/EclipseEditorOverlay )

Programatically manipulating the Eclipse RCP EditorArea Sashes

I have an eclipse RCP application that uses and Editor Area. I have a few things that I would like to do programatically but cannot find any documentation:
1) Do not restore editor sash layout. I.e., I like to use rcp saveAndRestore functionality, but for my perspectives, views, and other momentos. I do not however want to restore the editor area multiple tab groups at all. I choose not to implement the IPersistableEditor interface, and therefore my editor sessions are not restored, but when my application restarts, it still has split windows (swt sashes for multiple tab groups), etc, and i wish it was just 1 editor area tab group like default.
2) I would like to programaticaly split/duplicate an editor into another tab group, for example I would like a button that says "Split Horizontal" and that opens a new editor in a new tab group beside the current one.
Any help is much appreciated! Happy Coding!
/P
1) Funny, seems like a bug in the platform.
You can explicitly close all editors upon workbench window close. One option to do this would be to override the preWindowShellClose method in your WorkbenchWindowAdvisor:
public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
#Override
public boolean preWindowShellClose() {
getWindowConfigurer().getWindow().getActivePage().closeAllEditors(true);
return super.preWindowShellClose();
}
}
If you don't have access to the ApplicationWorkbenchWindowAdvisor, you can try to do the same with the IPerspectiveListenerX
2) I think there is no public API for this. The editor area behavior is defined in the presentation factory (see org.eclipse.ui.presentationFactories extension-point). You could clone the RCP standard presentation and implement the desired split-editor-area-on-demand functionality.

Is there a way to integrate Properties View within the Eclipse Multipage editor?

I am trying to implement an Eclipse editor which consists of a design part, Palette part and the Properties part for the selected palette item. All in the same editor page.
After a long time of googling, I have come to know that there are no proper articles or examples for this issue. Is there some solution that I could get from anyone here?
The SWT Design editor implements this feature in its editor. However, I am unable to access its source.
To access the properties view, you have to have three things:
Your editor must define its SelectionProvider (getSite().setSelectionProvider()). A SelectionProvider is either a JFace Viewer, or can be any class that return a corresponding ISelection interface.
The objects returned by the ISelection must either implement IPropertySource or return an IPropertySource adapter using the getAdapter(IPropertySource.class).
In multi-page editors you have to make sure, that the SelectionProvider also returns what expected.
For details about the first two point, see the following Eclipse Corner article: Take control of your properties, or if you would like to use the Tabbed properties view seen in GMF editors, The Eclipse Tabbed Properties View.

How to get from an EditPart to its Editor in Eclipse? (Eclipse plug-in development)

I am writing an eclipse plug-in that extends editor. Inside the editor I put some EditParts. From some of these edit parts I need a reference to their encapsulating editor (so that for example, when clicking an instance of MyEditPart, I want to programmatically close the editor).
Please advise on the API to get from an EditPart instance to the Editor it is in.
Thanks.
You can try:
IEditorPart editor = ((DefaultEditDomain) getViewer().getEditDomain()).getEditorPart();
from the EditPart.