[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[wtp-dev] StructuredTextEditor subclasses in WTP

As stated before in a previous note about editor contributions:
One main goal of the Structured Source editing framework is to provide a way for clients to extend the Structured Text Editor without having to subclass the editor.

That being said, some work was done this week to remove the existing subclasses of StructuredTextEditor in WTP.  
The following classes were removed:

If you were using or subclassing these editors, you will have to react to these changes.

For all subclass users & clients
The main thing you need to do is change all references of those classes to StructuredTextEditor.  

For subclass clients that create a new editor out of the subclasses
The only thing those subclasses really provided was special actions.  Those actions were turned into action delegates, so if you would like those actions in your editor, you can use the org.eclipse.ui.editorActions extension point to add those actions to your editor.  For a list of actions to add, you can check out the plugin.xml for each of the plugins that contributed an editor.  So for example, if you want the html editor actions, look for the editorActions extension point in org.eclipse.wst.html.ui's plugin.xml and copy those (changing the target id to target your editor)

For multipageeditors that use a subclass as one of their pages
In your createPages method, where you create a new instance of a source editor (for example, new StructuredTextEditorXML()) create a new instance of StructuredTextEditor instead.  Then in your createSite method, have something like the following:
                IEditorSite site = null;
                if (editor == fSourceEditor) {           // the StructuredTextEditor page
                        site = new MultiPageEditorSite(this, editor) {
                                public String getId() {
                                        // sets this id so nested editor is considered xml source page editor
                                        return ContentTypeIdForXML.ContentTypeID_XML + ".source"; //$NON-NLS-1$;
                else {
                        site = super.createSite(editor);
                return site;

By setting the id in your site, the nested editor will be considered to be a specific editor and pick up all actions for that editor.  
Here are the ids you can use:
StructuredTextEditorJSP                ContentTypeIdForJSP.ContentTypeID_JSP + ".source"; //$NON-NLS-1$;
StructuredTextEditorHTML                ContentTypeIdForHTML.ContentTypeID_HTML + ".source"; //$NON-NLS-1$;
StructuredTextEditorCSS                ContentTypeIdForCSS.ContentTypeID_CSS + ".source"; //$NON-NLS-1$;
StructuredTextEditorXML                ContentTypeIdForXML.ContentTypeID_XML + ".source"; //$NON-NLS-1$;

More details about changes made can be found here:

Amy Wu
Structured Source Editor
919.254.0299, T/L 444.0299