View Javadoc
1   package fr.ifremer.tutti.ui.swing.content.report;
2   
3   /*
4    * #%L
5    * Tutti :: UI
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2012 - 2017 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU General Public License as
13   * published by the Free Software Foundation, either version 3 of the
14   * License, or (at your option) any later version.
15   * 
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   * 
21   * You should have received a copy of the GNU General Public
22   * License along with this program.  If not, see
23   * <http://www.gnu.org/licenses/gpl-3.0.html>.
24   * #L%
25   */
26  
27  import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
28  import fr.ifremer.tutti.ui.swing.TuttiHelpBroker;
29  import fr.ifremer.tutti.ui.swing.util.TuttiUI;
30  import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
31  import java.awt.BorderLayout;
32  import java.awt.Component;
33  import java.awt.Container;
34  import java.awt.GridBagConstraints;
35  import java.awt.GridLayout;
36  import java.awt.Insets;
37  import java.awt.LayoutManager;
38  import java.io.File;
39  import java.util.ArrayList;
40  import java.util.HashMap;
41  import java.util.List;
42  import java.util.Map;
43  import java.util.TreeMap;
44  import javax.swing.JButton;
45  import javax.swing.JLabel;
46  import javax.swing.JPanel;
47  import jaxx.runtime.JAXXBinding;
48  import jaxx.runtime.JAXXContext;
49  import jaxx.runtime.JAXXObject;
50  import jaxx.runtime.JAXXObjectDescriptor;
51  import jaxx.runtime.JAXXUtil;
52  import jaxx.runtime.JAXXValidator;
53  import jaxx.runtime.SwingUtil;
54  import jaxx.runtime.binding.DefaultJAXXBinding;
55  import jaxx.runtime.context.DefaultJAXXContext;
56  import jaxx.runtime.swing.Table;
57  import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
58  import jaxx.runtime.swing.help.JAXXHelpUI;
59  import jaxx.runtime.validator.swing.SwingValidator;
60  import jaxx.runtime.validator.swing.SwingValidatorUtil;
61  import jaxx.runtime.validator.swing.meta.Validator;
62  import jaxx.runtime.validator.swing.meta.ValidatorField;
63  import jaxx.runtime.validator.swing.ui.ImageValidationUI;
64  import org.apache.commons.logging.Log;
65  import org.apache.commons.logging.LogFactory;
66  import static jaxx.runtime.SwingUtil.getStringValue;
67  import static org.nuiton.i18n.I18n.t;
68  
69  public class ReportUI extends JPanel implements JAXXHelpUI<TuttiHelpBroker>, TuttiUI<ReportUIModel, ReportUIHandler>, JAXXObject, JAXXValidator {
70  
71      /*-----------------------------------------------------------------------*/
72      /*------------------ Constants for all public bindings ------------------*/
73      /*-----------------------------------------------------------------------*/
74  
75      public static final String BINDING_DISPLAY_REPORT_BUTTON_ENABLED = "displayReportButton.enabled";
76      public static final String BINDING_FISHING_OPERATION_COMBO_BOX_SELECTED_ITEM = "fishingOperationComboBox.selectedItem";
77      public static final String BINDING_GENERATE_BUTTON_ENABLED = "generateButton.enabled";
78      public static final String BINDING_REPORT_COMBO_BOX_SELECTED_ITEM = "reportComboBox.selectedItem";
79      public static final String BINDING_SAVE_REPORT_BUTTON_ENABLED = "saveReportButton.enabled";
80  
81      /*-----------------------------------------------------------------------*/
82      /*------------------------- Other static fields -------------------------*/
83      /*-----------------------------------------------------------------------*/
84  
85      private static final String $jaxxObjectDescriptor = "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";
86      private static final Log log = LogFactory.getLog(ReportUI.class);
87      private static final long serialVersionUID = 1L;
88  
89      /*-----------------------------------------------------------------------*/
90      /*--------------------------- Internal states ---------------------------*/
91      /*-----------------------------------------------------------------------*/
92  
93      protected List<Object> $activeBindings = new ArrayList<Object>();
94      protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
95      protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
96      protected Map<String, Object> $objectMap = new HashMap<String, Object>();
97      protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
98      private boolean allComponentsCreated;
99      protected final JAXXContext delegateContext = new DefaultJAXXContext();
100 
101     /*-----------------------------------------------------------------------*/
102     /*------------------------ Protected components  ------------------------*/
103     /*-----------------------------------------------------------------------*/
104 
105     protected TuttiHelpBroker broker;
106     protected JButton closeButton;
107     protected JButton displayReportButton;
108     @ValidatorField( validatorId = "validator",  propertyName = "fishingOperation",  editorName = "fishingOperationComboBox")
109     protected BeanFilterableComboBox<FishingOperation> fishingOperationComboBox;
110     protected JLabel fishingOperationLabel;
111     protected Table form;
112     protected JButton generateButton;
113     protected final ReportUIHandler handler = createHandler();
114     protected ReportUIModel model;
115     @ValidatorField( validatorId = "validator",  propertyName = "report",  editorName = "reportComboBox")
116     protected BeanFilterableComboBox<File> reportComboBox;
117     protected JLabel reportLabel;
118     protected ReportUI reportTopPanel = this;
119     protected JButton saveReportButton;
120     @Validator( validatorId = "validator")
121     protected SwingValidator<ReportUIModel> validator;
122     protected List<String> validatorIds = new ArrayList<String>();
123 
124     /*-----------------------------------------------------------------------*/
125     /*------------------------- Private components  -------------------------*/
126     /*-----------------------------------------------------------------------*/
127 
128     private JPanel $JPanel0;
129     private JPanel $JPanel1;
130     private JPanel $JPanel2;
131     private JPanel $JPanel3;
132 
133     /*-----------------------------------------------------------------------*/
134     /*---------------------------- Constructors  ----------------------------*/
135     /*-----------------------------------------------------------------------*/
136 
137     public ReportUI(TuttiUI parentUI) {
138         TuttiUIUtil.setParentUI(this, parentUI);
139             $initialize();
140     }
141 
142     public ReportUI(LayoutManager param0, boolean param1) {
143         super(param0 ,param1);
144         $initialize();
145     }
146 
147     public ReportUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
148         super(param1 ,param2);
149         JAXXUtil.initContext(this, parentContext);
150         $initialize();
151     }
152 
153     public ReportUI(LayoutManager param0) {
154         super(param0);
155         $initialize();
156     }
157 
158     public ReportUI(JAXXContext parentContext, LayoutManager param1) {
159         super(param1);
160         JAXXUtil.initContext(this, parentContext);
161         $initialize();
162     }
163 
164     public ReportUI() {
165         $initialize();
166     }
167 
168     public ReportUI(JAXXContext parentContext) {
169         JAXXUtil.initContext(this, parentContext);
170         $initialize();
171     }
172 
173     public ReportUI(boolean param0) {
174         super(param0);
175         $initialize();
176     }
177 
178     public ReportUI(JAXXContext parentContext, boolean param1) {
179         super(param1);
180         JAXXUtil.initContext(this, parentContext);
181         $initialize();
182     }
183 
184     /*-----------------------------------------------------------------------*/
185     /*--------------------------- Statics methods ---------------------------*/
186     /*-----------------------------------------------------------------------*/
187 
188     public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
189         return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
190     }
191 
192     /*-----------------------------------------------------------------------*/
193     /*---------------------- JAXXObject implementation ----------------------*/
194     /*-----------------------------------------------------------------------*/
195 
196     @Override
197     public void applyDataBinding(String $binding) {
198         if (allComponentsCreated && $bindings.containsKey($binding)) {
199             getDataBinding($binding).applyDataBinding();
200         }
201         processDataBinding($binding);
202     }
203 
204     @Override
205     public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
206         super.firePropertyChange(propertyName, oldValue, newValue);
207     }
208 
209     @Override
210     public Map<String, Object> get$objectMap() {
211         return $objectMap;
212     }
213 
214     @Override
215     public JAXXBinding getDataBinding(String bindingId) {
216         return $bindings.get(bindingId);
217     }
218 
219     @Override
220     public JAXXBinding[] getDataBindings() {
221         return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
222     }
223 
224     @Override
225     public Object getObjectById(String id) {
226         return $objectMap.get(id);
227     }
228 
229     @Override
230     public void processDataBinding(String $binding, boolean $force) {
231         if (!$force && $activeBindings.contains($binding)) { 
232             return;
233         }
234         $activeBindings.add($binding);
235         try {
236             if (allComponentsCreated && $bindings.containsKey($binding)) {
237                 getDataBinding($binding).processDataBinding();
238             }
239         } finally {
240             $activeBindings.remove($binding);
241         }
242     }
243 
244     @Override
245     public void processDataBinding(String $binding) {
246         processDataBinding($binding, false);
247     }
248 
249     @Override
250     public void registerDataBinding(JAXXBinding binding) {
251         $bindings.put(binding.getId(), binding);
252     }
253 
254     @Override
255     public void removeDataBinding(String $binding) {
256         if (allComponentsCreated && $bindings.containsKey($binding)) {
257             getDataBinding($binding).removeDataBinding();
258         }
259     }
260 
261     /*-----------------------------------------------------------------------*/
262     /*--------------------- JAXXContext implementation  ---------------------*/
263     /*-----------------------------------------------------------------------*/
264 
265     @Override
266     public <T> T getContextValue(Class<T> clazz) {
267         return delegateContext.getContextValue(clazz, null);
268     }
269 
270     @Override
271     public <T> T getContextValue(Class<T> clazz, String name) {
272         return delegateContext.getContextValue(clazz, name);
273     }
274 
275     @Override
276     public JAXXContext getDelegateContext() {
277         return delegateContext;
278     }
279 
280     @Override
281     public <O extends Container> O getParentContainer(Class<O> clazz) {
282         return SwingUtil.getParentContainer(this, clazz);
283     }
284 
285     @Override
286     public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
287         return SwingUtil.getParentContainer(source, clazz);
288     }
289 
290     @Override
291     public <T> void removeContextValue(Class<T> clazz) {
292         delegateContext.removeContextValue(clazz, null);
293     }
294 
295     @Override
296     public <T> void removeContextValue(Class<T> clazz, String name) {
297         delegateContext.removeContextValue(clazz, name);
298     }
299 
300     @Override
301     public <T> void setContextValue(T o) {
302         delegateContext.setContextValue(o, null);
303     }
304 
305     @Override
306     public <T> void setContextValue(T o, String name) {
307         delegateContext.setContextValue(o, name);
308     }
309 
310     /*-----------------------------------------------------------------------*/
311     /*-------------------- JAXXValidator implementation  --------------------*/
312     /*-----------------------------------------------------------------------*/
313 
314     @Override
315     public SwingValidator<?> getValidator(String validatorId) {
316         return (SwingValidator<?>) (validatorIds.contains(validatorId) ? getObjectById(validatorId) : null);
317     }
318 
319     @Override
320     public List<String> getValidatorIds() {
321         return validatorIds;
322     }
323 
324     @Override
325     public void registerValidatorFields() {
326         SwingValidatorUtil.detectValidatorFields(this);
327     }
328 
329     /*-----------------------------------------------------------------------*/
330     /*----------------------- Public acessor methods  -----------------------*/
331     /*-----------------------------------------------------------------------*/
332 
333     public TuttiHelpBroker getBroker() {
334         return broker;
335     }
336 
337     public JButton getCloseButton() {
338         return closeButton;
339     }
340 
341     public JButton getDisplayReportButton() {
342         return displayReportButton;
343     }
344 
345     public BeanFilterableComboBox<FishingOperation> getFishingOperationComboBox() {
346         return fishingOperationComboBox;
347     }
348 
349     public JLabel getFishingOperationLabel() {
350         return fishingOperationLabel;
351     }
352 
353     public Table getForm() {
354         return form;
355     }
356 
357     public JButton getGenerateButton() {
358         return generateButton;
359     }
360 
361     public ReportUIHandler getHandler() {
362         return handler;
363     }
364 
365     public ReportUIModel getModel() {
366         return model;
367     }
368 
369     public BeanFilterableComboBox<File> getReportComboBox() {
370         return reportComboBox;
371     }
372 
373     public JLabel getReportLabel() {
374         return reportLabel;
375     }
376 
377     public JButton getSaveReportButton() {
378         return saveReportButton;
379     }
380 
381     public SwingValidator<ReportUIModel> getValidator() {
382         return validator;
383     }
384 
385     /*-----------------------------------------------------------------------*/
386     /*---------------------------- Other methods ----------------------------*/
387     /*-----------------------------------------------------------------------*/
388 
389     @Override
390     public void registerHelpId(TuttiHelpBroker broker, Component component, String helpId) {
391         broker.installUI(component, helpId);
392     }
393 
394     @Override
395     public void showHelp(String helpId) {
396         getBroker().showHelp(this, helpId);
397     }
398 
399     /*-----------------------------------------------------------------------*/
400     /*--------------------- Protected acessors methods  ---------------------*/
401     /*-----------------------------------------------------------------------*/
402 
403     protected JPanel get$JPanel0() {
404         return $JPanel0;
405     }
406 
407     protected JPanel get$JPanel1() {
408         return $JPanel1;
409     }
410 
411     protected JPanel get$JPanel2() {
412         return $JPanel2;
413     }
414 
415     protected JPanel get$JPanel3() {
416         return $JPanel3;
417     }
418 
419     /*-----------------------------------------------------------------------*/
420     /*--------------------- Components creation methods ---------------------*/
421     /*-----------------------------------------------------------------------*/
422 
423     protected void addChildrenToForm() {
424         if (!allComponentsCreated) {
425             return;
426         }
427         form.add($JPanel0, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.3, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
428         form.add(fishingOperationLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
429         form.add(SwingUtil.boxComponentWithJxLayer(fishingOperationComboBox), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
430         form.add(reportLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, 17, 1, new Insets(3, 3, 3, 3), 0, 0));
431         form.add(SwingUtil.boxComponentWithJxLayer(reportComboBox), new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
432         form.add($JPanel1, new GridBagConstraints(0, 3, 2, 1, 0.0, 0.3, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
433         form.add($JPanel3, new GridBagConstraints(0, 4, 2, 1, 0.0, 0.1, 15, 1, new Insets(3, 3, 3, 3), 0, 0));
434     }
435 
436     protected void addChildrenToReportTopPanel() {
437         if (!allComponentsCreated) {
438             return;
439         }
440         add(form);
441     }
442 
443     protected void addChildrenToValidator() {
444         if (!allComponentsCreated) {
445             return;
446         }
447         validator.setUiClass(ImageValidationUI.class);
448         validator.setBean(model);
449     }
450 
451     protected void createBroker() {
452         $objectMap.put("broker", broker = new TuttiHelpBroker("tutti.report.help"));
453     }
454 
455     protected void createCloseButton() {
456         $objectMap.put("closeButton", closeButton = new JButton());
457         
458         closeButton.setName("closeButton");
459         closeButton.setText(t("tutti.report.action.cancel"));
460         closeButton.setToolTipText(t("tutti.report.action.cancel.tip"));
461         closeButton.putClientProperty("help", "tutti.report.action.cancel.help");
462         closeButton.putClientProperty("applicationAction", fr.ifremer.tutti.ui.swing.content.actions.GoToPreviousScreenAction.class);
463     }
464 
465     protected void createDisplayReportButton() {
466         $objectMap.put("displayReportButton", displayReportButton = new JButton());
467         
468         displayReportButton.setName("displayReportButton");
469         displayReportButton.setText(t("tutti.report.action.openReport"));
470         displayReportButton.setToolTipText(t("tutti.report.action.openReport.tip"));
471         displayReportButton.putClientProperty("help", "tutti.report.action.openReport.help");
472         displayReportButton.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.report.actions.OpenReportAction.class);
473     }
474 
475     protected void createFishingOperationComboBox() {
476         $objectMap.put("fishingOperationComboBox", fishingOperationComboBox = new BeanFilterableComboBox<FishingOperation>(this));
477         
478         fishingOperationComboBox.setName("fishingOperationComboBox");
479         fishingOperationComboBox.setProperty("fishingOperation");
480         fishingOperationComboBox.setShowReset(true);
481         fishingOperationComboBox.putClientProperty("help", "tutti.report.field.fishingOperation.help");
482         fishingOperationComboBox.putClientProperty("validatorLabel", t("tutti.report.field.fishingOperation"));
483     }
484 
485     protected void createFishingOperationLabel() {
486         $objectMap.put("fishingOperationLabel", fishingOperationLabel = new JLabel());
487         
488         fishingOperationLabel.setName("fishingOperationLabel");
489         fishingOperationLabel.setText(t("tutti.report.field.fishingOperation"));
490         fishingOperationLabel.setToolTipText(t("tutti.report.field.fishingOperation.tip"));
491         fishingOperationLabel.putClientProperty("help", "tutti.report.field.fishingOperation.help");
492     }
493 
494     protected void createForm() {
495         $objectMap.put("form", form = new Table());
496         
497         form.setName("form");
498     }
499 
500     protected void createGenerateButton() {
501         $objectMap.put("generateButton", generateButton = new JButton());
502         
503         generateButton.setName("generateButton");
504         generateButton.setText(t("tutti.report.action.generate"));
505         generateButton.setToolTipText(t("tutti.report.action.generate.tip"));
506         generateButton.putClientProperty("help", "tutti.report.action.generate.help");
507         generateButton.putClientProperty("applicationAction", fr.ifremer.tutti.ui.swing.content.report.actions.GenerateReportAction.class);
508     }
509 
510     protected ReportUIHandler createHandler() {
511         return new ReportUIHandler();
512     }
513 
514     protected void createModel() {
515         $objectMap.put("model", model = getContextValue(ReportUIModel.class));
516     }
517 
518     protected void createReportComboBox() {
519         $objectMap.put("reportComboBox", reportComboBox = new BeanFilterableComboBox<File>(this));
520         
521         reportComboBox.setName("reportComboBox");
522         reportComboBox.setProperty("report");
523         reportComboBox.setShowReset(true);
524         reportComboBox.putClientProperty("help", "tutti.report.field.report.help");
525         reportComboBox.putClientProperty("validatorLabel", t("tutti.report.field.report"));
526     }
527 
528     protected void createReportLabel() {
529         $objectMap.put("reportLabel", reportLabel = new JLabel());
530         
531         reportLabel.setName("reportLabel");
532         reportLabel.setText(t("tutti.report.field.report"));
533         reportLabel.setToolTipText(t("tutti.report.field.report.tip"));
534         reportLabel.putClientProperty("help", "tutti.report.field.report.help");
535     }
536 
537     protected void createSaveReportButton() {
538         $objectMap.put("saveReportButton", saveReportButton = new JButton());
539         
540         saveReportButton.setName("saveReportButton");
541         saveReportButton.setText(t("tutti.report.action.save"));
542         saveReportButton.setToolTipText(t("tutti.report.action.save.tip"));
543         saveReportButton.putClientProperty("help", "tutti.report.action.save.help");
544         saveReportButton.putClientProperty("applicationAction", fr.ifremer.tutti.ui.swing.content.report.actions.SaveReportAction.class);
545     }
546 
547     protected void createValidator() {
548         $objectMap.put("validator", validator = SwingValidator.newValidator(ReportUIModel.class, null));
549     }
550 
551     /*-----------------------------------------------------------------------*/
552     /*------------------------ Internal jaxx methods ------------------------*/
553     /*-----------------------------------------------------------------------*/
554 
555     private void $completeSetup() {
556         allComponentsCreated = true;
557         if (log.isDebugEnabled()) {
558             log.debug(this);
559         }
560         addChildrenToReportTopPanel();
561         addChildrenToValidator();
562         addChildrenToForm();
563         // inline complete setup of $JPanel1
564         $JPanel1.add(generateButton);
565         $JPanel1.add($JPanel2);
566         $JPanel1.add(closeButton);
567         // inline complete setup of $JPanel2
568         $JPanel2.add(displayReportButton);
569         $JPanel2.add(saveReportButton);
570         
571         // apply 5 data bindings
572         JAXXUtil.applyDataBinding(this, $bindings.keySet());
573         
574         // apply 17 property setters
575         fishingOperationComboBox.setBeanType(FishingOperation.class);
576         reportComboBox.setBeanType(File.class);
577         fishingOperationLabel.setLabelFor(fishingOperationComboBox);
578         fishingOperationComboBox.setBean(model);
579         reportLabel.setLabelFor(reportComboBox);
580         reportComboBox.setBean(model);
581         generateButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.report.action.generate.mnemonic"),'Z'));
582         generateButton.setIcon(SwingUtil.createActionIcon("generate"));
583         displayReportButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.report.action.openReport.mnemonic"),'Z'));
584         displayReportButton.setIcon(SwingUtil.createActionIcon("open-file"));
585         saveReportButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.report.action.save.mnemonic"),'Z'));
586         saveReportButton.setIcon(SwingUtil.createActionIcon("save"));
587         closeButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.report.action.cancel.mnemonic"),'Z'));
588         closeButton.setIcon(SwingUtil.createActionIcon("cancel"));
589         // late initializer
590         // help broker setup
591         TuttiHelpBroker _broker = getBroker();
592         registerHelpId(_broker, reportTopPanel, "tutti.report.help");
593         registerHelpId(_broker, fishingOperationLabel, "tutti.report.field.fishingOperation.help");
594         registerHelpId(_broker, fishingOperationComboBox, "tutti.report.field.fishingOperation.help");
595         registerHelpId(_broker, reportLabel, "tutti.report.field.report.help");
596         registerHelpId(_broker, reportComboBox, "tutti.report.field.report.help");
597         registerHelpId(_broker, generateButton, "tutti.report.action.generate.help");
598         registerHelpId(_broker, displayReportButton, "tutti.report.action.openReport.help");
599         registerHelpId(_broker, saveReportButton, "tutti.report.action.save.help");
600         registerHelpId(_broker, closeButton, "tutti.report.action.cancel.help");
601         _broker.prepareUI(this);
602         // register 1 validator(s)
603         validatorIds = SwingValidatorUtil.detectValidators(this);
604         SwingValidatorUtil.installUI(this);
605     }
606 
607     private void $initialize() {
608         if (allComponentsCreated) {
609             return;
610         }
611         if (log.isDebugEnabled()) {
612             log.debug(this);
613         }
614         handler.beforeInit(this);
615         $objectMap.put("reportTopPanel", reportTopPanel);
616         createModel();
617         createBroker();
618         createValidator();
619         createForm();
620         // inline creation of $JPanel0
621         $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
622         
623         $JPanel0.setName("$JPanel0");
624         createFishingOperationLabel();
625         createFishingOperationComboBox();
626         createReportLabel();
627         createReportComboBox();
628         // inline creation of $JPanel1
629         $objectMap.put("$JPanel1", $JPanel1 = new JPanel());
630         
631         $JPanel1.setName("$JPanel1");
632         $JPanel1.setLayout(new GridLayout(0, 1));
633         SwingUtil.setComponentHeight($JPanel1,50);
634         createGenerateButton();
635         // inline creation of $JPanel2
636         $objectMap.put("$JPanel2", $JPanel2 = new JPanel());
637         
638         $JPanel2.setName("$JPanel2");
639         $JPanel2.setLayout(new GridLayout(1, 0));
640         createDisplayReportButton();
641         createSaveReportButton();
642         createCloseButton();
643         // inline creation of $JPanel3
644         $objectMap.put("$JPanel3", $JPanel3 = new JPanel());
645         
646         $JPanel3.setName("$JPanel3");
647         // inline creation of reportTopPanel
648         setName("reportTopPanel");
649         setLayout(new BorderLayout());
650         reportTopPanel.putClientProperty("help", "tutti.report.help");
651         
652         // registers 5 data bindings
653         $registerDefaultBindings();
654         $completeSetup();
655         handler.afterInit(this);
656     }
657 
658     private void $registerDefaultBindings() {
659         // register 5 data bindings
660         registerDataBinding(new DefaultJAXXBinding(this, BINDING_FISHING_OPERATION_COMBO_BOX_SELECTED_ITEM, true) {
661         
662             @Override
663             public void applyDataBinding() {
664                 if (model != null) {
665                     model.addPropertyChangeListener("fishingOperation", this);
666                 }
667             }
668         
669             @Override
670             public void processDataBinding() {
671                 if (model != null) {
672                     fishingOperationComboBox.setSelectedItem(model.getFishingOperation());
673                 }
674             }
675         
676             @Override
677             public void removeDataBinding() {
678                 if (model != null) {
679                     model.removePropertyChangeListener("fishingOperation", this);
680                 }
681             }
682         });
683         registerDataBinding(new DefaultJAXXBinding(this, BINDING_REPORT_COMBO_BOX_SELECTED_ITEM, true) {
684         
685             @Override
686             public void applyDataBinding() {
687                 if (model != null) {
688                     model.addPropertyChangeListener("report", this);
689                 }
690             }
691         
692             @Override
693             public void processDataBinding() {
694                 if (model != null) {
695                     reportComboBox.setSelectedItem(model.getReport());
696                 }
697             }
698         
699             @Override
700             public void removeDataBinding() {
701                 if (model != null) {
702                     model.removePropertyChangeListener("report", this);
703                 }
704             }
705         });
706         registerDataBinding(new DefaultJAXXBinding(this, BINDING_GENERATE_BUTTON_ENABLED, true) {
707         
708             @Override
709             public void applyDataBinding() {
710                 if (model != null) {
711                     model.addPropertyChangeListener("valid", this);
712                 }
713             }
714         
715             @Override
716             public void processDataBinding() {
717                 if (model != null) {
718                     generateButton.setEnabled(model.isValid());
719                 }
720             }
721         
722             @Override
723             public void removeDataBinding() {
724                 if (model != null) {
725                     model.removePropertyChangeListener("valid", this);
726                 }
727             }
728         });
729         registerDataBinding(new DefaultJAXXBinding(this, BINDING_DISPLAY_REPORT_BUTTON_ENABLED, true, true) {
730         
731             @Override
732             public void applyDataBinding() {
733                 if (model != null) {
734                     model.addPropertyChangeListener("valid", this);
735                 }
736                 if (model != null) {
737                     model.addPropertyChangeListener("reportDone", this);
738                 }
739             }
740         
741             @Override
742             public void processDataBinding() {
743                 if (model != null) {
744                     displayReportButton.setEnabled(model.isValid() && model.isReportDone());
745                 }
746             }
747         
748             @Override
749             public void removeDataBinding() {
750                 if (model != null) {
751                     model.removePropertyChangeListener("valid", this);
752                 }
753                 if (model != null) {
754                     model.removePropertyChangeListener("reportDone", this);
755                 }
756             }
757         });
758         registerDataBinding(new DefaultJAXXBinding(this, BINDING_SAVE_REPORT_BUTTON_ENABLED, true, true) {
759         
760             @Override
761             public void applyDataBinding() {
762                 if (model != null) {
763                     model.addPropertyChangeListener("valid", this);
764                 }
765                 if (model != null) {
766                     model.addPropertyChangeListener("reportDone", this);
767                 }
768             }
769         
770             @Override
771             public void processDataBinding() {
772                 if (model != null) {
773                     saveReportButton.setEnabled(model.isValid() && model.isReportDone());
774                 }
775             }
776         
777             @Override
778             public void removeDataBinding() {
779                 if (model != null) {
780                     model.removePropertyChangeListener("valid", this);
781                 }
782                 if (model != null) {
783                     model.removePropertyChangeListener("reportDone", this);
784                 }
785             }
786         });
787     }
788 
789 }