View Javadoc
1   package fr.ifremer.tutti.ui.swing.content.protocol.calcifiedpiecessampling;
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.referential.Species;
28  import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolSpeciesRowModel;
29  import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIModel;
30  import fr.ifremer.tutti.ui.swing.util.TuttiUI;
31  import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
32  import java.awt.BorderLayout;
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.awt.event.KeyEvent;
39  import java.awt.event.KeyListener;
40  import java.awt.event.MouseEvent;
41  import java.awt.event.MouseListener;
42  import java.util.ArrayList;
43  import java.util.HashMap;
44  import java.util.List;
45  import java.util.Map;
46  import java.util.TreeMap;
47  import javax.swing.JButton;
48  import javax.swing.JCheckBox;
49  import javax.swing.JMenuItem;
50  import javax.swing.JPanel;
51  import javax.swing.JPopupMenu;
52  import javax.swing.JScrollPane;
53  import jaxx.runtime.JAXXBinding;
54  import jaxx.runtime.JAXXContext;
55  import jaxx.runtime.JAXXObject;
56  import jaxx.runtime.JAXXObjectDescriptor;
57  import jaxx.runtime.JAXXUtil;
58  import jaxx.runtime.SwingUtil;
59  import jaxx.runtime.binding.DefaultJAXXBinding;
60  import jaxx.runtime.context.DefaultJAXXContext;
61  import jaxx.runtime.swing.Table;
62  import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
63  import org.apache.commons.logging.Log;
64  import org.apache.commons.logging.LogFactory;
65  import org.jdesktop.swingx.JXTable;
66  import static org.nuiton.i18n.I18n.t;
67  
68  public class CalcifiedPiecesSamplingEditorUI extends JPanel implements TuttiUI<EditProtocolUIModel, CalcifiedPiecesSamplingEditorUIHandler>, JAXXObject {
69  
70      /*-----------------------------------------------------------------------*/
71      /*------------------ Constants for all public bindings ------------------*/
72      /*-----------------------------------------------------------------------*/
73  
74      public static final String BINDING_ADD_SPECIES_BUTTON_ENABLED = "addSpeciesButton.enabled";
75      public static final String BINDING_SPECIES_COMBO_BOX_ENABLED = "speciesComboBox.enabled";
76  
77      /*-----------------------------------------------------------------------*/
78      /*------------------------- Other static fields -------------------------*/
79      /*-----------------------------------------------------------------------*/
80  
81      private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAMVXW28bRRSeOPekadqEXNqk4IRUalUYF0QFUkrbxHWEIyeNYodG5MGsdyfxpOvdYWeWbGQV8RP4CfDOCxJvPCEEPCPBC+IvIMQDr4gze/F61+ubEok8bJKZc75zzndmvpn5+k80zC20cqo4DrZsQ9Aawdsbh4fPKqdEFU8JVy3KhGkh72cghVJHaFJrjHOBXj8qSPeM757JmjVmGsRo8l4voAkuznXCq4QIgW5FPVTOM8XG9LrDbCtAbSSVhPrl33+lvtA+/yqFkMMgu2koJd3NK6xkqIBSVBNoBiJ9qmR0xTiBNCxqnEC+U3Isqyuc7yo18gn6DI0W0AhTLAATaLX3kl0M199hAo2pjO8pBtEFqhxbmB5bpEYsLGwhKLYp5mcQHqumIQANM8sUpmrqWFV0lR5TojFKVMK5UmO6NMwG43vueNEfz2kUUjjIM+ZGHhFouGZqMuijPoJKlD3/n4P8jgQIAaegkJJS0cmeyWwobF7y5fhQ2+7gDjHs0GGaQ2oiy/i+eSZnBJqLuMixvCA1aT7d8LoGQYkgoZscfyVqc92zKTKiUsLbGE1AvhuqoKYBS3YmmqzshzQbD5Ol0FBLZrsJJAExaDbi4o1K4xuhD3EiPnL41ajJ6JpL2X2BFiPL1EN152J5cK8oWGAVc9N0BHqQ4EjcduMKUQy8CZ8tqgtiSbTAT8KthKTWFGFbVJxnq0R94cJGexGMx9wUTfNJjlUY2kytbRdVy9R1SSrUuRDBDaeiXmPBYhJoybRO8CkIzAthMs/PwduHDW7eYLDJlyIkgHzgUD7C/T1whIYtG4aB7qNWxdmHKU9rFmNaIwHd2X/nZ3/77o9vtwKBmYPYc4mmTfoIGx+2ECOWoDL0tKcutqB6Zkdh60donMN6VT3xXE5IrOhPQ3IQ77p0x9Idf6DwKkAMj/7+/Q/zH/8yiFJbaEI3FW1LkfZ5NC6qFrBg6prDHj9xM7pyNgbfazI3AZGr5tk+4VKDh4RlEweqX06ovpFCZfznf2aL3zwJGBiAjG60NQ9ZGP4IjVADtIi4IuvrZ6KoTjJObM0MdTJJOZGUmOS17UvMu+53Pansq2VYuc8JPamKA4NC7Qt1Vw7xCRHh8J27Lx1XOR67dcq/NhBjEHhKVypEf05FVdp1izZSdSEFSj243wZwsuLuH1d4OsLB3rhC33rP2DFIzTSoKtA7nmqTJm3Giqtr2NOsYBR0CNcabjNlhYH+qoq09HRQoNP6JRxBXnCO8/HoXhSsyi6+BAH2DPMSGNaGay1XIXHg170+qoLDrFyFowi4qK/2w4Z0WoVMJoVp6iXKSm7oTD8QgrLWlrYeF6zLmuyrrd6x8n+1NReP3rGtXq69tLWlqh7b2spG321thWjX1tiJ3q2tg2ENa801yBBAsa5h/zhv5DxKDCllcAldrq/EznpMea7GxDnoUry41zphtysmBt9DMX4Xl5OiBVeIsOTbySUHhm36lO7o06aWlgtMD8VEFuogHAjN7L9ZT8fZh7PBO9aIJq+ld+6mV95PG7aup6GGqTKHLa+TYMupl7nlNhrXrMheSyQifiXrRsRQIhF+o+ejvXAv7HDtjrfsZrKZbFYrM+QymSnKUL1yE39w9EvNqPeseLtBz0K0bm86gZ+lNnbJBFUuk6CnQazuKyf+sLowPYll+83qImAR22Saji+fpl4XUuv7shtXcAuc8i75gCwfzgI9rDe/hAqU++riG+h456BQyu8VcuX8bim3/+FGoVzMFXLZUv7ZbmJWjTdTD8mM6Mq5CZyhqw81RSjpCjU0SONRC+6A/E50RZTDP8rPT8kIN3vIaUw+V0vnjHTAud0DzhBVvZdoG4zZnqr5tQPC/IURFi+McOvCCOkLI9wDhP8AJzKpWzEUAAA=";
82      private static final Log log = LogFactory.getLog(CalcifiedPiecesSamplingEditorUI.class);
83      private static final long serialVersionUID = 1L;
84  
85      /*-----------------------------------------------------------------------*/
86      /*--------------------------- Internal states ---------------------------*/
87      /*-----------------------------------------------------------------------*/
88  
89      protected List<Object> $activeBindings = new ArrayList<Object>();
90      protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
91      protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
92      protected Map<String, Object> $objectMap = new HashMap<String, Object>();
93      protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
94      private boolean allComponentsCreated;
95      protected final JAXXContext delegateContext = new DefaultJAXXContext();
96  
97      /*-----------------------------------------------------------------------*/
98      /*------------------------ Protected components  ------------------------*/
99      /*-----------------------------------------------------------------------*/
100 
101     protected JButton addSpeciesButton;
102     protected JPanel cpsActions;
103     protected CalcifiedPiecesSamplingEditorUI cpsPanel = this;
104     protected JXTable cpsTable;
105     protected JPopupMenu cpsTablePopup;
106     protected JMenuItem deleteCpsRowMenu;
107     protected JMenuItem deleteSpeciesMenu;
108     protected JButton exportCpsButton;
109     protected final CalcifiedPiecesSamplingEditorUIHandler handler = createHandler();
110     protected JButton importCpsButton;
111     protected JCheckBox maturityCheckBox;
112     protected EditProtocolUIModel model;
113     protected BeanFilterableComboBox<Species> speciesComboBox;
114     protected JMenuItem splitCpsRowMenu;
115 
116     /*-----------------------------------------------------------------------*/
117     /*------------------------- Private components  -------------------------*/
118     /*-----------------------------------------------------------------------*/
119 
120     private JScrollPane $JScrollPane0;
121     private Table $Table0;
122 
123     /*-----------------------------------------------------------------------*/
124     /*---------------------------- Constructors  ----------------------------*/
125     /*-----------------------------------------------------------------------*/
126 
127     public CalcifiedPiecesSamplingEditorUI(TuttiUI parentUI) {
128         TuttiUIUtil.setParentUI(this, parentUI);
129             $initialize();
130     }
131 
132     public CalcifiedPiecesSamplingEditorUI(LayoutManager param0, boolean param1) {
133         super(param0 ,param1);
134         $initialize();
135     }
136 
137     public CalcifiedPiecesSamplingEditorUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
138         super(param1 ,param2);
139         JAXXUtil.initContext(this, parentContext);
140         $initialize();
141     }
142 
143     public CalcifiedPiecesSamplingEditorUI(LayoutManager param0) {
144         super(param0);
145         $initialize();
146     }
147 
148     public CalcifiedPiecesSamplingEditorUI(JAXXContext parentContext, LayoutManager param1) {
149         super(param1);
150         JAXXUtil.initContext(this, parentContext);
151         $initialize();
152     }
153 
154     public CalcifiedPiecesSamplingEditorUI() {
155         $initialize();
156     }
157 
158     public CalcifiedPiecesSamplingEditorUI(JAXXContext parentContext) {
159         JAXXUtil.initContext(this, parentContext);
160         $initialize();
161     }
162 
163     public CalcifiedPiecesSamplingEditorUI(boolean param0) {
164         super(param0);
165         $initialize();
166     }
167 
168     public CalcifiedPiecesSamplingEditorUI(JAXXContext parentContext, boolean param1) {
169         super(param1);
170         JAXXUtil.initContext(this, parentContext);
171         $initialize();
172     }
173 
174     /*-----------------------------------------------------------------------*/
175     /*--------------------------- Statics methods ---------------------------*/
176     /*-----------------------------------------------------------------------*/
177 
178     public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
179         return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
180     }
181 
182     /*-----------------------------------------------------------------------*/
183     /*---------------------- JAXXObject implementation ----------------------*/
184     /*-----------------------------------------------------------------------*/
185 
186     @Override
187     public void applyDataBinding(String $binding) {
188         if (allComponentsCreated && $bindings.containsKey($binding)) {
189             getDataBinding($binding).applyDataBinding();
190         }
191         processDataBinding($binding);
192     }
193 
194     @Override
195     public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
196         super.firePropertyChange(propertyName, oldValue, newValue);
197     }
198 
199     @Override
200     public Map<String, Object> get$objectMap() {
201         return $objectMap;
202     }
203 
204     @Override
205     public JAXXBinding getDataBinding(String bindingId) {
206         return $bindings.get(bindingId);
207     }
208 
209     @Override
210     public JAXXBinding[] getDataBindings() {
211         return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
212     }
213 
214     @Override
215     public Object getObjectById(String id) {
216         return $objectMap.get(id);
217     }
218 
219     @Override
220     public void processDataBinding(String $binding, boolean $force) {
221         if (!$force && $activeBindings.contains($binding)) { 
222             return;
223         }
224         $activeBindings.add($binding);
225         try {
226             if (allComponentsCreated && $bindings.containsKey($binding)) {
227                 getDataBinding($binding).processDataBinding();
228             }
229         } finally {
230             $activeBindings.remove($binding);
231         }
232     }
233 
234     @Override
235     public void processDataBinding(String $binding) {
236         processDataBinding($binding, false);
237     }
238 
239     @Override
240     public void registerDataBinding(JAXXBinding binding) {
241         $bindings.put(binding.getId(), binding);
242     }
243 
244     @Override
245     public void removeDataBinding(String $binding) {
246         if (allComponentsCreated && $bindings.containsKey($binding)) {
247             getDataBinding($binding).removeDataBinding();
248         }
249     }
250 
251     /*-----------------------------------------------------------------------*/
252     /*--------------------- JAXXContext implementation  ---------------------*/
253     /*-----------------------------------------------------------------------*/
254 
255     @Override
256     public <T> T getContextValue(Class<T> clazz) {
257         return delegateContext.getContextValue(clazz, null);
258     }
259 
260     @Override
261     public <T> T getContextValue(Class<T> clazz, String name) {
262         return delegateContext.getContextValue(clazz, name);
263     }
264 
265     @Override
266     public JAXXContext getDelegateContext() {
267         return delegateContext;
268     }
269 
270     @Override
271     public <O extends Container> O getParentContainer(Class<O> clazz) {
272         return SwingUtil.getParentContainer(this, clazz);
273     }
274 
275     @Override
276     public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
277         return SwingUtil.getParentContainer(source, clazz);
278     }
279 
280     @Override
281     public <T> void removeContextValue(Class<T> clazz) {
282         delegateContext.removeContextValue(clazz, null);
283     }
284 
285     @Override
286     public <T> void removeContextValue(Class<T> clazz, String name) {
287         delegateContext.removeContextValue(clazz, name);
288     }
289 
290     @Override
291     public <T> void setContextValue(T o) {
292         delegateContext.setContextValue(o, null);
293     }
294 
295     @Override
296     public <T> void setContextValue(T o, String name) {
297         delegateContext.setContextValue(o, name);
298     }
299 
300     /*-----------------------------------------------------------------------*/
301     /*---------------------------- Event methods ----------------------------*/
302     /*-----------------------------------------------------------------------*/
303 
304     public void doKeyPressed__on__cpsTable(KeyEvent event) {
305         if (log.isDebugEnabled()) {
306             log.debug(event);
307         }
308         handler.openRowMenu(event, cpsTablePopup);
309     }
310 
311     public void doMouseClicked__on__cpsTable(MouseEvent event) {
312         if (log.isDebugEnabled()) {
313             log.debug(event);
314         }
315         handler.autoSelectRowInTable(event, cpsTablePopup);
316     }
317 
318     /*-----------------------------------------------------------------------*/
319     /*----------------------- Public acessor methods  -----------------------*/
320     /*-----------------------------------------------------------------------*/
321 
322     public JButton getAddSpeciesButton() {
323         return addSpeciesButton;
324     }
325 
326     public JPanel getCpsActions() {
327         return cpsActions;
328     }
329 
330     public JXTable getCpsTable() {
331         return cpsTable;
332     }
333 
334     public JPopupMenu getCpsTablePopup() {
335         return cpsTablePopup;
336     }
337 
338     public JMenuItem getDeleteCpsRowMenu() {
339         return deleteCpsRowMenu;
340     }
341 
342     public JMenuItem getDeleteSpeciesMenu() {
343         return deleteSpeciesMenu;
344     }
345 
346     public JButton getExportCpsButton() {
347         return exportCpsButton;
348     }
349 
350     public CalcifiedPiecesSamplingEditorUIHandler getHandler() {
351         return handler;
352     }
353 
354     public JButton getImportCpsButton() {
355         return importCpsButton;
356     }
357 
358     public JCheckBox getMaturityCheckBox() {
359         return maturityCheckBox;
360     }
361 
362     public EditProtocolUIModel getModel() {
363         return model;
364     }
365 
366     public BeanFilterableComboBox<Species> getSpeciesComboBox() {
367         return speciesComboBox;
368     }
369 
370     public JMenuItem getSplitCpsRowMenu() {
371         return splitCpsRowMenu;
372     }
373 
374     /*-----------------------------------------------------------------------*/
375     /*--------------------- Protected acessors methods  ---------------------*/
376     /*-----------------------------------------------------------------------*/
377 
378     protected JScrollPane get$JScrollPane0() {
379         return $JScrollPane0;
380     }
381 
382     protected Table get$Table0() {
383         return $Table0;
384     }
385 
386     /*-----------------------------------------------------------------------*/
387     /*--------------------- Components creation methods ---------------------*/
388     /*-----------------------------------------------------------------------*/
389 
390     protected void addChildrenToCpsActions() {
391         if (!allComponentsCreated) {
392             return;
393         }
394         cpsActions.add(importCpsButton);
395         cpsActions.add(exportCpsButton);
396     }
397 
398     protected void addChildrenToCpsPanel() {
399         if (!allComponentsCreated) {
400             return;
401         }
402         add(cpsActions, BorderLayout.NORTH);
403         add($Table0, BorderLayout.CENTER);
404     }
405 
406     protected void addChildrenToCpsTablePopup() {
407         if (!allComponentsCreated) {
408             return;
409         }
410         cpsTablePopup.add(splitCpsRowMenu);
411         cpsTablePopup.add(deleteCpsRowMenu);
412         cpsTablePopup.add(deleteSpeciesMenu);
413     }
414 
415     protected void createAddSpeciesButton() {
416         $objectMap.put("addSpeciesButton", addSpeciesButton = new JButton());
417         
418         addSpeciesButton.setName("addSpeciesButton");
419         addSpeciesButton.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.protocol.calcifiedpiecessampling.actions.AddSpeciesAction.class);
420     }
421 
422     protected void createCpsActions() {
423         $objectMap.put("cpsActions", cpsActions = new JPanel());
424         
425         cpsActions.setName("cpsActions");
426         cpsActions.setLayout(new GridLayout());
427     }
428 
429     protected void createCpsTable() {
430         $objectMap.put("cpsTable", cpsTable = new JXTable());
431         
432         cpsTable.setName("cpsTable");
433         cpsTable.addKeyListener(JAXXUtil.getEventListener(KeyListener.class, "keyPressed", this, "doKeyPressed__on__cpsTable"));
434         cpsTable.addMouseListener(JAXXUtil.getEventListener(MouseListener.class, "mouseClicked", this, "doMouseClicked__on__cpsTable"));
435     }
436 
437     protected void createCpsTablePopup() {
438         $objectMap.put("cpsTablePopup", cpsTablePopup = new JPopupMenu());
439         
440         cpsTablePopup.setName("cpsTablePopup");
441     }
442 
443     protected void createDeleteCpsRowMenu() {
444         $objectMap.put("deleteCpsRowMenu", deleteCpsRowMenu = new JMenuItem());
445         
446         deleteCpsRowMenu.setName("deleteCpsRowMenu");
447         deleteCpsRowMenu.setText(t("tutti.editCps.deleteRow"));
448         deleteCpsRowMenu.setToolTipText(t("tutti.editCps.deleteRow.tip"));
449         deleteCpsRowMenu.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.protocol.calcifiedpiecessampling.actions.DeleteRowAction.class);
450     }
451 
452     protected void createDeleteSpeciesMenu() {
453         $objectMap.put("deleteSpeciesMenu", deleteSpeciesMenu = new JMenuItem());
454         
455         deleteSpeciesMenu.setName("deleteSpeciesMenu");
456         deleteSpeciesMenu.setText(t("tutti.editCps.deleteSpecies"));
457         deleteSpeciesMenu.setToolTipText(t("tutti.editCps.deleteSpecies.tip"));
458         deleteSpeciesMenu.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.protocol.calcifiedpiecessampling.actions.DeleteSpeciesAction.class);
459     }
460 
461     protected void createExportCpsButton() {
462         $objectMap.put("exportCpsButton", exportCpsButton = new JButton());
463         
464         exportCpsButton.setName("exportCpsButton");
465         exportCpsButton.setText(t("tutti.editProtocol.action.exportProtocolCps"));
466         exportCpsButton.setToolTipText(t("tutti.editProtocol.action.exportProtocolCps.tip"));
467         exportCpsButton.putClientProperty("help", "tutti.editProtocol.action.exportProtocolCps.help");
468         exportCpsButton.putClientProperty("applicationAction", fr.ifremer.tutti.ui.swing.content.protocol.calcifiedpiecessampling.actions.ExportProtocolCpsAction.class);
469     }
470 
471     protected CalcifiedPiecesSamplingEditorUIHandler createHandler() {
472         return new CalcifiedPiecesSamplingEditorUIHandler();
473     }
474 
475     protected void createImportCpsButton() {
476         $objectMap.put("importCpsButton", importCpsButton = new JButton());
477         
478         importCpsButton.setName("importCpsButton");
479         importCpsButton.setText(t("tutti.editProtocol.action.importProtocolCps"));
480         importCpsButton.setToolTipText(t("tutti.editProtocol.action.importProtocolCps.tip"));
481         importCpsButton.putClientProperty("help", "tutti.editProtocol.action.importProtocolCps.help");
482         importCpsButton.putClientProperty("applicationAction", fr.ifremer.tutti.ui.swing.content.protocol.calcifiedpiecessampling.actions.ImportProtocolCpsAction.class);
483     }
484 
485     protected void createMaturityCheckBox() {
486         $objectMap.put("maturityCheckBox", maturityCheckBox = new JCheckBox());
487         
488         maturityCheckBox.setName("maturityCheckBox");
489         maturityCheckBox.setText(t("tutti.editCps.field.maturity"));
490         maturityCheckBox.setToolTipText(t("tutti.editCps.field.maturity.tip"));
491         maturityCheckBox.putClientProperty("help", "tutti.editCps.field.maturity.help");
492     }
493 
494     protected void createModel() {
495         $objectMap.put("model", model = getContextValue(EditProtocolUIModel.class));
496     }
497 
498     protected void createSpeciesComboBox() {
499         $objectMap.put("speciesComboBox", speciesComboBox = new BeanFilterableComboBox<Species>(this));
500         
501         speciesComboBox.setName("speciesComboBox");
502         speciesComboBox.setShowReset(true);
503         speciesComboBox.setToolTipText(t("tutti.editCps.field.species.tip"));
504         speciesComboBox.putClientProperty("help", "tutti.editCps.field.species.help");
505     }
506 
507     protected void createSplitCpsRowMenu() {
508         $objectMap.put("splitCpsRowMenu", splitCpsRowMenu = new JMenuItem());
509         
510         splitCpsRowMenu.setName("splitCpsRowMenu");
511         splitCpsRowMenu.setText(t("tutti.editCps.splitRow"));
512         splitCpsRowMenu.setToolTipText(t("tutti.editCps.splitRow.tip"));
513         splitCpsRowMenu.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.protocol.calcifiedpiecessampling.actions.SplitSpeciesAction.class);
514     }
515 
516     /*-----------------------------------------------------------------------*/
517     /*------------------------ Internal jaxx methods ------------------------*/
518     /*-----------------------------------------------------------------------*/
519 
520     private void $completeSetup() {
521         allComponentsCreated = true;
522         if (log.isDebugEnabled()) {
523             log.debug(this);
524         }
525         addChildrenToCpsPanel();
526         addChildrenToCpsTablePopup();
527         addChildrenToCpsActions();
528         // inline complete setup of $Table0
529         $Table0.add(speciesComboBox, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
530         $Table0.add(maturityCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
531         $Table0.add(addSpeciesButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
532         $Table0.add($JScrollPane0, new GridBagConstraints(0, 1, 3, 1, 0.0, 1.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
533         // inline complete setup of $JScrollPane0
534         $JScrollPane0.getViewport().add(cpsTable);
535         
536         // apply 2 data bindings
537         JAXXUtil.applyDataBinding(this, $bindings.keySet());
538         
539         // apply 12 property setters
540         speciesComboBox.setBeanType(Species.class);
541         splitCpsRowMenu.setIcon(SwingUtil.createActionIcon("add"));
542         deleteCpsRowMenu.setIcon(SwingUtil.createActionIcon("delete2"));
543         deleteSpeciesMenu.setIcon(SwingUtil.createActionIcon("delete2"));
544         importCpsButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.editProtocol.action.importProtocolCps.mnemonic"),'Z'));
545         importCpsButton.setIcon(SwingUtil.createActionIcon("import"));
546         exportCpsButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.editProtocol.action.exportProtocolCps.mnemonic"),'Z'));
547         exportCpsButton.setIcon(SwingUtil.createActionIcon("export"));
548         addSpeciesButton.setIcon(SwingUtil.createActionIcon("add"));
549         cpsTable.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
550     }
551 
552     private void $initialize() {
553         if (allComponentsCreated) {
554             return;
555         }
556         if (log.isDebugEnabled()) {
557             log.debug(this);
558         }
559         handler.beforeInit(this);
560         $objectMap.put("cpsPanel", cpsPanel);
561         createModel();
562         createCpsTablePopup();
563         createSplitCpsRowMenu();
564         createDeleteCpsRowMenu();
565         createDeleteSpeciesMenu();
566         createCpsActions();
567         createImportCpsButton();
568         createExportCpsButton();
569         // inline creation of $Table0
570         $objectMap.put("$Table0", $Table0 = new Table());
571         
572         $Table0.setName("$Table0");
573         createSpeciesComboBox();
574         createMaturityCheckBox();
575         createAddSpeciesButton();
576         // inline creation of $JScrollPane0
577         $objectMap.put("$JScrollPane0", $JScrollPane0 = new JScrollPane());
578         
579         $JScrollPane0.setName("$JScrollPane0");
580         createCpsTable();
581         // inline creation of cpsPanel
582         setName("cpsPanel");
583         setLayout(new BorderLayout());
584         
585         // registers 2 data bindings
586         $registerDefaultBindings();
587         $completeSetup();
588         handler.afterInit(this);
589     }
590 
591     private void $registerDefaultBindings() {
592         // register 2 data bindings
593         registerDataBinding(new DefaultJAXXBinding(this, BINDING_SPECIES_COMBO_BOX_ENABLED, true) {
594         
595             @Override
596             public void applyDataBinding() {
597                 if (speciesComboBox != null) {
598                     speciesComboBox.addPropertyChangeListener("empty", this);
599                 }
600             }
601         
602             @Override
603             public void processDataBinding() {
604                 if (speciesComboBox != null) {
605                     speciesComboBox.setEnabled(!speciesComboBox.isEmpty());
606                 }
607             }
608         
609             @Override
610             public void removeDataBinding() {
611                 if (speciesComboBox != null) {
612                     speciesComboBox.removePropertyChangeListener("empty", this);
613                 }
614             }
615         });
616         registerDataBinding(new DefaultJAXXBinding(this, BINDING_ADD_SPECIES_BUTTON_ENABLED, true) {
617         
618             @Override
619             public void applyDataBinding() {
620                 if (speciesComboBox != null) {
621                     speciesComboBox.addPropertyChangeListener("selectedItem", this);
622                 }
623             }
624         
625             @Override
626             public void processDataBinding() {
627                 if (speciesComboBox != null) {
628                     addSpeciesButton.setEnabled( speciesComboBox.getSelectedItem() != null );
629                 }
630             }
631         
632             @Override
633             public void removeDataBinding() {
634                 if (speciesComboBox != null) {
635                     speciesComboBox.removePropertyChangeListener("selectedItem", this);
636                 }
637             }
638         });
639     }
640 
641 }