View Javadoc
1   package fr.ifremer.reefdb.ui.swing.content.manage.referential.pmfm.menu;
2   
3   /*-
4    * #%L
5    * Reef DB :: UI
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2014 - 2022 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU Affero General Public License as published by
13   * the Free Software Foundation, either version 3 of the License, or
14   * (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 Affero General Public License
22   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23   * #L%
24   */
25  
26  
27  import fr.ifremer.quadrige3.ui.core.dto.referential.StatusDTO;
28  import fr.ifremer.quadrige3.ui.swing.ApplicationUI;
29  import fr.ifremer.quadrige3.ui.swing.ApplicationUIUtil;
30  import fr.ifremer.quadrige3.ui.swing.component.bean.ExtendedComboBox;
31  import fr.ifremer.reefdb.dto.BooleanDTO;
32  import fr.ifremer.reefdb.dto.referential.UnitDTO;
33  import fr.ifremer.reefdb.dto.referential.pmfm.FractionDTO;
34  import fr.ifremer.reefdb.dto.referential.pmfm.MatrixDTO;
35  import fr.ifremer.reefdb.dto.referential.pmfm.MethodDTO;
36  import fr.ifremer.reefdb.dto.referential.pmfm.ParameterDTO;
37  import fr.ifremer.reefdb.ui.swing.ReefDbHelpBroker;
38  import fr.ifremer.reefdb.ui.swing.ReefDbUIContext;
39  import fr.ifremer.reefdb.ui.swing.content.manage.filter.element.menu.ApplyFilterUI;
40  import fr.ifremer.reefdb.ui.swing.content.manage.referential.menu.ReferentialMenuUI;
41  import fr.ifremer.reefdb.ui.swing.util.ReefDbUI;
42  import java.awt.BorderLayout;
43  import java.awt.Component;
44  import java.awt.Container;
45  import java.awt.FlowLayout;
46  import java.awt.GridBagConstraints;
47  import java.awt.GridLayout;
48  import java.awt.Insets;
49  import java.awt.LayoutManager;
50  import java.awt.event.KeyEvent;
51  import java.awt.event.KeyListener;
52  import java.util.ArrayList;
53  import java.util.HashMap;
54  import java.util.List;
55  import java.util.Map;
56  import java.util.TreeMap;
57  import javax.swing.BorderFactory;
58  import javax.swing.Box;
59  import javax.swing.BoxLayout;
60  import javax.swing.JButton;
61  import javax.swing.JLabel;
62  import javax.swing.JPanel;
63  import javax.swing.JTextField;
64  import javax.swing.SwingConstants;
65  import jaxx.runtime.JAXXBinding;
66  import jaxx.runtime.JAXXContext;
67  import jaxx.runtime.JAXXObject;
68  import jaxx.runtime.JAXXObjectDescriptor;
69  import jaxx.runtime.JAXXUtil;
70  import jaxx.runtime.SwingUtil;
71  import jaxx.runtime.binding.DefaultJAXXBinding;
72  import jaxx.runtime.context.DefaultJAXXContext;
73  import jaxx.runtime.swing.Table;
74  import jaxx.runtime.swing.help.JAXXHelpUI;
75  import org.apache.commons.logging.Log;
76  import org.apache.commons.logging.LogFactory;
77  import static org.nuiton.i18n.I18n.t;
78  
79  public class PmfmMenuUI extends JPanel implements JAXXHelpUI<ReefDbHelpBroker>, ReferentialMenuUI<PmfmMenuUIModel, PmfmMenuUIHandler>, JAXXObject {
80  
81      /*-----------------------------------------------------------------------*/
82      /*------------------ Constants for all public bindings ------------------*/
83      /*-----------------------------------------------------------------------*/
84  
85      public static final String BINDING_FRACTIONS_COMBO_SELECTED_ITEM = "fractionsCombo.selectedItem";
86      public static final String BINDING_LOCAL_COMBO_SELECTED_ITEM = "localCombo.selectedItem";
87      public static final String BINDING_MATRICES_COMBO_SELECTED_ITEM = "matricesCombo.selectedItem";
88      public static final String BINDING_METHODS_COMBO_SELECTED_ITEM = "methodsCombo.selectedItem";
89      public static final String BINDING_NAME_EDITOR_TEXT = "nameEditor.text";
90      public static final String BINDING_PARAMETERS_COMBO_SELECTED_ITEM = "parametersCombo.selectedItem";
91      public static final String BINDING_STATUS_COMBO_SELECTED_ITEM = "statusCombo.selectedItem";
92      public static final String BINDING_UNITS_COMBO_SELECTED_ITEM = "unitsCombo.selectedItem";
93  
94      /*-----------------------------------------------------------------------*/
95      /*------------------------- Other static fields -------------------------*/
96      /*-----------------------------------------------------------------------*/
97  
98      private static final String $jaxxObjectDescriptor = "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";
99      private static final Log log = LogFactory.getLog(PmfmMenuUI.class);
100     private static final long serialVersionUID = 1L;
101 
102     /*-----------------------------------------------------------------------*/
103     /*--------------------------- Internal states ---------------------------*/
104     /*-----------------------------------------------------------------------*/
105 
106     protected List<Object> $activeBindings = new ArrayList<Object>();
107     protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
108     protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
109     protected Map<String, Object> $objectMap = new HashMap<String, Object>();
110     protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
111     private boolean allComponentsCreated;
112     protected final JAXXContext delegateContext = new DefaultJAXXContext();
113 
114     /*-----------------------------------------------------------------------*/
115     /*------------------------ Protected components  ------------------------*/
116     /*-----------------------------------------------------------------------*/
117 
118     protected ApplyFilterUI applyFilterUI;
119     protected ReefDbHelpBroker broker;
120     protected JButton clearButton;
121     protected ExtendedComboBox<FractionDTO> fractionsCombo;
122     protected JLabel fractionsLabel;
123     protected final PmfmMenuUIHandler handler = createHandler();
124     protected ExtendedComboBox<BooleanDTO> localCombo;
125     protected JLabel localLabel;
126     protected JPanel localPanel;
127     protected ExtendedComboBox<MatrixDTO> matricesCombo;
128     protected JLabel matricesLabel;
129     protected JPanel menuPanel;
130     protected ExtendedComboBox<MethodDTO> methodsCombo;
131     protected JLabel methodsLabel;
132     protected PmfmMenuUIModel model;
133     protected JTextField nameEditor;
134     protected JLabel nameLabel;
135     protected JPanel namePanel;
136     protected ExtendedComboBox<ParameterDTO> parametersCombo;
137     protected JLabel parametersLabel;
138     protected JButton searchButton;
139     protected JPanel selectionButtonsPanel;
140     protected Table selectionPanel;
141     protected ExtendedComboBox<StatusDTO> statusCombo;
142     protected JLabel statusLabel;
143     protected ExtendedComboBox<UnitDTO> unitsCombo;
144     protected JLabel unitsLabel;
145 
146     /*-----------------------------------------------------------------------*/
147     /*------------------------- Private components  -------------------------*/
148     /*-----------------------------------------------------------------------*/
149 
150     private PmfmMenuUI $JPanel0 = this;
151     private JPanel $JPanel1;
152     private JPanel $JPanel2;
153     private JPanel $JPanel3;
154     private JPanel $JPanel4;
155     private JPanel $JPanel5;
156     private JPanel $JPanel6;
157 
158     /*-----------------------------------------------------------------------*/
159     /*---------------------------- Constructors  ----------------------------*/
160     /*-----------------------------------------------------------------------*/
161 
162     public PmfmMenuUI(ApplicationUI parentUI) {
163         ApplicationUIUtil.setParentUI(this, parentUI);
164             $initialize();
165     }
166 
167     public PmfmMenuUI(LayoutManager param0, boolean param1) {
168         super(param0 ,param1);
169         $initialize();
170     }
171 
172     public PmfmMenuUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
173         super(param1 ,param2);
174         JAXXUtil.initContext(this, parentContext);
175         $initialize();
176     }
177 
178     public PmfmMenuUI(boolean param0) {
179         super(param0);
180         $initialize();
181     }
182 
183     public PmfmMenuUI(JAXXContext parentContext, boolean param1) {
184         super(param1);
185         JAXXUtil.initContext(this, parentContext);
186         $initialize();
187     }
188 
189     public PmfmMenuUI() {
190         $initialize();
191     }
192 
193     public PmfmMenuUI(JAXXContext parentContext) {
194         JAXXUtil.initContext(this, parentContext);
195         $initialize();
196     }
197 
198     public PmfmMenuUI(LayoutManager param0) {
199         super(param0);
200         $initialize();
201     }
202 
203     public PmfmMenuUI(JAXXContext parentContext, LayoutManager param1) {
204         super(param1);
205         JAXXUtil.initContext(this, parentContext);
206         $initialize();
207     }
208 
209     /*-----------------------------------------------------------------------*/
210     /*--------------------------- Statics methods ---------------------------*/
211     /*-----------------------------------------------------------------------*/
212 
213     public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
214         return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
215     }
216 
217     /*-----------------------------------------------------------------------*/
218     /*---------------------- JAXXObject implementation ----------------------*/
219     /*-----------------------------------------------------------------------*/
220 
221     @Override
222     public void applyDataBinding(String $binding) {
223         if (allComponentsCreated && $bindings.containsKey($binding)) {
224             getDataBinding($binding).applyDataBinding();
225         }
226         processDataBinding($binding);
227     }
228 
229     @Override
230     public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
231         super.firePropertyChange(propertyName, oldValue, newValue);
232     }
233 
234     @Override
235     public Map<String, Object> get$objectMap() {
236         return $objectMap;
237     }
238 
239     @Override
240     public JAXXBinding getDataBinding(String bindingId) {
241         return $bindings.get(bindingId);
242     }
243 
244     @Override
245     public JAXXBinding[] getDataBindings() {
246         return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
247     }
248 
249     @Override
250     public Object getObjectById(String id) {
251         return $objectMap.get(id);
252     }
253 
254     @Override
255     public void processDataBinding(String $binding, boolean $force) {
256         if (!$force && $activeBindings.contains($binding)) { 
257             return;
258         }
259         $activeBindings.add($binding);
260         try {
261             if (allComponentsCreated && $bindings.containsKey($binding)) {
262                 getDataBinding($binding).processDataBinding();
263             }
264         } finally {
265             $activeBindings.remove($binding);
266         }
267     }
268 
269     @Override
270     public void processDataBinding(String $binding) {
271         processDataBinding($binding, false);
272     }
273 
274     @Override
275     public void registerDataBinding(JAXXBinding binding) {
276         $bindings.put(binding.getId(), binding);
277     }
278 
279     @Override
280     public void removeDataBinding(String $binding) {
281         if (allComponentsCreated && $bindings.containsKey($binding)) {
282             getDataBinding($binding).removeDataBinding();
283         }
284     }
285 
286     /*-----------------------------------------------------------------------*/
287     /*--------------------- JAXXContext implementation  ---------------------*/
288     /*-----------------------------------------------------------------------*/
289 
290     @Override
291     public <T> T getContextValue(Class<T> clazz) {
292         return delegateContext.getContextValue(clazz, null);
293     }
294 
295     @Override
296     public <T> T getContextValue(Class<T> clazz, String name) {
297         return delegateContext.getContextValue(clazz, name);
298     }
299 
300     @Override
301     public JAXXContext getDelegateContext() {
302         return delegateContext;
303     }
304 
305     @Override
306     public <O extends Container> O getParentContainer(Class<O> clazz) {
307         return SwingUtil.getParentContainer(this, clazz);
308     }
309 
310     @Override
311     public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
312         return SwingUtil.getParentContainer(source, clazz);
313     }
314 
315     @Override
316     public <T> void removeContextValue(Class<T> clazz) {
317         delegateContext.removeContextValue(clazz, null);
318     }
319 
320     @Override
321     public <T> void removeContextValue(Class<T> clazz, String name) {
322         delegateContext.removeContextValue(clazz, name);
323     }
324 
325     @Override
326     public <T> void setContextValue(T o) {
327         delegateContext.setContextValue(o, null);
328     }
329 
330     @Override
331     public <T> void setContextValue(T o, String name) {
332         delegateContext.setContextValue(o, name);
333     }
334 
335     /*-----------------------------------------------------------------------*/
336     /*---------------------------- Event methods ----------------------------*/
337     /*-----------------------------------------------------------------------*/
338 
339     public void doKeyReleased__on__nameEditor(KeyEvent event) {
340         if (log.isDebugEnabled()) {
341             log.debug(event);
342         }
343         handler.setText(event, "name");
344     }
345 
346     /*-----------------------------------------------------------------------*/
347     /*----------------------- Public acessor methods  -----------------------*/
348     /*-----------------------------------------------------------------------*/
349 
350     public ApplyFilterUI getApplyFilterUI() {
351         return applyFilterUI;
352     }
353 
354     public ReefDbHelpBroker getBroker() {
355         return broker;
356     }
357 
358     public JButton getClearButton() {
359         return clearButton;
360     }
361 
362     public ExtendedComboBox<FractionDTO> getFractionsCombo() {
363         return fractionsCombo;
364     }
365 
366     public JLabel getFractionsLabel() {
367         return fractionsLabel;
368     }
369 
370     public PmfmMenuUIHandler getHandler() {
371         return handler;
372     }
373 
374     public ExtendedComboBox<BooleanDTO> getLocalCombo() {
375         return localCombo;
376     }
377 
378     public JLabel getLocalLabel() {
379         return localLabel;
380     }
381 
382     public JPanel getLocalPanel() {
383         return localPanel;
384     }
385 
386     public ExtendedComboBox<MatrixDTO> getMatricesCombo() {
387         return matricesCombo;
388     }
389 
390     public JLabel getMatricesLabel() {
391         return matricesLabel;
392     }
393 
394     public JPanel getMenuPanel() {
395         return menuPanel;
396     }
397 
398     public ExtendedComboBox<MethodDTO> getMethodsCombo() {
399         return methodsCombo;
400     }
401 
402     public JLabel getMethodsLabel() {
403         return methodsLabel;
404     }
405 
406     public PmfmMenuUIModel getModel() {
407         return model;
408     }
409 
410     public JTextField getNameEditor() {
411         return nameEditor;
412     }
413 
414     public JLabel getNameLabel() {
415         return nameLabel;
416     }
417 
418     public JPanel getNamePanel() {
419         return namePanel;
420     }
421 
422     public ExtendedComboBox<ParameterDTO> getParametersCombo() {
423         return parametersCombo;
424     }
425 
426     public JLabel getParametersLabel() {
427         return parametersLabel;
428     }
429 
430     public JButton getSearchButton() {
431         return searchButton;
432     }
433 
434     public JPanel getSelectionButtonsPanel() {
435         return selectionButtonsPanel;
436     }
437 
438     public Table getSelectionPanel() {
439         return selectionPanel;
440     }
441 
442     public ExtendedComboBox<StatusDTO> getStatusCombo() {
443         return statusCombo;
444     }
445 
446     public JLabel getStatusLabel() {
447         return statusLabel;
448     }
449 
450     public ExtendedComboBox<UnitDTO> getUnitsCombo() {
451         return unitsCombo;
452     }
453 
454     public JLabel getUnitsLabel() {
455         return unitsLabel;
456     }
457 
458     /*-----------------------------------------------------------------------*/
459     /*---------------------------- Other methods ----------------------------*/
460     /*-----------------------------------------------------------------------*/
461 
462     @Override
463     public void registerHelpId(ReefDbHelpBroker broker, Component component, String helpId) {
464         broker.installUI(component, helpId);
465     }
466 
467     @Override
468     public void showHelp(String helpId) {
469         getBroker().showHelp(this, helpId);
470     }
471 
472     /*-----------------------------------------------------------------------*/
473     /*--------------------- Protected acessors methods  ---------------------*/
474     /*-----------------------------------------------------------------------*/
475 
476     protected JPanel get$JPanel1() {
477         return $JPanel1;
478     }
479 
480     protected JPanel get$JPanel2() {
481         return $JPanel2;
482     }
483 
484     protected JPanel get$JPanel3() {
485         return $JPanel3;
486     }
487 
488     protected JPanel get$JPanel4() {
489         return $JPanel4;
490     }
491 
492     protected JPanel get$JPanel5() {
493         return $JPanel5;
494     }
495 
496     protected JPanel get$JPanel6() {
497         return $JPanel6;
498     }
499 
500     /*-----------------------------------------------------------------------*/
501     /*--------------------- Components creation methods ---------------------*/
502     /*-----------------------------------------------------------------------*/
503 
504     protected void addChildrenToLocalPanel() {
505         if (!allComponentsCreated) {
506             return;
507         }
508         localPanel.add(localLabel, BorderLayout.PAGE_START);
509         localPanel.add(localCombo, BorderLayout.CENTER);
510     }
511 
512     protected void addChildrenToMenuPanel() {
513         if (!allComponentsCreated) {
514             return;
515         }
516         menuPanel.add(applyFilterUI);
517         menuPanel.add(selectionPanel);
518         menuPanel.add(selectionButtonsPanel);
519     }
520 
521     protected void addChildrenToNamePanel() {
522         if (!allComponentsCreated) {
523             return;
524         }
525         namePanel.add(nameLabel, BorderLayout.PAGE_START);
526         namePanel.add(nameEditor, BorderLayout.CENTER);
527     }
528 
529     protected void addChildrenToSelectionButtonsPanel() {
530         if (!allComponentsCreated) {
531             return;
532         }
533         selectionButtonsPanel.add(clearButton);
534         selectionButtonsPanel.add(searchButton);
535     }
536 
537     protected void addChildrenToSelectionPanel() {
538         if (!allComponentsCreated) {
539             return;
540         }
541         selectionPanel.add(localPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
542         selectionPanel.add(namePanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
543         selectionPanel.add($JPanel1, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
544         selectionPanel.add($JPanel2, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
545         selectionPanel.add($JPanel3, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
546         selectionPanel.add($JPanel4, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
547         selectionPanel.add($JPanel5, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
548         selectionPanel.add($JPanel6, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
549     }
550 
551     protected void createApplyFilterUI() {
552         $objectMap.put("applyFilterUI", applyFilterUI = new ApplyFilterUI(this));
553         
554         applyFilterUI.setName("applyFilterUI");
555     }
556 
557     protected void createBroker() {
558         $objectMap.put("broker", broker = new ReefDbHelpBroker("reefdb.home.help"));
559     }
560 
561     protected void createClearButton() {
562         $objectMap.put("clearButton", clearButton = new JButton());
563         
564         clearButton.setName("clearButton");
565         clearButton.setText(t("reefdb.action.search.clear.label"));
566         clearButton.setToolTipText(t("reefdb.action.search.clear.tip"));
567         clearButton.putClientProperty("applicationAction", ClearAction.class);
568     }
569 
570     protected void createFractionsCombo() {
571         $objectMap.put("fractionsCombo", fractionsCombo = new ExtendedComboBox<FractionDTO>(this));
572         
573         fractionsCombo.setName("fractionsCombo");
574         fractionsCombo.setFilterable(true);
575         fractionsCombo.setShowDecorator(false);
576         fractionsCombo.setProperty("fraction");
577         fractionsCombo.setShowReset(true);
578     }
579 
580     protected void createFractionsLabel() {
581         $objectMap.put("fractionsLabel", fractionsLabel = new JLabel());
582         
583         fractionsLabel.setName("fractionsLabel");
584         fractionsLabel.setText(t("reefdb.property.pmfm.fraction"));
585     }
586 
587     protected PmfmMenuUIHandler createHandler() {
588         return new PmfmMenuUIHandler();
589     }
590 
591     protected void createLocalCombo() {
592         $objectMap.put("localCombo", localCombo = new ExtendedComboBox<BooleanDTO>(this));
593         
594         localCombo.setName("localCombo");
595         localCombo.setFilterable(true);
596         localCombo.setShowDecorator(false);
597         localCombo.setProperty("isLocal");
598         localCombo.setShowReset(true);
599     }
600 
601     protected void createLocalLabel() {
602         $objectMap.put("localLabel", localLabel = new JLabel());
603         
604         localLabel.setName("localLabel");
605         localLabel.setText(t("reefdb.filter.filterElement.local"));
606     }
607 
608     protected void createLocalPanel() {
609         $objectMap.put("localPanel", localPanel = new JPanel());
610         
611         localPanel.setName("localPanel");
612         localPanel.setLayout(new BorderLayout());
613     }
614 
615     protected void createMatricesCombo() {
616         $objectMap.put("matricesCombo", matricesCombo = new ExtendedComboBox<MatrixDTO>(this));
617         
618         matricesCombo.setName("matricesCombo");
619         matricesCombo.setFilterable(true);
620         matricesCombo.setShowDecorator(false);
621         matricesCombo.setProperty("matrix");
622         matricesCombo.setShowReset(true);
623     }
624 
625     protected void createMatricesLabel() {
626         $objectMap.put("matricesLabel", matricesLabel = new JLabel());
627         
628         matricesLabel.setName("matricesLabel");
629         matricesLabel.setText(t("reefdb.property.pmfm.matrix"));
630     }
631 
632     protected void createMenuPanel() {
633         $objectMap.put("menuPanel", menuPanel = new JPanel());
634         
635         menuPanel.setName("menuPanel");
636         menuPanel.setLayout(new BoxLayout(menuPanel, BoxLayout.PAGE_AXIS));
637     }
638 
639     protected void createMethodsCombo() {
640         $objectMap.put("methodsCombo", methodsCombo = new ExtendedComboBox<MethodDTO>(this));
641         
642         methodsCombo.setName("methodsCombo");
643         methodsCombo.setFilterable(true);
644         methodsCombo.setShowDecorator(false);
645         methodsCombo.setProperty("method");
646         methodsCombo.setShowReset(true);
647     }
648 
649     protected void createMethodsLabel() {
650         $objectMap.put("methodsLabel", methodsLabel = new JLabel());
651         
652         methodsLabel.setName("methodsLabel");
653         methodsLabel.setText(t("reefdb.property.pmfm.method"));
654     }
655 
656     protected void createModel() {
657         $objectMap.put("model", model = getContextValue(PmfmMenuUIModel.class));
658     }
659 
660     protected void createNameEditor() {
661         $objectMap.put("nameEditor", nameEditor = new JTextField());
662         
663         nameEditor.setName("nameEditor");
664         nameEditor.setColumns(15);
665         nameEditor.addKeyListener(JAXXUtil.getEventListener(KeyListener.class, "keyReleased", this, "doKeyReleased__on__nameEditor"));
666     }
667 
668     protected void createNameLabel() {
669         $objectMap.put("nameLabel", nameLabel = new JLabel());
670         
671         nameLabel.setName("nameLabel");
672         nameLabel.setText(t("reefdb.property.name"));
673     }
674 
675     protected void createNamePanel() {
676         $objectMap.put("namePanel", namePanel = new JPanel());
677         
678         namePanel.setName("namePanel");
679         namePanel.setLayout(new BorderLayout());
680     }
681 
682     protected void createParametersCombo() {
683         $objectMap.put("parametersCombo", parametersCombo = new ExtendedComboBox<ParameterDTO>(this));
684         
685         parametersCombo.setName("parametersCombo");
686         parametersCombo.setFilterable(true);
687         parametersCombo.setShowDecorator(false);
688         parametersCombo.setProperty("parameter");
689         parametersCombo.setShowReset(true);
690     }
691 
692     protected void createParametersLabel() {
693         $objectMap.put("parametersLabel", parametersLabel = new JLabel());
694         
695         parametersLabel.setName("parametersLabel");
696         parametersLabel.setText(t("reefdb.property.pmfm.parameter"));
697     }
698 
699     protected void createSearchButton() {
700         $objectMap.put("searchButton", searchButton = new JButton());
701         
702         searchButton.setName("searchButton");
703         searchButton.setText(t("reefdb.action.search.label"));
704         searchButton.setToolTipText(t("reefdb.action.search.tip"));
705         searchButton.putClientProperty("applicationAction", SearchAction.class);
706     }
707 
708     protected void createSelectionButtonsPanel() {
709         $objectMap.put("selectionButtonsPanel", selectionButtonsPanel = new JPanel());
710         
711         selectionButtonsPanel.setName("selectionButtonsPanel");
712         selectionButtonsPanel.setLayout(new GridLayout(1,0));
713     }
714 
715     protected void createSelectionPanel() {
716         $objectMap.put("selectionPanel", selectionPanel = new Table());
717         
718         selectionPanel.setName("selectionPanel");
719     }
720 
721     protected void createStatusCombo() {
722         $objectMap.put("statusCombo", statusCombo = new ExtendedComboBox<StatusDTO>(this));
723         
724         statusCombo.setName("statusCombo");
725         statusCombo.setFilterable(true);
726         statusCombo.setShowDecorator(false);
727         statusCombo.setProperty("status");
728         statusCombo.setShowReset(true);
729     }
730 
731     protected void createStatusLabel() {
732         $objectMap.put("statusLabel", statusLabel = new JLabel());
733         
734         statusLabel.setName("statusLabel");
735         statusLabel.setText(t("reefdb.property.status"));
736     }
737 
738     protected void createUnitsCombo() {
739         $objectMap.put("unitsCombo", unitsCombo = new ExtendedComboBox<UnitDTO>(this));
740         
741         unitsCombo.setName("unitsCombo");
742         unitsCombo.setFilterable(true);
743         unitsCombo.setShowDecorator(false);
744         unitsCombo.setProperty("unit");
745         unitsCombo.setShowReset(true);
746     }
747 
748     protected void createUnitsLabel() {
749         $objectMap.put("unitsLabel", unitsLabel = new JLabel());
750         
751         unitsLabel.setName("unitsLabel");
752         unitsLabel.setText(t("reefdb.property.pmfm.unit"));
753     }
754 
755     /*-----------------------------------------------------------------------*/
756     /*------------------------ Internal jaxx methods ------------------------*/
757     /*-----------------------------------------------------------------------*/
758 
759     private void $completeSetup() {
760         allComponentsCreated = true;
761         if (log.isDebugEnabled()) {
762             log.debug(this);
763         }
764         // inline complete setup of $JPanel0
765         add(menuPanel);
766         addChildrenToMenuPanel();
767         addChildrenToSelectionPanel();
768         addChildrenToLocalPanel();
769         addChildrenToNamePanel();
770         // inline complete setup of $JPanel1
771         $JPanel1.add(parametersLabel, BorderLayout.PAGE_START);
772         $JPanel1.add(parametersCombo, BorderLayout.CENTER);
773         // inline complete setup of $JPanel2
774         $JPanel2.add(matricesLabel, BorderLayout.PAGE_START);
775         $JPanel2.add(matricesCombo, BorderLayout.CENTER);
776         // inline complete setup of $JPanel3
777         $JPanel3.add(fractionsLabel, BorderLayout.PAGE_START);
778         $JPanel3.add(fractionsCombo, BorderLayout.CENTER);
779         // inline complete setup of $JPanel4
780         $JPanel4.add(methodsLabel, BorderLayout.PAGE_START);
781         $JPanel4.add(methodsCombo, BorderLayout.CENTER);
782         // inline complete setup of $JPanel5
783         $JPanel5.add(unitsLabel, BorderLayout.PAGE_START);
784         $JPanel5.add(unitsCombo, BorderLayout.CENTER);
785         // inline complete setup of $JPanel6
786         $JPanel6.add(statusLabel, BorderLayout.PAGE_START);
787         $JPanel6.add(statusCombo, BorderLayout.CENTER);
788         addChildrenToSelectionButtonsPanel();
789         
790         // apply 8 data bindings
791         JAXXUtil.applyDataBinding(this, $bindings.keySet());
792         
793         // apply 37 property setters
794         localCombo.setBeanType(BooleanDTO.class);
795         parametersCombo.setBeanType(ParameterDTO.class);
796         matricesCombo.setBeanType(MatrixDTO.class);
797         fractionsCombo.setBeanType(FractionDTO.class);
798         methodsCombo.setBeanType(MethodDTO.class);
799         unitsCombo.setBeanType(UnitDTO.class);
800         statusCombo.setBeanType(StatusDTO.class);
801         clearButton.setAlignmentX(Component.CENTER_ALIGNMENT);
802         searchButton.setAlignmentX(Component.CENTER_ALIGNMENT);
803         selectionPanel.setBorder(BorderFactory.createTitledBorder(t("reefdb.config.menu.title")));
804         localLabel.setLabelFor(localCombo);
805         localCombo.setBean(model);
806         nameLabel.setLabelFor(nameEditor);
807         parametersLabel.setLabelFor(parametersCombo);
808         parametersCombo.setBean(model);
809         matricesLabel.setLabelFor(matricesCombo);
810         matricesCombo.setBean(model);
811         fractionsLabel.setLabelFor(fractionsCombo);
812         fractionsCombo.setBean(model);
813         methodsLabel.setLabelFor(methodsCombo);
814         methodsCombo.setBean(model);
815         unitsLabel.setLabelFor(unitsCombo);
816         unitsCombo.setBean(model);
817         statusLabel.setLabelFor(statusCombo);
818         statusCombo.setBean(model);
819         clearButton.setIcon(SwingUtil.createActionIcon("reset"));
820         searchButton.setIcon(SwingUtil.createActionIcon("find"));
821     }
822 
823     private void $initialize() {
824         if (allComponentsCreated) {
825             return;
826         }
827         if (log.isDebugEnabled()) {
828             log.debug(this);
829         }
830         handler.beforeInit(this);
831         $objectMap.put("$JPanel0", $JPanel0);
832         createModel();
833         createBroker();
834         createMenuPanel();
835         createApplyFilterUI();
836         createSelectionPanel();
837         createLocalPanel();
838         createLocalLabel();
839         createLocalCombo();
840         createNamePanel();
841         createNameLabel();
842         createNameEditor();
843         // inline creation of $JPanel1
844         $objectMap.put("$JPanel1", $JPanel1 = new JPanel());
845         
846         $JPanel1.setName("$JPanel1");
847         $JPanel1.setLayout(new BorderLayout());
848         createParametersLabel();
849         createParametersCombo();
850         // inline creation of $JPanel2
851         $objectMap.put("$JPanel2", $JPanel2 = new JPanel());
852         
853         $JPanel2.setName("$JPanel2");
854         $JPanel2.setLayout(new BorderLayout());
855         createMatricesLabel();
856         createMatricesCombo();
857         // inline creation of $JPanel3
858         $objectMap.put("$JPanel3", $JPanel3 = new JPanel());
859         
860         $JPanel3.setName("$JPanel3");
861         $JPanel3.setLayout(new BorderLayout());
862         createFractionsLabel();
863         createFractionsCombo();
864         // inline creation of $JPanel4
865         $objectMap.put("$JPanel4", $JPanel4 = new JPanel());
866         
867         $JPanel4.setName("$JPanel4");
868         $JPanel4.setLayout(new BorderLayout());
869         createMethodsLabel();
870         createMethodsCombo();
871         // inline creation of $JPanel5
872         $objectMap.put("$JPanel5", $JPanel5 = new JPanel());
873         
874         $JPanel5.setName("$JPanel5");
875         $JPanel5.setLayout(new BorderLayout());
876         createUnitsLabel();
877         createUnitsCombo();
878         // inline creation of $JPanel6
879         $objectMap.put("$JPanel6", $JPanel6 = new JPanel());
880         
881         $JPanel6.setName("$JPanel6");
882         $JPanel6.setLayout(new BorderLayout());
883         createStatusLabel();
884         createStatusCombo();
885         createSelectionButtonsPanel();
886         createClearButton();
887         createSearchButton();
888         // inline creation of $JPanel0
889         setName("$JPanel0");
890         
891         // registers 8 data bindings
892         $registerDefaultBindings();
893         $completeSetup();
894         handler.afterInit(this);
895     }
896 
897     private void $registerDefaultBindings() {
898         // register 8 data bindings
899         registerDataBinding(new DefaultJAXXBinding(this, BINDING_LOCAL_COMBO_SELECTED_ITEM, true) {
900         
901             @Override
902             public void applyDataBinding() {
903                 if (model != null) {
904                     model.addPropertyChangeListener("isLocal", this);
905                 }
906             }
907         
908             @Override
909             public void processDataBinding() {
910                 if (model != null) {
911                     localCombo.setSelectedItem(model.getIsLocal());
912                 }
913             }
914         
915             @Override
916             public void removeDataBinding() {
917                 if (model != null) {
918                     model.removePropertyChangeListener("isLocal", this);
919                 }
920             }
921         });
922         registerDataBinding(new DefaultJAXXBinding(this, BINDING_NAME_EDITOR_TEXT, true) {
923         
924             @Override
925             public void applyDataBinding() {
926                 if (model != null) {
927                     model.addPropertyChangeListener("name", this);
928                 }
929             }
930         
931             @Override
932             public void processDataBinding() {
933                 if (model != null) {
934                     SwingUtil.setText(nameEditor, model.getName());
935                 }
936             }
937         
938             @Override
939             public void removeDataBinding() {
940                 if (model != null) {
941                     model.removePropertyChangeListener("name", this);
942                 }
943             }
944         });
945         registerDataBinding(new DefaultJAXXBinding(this, BINDING_PARAMETERS_COMBO_SELECTED_ITEM, true) {
946         
947             @Override
948             public void applyDataBinding() {
949                 if (model != null) {
950                     model.addPropertyChangeListener("parameter", this);
951                 }
952             }
953         
954             @Override
955             public void processDataBinding() {
956                 if (model != null) {
957                     parametersCombo.setSelectedItem(model.getParameter());
958                 }
959             }
960         
961             @Override
962             public void removeDataBinding() {
963                 if (model != null) {
964                     model.removePropertyChangeListener("parameter", this);
965                 }
966             }
967         });
968         registerDataBinding(new DefaultJAXXBinding(this, BINDING_MATRICES_COMBO_SELECTED_ITEM, true) {
969         
970             @Override
971             public void applyDataBinding() {
972                 if (model != null) {
973                     model.addPropertyChangeListener("matrix", this);
974                 }
975             }
976         
977             @Override
978             public void processDataBinding() {
979                 if (model != null) {
980                     matricesCombo.setSelectedItem(model.getMatrix());
981                 }
982             }
983         
984             @Override
985             public void removeDataBinding() {
986                 if (model != null) {
987                     model.removePropertyChangeListener("matrix", this);
988                 }
989             }
990         });
991         registerDataBinding(new DefaultJAXXBinding(this, BINDING_FRACTIONS_COMBO_SELECTED_ITEM, true) {
992         
993             @Override
994             public void applyDataBinding() {
995                 if (model != null) {
996                     model.addPropertyChangeListener("fraction", this);
997                 }
998             }
999         
1000             @Override
1001             public void processDataBinding() {
1002                 if (model != null) {
1003                     fractionsCombo.setSelectedItem(model.getFraction());
1004                 }
1005             }
1006         
1007             @Override
1008             public void removeDataBinding() {
1009                 if (model != null) {
1010                     model.removePropertyChangeListener("fraction", this);
1011                 }
1012             }
1013         });
1014         registerDataBinding(new DefaultJAXXBinding(this, BINDING_METHODS_COMBO_SELECTED_ITEM, true) {
1015         
1016             @Override
1017             public void applyDataBinding() {
1018                 if (model != null) {
1019                     model.addPropertyChangeListener("method", this);
1020                 }
1021             }
1022         
1023             @Override
1024             public void processDataBinding() {
1025                 if (model != null) {
1026                     methodsCombo.setSelectedItem(model.getMethod());
1027                 }
1028             }
1029         
1030             @Override
1031             public void removeDataBinding() {
1032                 if (model != null) {
1033                     model.removePropertyChangeListener("method", this);
1034                 }
1035             }
1036         });
1037         registerDataBinding(new DefaultJAXXBinding(this, BINDING_UNITS_COMBO_SELECTED_ITEM, true) {
1038         
1039             @Override
1040             public void applyDataBinding() {
1041                 if (model != null) {
1042                     model.addPropertyChangeListener("unit", this);
1043                 }
1044             }
1045         
1046             @Override
1047             public void processDataBinding() {
1048                 if (model != null) {
1049                     unitsCombo.setSelectedItem(model.getUnit());
1050                 }
1051             }
1052         
1053             @Override
1054             public void removeDataBinding() {
1055                 if (model != null) {
1056                     model.removePropertyChangeListener("unit", this);
1057                 }
1058             }
1059         });
1060         registerDataBinding(new DefaultJAXXBinding(this, BINDING_STATUS_COMBO_SELECTED_ITEM, true) {
1061         
1062             @Override
1063             public void applyDataBinding() {
1064                 if (model != null) {
1065                     model.addPropertyChangeListener("status", this);
1066                 }
1067             }
1068         
1069             @Override
1070             public void processDataBinding() {
1071                 if (model != null) {
1072                     statusCombo.setSelectedItem(model.getStatus());
1073                 }
1074             }
1075         
1076             @Override
1077             public void removeDataBinding() {
1078                 if (model != null) {
1079                     model.removePropertyChangeListener("status", this);
1080                 }
1081             }
1082         });
1083     }
1084 
1085 }