summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org/madore/damlengine/TodoElement.java6
-rw-r--r--org/madore/damlengine/TodoEntryTitleElement.java46
2 files changed, 50 insertions, 2 deletions
diff --git a/org/madore/damlengine/TodoElement.java b/org/madore/damlengine/TodoElement.java
index c779e89..462b503 100644
--- a/org/madore/damlengine/TodoElement.java
+++ b/org/madore/damlengine/TodoElement.java
@@ -14,14 +14,16 @@ public abstract class TodoElement extends TodoItem {
public static class TitleDisambiguationFactory extends Factory {
Factory mainTitleFactory = new TodoTitleElement.Factory();
- Factory entryTitleFactory = new TodoDefaultElement.Factory();
+ Factory entryTitleFactory = new TodoEntryTitleElement.Factory();
public TodoElement newItem(Element node,
Context ctx,
TodoItem caller) {
if ( caller instanceof TodoDamlElement )
return mainTitleFactory.newItem(node, ctx, caller);
- else
+ else if ( caller instanceof TodoEntryElement )
return entryTitleFactory.newItem(node, ctx, caller);
+ else
+ throw new IllegalArgumentException("title element can only be child of daml or entry elements");
}
}
diff --git a/org/madore/damlengine/TodoEntryTitleElement.java b/org/madore/damlengine/TodoEntryTitleElement.java
new file mode 100644
index 0000000..26f8670
--- /dev/null
+++ b/org/madore/damlengine/TodoEntryTitleElement.java
@@ -0,0 +1,46 @@
+package org.madore.damlengine;
+
+import java.util.ArrayList;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+import org.w3c.dom.*;
+
+public final class TodoEntryTitleElement extends TodoDefaultElement {
+
+ public static class Factory extends TodoElement.Factory {
+ @Override
+ public TodoEntryTitleElement newItem(Element node,
+ Context ctx,
+ TodoItem caller) {
+ return new TodoEntryTitleElement(node, ctx, caller);
+ }
+ }
+
+ public TodoEntryTitleElement(Element node,
+ Context ctx,
+ TodoItem caller) {
+ super(node, ctx, caller);
+ }
+
+ @Override
+ public void handleNodeOnly() {
+ Element h2 = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "h2");
+ String explicitLang = LangHelper.getLangNorec(node);
+ if ( explicitLang != null )
+ LangHelper.setLangNorec(h2, explicitLang);
+ node.getParentNode().replaceChild(h2, node);
+ h2.setAttributeNS(null, "class", "weblog-entry-title");
+ ArrayList<Node> childList = getChildList(this.node);
+ ArrayList<TodoElement> toProcess = new ArrayList<TodoElement>(childList.size());
+ for ( Node child : childList ) {
+ h2.appendChild(child);
+ if ( child.getNodeType() == Node.ELEMENT_NODE ) {
+ TodoElement it
+ = TodoElement.getTodoElement((Element)child, this.ctx, this);
+ toProcess.add(it);
+ }
+ }
+ this.ownerDeque.registerAtStart(toProcess);
+ }
+
+}