1 package fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import com.google.common.collect.Multimap;
26 import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
27 import fr.ifremer.tutti.type.WeightUnit;
28 import fr.ifremer.tutti.ui.swing.content.operation.catches.AbstractTuttiBatchUIModel;
29 import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
30 import fr.ifremer.tutti.ui.swing.util.computable.ComputableData;
31 import org.apache.commons.collections4.CollectionUtils;
32 import org.nuiton.jaxx.application.swing.tab.TabContentModel;
33
34 import static org.nuiton.i18n.I18n.n;
35
36
37
38
39
40 public class MarineLitterBatchUIModel extends AbstractTuttiBatchUIModel<MarineLitterBatchRowModel, MarineLitterBatchUIModel>
41 implements TabContentModel {
42
43 private static final long serialVersionUID = 1L;
44
45 public static final String PROPERTY_REMOVE_BATCH_ENABLED = "removeBatchEnabled";
46
47
48
49
50
51
52 protected boolean removeBatchEnabled;
53
54 private final WeightUnit weightUnit;
55
56 public MarineLitterBatchUIModel(EditCatchesUIModel catchesUIModel, WeightUnit weightUnit) {
57 super(catchesUIModel, EditCatchesUIModel.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT);
58 this.weightUnit = weightUnit;
59 }
60
61 public WeightUnit getWeightUnit() {
62 return weightUnit;
63 }
64
65 public ComputableData<Float> getMarineLitterTotalComputedOrNotWeight() {
66 return catchesUIModel.getMarineLitterTotalComputedOrNotWeight();
67 }
68
69 public Float getMarineLitterTotalWeight() {
70 return catchesUIModel.getMarineLitterTotalWeight();
71 }
72
73 public void setMarineLitterTotalWeight(Float marineLitterTotalWeight) {
74 catchesUIModel.setMarineLitterTotalWeight(marineLitterTotalWeight);
75 }
76
77 public Float getMarineLitterTotalComputedWeight() {
78 return catchesUIModel.getMarineLitterTotalComputedWeight();
79 }
80
81 public void setMarineLitterTotalComputedWeight(Float marineLitterTotalWeight) {
82 catchesUIModel.setMarineLitterTotalComputedWeight(marineLitterTotalWeight);
83 }
84
85 public boolean isRemoveBatchEnabled() {
86 return removeBatchEnabled;
87 }
88
89 public void setRemoveBatchEnabled(boolean removeBatchEnabled) {
90 this.removeBatchEnabled = removeBatchEnabled;
91 firePropertyChange(PROPERTY_REMOVE_BATCH_ENABLED, null, removeBatchEnabled);
92 }
93
94 public Multimap<CaracteristicQualitativeValue, CaracteristicQualitativeValue> getMarineLitterCategoriesUsed() {
95 return catchesUIModel.getMarineLitterCategoriesUsed();
96 }
97
98
99
100
101
102 @Override
103 public boolean isEmpty() {
104 boolean result = getMarineLitterTotalWeight() == null;
105 if (result && CollectionUtils.isNotEmpty(getRows())) {
106
107
108 for (MarineLitterBatchRowModel row : rows) {
109 if (row.isValid()) {
110
111
112 result = false;
113 break;
114 }
115 }
116 }
117 return result;
118 }
119
120 @Override
121 public String getTitle() {
122 return n("tutti.label.tab.marineLitter");
123 }
124
125 @Override
126 public String getIcon() {
127 return null;
128 }
129
130 @Override
131 public boolean isCloseable() {
132 return false;
133 }
134 }