Bug 245547 - [ui] Templates View for XML
Summary: [ui] Templates View for XML
Status: NEW
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xml (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: Future   Edit
Assignee: wst.xml CLA
QA Contact: Nick Sandonato CLA
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks: 245550
  Show dependency tree
 
Reported: 2008-08-28 11:38 EDT by David Carver CLA
Modified: 2013-07-18 14:17 EDT (History)
4 users (show)

See Also:


Attachments
Provides ability for XML Templats to display and be used in Templates View (10.84 KB, patch)
2008-08-28 14:45 EDT, David Carver CLA
thatnitind: review-
Details | Diff
Makes the Templates Pages configurable by Editor (32.36 KB, patch)
2008-08-29 10:44 EDT, David Carver CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Carver CLA 2008-08-28 11:38:27 EDT
Eclipse 3.4
Web Tools 3.0

Eclipse provides a view to see all of the templates a particular editor supports.  Currently none of the SSE based editors contribute to this view.   As more an more generalized templates are created, it would be nice to have this templates view populated.   XSL Tools could use this for creating some common templates that then could be dragged and dropped into the editor.   It is also handy for viewing the available templates at a glance.
Comment 1 Nitin Dahyabhai CLA 2008-08-28 12:33:26 EDT
Dave, how much work would be entailed in supporting this view?  Ideally it would be something we could implement in the StructuredTextEditor with some flexibility to show the templates for the relevant content type(s).
Comment 2 David Carver CLA 2008-08-28 14:29:36 EDT
(In reply to comment #1)
> Dave, how much work would be entailed in supporting this view?  Ideally it
> would be something we could implement in the StructuredTextEditor with some
> flexibility to show the templates for the relevant content type(s).
> 

I'm working on a prototype patch right now for review.  It doesn't seem overly difficult, and yes, I agree ideally it should be in the Structured TextEditor, maybe with an extension point so that other editors can contribute the various TemplatePage implementations, because depending on your contentType, you may not want to see XSL templates in an XSD Editor, but you may want to see XSD Templates in the XSL Editor.

Comment 3 David Carver CLA 2008-08-28 14:45:47 EDT
Created attachment 111237 [details]
Provides ability for XML Templats to display and be used in Templates View

This patch is a proof of concept patch that shows how to make the XML Editor's Templates available for use with in the Templates View.   This probably needs a SSE extension point, where an editor can contribute various TemplatePages to the particular editor for possible inclusion.

For XSL Tools we would need the ability to display both XML, XPath, XSL, and possibly templates from other XML editors.   I've tested this patch very briefly, and it seems to work.  You will need to open a file in the XML Editor.  If the Templates View is open it will display the available templates.

As of right now it looks for the XML_Default partioning to determine what templates can be displayed.
Comment 4 Nitin Dahyabhai CLA 2008-08-28 14:50:33 EDT
Comment on attachment 111237 [details]
Provides ability for XML Templats to display and be used in Templates View

Subclassing the StructuredTextEditor makes it much harder to drop into another multi-page editor.  Plus I'm interested in this working in all of the supported languages--I don't see how even XSL templates would be shown.
Comment 5 David Carver CLA 2008-08-28 15:06:47 EDT
(In reply to comment #4)
> (From update of attachment 111237 [details])
> Subclassing the StructuredTextEditor makes it much harder to drop into another
> multi-page editor.  Plus I'm interested in this working in all of the supported
> languages--I don't see how even XSL templates would be shown.
> 

As I said with the patch, it's a proof of concept patch, it isn't fully implemented, but is provided to give an idea of how it can be done.  Ideally, I could see adding something to the sourceViewerConfiguration or adding a new extension point in org.eclipse.wst.sse.ui.editorConfiguration.   It could also be a new provisionalDefinition, that takes a list of classes to be used to contribute to the Templates View.

If we go the extension point route, then all an implementation has to do is provide a list of classes that extend the AbstractTemplatesPage class, and contribute their templates to the view.   For XSL, we could then say, we wanted to use XMLTemplatesPage, XSLTemplatesPage, XPathTemplatesPage, HTMLTemplatesPage, CSSTemplatesPage, etc.  to provide the various templates to be available for the editor.

Comment 6 David Carver CLA 2008-08-29 10:44:33 EDT
Created attachment 111304 [details]
Makes the Templates Pages configurable by Editor

This patch makes the templates page configuration more configurable.  The Structured Text Editor controls what TemplatesPage implementation will be instatiated based on the provisionalProvider configuration extension point of "templatesPageConfiguration".   This takes a instance of AbstractTemplatesPageConfiguration which provides the actual implementation if ITemplatesPage to be used by the view.

In order for this to work, the TemplatesPage view needs to be defined, this is already done in the JDT plugin, but the TemplatesPage view comes from the platform so there is no dependency on JDT.

This patch implements the template pages for the XML editor only.  Other editors would need to provide their own implementations and configurations.
Comment 7 David Carver CLA 2008-09-15 17:40:01 EDT
is this still on target for 3.1M2?  I would like to implement this support in XSL Tools 1.0M3, but need this patch in SSE first.
Comment 8 Nitin Dahyabhai CLA 2008-09-15 21:13:16 EDT
Dave, your patch does multiple things--adding the templates page and also refactoring unrelated sections--which makes reading it harder, but yes, still planning for M2.
Comment 9 David Carver CLA 2008-09-15 22:07:30 EDT
Yeah, I realize it had the refactorings as well as the new functionality.   I did the refactoring to make it easier to read and know what was happening within the code from an outsiders stand point.   They were all just Extract Method refactorings so no other code changes were done from a refactoring stand point.  It's about the most basic refactoring that one can do.
Comment 10 Nitin Dahyabhai CLA 2008-09-16 00:32:07 EDT
I'm pulling this off of M2 for now.  The way the abstract page from the platform is written, there is no way to reconfigure it after it has been created.
Comment 11 David Carver CLA 2008-09-16 09:50:30 EDT
(In reply to comment #10)
> I'm pulling this off of M2 for now.  The way the abstract page from the
> platform is written, there is no way to reconfigure it after it has been
> created.
> 

I'm not sure I understand what you mean.   When I was doing testing, if you had a Java Editor up it would switch to the Java Editor templates, if I had the XML Editor open it switched to the XML Templates.    Are you saying that if you have two different SSE editors open (XML and XSLT) it will only show the first one that is configured?
  
Comment 12 David Carver CLA 2008-09-16 10:37:45 EDT
I just did a test on this by re-applying the current patch, and then creating a XSL Tools configuration that uses the patch to provide access to the XPath templates when the XSLT editor is active.   With an XML File open in the XML Editor, the XML Editor templates are shown in the view, if I switch to the XSLT editor, the view is populated with the XPath templates.  If I switch to a Java Editor, it populates with the Java Editor templates.

It's working as I would expect.   Again, I'm not to sure on what you mean by reconfigure it after it has been created.  If you add templates to the appropropriate preference page, they will get added to the view.
Comment 13 David Carver CLA 2008-11-24 15:33:13 EST
Just checking to see if this is going to be added in the M4 time frame or not.   Because we only have really two more full milestone releases to get this in.   If it isn't going to be added natively with in the SSE, then I'll go with my work around to add support for XSL Tools to have the templates view work with it's editor.
Comment 14 David Carver CLA 2008-11-26 14:41:25 EST
I've got this working for XPath templates in XSL Tools 1.0M4.  Once this bug is addressed, I'll migrate our implementation over to the more SSE compliant way of doing this.
Comment 15 Nitin Dahyabhai CLA 2008-11-28 00:47:23 EST
Thanks, Dave.  It's been surprisingly hard to find time to work on a more general solution.
Comment 16 David Carver CLA 2009-03-19 21:32:35 EDT
Targeting for Future...Maybe for 3.2.