Bug 259089 - HtmlDocumentBuilder beginDocument extensibility improvements
Summary: HtmlDocumentBuilder beginDocument extensibility improvements
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 enhancement (vote)
Target Milestone: 1.0.0   Edit
Assignee: David Green CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-12-17 08:04 EST by Matthias Kempka CLA
Modified: 2011-01-06 10:01 EST (History)
0 users

See Also:


Attachments
mylyn/context/zip (1.16 KB, application/octet-stream)
2008-12-21 00:08 EST, David Green CLA
no flags Details
patch for HtmlDocumentBuilder (4.04 KB, patch)
2008-12-22 05:45 EST, Matthias Kempka CLA
no flags Details | Diff
patch with changes (15.19 KB, patch)
2008-12-29 23:43 EST, David Green CLA
no flags Details | Diff
mylyn/context/zip (230.00 KB, application/octet-stream)
2008-12-29 23:43 EST, David Green CLA
no flags Details
mylyn/context/zip (145.50 KB, application/octet-stream)
2009-01-28 10:30 EST, David Green CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Kempka CLA 2008-12-17 08:04:02 EST
Build ID: CVS Head


I extended the class org.eclipse.mylyn.wikitext.core.parser.builder.HtmlDocumentBuilder to create my own HTML Variation. Specifically I want to parameterize style sheets and include some javascript links. I found that the only ways to influence the <head>...<head/> contents at all are the calls to setTitle(...) and addCssStyleSheet(...). For me this is insufficient because I want to add some more attributes to the style sheet link. I also want to include a link to some Javascript file.

The only way to make this work is to override beginDocument() and not call super.beginDocument(). So I have to write everything until <body> myself.

Please provide a hook in HtmlDocumentBuilder.beginDocument() to allow subclasses adding own stuff to the HTML head.
Comment 1 David Green CLA 2008-12-21 00:05:23 EST
Matthias,

Thanks for the bug posting.  Great idea.  Feel free to post a patch to this bug, and I'll take a look in January.
Comment 2 David Green CLA 2008-12-21 00:08:49 EST
Created attachment 121017 [details]
mylyn/context/zip
Comment 3 Matthias Kempka CLA 2008-12-22 05:45:53 EST
Created attachment 121053 [details]
patch for HtmlDocumentBuilder

I added a patch that includes all the changes that I thought interesting for subclasses:
 - allow to add custom attributes for style sheets
 - provide a hook for subclasses appending custom elements in the HTML head section
 - defined body start and body end in own methods that may be overridden in subclasses (sometimes I want to do things like <div class="presentation"> and </div> inside the body but around everything that actually is in the body).
Comment 4 David Green CLA 2008-12-29 23:43:24 EST
Created attachment 121324 [details]
patch with changes

Matthias,

Thanks for the patch.  I've attached a new patch based on yours with some notable changes:

* eliminated @addToHead()@ in favor of @emitHeadContents()@
* altered @addCssStylesheet()@ to return a @Stylesheet@.  This allows for attributes to be added without overloading the addCssStylesheet method
* changes to corresponding Ant tasks to enable attributes there
* a JUnit test

Please take a look and let me know what you think.
Comment 5 David Green CLA 2008-12-29 23:43:38 EST
Created attachment 121325 [details]
mylyn/context/zip
Comment 6 Matthias Kempka CLA 2009-01-28 08:35:28 EST
I think the changes you made are good. They will do what I need. I couldn't apply it against a copy of the current cvs head, though, it seems it's already too far away.
Comment 7 David Green CLA 2009-01-28 10:30:02 EST
Thanks for the feedback.  Integrated into CVS with some minor changes.  Please reopen this bug if there are any issues.
Comment 8 David Green CLA 2009-01-28 10:30:06 EST
Created attachment 124030 [details]
mylyn/context/zip