1 package fr.ifremer.dali.ui.swing.content.observation.survey.measurement.ungrouped;
2
3 import fr.ifremer.dali.ui.swing.DaliHelpBroker;
4 import fr.ifremer.dali.ui.swing.DaliUIContext;
5 import fr.ifremer.dali.ui.swing.util.DaliUI;
6 import fr.ifremer.quadrige3.ui.swing.ApplicationUI;
7 import fr.ifremer.quadrige3.ui.swing.ApplicationUIUtil;
8 import fr.ifremer.quadrige3.ui.swing.plaf.WaitBlockingLayerUI;
9 import fr.ifremer.quadrige3.ui.swing.table.SwingTable;
10 import java.awt.BorderLayout;
11 import java.awt.Component;
12 import java.awt.Container;
13 import java.awt.LayoutManager;
14 import java.util.ArrayList;
15 import java.util.HashMap;
16 import java.util.List;
17 import java.util.Map;
18 import java.util.TreeMap;
19 import javax.swing.BorderFactory;
20 import javax.swing.Box;
21 import javax.swing.BoxLayout;
22 import javax.swing.JPanel;
23 import javax.swing.JScrollPane;
24 import jaxx.runtime.JAXXBinding;
25 import jaxx.runtime.JAXXContext;
26 import jaxx.runtime.JAXXObject;
27 import jaxx.runtime.JAXXObjectDescriptor;
28 import jaxx.runtime.JAXXUtil;
29 import jaxx.runtime.SwingUtil;
30 import jaxx.runtime.binding.DefaultJAXXBinding;
31 import jaxx.runtime.context.DefaultJAXXContext;
32 import jaxx.runtime.swing.help.JAXXHelpUI;
33 import org.apache.commons.logging.Log;
34 import org.apache.commons.logging.LogFactory;
35 import static org.nuiton.i18n.I18n.t;
36
37 public class SurveyMeasurementsUngroupedTableUI extends JPanel implements JAXXHelpUI<DaliHelpBroker>, DaliUI<SurveyMeasurementsUngroupedTableUIModel, SurveyMeasurementsUngroupedTableUIHandler>, JAXXObject {
38
39
40
41
42
43 public static final String BINDING_TABLE_BLOCK_LAYER_BLOCK = "tableBlockLayer.block";
44
45
46
47
48
49 private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAL1UTU9bRxS9drETSBOSoBBQEpXQSiFROl5U6oaqIXwpRuZDsVFpvSBjv8GeZPxmmJkHz0FE/Qn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og(SurveyMeasurementsUngroupedTableUI.class);
51 private static final long serialVersionUID = 1L;
52
53
54
55
56
57 protected List<Object> $activeBindings = new ArrayList<Object>();
58 protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
59 protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
60 protected Map<String, Object> $objectMap = new HashMap<String, Object>();
61 protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
62 private boolean allComponentsCreated;
63 protected final JAXXContext delegateContext = new DefaultJAXXContext();
64
65
66
67
68
69 protected DaliHelpBroker broker;
70 protected final SurveyMeasurementsUngroupedTableUIHandler handler = createHandler();
71 protected SurveyMeasurementsUngroupedTableUIModel model;
72 protected SurveyMeasurementsUngroupedTableUI surveyUngroupedMeasurementPanel = this;
73 protected SwingTable surveyUngroupedMeasurementTable;
74 protected WaitBlockingLayerUI tableBlockLayer;
75 protected JScrollPane tableScrollPane;
76
77
78
79
80
81 public SurveyMeasurementsUngroupedTableUI(ApplicationUI parentUI) {
82 ApplicationUIUtil.setParentUI(this, parentUI);
83 $initialize();
84 }
85
86 public SurveyMeasurementsUngroupedTableUI() {
87 $initialize();
88 }
89
90 public SurveyMeasurementsUngroupedTableUI(JAXXContext parentContext) {
91 JAXXUtil.initContext(this, parentContext);
92 $initialize();
93 }
94
95 public SurveyMeasurementsUngroupedTableUI(boolean param0) {
96 super(param0);
97 $initialize();
98 }
99
100 public SurveyMeasurementsUngroupedTableUI(JAXXContext parentContext, boolean param1) {
101 super(param1);
102 JAXXUtil.initContext(this, parentContext);
103 $initialize();
104 }
105
106 public SurveyMeasurementsUngroupedTableUI(LayoutManager param0) {
107 super(param0);
108 $initialize();
109 }
110
111 public SurveyMeasurementsUngroupedTableUI(JAXXContext parentContext, LayoutManager param1) {
112 super(param1);
113 JAXXUtil.initContext(this, parentContext);
114 $initialize();
115 }
116
117 public SurveyMeasurementsUngroupedTableUI(LayoutManager param0, boolean param1) {
118 super(param0 ,param1);
119 $initialize();
120 }
121
122 public SurveyMeasurementsUngroupedTableUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
123 super(param1 ,param2);
124 JAXXUtil.initContext(this, parentContext);
125 $initialize();
126 }
127
128
129
130
131
132 public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
133 return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
134 }
135
136
137
138
139
140 @Override
141 public void applyDataBinding(String $binding) {
142 if (allComponentsCreated && $bindings.containsKey($binding)) {
143 getDataBinding($binding).applyDataBinding();
144 }
145 processDataBinding($binding);
146 }
147
148 @Override
149 public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
150 super.firePropertyChange(propertyName, oldValue, newValue);
151 }
152
153 @Override
154 public Map<String, Object> get$objectMap() {
155 return $objectMap;
156 }
157
158 @Override
159 public JAXXBinding getDataBinding(String bindingId) {
160 return $bindings.get(bindingId);
161 }
162
163 @Override
164 public JAXXBinding[] getDataBindings() {
165 return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
166 }
167
168 @Override
169 public Object getObjectById(String id) {
170 return $objectMap.get(id);
171 }
172
173 @Override
174 public void processDataBinding(String $binding, boolean $force) {
175 if (!$force && $activeBindings.contains($binding)) {
176 return;
177 }
178 $activeBindings.add($binding);
179 try {
180 if (allComponentsCreated && $bindings.containsKey($binding)) {
181 getDataBinding($binding).processDataBinding();
182 }
183 } finally {
184 $activeBindings.remove($binding);
185 }
186 }
187
188 @Override
189 public void processDataBinding(String $binding) {
190 processDataBinding($binding, false);
191 }
192
193 @Override
194 public void registerDataBinding(JAXXBinding binding) {
195 $bindings.put(binding.getId(), binding);
196 }
197
198 @Override
199 public void removeDataBinding(String $binding) {
200 if (allComponentsCreated && $bindings.containsKey($binding)) {
201 getDataBinding($binding).removeDataBinding();
202 }
203 }
204
205
206
207
208
209 @Override
210 public <T> T getContextValue(Class<T> clazz) {
211 return delegateContext.getContextValue(clazz, null);
212 }
213
214 @Override
215 public <T> T getContextValue(Class<T> clazz, String name) {
216 return delegateContext.getContextValue(clazz, name);
217 }
218
219 @Override
220 public JAXXContext getDelegateContext() {
221 return delegateContext;
222 }
223
224 @Override
225 public <O extends Container> O getParentContainer(Class<O> clazz) {
226 return SwingUtil.getParentContainer(this, clazz);
227 }
228
229 @Override
230 public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
231 return SwingUtil.getParentContainer(source, clazz);
232 }
233
234 @Override
235 public <T> void removeContextValue(Class<T> clazz) {
236 delegateContext.removeContextValue(clazz, null);
237 }
238
239 @Override
240 public <T> void removeContextValue(Class<T> clazz, String name) {
241 delegateContext.removeContextValue(clazz, name);
242 }
243
244 @Override
245 public <T> void setContextValue(T o) {
246 delegateContext.setContextValue(o, null);
247 }
248
249 @Override
250 public <T> void setContextValue(T o, String name) {
251 delegateContext.setContextValue(o, name);
252 }
253
254
255
256
257
258 public DaliHelpBroker getBroker() {
259 return broker;
260 }
261
262 public SurveyMeasurementsUngroupedTableUIHandler getHandler() {
263 return handler;
264 }
265
266 public SurveyMeasurementsUngroupedTableUIModel getModel() {
267 return model;
268 }
269
270 public SwingTable getSurveyUngroupedMeasurementTable() {
271 return surveyUngroupedMeasurementTable;
272 }
273
274 public WaitBlockingLayerUI getTableBlockLayer() {
275 return tableBlockLayer;
276 }
277
278 public JScrollPane getTableScrollPane() {
279 return tableScrollPane;
280 }
281
282
283
284
285
286 @Override
287 public void registerHelpId(DaliHelpBroker broker, Component component, String helpId) {
288 broker.installUI(component, helpId);
289 }
290
291 @Override
292 public void showHelp(String helpId) {
293 getBroker().showHelp(this, helpId);
294 }
295
296
297
298
299
300 protected void addChildrenToSurveyUngroupedMeasurementPanel() {
301 if (!allComponentsCreated) {
302 return;
303 }
304 add(SwingUtil.boxComponentWithJxLayer(tableScrollPane));
305 }
306
307 protected void addChildrenToTableScrollPane() {
308 if (!allComponentsCreated) {
309 return;
310 }
311 tableScrollPane.getViewport().add(surveyUngroupedMeasurementTable);
312 }
313
314 protected void createBroker() {
315 $objectMap.put("broker", broker = new DaliHelpBroker("dali.home.help"));
316 }
317
318 protected SurveyMeasurementsUngroupedTableUIHandler createHandler() {
319 return new SurveyMeasurementsUngroupedTableUIHandler();
320 }
321
322 protected void createModel() {
323 $objectMap.put("model", model = getContextValue(SurveyMeasurementsUngroupedTableUIModel.class));
324 }
325
326 protected void createSurveyUngroupedMeasurementTable() {
327 $objectMap.put("surveyUngroupedMeasurementTable", surveyUngroupedMeasurementTable = new SwingTable());
328
329 surveyUngroupedMeasurementTable.setName("surveyUngroupedMeasurementTable");
330 }
331
332 protected void createTableBlockLayer() {
333 $objectMap.put("tableBlockLayer", tableBlockLayer = new WaitBlockingLayerUI());
334 }
335
336 protected void createTableScrollPane() {
337 $objectMap.put("tableScrollPane", tableScrollPane = new JScrollPane());
338
339 tableScrollPane.setName("tableScrollPane");
340 }
341
342
343
344
345
346 private void $completeSetup() {
347 allComponentsCreated = true;
348 if (log.isDebugEnabled()) {
349 log.debug(this);
350 }
351 addChildrenToSurveyUngroupedMeasurementPanel();
352 addChildrenToTableScrollPane();
353
354
355 JAXXUtil.applyDataBinding(this, $bindings.keySet());
356
357
358 tableScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
359 setBorder(BorderFactory.createTitledBorder(t("dali.survey.measurement.title")));
360 tableBlockLayer.setBlockingColor(handler.getConfig().getColorBlockingLayer());
361 }
362
363 private void $initialize() {
364 if (allComponentsCreated) {
365 return;
366 }
367 if (log.isDebugEnabled()) {
368 log.debug(this);
369 }
370 handler.beforeInit(this);
371 $objectMap.put("surveyUngroupedMeasurementPanel", surveyUngroupedMeasurementPanel);
372 createModel();
373 createBroker();
374 createTableBlockLayer();
375 createTableScrollPane();
376 createSurveyUngroupedMeasurementTable();
377
378 setName("surveyUngroupedMeasurementPanel");
379 setLayout(new BorderLayout());
380 surveyUngroupedMeasurementPanel.putClientProperty("panelType", DaliUI.EDITION_PANEL_TYPE);
381
382
383 $registerDefaultBindings();
384 $completeSetup();
385 handler.afterInit(this);
386 }
387
388 private void $registerDefaultBindings() {
389
390 registerDataBinding(new DefaultJAXXBinding(this, BINDING_TABLE_BLOCK_LAYER_BLOCK, true) {
391
392 @Override
393 public void applyDataBinding() {
394 if (model != null) {
395 model.addPropertyChangeListener("loading", this);
396 }
397 }
398
399 @Override
400 public void processDataBinding() {
401 if (model != null) {
402 tableBlockLayer.setBlock(model.isLoading());
403 }
404 }
405
406 @Override
407 public void removeDataBinding() {
408 if (model != null) {
409 model.removePropertyChangeListener("loading", this);
410 }
411 }
412 });
413 }
414
415 }