1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
package org.madore.damlengine;
import java.util.ArrayList;
import org.w3c.dom.*;
public final class TodoTitleOrSubtitle extends TodoElement {
public enum Type {
TITLE("h1","title"),
SUBTITLE("p","subtitle");
final String eltName;
final String eltClass;
Type(String eltName, String eltClass) {
this.eltName = eltName;
this.eltClass = eltClass;
}
}
final Type t;
public TodoTitleOrSubtitle(Type t,
Element node,
Context ctx,
TodoItem caller) {
super(node, ctx, caller);
this.t = t;
}
@Override
public void handle() {
Element elt = ctx.doc.createElementNS(DamlEngine.XHTML_NS, t.eltName);
String expLang = (t==Type.TITLE)?ctx.titleLang:ctx.subtitleLang;
if ( expLang != null )
LangHelper.setLangNorec(node, expLang);
elt.setAttributeNS(null, "class", t.eltClass);
node.getParentNode().replaceChild(elt, node);
ArrayList<Node> childList
= TodoDefaultElement.getChildList((t==Type.TITLE)?ctx.title:ctx.subtitle);
for ( Node child : childList )
elt.appendChild(child.cloneNode(true));
TodoElement it
= TodoElement.getTodoElement(elt, this.ctx, this);
this.ownerDeque.registerAtStart(it);
}
}
|