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
26
27 import fr.ifremer.tutti.ui.swing.TuttiHelpBroker;
28 import fr.ifremer.tutti.ui.swing.TuttiUIContext;
29 import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
30 import fr.ifremer.tutti.ui.swing.util.TuttiUI;
31 import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
32 import fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachment;
33 import fr.ifremer.tutti.ui.swing.util.computable.ComputableDataEditor;
34 import java.awt.BorderLayout;
35 import java.awt.Color;
36 import java.awt.Component;
37 import java.awt.Container;
38 import java.awt.Dimension;
39 import java.awt.GridBagConstraints;
40 import java.awt.GridLayout;
41 import java.awt.Insets;
42 import java.awt.LayoutManager;
43 import java.awt.event.KeyEvent;
44 import java.awt.event.KeyListener;
45 import java.awt.event.MouseEvent;
46 import java.awt.event.MouseListener;
47 import java.util.ArrayList;
48 import java.util.HashMap;
49 import java.util.List;
50 import java.util.Map;
51 import java.util.TreeMap;
52 import javax.swing.JButton;
53 import javax.swing.JLabel;
54 import javax.swing.JMenu;
55 import javax.swing.JMenuBar;
56 import javax.swing.JMenuItem;
57 import javax.swing.JPanel;
58 import javax.swing.JPopupMenu;
59 import javax.swing.JScrollPane;
60 import javax.swing.JToolBar;
61 import javax.swing.ListSelectionModel;
62 import jaxx.runtime.JAXXBinding;
63 import jaxx.runtime.JAXXContext;
64 import jaxx.runtime.JAXXObject;
65 import jaxx.runtime.JAXXObjectDescriptor;
66 import jaxx.runtime.JAXXUtil;
67 import jaxx.runtime.JAXXValidator;
68 import jaxx.runtime.SwingUtil;
69 import jaxx.runtime.binding.DefaultJAXXBinding;
70 import jaxx.runtime.context.DefaultJAXXContext;
71 import jaxx.runtime.swing.Table;
72 import jaxx.runtime.swing.help.JAXXHelpUI;
73 import jaxx.runtime.validator.swing.SwingValidator;
74 import jaxx.runtime.validator.swing.SwingValidatorUtil;
75 import jaxx.runtime.validator.swing.meta.Validator;
76 import jaxx.runtime.validator.swing.meta.ValidatorField;
77 import jaxx.runtime.validator.swing.ui.ImageValidationUI;
78 import org.apache.commons.logging.Log;
79 import org.apache.commons.logging.LogFactory;
80 import org.jdesktop.swingx.JXTable;
81 import static org.nuiton.i18n.I18n.t;
82
83 public class MarineLitterBatchUI extends JPanel implements JAXXHelpUI<TuttiHelpBroker>, TuttiUI<MarineLitterBatchUIModel, MarineLitterBatchUIHandler>, JAXXObject, JAXXValidator {
84
85
86
87
88
89 public static final String BINDING_MARINE_LITTER_TOTAL_WEIGHT_FIELD_BEAN = "marineLitterTotalWeightField.bean";
90 public static final String BINDING_MARINE_LITTER_TOTAL_WEIGHT_FIELD_NUMBER_VALUE = "marineLitterTotalWeightField.numberValue";
91 public static final String BINDING_REMOVE_MARINE_LITTER_BATCH_MENU_ENABLED = "removeMarineLitterBatchMenu.enabled";
92
93
94
95
96
97 private static final String $jaxxObjectDescriptor = "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";
98 private static final Log log = LogFactory.getLog(MarineLitterBatchUI.class);
99 private static final long serialVersionUID = 1L;
100
101
102
103
104
105 protected List<Object> $activeBindings = new ArrayList<Object>();
106 protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
107 protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
108 protected Map<String, Object> $objectMap = new HashMap<String, Object>();
109 protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
110 private boolean allComponentsCreated;
111 protected final JAXXContext delegateContext = new DefaultJAXXContext();
112
113
114
115
116
117 protected TuttiHelpBroker broker;
118 protected JButton createMarineLitterBatchButton;
119 protected MarineLitterBatchUI editMarineLitterBatchTopPanel = this;
120 protected JMenuItem exportMultiPostButton;
121 protected Table form;
122 protected final MarineLitterBatchUIHandler handler = createHandler();
123 protected JMenuItem importMultiPostButton;
124 protected ButtonAttachment marineLitterBatchAttachmentsButton;
125 protected JToolBar marineLitterBatchTabToolBar;
126 @ValidatorField( validatorId = "validator", propertyName = "marineLitterTotalWeight", editorName = "marineLitterTotalWeightField")
127 protected ComputableDataEditor<Float> marineLitterTotalWeightField;
128 protected JLabel marineLitterTotalWeightLabel;
129 protected JMenuBar menu;
130 protected JMenu menuAction;
131 protected MarineLitterBatchUIModel model;
132 protected JMenuItem removeMarineLitterBatchMenu;
133 protected JXTable table;
134 protected JPopupMenu tablePopup;
135 protected JScrollPane tableScrollPane;
136 protected JPanel tableToolbar;
137 @Validator( validatorId = "validator")
138 protected SwingValidator<MarineLitterBatchUIModel> validator;
139 protected List<String> validatorIds = new ArrayList<String>();
140
141
142
143
144
145 private JPanel $JPanel0;
146
147
148
149
150
151 public MarineLitterBatchUI(TuttiUI parentUI) {
152 TuttiUIUtil.setParentUI(this, parentUI);
153 $initialize();
154 }
155
156 public MarineLitterBatchUI(LayoutManager param0, boolean param1) {
157 super(param0 ,param1);
158 $initialize();
159 }
160
161 public MarineLitterBatchUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
162 super(param1 ,param2);
163 JAXXUtil.initContext(this, parentContext);
164 $initialize();
165 }
166
167 public MarineLitterBatchUI(LayoutManager param0) {
168 super(param0);
169 $initialize();
170 }
171
172 public MarineLitterBatchUI(JAXXContext parentContext, LayoutManager param1) {
173 super(param1);
174 JAXXUtil.initContext(this, parentContext);
175 $initialize();
176 }
177
178 public MarineLitterBatchUI() {
179 $initialize();
180 }
181
182 public MarineLitterBatchUI(JAXXContext parentContext) {
183 JAXXUtil.initContext(this, parentContext);
184 $initialize();
185 }
186
187 public MarineLitterBatchUI(boolean param0) {
188 super(param0);
189 $initialize();
190 }
191
192 public MarineLitterBatchUI(JAXXContext parentContext, boolean param1) {
193 super(param1);
194 JAXXUtil.initContext(this, parentContext);
195 $initialize();
196 }
197
198
199
200
201
202 public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
203 return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
204 }
205
206
207
208
209
210 @Override
211 public void applyDataBinding(String $binding) {
212 if (allComponentsCreated && $bindings.containsKey($binding)) {
213 getDataBinding($binding).applyDataBinding();
214 }
215 processDataBinding($binding);
216 }
217
218 @Override
219 public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
220 super.firePropertyChange(propertyName, oldValue, newValue);
221 }
222
223 @Override
224 public Map<String, Object> get$objectMap() {
225 return $objectMap;
226 }
227
228 @Override
229 public JAXXBinding getDataBinding(String bindingId) {
230 return $bindings.get(bindingId);
231 }
232
233 @Override
234 public JAXXBinding[] getDataBindings() {
235 return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
236 }
237
238 @Override
239 public Object getObjectById(String id) {
240 return $objectMap.get(id);
241 }
242
243 @Override
244 public void processDataBinding(String $binding, boolean $force) {
245 if (!$force && $activeBindings.contains($binding)) {
246 return;
247 }
248 $activeBindings.add($binding);
249 try {
250 if (allComponentsCreated && $bindings.containsKey($binding)) {
251 getDataBinding($binding).processDataBinding();
252 }
253 } finally {
254 $activeBindings.remove($binding);
255 }
256 }
257
258 @Override
259 public void processDataBinding(String $binding) {
260 processDataBinding($binding, false);
261 }
262
263 @Override
264 public void registerDataBinding(JAXXBinding binding) {
265 $bindings.put(binding.getId(), binding);
266 }
267
268 @Override
269 public void removeDataBinding(String $binding) {
270 if (allComponentsCreated && $bindings.containsKey($binding)) {
271 getDataBinding($binding).removeDataBinding();
272 }
273 }
274
275
276
277
278
279 @Override
280 public <T> T getContextValue(Class<T> clazz) {
281 return delegateContext.getContextValue(clazz, null);
282 }
283
284 @Override
285 public <T> T getContextValue(Class<T> clazz, String name) {
286 return delegateContext.getContextValue(clazz, name);
287 }
288
289 @Override
290 public JAXXContext getDelegateContext() {
291 return delegateContext;
292 }
293
294 @Override
295 public <O extends Container> O getParentContainer(Class<O> clazz) {
296 return SwingUtil.getParentContainer(this, clazz);
297 }
298
299 @Override
300 public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
301 return SwingUtil.getParentContainer(source, clazz);
302 }
303
304 @Override
305 public <T> void removeContextValue(Class<T> clazz) {
306 delegateContext.removeContextValue(clazz, null);
307 }
308
309 @Override
310 public <T> void removeContextValue(Class<T> clazz, String name) {
311 delegateContext.removeContextValue(clazz, name);
312 }
313
314 @Override
315 public <T> void setContextValue(T o) {
316 delegateContext.setContextValue(o, null);
317 }
318
319 @Override
320 public <T> void setContextValue(T o, String name) {
321 delegateContext.setContextValue(o, name);
322 }
323
324
325
326
327
328 @Override
329 public SwingValidator<?> getValidator(String validatorId) {
330 return (SwingValidator<?>) (validatorIds.contains(validatorId) ? getObjectById(validatorId) : null);
331 }
332
333 @Override
334 public List<String> getValidatorIds() {
335 return validatorIds;
336 }
337
338 @Override
339 public void registerValidatorFields() {
340 SwingValidatorUtil.detectValidatorFields(this);
341 }
342
343
344
345
346
347 public void doKeyPressed__on__table(KeyEvent event) {
348 if (log.isDebugEnabled()) {
349 log.debug(event);
350 }
351 handler.openRowMenu(event, tablePopup);
352 }
353
354 public void doMouseClicked__on__table(MouseEvent event) {
355 if (log.isDebugEnabled()) {
356 log.debug(event);
357 }
358 handler.autoSelectRowInTable(event, tablePopup);
359 }
360
361
362
363
364
365 public TuttiHelpBroker getBroker() {
366 return broker;
367 }
368
369 public JButton getCreateMarineLitterBatchButton() {
370 return createMarineLitterBatchButton;
371 }
372
373 public JMenuItem getExportMultiPostButton() {
374 return exportMultiPostButton;
375 }
376
377 public Table getForm() {
378 return form;
379 }
380
381 public MarineLitterBatchUIHandler getHandler() {
382 return handler;
383 }
384
385 public JMenuItem getImportMultiPostButton() {
386 return importMultiPostButton;
387 }
388
389 public ButtonAttachment getMarineLitterBatchAttachmentsButton() {
390 return marineLitterBatchAttachmentsButton;
391 }
392
393 public JToolBar getMarineLitterBatchTabToolBar() {
394 return marineLitterBatchTabToolBar;
395 }
396
397 public ComputableDataEditor<Float> getMarineLitterTotalWeightField() {
398 return marineLitterTotalWeightField;
399 }
400
401 public JLabel getMarineLitterTotalWeightLabel() {
402 return marineLitterTotalWeightLabel;
403 }
404
405 public JMenuBar getMenu() {
406 return menu;
407 }
408
409 public JMenu getMenuAction() {
410 return menuAction;
411 }
412
413 public MarineLitterBatchUIModel getModel() {
414 return model;
415 }
416
417 public JMenuItem getRemoveMarineLitterBatchMenu() {
418 return removeMarineLitterBatchMenu;
419 }
420
421 public JXTable getTable() {
422 return table;
423 }
424
425 public JPopupMenu getTablePopup() {
426 return tablePopup;
427 }
428
429 public JScrollPane getTableScrollPane() {
430 return tableScrollPane;
431 }
432
433 public JPanel getTableToolbar() {
434 return tableToolbar;
435 }
436
437 public SwingValidator<MarineLitterBatchUIModel> getValidator() {
438 return validator;
439 }
440
441
442
443
444
445 @Override
446 public void registerHelpId(TuttiHelpBroker broker, Component component, String helpId) {
447 broker.installUI(component, helpId);
448 }
449
450 @Override
451 public void showHelp(String helpId) {
452 getBroker().showHelp(this, helpId);
453 }
454
455
456
457
458
459 protected JPanel get$JPanel0() {
460 return $JPanel0;
461 }
462
463
464
465
466
467 protected void addChildrenToEditMarineLitterBatchTopPanel() {
468 if (!allComponentsCreated) {
469 return;
470 }
471 add(marineLitterBatchTabToolBar);
472 add(form, BorderLayout.NORTH);
473 add(tableScrollPane, BorderLayout.CENTER);
474 }
475
476 protected void addChildrenToForm() {
477 if (!allComponentsCreated) {
478 return;
479 }
480 form.add(marineLitterTotalWeightLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 17, 1, new Insets(3, 3, 3, 3), 0, 0));
481 form.add(SwingUtil.boxComponentWithJxLayer(marineLitterTotalWeightField), new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
482 form.add(tableToolbar, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
483 }
484
485 protected void addChildrenToMarineLitterBatchTabToolBar() {
486 if (!allComponentsCreated) {
487 return;
488 }
489 marineLitterBatchTabToolBar.add(menu);
490 marineLitterBatchTabToolBar.add(marineLitterBatchAttachmentsButton);
491 }
492
493 protected void addChildrenToMenu() {
494 if (!allComponentsCreated) {
495 return;
496 }
497 menu.add(menuAction);
498 }
499
500 protected void addChildrenToMenuAction() {
501 if (!allComponentsCreated) {
502 return;
503 }
504 menuAction.add(importMultiPostButton);
505 menuAction.add(exportMultiPostButton);
506 }
507
508 protected void addChildrenToTablePopup() {
509 if (!allComponentsCreated) {
510 return;
511 }
512 tablePopup.add(removeMarineLitterBatchMenu);
513 }
514
515 protected void addChildrenToTableScrollPane() {
516 if (!allComponentsCreated) {
517 return;
518 }
519 tableScrollPane.getViewport().add(table);
520 }
521
522 protected void addChildrenToTableToolbar() {
523 if (!allComponentsCreated) {
524 return;
525 }
526 tableToolbar.add($JPanel0, BorderLayout.WEST);
527 }
528
529 protected void addChildrenToValidator() {
530 if (!allComponentsCreated) {
531 return;
532 }
533 validator.setUiClass(ImageValidationUI.class);
534 validator.setBean(model);
535 }
536
537 protected void createBroker() {
538 $objectMap.put("broker", broker = new TuttiHelpBroker("tutti.editMarineLitterBatch.help"));
539 }
540
541 protected void createCreateMarineLitterBatchButton() {
542 $objectMap.put("createMarineLitterBatchButton", createMarineLitterBatchButton = new JButton());
543
544 createMarineLitterBatchButton.setName("createMarineLitterBatchButton");
545 createMarineLitterBatchButton.setText(t("tutti.editMarineLitterBatch.action.createBatch"));
546 createMarineLitterBatchButton.setToolTipText(t("tutti.editMarineLitterBatch.action.createBatch.tip"));
547 createMarineLitterBatchButton.putClientProperty("help", "tutti.editMarineLitterBatch.action.createBatch.help");
548 createMarineLitterBatchButton.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.actions.OpenCreateMarineLitterBatchUIAction.class);
549 }
550
551 protected void createExportMultiPostButton() {
552 $objectMap.put("exportMultiPostButton", exportMultiPostButton = new JMenuItem());
553
554 exportMultiPostButton.setName("exportMultiPostButton");
555 exportMultiPostButton.setText(t("tutti.editMarineLitterBatch.action.exportMultiPost"));
556 exportMultiPostButton.setToolTipText(t("tutti.editMarineLitterBatch.action.exportMultiPost.tip"));
557 exportMultiPostButton.putClientProperty("help", "tutti.editMarineLitterBatch.action.exportMultiPost.help");
558 exportMultiPostButton.putClientProperty("applicationAction", fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.actions.ExportMultiPostMarineLitterAction.class);
559 }
560
561 protected void createForm() {
562 $objectMap.put("form", form = new Table());
563
564 form.setName("form");
565 }
566
567 protected MarineLitterBatchUIHandler createHandler() {
568 return new MarineLitterBatchUIHandler();
569 }
570
571 protected void createImportMultiPostButton() {
572 $objectMap.put("importMultiPostButton", importMultiPostButton = new JMenuItem());
573
574 importMultiPostButton.setName("importMultiPostButton");
575 importMultiPostButton.setText(t("tutti.editMarineLitterBatch.action.importMultiPost"));
576 importMultiPostButton.setToolTipText(t("tutti.editMarineLitterBatch.action.importMultiPost.tip"));
577 importMultiPostButton.putClientProperty("help", "tutti.editMarineLitterBatch.action.importMultiPost.help");
578 importMultiPostButton.putClientProperty("applicationAction", fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.actions.ImportMultiPostMarineLitterAction.class);
579 }
580
581 protected void createMarineLitterBatchAttachmentsButton() {
582 $objectMap.put("marineLitterBatchAttachmentsButton", marineLitterBatchAttachmentsButton = new ButtonAttachment(handler.getContext(), getContextValue(EditCatchesUIModel.class)));
583
584 marineLitterBatchAttachmentsButton.setName("marineLitterBatchAttachmentsButton");
585 marineLitterBatchAttachmentsButton.setToolTipText(t("tutti.editMarineLitterBatch.action.attachments.tip"));
586 marineLitterBatchAttachmentsButton.setFocusPainted(false);
587 }
588
589 protected void createMarineLitterBatchTabToolBar() {
590 $objectMap.put("marineLitterBatchTabToolBar", marineLitterBatchTabToolBar = new JToolBar());
591
592 marineLitterBatchTabToolBar.setName("marineLitterBatchTabToolBar");
593 marineLitterBatchTabToolBar.setBorderPainted(false);
594 marineLitterBatchTabToolBar.setOpaque(true);
595 marineLitterBatchTabToolBar.setFloatable(false);
596 }
597
598 protected void createMarineLitterTotalWeightField() {
599 $objectMap.put("marineLitterTotalWeightField", marineLitterTotalWeightField = new ComputableDataEditor<Float>(this));
600
601 marineLitterTotalWeightField.setName("marineLitterTotalWeightField");
602 marineLitterTotalWeightField.setShowReset(true);
603 marineLitterTotalWeightField.putClientProperty("help", "tutti.editMarineLitterBatch.field.marineLitterTotalWeight.help");
604 }
605
606 protected void createMarineLitterTotalWeightLabel() {
607 $objectMap.put("marineLitterTotalWeightLabel", marineLitterTotalWeightLabel = new JLabel());
608
609 marineLitterTotalWeightLabel.setName("marineLitterTotalWeightLabel");
610 marineLitterTotalWeightLabel.setText(t("tutti.editMarineLitterBatch.field.marineLitterTotalWeight"));
611 marineLitterTotalWeightLabel.setToolTipText(t("tutti.editMarineLitterBatch.field.marineLitterTotalWeight.tip"));
612 marineLitterTotalWeightLabel.putClientProperty("help", "tutti.editMarineLitterBatch.field.marineLitterTotalWeight.help");
613 marineLitterTotalWeightLabel.putClientProperty("addWeightUnit", model.getWeightUnit());
614 }
615
616 protected void createMenu() {
617 $objectMap.put("menu", menu = new JMenuBar());
618
619 menu.setName("menu");
620 }
621
622 protected void createMenuAction() {
623 $objectMap.put("menuAction", menuAction = new JMenu());
624
625 menuAction.setName("menuAction");
626 menuAction.setOpaque(true);
627 menuAction.setText(t("tutti.toolbar.menu.action"));
628 menuAction.setToolTipText(t("tutti.toolbar.menu.action.tip"));
629 }
630
631 protected void createModel() {
632 $objectMap.put("model", model = getContextValue(MarineLitterBatchUIModel.class));
633 }
634
635 protected void createRemoveMarineLitterBatchMenu() {
636 $objectMap.put("removeMarineLitterBatchMenu", removeMarineLitterBatchMenu = new JMenuItem());
637
638 removeMarineLitterBatchMenu.setName("removeMarineLitterBatchMenu");
639 removeMarineLitterBatchMenu.setText(t("tutti.editMarineLitterBatch.action.removeBatch"));
640 removeMarineLitterBatchMenu.setToolTipText(t("tutti.editMarineLitterBatch.action.removeBatch.tip"));
641 removeMarineLitterBatchMenu.putClientProperty("help", "tutti.editMarineLitterBatch.action.removeBatch.help");
642 removeMarineLitterBatchMenu.putClientProperty("applicationAction", fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.actions.RemoveMarineLitterBatchAction.class);
643 }
644
645 protected void createTable() {
646 $objectMap.put("table", table = new JXTable());
647
648 table.setName("table");
649 table.setSortable(false);
650 table.addKeyListener(JAXXUtil.getEventListener(KeyListener.class, "keyPressed", this, "doKeyPressed__on__table"));
651 table.addMouseListener(JAXXUtil.getEventListener(MouseListener.class, "mouseClicked", this, "doMouseClicked__on__table"));
652 }
653
654 protected void createTablePopup() {
655 $objectMap.put("tablePopup", tablePopup = new JPopupMenu());
656
657 tablePopup.setName("tablePopup");
658 tablePopup.setLabel("tutti.editMarineLitterBatch.title.batchActions");
659 }
660
661 protected void createTableScrollPane() {
662 $objectMap.put("tableScrollPane", tableScrollPane = new JScrollPane());
663
664 tableScrollPane.setName("tableScrollPane");
665 }
666
667 protected void createTableToolbar() {
668 $objectMap.put("tableToolbar", tableToolbar = new JPanel());
669
670 tableToolbar.setName("tableToolbar");
671 tableToolbar.setLayout(new BorderLayout());
672 SwingUtil.setComponentHeight(tableToolbar,50);
673 }
674
675 protected void createValidator() {
676 $objectMap.put("validator", validator = SwingValidator.newValidator(MarineLitterBatchUIModel.class, null));
677 }
678
679
680
681
682
683 private void $completeSetup() {
684 allComponentsCreated = true;
685 if (log.isDebugEnabled()) {
686 log.debug(this);
687 }
688 addChildrenToEditMarineLitterBatchTopPanel();
689 addChildrenToValidator();
690 addChildrenToMarineLitterBatchTabToolBar();
691 addChildrenToMenu();
692 addChildrenToMenuAction();
693 addChildrenToTablePopup();
694 addChildrenToForm();
695 addChildrenToTableToolbar();
696
697 $JPanel0.add(createMarineLitterBatchButton);
698 addChildrenToTableScrollPane();
699
700
701 JAXXUtil.applyDataBinding(this, $bindings.keySet());
702
703
704 menu.setBorder(null);
705 menu.setBackground(javax.swing.UIManager.getColor("MenuBar.background"));
706 menuAction.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.toolbar.menu.action.mnemonic"),'Z'));
707 importMultiPostButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.editMarineLitterBatch.action.importMultiPost.mnemonic"),'Z'));
708 importMultiPostButton.setIcon(SwingUtil.createActionIcon("import"));
709 exportMultiPostButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.editMarineLitterBatch.action.exportMultiPost.mnemonic"),'Z'));
710 exportMultiPostButton.setIcon(SwingUtil.createActionIcon("export"));
711 removeMarineLitterBatchMenu.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.editMarineLitterBatch.action.removeBatch.mnemonic"),'Z'));
712 removeMarineLitterBatchMenu.setIcon(SwingUtil.createActionIcon("batch-delete"));
713 marineLitterTotalWeightLabel.setLabelFor(marineLitterTotalWeightField);
714 marineLitterTotalWeightField.setComputedDataColor(handler.getConfig().getColorComputedWeights());
715 marineLitterTotalWeightField.setAutoPopup(handler.getConfig().isAutoPopupNumberEditor());
716 marineLitterTotalWeightField.setNumberType(Float.class);
717 marineLitterTotalWeightField.setShowPopupButton(handler.getConfig().isShowNumberEditorButton());
718 createMarineLitterBatchButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.editMarineLitterBatch.action.createBatch.mnemonic"),'Z'));
719 createMarineLitterBatchButton.setIcon(SwingUtil.createActionIcon("batch-create"));
720 table.setSelectionForeground(Color.BLACK);
721 table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
722
723
724 TuttiHelpBroker _broker = getBroker();
725 registerHelpId(_broker, editMarineLitterBatchTopPanel, "tutti.editMarineLitterBatch.help");
726 registerHelpId(_broker, importMultiPostButton, "tutti.editMarineLitterBatch.action.importMultiPost.help");
727 registerHelpId(_broker, exportMultiPostButton, "tutti.editMarineLitterBatch.action.exportMultiPost.help");
728 registerHelpId(_broker, removeMarineLitterBatchMenu, "tutti.editMarineLitterBatch.action.removeBatch.help");
729 registerHelpId(_broker, marineLitterTotalWeightLabel, "tutti.editMarineLitterBatch.field.marineLitterTotalWeight.help");
730 registerHelpId(_broker, marineLitterTotalWeightField, "tutti.editMarineLitterBatch.field.marineLitterTotalWeight.help");
731 registerHelpId(_broker, createMarineLitterBatchButton, "tutti.editMarineLitterBatch.action.createBatch.help");
732 _broker.prepareUI(this);
733
734 validatorIds = SwingValidatorUtil.detectValidators(this);
735 SwingValidatorUtil.installUI(this);
736 }
737
738 private void $initialize() {
739 if (allComponentsCreated) {
740 return;
741 }
742 if (log.isDebugEnabled()) {
743 log.debug(this);
744 }
745 handler.beforeInit(this);
746 $objectMap.put("editMarineLitterBatchTopPanel", editMarineLitterBatchTopPanel);
747 createModel();
748 createValidator();
749 createBroker();
750 createMarineLitterBatchTabToolBar();
751 createMenu();
752 createMenuAction();
753 createImportMultiPostButton();
754 createExportMultiPostButton();
755 createMarineLitterBatchAttachmentsButton();
756 createTablePopup();
757 createRemoveMarineLitterBatchMenu();
758 createForm();
759 createMarineLitterTotalWeightLabel();
760 createMarineLitterTotalWeightField();
761 createTableToolbar();
762
763 $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
764
765 $JPanel0.setName("$JPanel0");
766 $JPanel0.setLayout(new GridLayout(1,0));
767 createCreateMarineLitterBatchButton();
768 createTableScrollPane();
769 createTable();
770
771 setName("editMarineLitterBatchTopPanel");
772 setLayout(new BorderLayout());
773 editMarineLitterBatchTopPanel.putClientProperty("help", "tutti.editMarineLitterBatch.help");
774
775
776 $registerDefaultBindings();
777 $completeSetup();
778 handler.afterInit(this);
779 }
780
781 private void $registerDefaultBindings() {
782
783 registerDataBinding(new DefaultJAXXBinding(this, BINDING_REMOVE_MARINE_LITTER_BATCH_MENU_ENABLED, true) {
784
785 @Override
786 public void applyDataBinding() {
787 if (model != null) {
788 model.addPropertyChangeListener("removeBatchEnabled", this);
789 }
790 }
791
792 @Override
793 public void processDataBinding() {
794 if (model != null) {
795 removeMarineLitterBatchMenu.setEnabled(model.isRemoveBatchEnabled());
796 }
797 }
798
799 @Override
800 public void removeDataBinding() {
801 if (model != null) {
802 model.removePropertyChangeListener("removeBatchEnabled", this);
803 }
804 }
805 });
806 registerDataBinding(new DefaultJAXXBinding(this, BINDING_MARINE_LITTER_TOTAL_WEIGHT_FIELD_NUMBER_VALUE, true) {
807
808 @Override
809 public void applyDataBinding() {
810 if (model != null) {
811 model.addPropertyChangeListener("marineLitterTotalWeight", this);
812 }
813 }
814
815 @Override
816 public void processDataBinding() {
817 if (model != null) {
818 marineLitterTotalWeightField.setNumberValue(model.getMarineLitterTotalWeight());
819 }
820 }
821
822 @Override
823 public void removeDataBinding() {
824 if (model != null) {
825 model.removePropertyChangeListener("marineLitterTotalWeight", this);
826 }
827 }
828 });
829 registerDataBinding(new DefaultJAXXBinding(this, BINDING_MARINE_LITTER_TOTAL_WEIGHT_FIELD_BEAN, true) {
830
831 @Override
832 public void applyDataBinding() {
833 if (model != null) {
834 model.addPropertyChangeListener("marineLitterTotalComputedOrNotWeight", this);
835 }
836 }
837
838 @Override
839 public void processDataBinding() {
840 if (model != null) {
841 marineLitterTotalWeightField.setBean(model.getMarineLitterTotalComputedOrNotWeight());
842 }
843 }
844
845 @Override
846 public void removeDataBinding() {
847 if (model != null) {
848 model.removePropertyChangeListener("marineLitterTotalComputedOrNotWeight", this);
849 }
850 }
851 });
852 }
853
854 }