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 package info.magnolia.templating.editor.client.dom.processor;
35
36 import com.google.gwt.dom.client.Element;
37 import com.google.gwt.dom.client.Node;
38
39 import info.magnolia.rendering.template.AreaDefinition;
40 import info.magnolia.templating.editor.client.PageEditor;
41 import info.magnolia.templating.editor.client.dom.MgnlElement;
42
43
44
45
46 public class ElementProcessor {
47
48 static final String NAVIGATION_ROLE = "navigation";
49
50 public static boolean process(Node node, MgnlElement mgnlElement) {
51
52 Element element = node.cast();
53
54
55 if (element.getAttribute("role").equals(NAVIGATION_ROLE)) {
56 return false;
57 }
58
59 if (element.hasTagName("A")) {
60 disableLink(element);
61 removeHover(element);
62 }
63 PageEditor.model.addElement(mgnlElement, element);
64
65 if (element.hasAttribute(AreaDefinition.CMS_ADD)) {
66 mgnlElement.setComponentElement(element);
67 }
68
69 else if (element.hasAttribute(AreaDefinition.CMS_PLACEHOLDER)) {
70 mgnlElement.setAreaElement(element);
71 }
72
73 else if (element.hasAttribute(AreaDefinition.CMS_EDIT)) {
74 mgnlElement.setEditElement(element);
75 }
76
77 else {
78 if (mgnlElement.getFirstElement() == null) {
79 mgnlElement.setFirstElement(element);
80 }
81
82 if (mgnlElement.getLastElement() == null || !mgnlElement.getLastElement().isOrHasChild(element)) {
83 mgnlElement.setLastElement(element);
84 }
85 }
86 return true;
87
88 }
89
90 public static void removeHover (Element element) {
91 element.addClassName("disabled");
92 }
93
94 public native static void disableLink(Element element)
95
96
97
98
99
100 ;
101 }