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;
35
36 import info.magnolia.templating.editor.client.dom.CMSBoundary;
37
38 import com.google.gwt.dom.client.Document;
39 import com.google.gwt.dom.client.Element;
40 import com.google.gwt.dom.client.Style;
41 import com.google.gwt.user.client.ui.FlowPanel;
42
43
44
45
46
47 public class AbstractOverlayWidget extends FlowPanel {
48
49 protected String label;
50 protected int level = 1;
51 protected CMSBoundary boundary;
52
53 public AbstractOverlayWidget(CMSBoundary boundary) {
54
55 this.boundary = boundary;
56 this.label = boundary.getComment().getAttribute("label");
57
58 for (CMSBoundary parent = boundary.getParentBoundary(); parent != null; parent = parent.getParentBoundary()) {
59 this.level++;
60 }
61
62
63
64
65
66
67 this.setStyleName("mgnlOverlay");
68
69 this.getElement().getStyle().setPosition(Style.Position.ABSOLUTE);
70 this.getElement().getStyle().setZIndex(level);
71
72 }
73
74 public void attach() {
75 Element body = Document.get().getBody();
76 body.appendChild(this.getElement());
77 onAttach();
78 }
79
80 public void setTop(double top) {
81 this.getElement().getStyle().setTop(top, Style.Unit.PX);
82 }
83
84 public void setLeft(double left) {
85 this.getElement().getStyle().setLeft(left, Style.Unit.PX);
86 }
87
88 public void setWidth(double width) {
89 this.getElement().getStyle().setWidth(width, Style.Unit.PX);
90 }
91
92 public void setHeight(double height) {
93 this.getElement().getStyle().setHeight(height, Style.Unit.PX);
94 }
95
96 public CMSBoundary getBoundary() {
97 return boundary;
98 }
99
100
101 }