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.admincentral.shellapp.pulse.item.list.footer;
35
36 import info.magnolia.ui.api.action.ActionDefinition;
37
38 import java.util.List;
39
40 import javax.inject.Inject;
41
42
43
44
45
46 public class PulseListFooterPresenter implements PulseListFooterView.Listener {
47
48 private final PulseListFooterView view;
49 private Listener listener;
50
51 @Inject
52 public PulseListFooterPresenter(final PulseListFooterView view) {
53 this.view = view;
54 this.view.setListener(this);
55 }
56
57 public void setListener(Listener listener) {
58 this.listener = listener;
59 }
60
61 public PulseListFooterView start(List<ActionDefinition> bulkActions, long totalAmount) {
62 for (ActionDefinition actionDefinition : bulkActions) {
63 String label = actionDefinition.getLabel();
64 String icon = actionDefinition.getIcon();
65
66 view.addAction(actionDefinition.getName(), label, icon);
67 }
68 view.updateStatus(totalAmount, 0);
69 return view;
70 }
71
72 @Override
73 public void onBulkActionTriggered(String actionId) {
74 listener.onBulkActionTriggered(actionId);
75 }
76
77 public void setActionEnabled(String actionId, boolean isEnabled) {
78 if (view != null) {
79 view.setActionEnabled(actionId, isEnabled);
80 }
81 }
82
83 public void updateStatus(long totalAmount, int totalSelected) {
84 if (view != null) {
85 view.updateStatus(totalAmount, totalSelected);
86 }
87 }
88
89
90
91
92 public interface Listener {
93
94 void onBulkActionTriggered(String actionId);
95 }
96 }