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.ui.dialog;
35
36
37 import static com.vaadin.server.Sizeable.Unit.PERCENTAGE;
38
39 import com.vaadin.ui.Alignment;
40 import com.vaadin.ui.Component;
41 import com.vaadin.ui.CssLayout;
42 import com.vaadin.ui.HorizontalLayout;
43
44
45
46
47 public class EditorActionLayout extends HorizontalLayout {
48
49 private final CssLayout toolbarSlot = new CssLayout();
50 private final CssLayout primaryActionSlot = new CssLayout();
51 private final CssLayout secondaryActionSlot = new CssLayout();
52
53 public EditorActionLayout() {
54 setWidth(100, PERCENTAGE);
55 addStyleName("actions");
56 removeStyleName("footer");
57 setSpacing(false);
58
59 addComponents(toolbarSlot, secondaryActionSlot, primaryActionSlot);
60 setExpandRatio(toolbarSlot, 0);
61 setExpandRatio(secondaryActionSlot, 1f);
62 setExpandRatio(primaryActionSlot, 0f);
63 setComponentAlignment(toolbarSlot, Alignment.MIDDLE_LEFT);
64 setComponentAlignment(primaryActionSlot, Alignment.MIDDLE_RIGHT);
65 setComponentAlignment(secondaryActionSlot, Alignment.MIDDLE_LEFT);
66 }
67
68 public void addPrimaryAction(Component actionControl) {
69 actionControl.addStyleName("action-control primary-actions");
70 this.primaryActionSlot.addComponentAsFirst(actionControl);
71 }
72
73 public void addSecondaryAction(Component actionControl) {
74 actionControl.addStyleName("action-control secondary-actions");
75 this.secondaryActionSlot.addComponent(actionControl);
76 }
77
78 public void setToolbarComponent(Component toolbarComponent) {
79 toolbarComponent.addStyleName("action-control toolbar-actions");
80 toolbarSlot.removeAllComponents();
81 toolbarSlot.addComponentAsFirst(toolbarComponent);
82 }
83
84 public void removeAllActions() {
85 this.primaryActionSlot.removeAllComponents();
86 this.secondaryActionSlot.removeAllComponents();
87 }
88 }