View Javadoc
1   package fr.ifremer.tutti.ui.swing.util.species;
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.type.WeightUnit;
28  import fr.ifremer.tutti.ui.swing.TuttiUIContext;
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.Container;
33  import java.awt.Dialog;
34  import java.awt.Dialog.ModalityType;
35  import java.awt.Frame;
36  import java.awt.GraphicsConfiguration;
37  import java.awt.GridBagConstraints;
38  import java.awt.GridLayout;
39  import java.awt.Insets;
40  import java.awt.Window;
41  import java.util.ArrayList;
42  import java.util.HashMap;
43  import java.util.List;
44  import java.util.Map;
45  import java.util.TreeMap;
46  import javax.swing.JButton;
47  import javax.swing.JDialog;
48  import javax.swing.JLabel;
49  import javax.swing.JPanel;
50  import jaxx.runtime.JAXXBinding;
51  import jaxx.runtime.JAXXContext;
52  import jaxx.runtime.JAXXObject;
53  import jaxx.runtime.JAXXObjectDescriptor;
54  import jaxx.runtime.JAXXUtil;
55  import jaxx.runtime.SwingUtil;
56  import jaxx.runtime.binding.DefaultJAXXBinding;
57  import jaxx.runtime.binding.SimpleJAXXObjectBinding;
58  import jaxx.runtime.context.DefaultJAXXContext;
59  import jaxx.runtime.swing.Table;
60  import org.apache.commons.logging.Log;
61  import org.apache.commons.logging.LogFactory;
62  import org.nuiton.jaxx.widgets.number.NumberEditor;
63  import static org.nuiton.i18n.I18n.t;
64  
65  public class EnterMelagWeightUI extends JDialog implements TuttiUI<TuttiUIContext, EnterMelagWeightUIHandler>, JAXXObject {
66  
67      /*-----------------------------------------------------------------------*/
68      /*---------------- Constants for all javaBean properties ----------------*/
69      /*-----------------------------------------------------------------------*/
70  
71      public static final String PROPERTY_WEIGHT_UNIT = "weightUnit";
72  
73      /*-----------------------------------------------------------------------*/
74      /*------------------ Constants for all public bindings ------------------*/
75      /*-----------------------------------------------------------------------*/
76  
77      public static final String BINDING_DIALOG_TITLE = "dialog.title";
78      public static final String BINDING_EDITOR_NUMBER_PATTERN = "editor.numberPattern";
79      public static final String BINDING_MESSAGE_TEXT = "message.text";
80      public static final String BINDING_VALIDATE_BUTTON_ENABLED = "validateButton.enabled";
81  
82      /*-----------------------------------------------------------------------*/
83      /*------------------------- Other static fields -------------------------*/
84      /*-----------------------------------------------------------------------*/
85  
86      private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAKVWS28jRRDumNhZO5sNJGJZlCC84SHvshpnkZBA4bHBJCJREqLYISt8WNozHbtXPT3NdM3awQrslRs/Ae5ckLhxQhw4c+CC+AsIcdgrorrHHr+xJXwY211VX339dVX1fPcnSeuQ3HxIWy0njCRwnzn72/fvf1R7yFz4gGk35AqCkMSfuRRJVcmil6xrIC9VD0x4sRNeLAW+CiSTfdFbBySn4UIw3WAMgLwwGOFqXSwn5q2WisIuakJqHOo3f/+V+tp7/G2KkJZCdlncSn5aVG8n8wckxT0gK5jpES0KKutII+SyjnyXzFpJUK2PqM8+I1+QhQOSUTREMCAbs2/ZYtj4lgKS8TgVQR3IW+ehw89D5rPQgQiAOxF3dBOTOxFw4WjFXM60syOBhYdM0PoZ4/UGnO4pZeEyQNJ+4DEBpDAZq2L+nu6VAoRpQS8014zRJMfd5Efi4UIx5yxx6UsJtCYYkBsDMndyGZPxyybuCz7TmtYxYMXo2ep47h/QGhPGZyVxzTCPo25AXgvCuiMj/CMdm6XJPUTQuObXkOGR/dqx3oMQV17eP6aSic3hdHZ1kNlVl0qXifdxu6gNWR3wj1eN51oScO0RFdyjwHrGfMcjJGsDcmA9O7167hXcXJWkwwiXUb/qaAucoCku/htDxW8ArfWf66u//fjHD7vdil/E3M+Ode1rWKxEFQaKhcBN6uW43E2VFQ+p2qpi3zCB3W67eX0MsXLHjOQw3zMmPC7SD6luIER64feffr7+6a9PkdQuyYmAervU+O+RLDRCVCEQXku9d88yutq8gs+nDTcU9QH1vLO+UnyubWvawQPvLRduXbZQlfUxqiTUatlfnqyWv7/XVWYOmT4/0b2nTvoTkuFScMnsNOg0+tjuX1SaRV7Qa+hxLU6UwjZfEqbAzzg0DH9rK9jnnXEqZBp2q0BSb2y2IuO2aXdgfr0eAy7WbNXZQp4GlwYOpkc32g0qPYEtg2pWuGCFIVWNrMPZkhGlOk0/KVEKm6YRhPxzbB8qtgWvS9/OxuV23N5OaeeosnNyCWTezB4gr/TzOYwHw2yUumNkGids0yyNIDgOVISipc+p0ChELp4cFRxqeDTtXaxQcFxzaEhuKTYeU8BBi5PgdnuIkmHbP3M6nliUSCzSrIw77+Vaxmpv2vzd0TIPYYSGrDGcMG3uP7s0Vvt4CE7bZxrnF7/7pjyUzA8kd4EU47nthgwnVDm+O+yt4WAncpyk8bhz/CQiFxv2XMMxE5uTo3p1NjisSwgCUeGqYsNuz8gCuOmRB5r7SrBtawJSbs94JcZYo1djyYJvdzLZ4x2n8cDkn6GihpS+O22P3XtiotbUdZmCROvCrIDDat+ZmYnVe4FJc0HjC89aOy4z24dm3BZu5W++k5eREJej53L6f8/l4w6NqSczdMVOOxszOQW9CNCZXHsb42i+xqWHvN4dQZ8zz9xURLP8pXk8Ho+wPgOnee7GrwcTMF6cicVX/4GwgQj/Au5q3ZC6CwAA";
87      private static final Log log = LogFactory.getLog(EnterMelagWeightUI.class);
88      private static final long serialVersionUID = 1L;
89  
90      /*-----------------------------------------------------------------------*/
91      /*--------------------------- Internal states ---------------------------*/
92      /*-----------------------------------------------------------------------*/
93  
94      protected List<Object> $activeBindings = new ArrayList<Object>();
95      protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
96      protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
97      protected Map<String, Object> $objectMap = new HashMap<String, Object>();
98      protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
99      private boolean allComponentsCreated;
100     protected final JAXXContext delegateContext = new DefaultJAXXContext();
101 
102     /*-----------------------------------------------------------------------*/
103     /*------------------------ Protected components  ------------------------*/
104     /*-----------------------------------------------------------------------*/
105 
106     protected JButton cancelButton;
107     protected EnterMelagWeightUI dialog = this;
108     protected NumberEditor editor;
109     protected final EnterMelagWeightUIHandler handler = createHandler();
110     protected JLabel message;
111     protected TuttiUIContext model;
112     protected Table table;
113     protected JButton validateButton;
114     protected WeightUnit weightUnit;
115 
116     /*-----------------------------------------------------------------------*/
117     /*------------------------- Private components  -------------------------*/
118     /*-----------------------------------------------------------------------*/
119 
120     private JPanel $JPanel0;
121 
122     /*-----------------------------------------------------------------------*/
123     /*---------------------- Raw body code from script ----------------------*/
124     /*-----------------------------------------------------------------------*/
125     
126     
127     public Float openAndGetWeightValue(WeightUnit weightUnit) {
128         return handler.openAndGetWeightValue(weightUnit);
129     }
130 
131     /*-----------------------------------------------------------------------*/
132     /*---------------------------- Constructors  ----------------------------*/
133     /*-----------------------------------------------------------------------*/
134 
135     public EnterMelagWeightUI(TuttiUIContext context) {
136         super(context.getMainUI(), true);
137             TuttiUIUtil.setApplicationContext(this, context);
138             $initialize();
139     }
140 
141     public EnterMelagWeightUI(Frame param0, String param1, boolean param2, GraphicsConfiguration param3) {
142         super(param0 ,param1 ,param2 ,param3);
143         $initialize();
144     }
145 
146     public EnterMelagWeightUI(JAXXContext parentContext, Frame param1, String param2, boolean param3, GraphicsConfiguration param4) {
147         super(param1 ,param2 ,param3 ,param4);
148         JAXXUtil.initContext(this, parentContext);
149         $initialize();
150     }
151 
152     public EnterMelagWeightUI(Dialog param0) {
153         super(param0);
154         $initialize();
155     }
156 
157     public EnterMelagWeightUI(JAXXContext parentContext, Dialog param1) {
158         super(param1);
159         JAXXUtil.initContext(this, parentContext);
160         $initialize();
161     }
162 
163     public EnterMelagWeightUI(Frame param0, String param1, boolean param2) {
164         super(param0 ,param1 ,param2);
165         $initialize();
166     }
167 
168     public EnterMelagWeightUI(JAXXContext parentContext, Frame param1, String param2, boolean param3) {
169         super(param1 ,param2 ,param3);
170         JAXXUtil.initContext(this, parentContext);
171         $initialize();
172     }
173 
174     public EnterMelagWeightUI() {
175         $initialize();
176     }
177 
178     public EnterMelagWeightUI(JAXXContext parentContext) {
179         JAXXUtil.initContext(this, parentContext);
180         $initialize();
181     }
182 
183     public EnterMelagWeightUI(Frame param0) {
184         super(param0);
185         $initialize();
186     }
187 
188     public EnterMelagWeightUI(JAXXContext parentContext, Frame param1) {
189         super(param1);
190         JAXXUtil.initContext(this, parentContext);
191         $initialize();
192     }
193 
194     public EnterMelagWeightUI(Frame param0, boolean param1) {
195         super(param0 ,param1);
196         $initialize();
197     }
198 
199     public EnterMelagWeightUI(JAXXContext parentContext, Frame param1, boolean param2) {
200         super(param1 ,param2);
201         JAXXUtil.initContext(this, parentContext);
202         $initialize();
203     }
204 
205     public EnterMelagWeightUI(Frame param0, String param1) {
206         super(param0 ,param1);
207         $initialize();
208     }
209 
210     public EnterMelagWeightUI(JAXXContext parentContext, Frame param1, String param2) {
211         super(param1 ,param2);
212         JAXXUtil.initContext(this, parentContext);
213         $initialize();
214     }
215 
216     public EnterMelagWeightUI(Window param0) {
217         super(param0);
218         $initialize();
219     }
220 
221     public EnterMelagWeightUI(JAXXContext parentContext, Window param1) {
222         super(param1);
223         JAXXUtil.initContext(this, parentContext);
224         $initialize();
225     }
226 
227     public EnterMelagWeightUI(Window param0, ModalityType param1) {
228         super(param0 ,param1);
229         $initialize();
230     }
231 
232     public EnterMelagWeightUI(JAXXContext parentContext, Window param1, ModalityType param2) {
233         super(param1 ,param2);
234         JAXXUtil.initContext(this, parentContext);
235         $initialize();
236     }
237 
238     public EnterMelagWeightUI(Window param0, String param1) {
239         super(param0 ,param1);
240         $initialize();
241     }
242 
243     public EnterMelagWeightUI(JAXXContext parentContext, Window param1, String param2) {
244         super(param1 ,param2);
245         JAXXUtil.initContext(this, parentContext);
246         $initialize();
247     }
248 
249     public EnterMelagWeightUI(Window param0, String param1, ModalityType param2) {
250         super(param0 ,param1 ,param2);
251         $initialize();
252     }
253 
254     public EnterMelagWeightUI(JAXXContext parentContext, Window param1, String param2, ModalityType param3) {
255         super(param1 ,param2 ,param3);
256         JAXXUtil.initContext(this, parentContext);
257         $initialize();
258     }
259 
260     public EnterMelagWeightUI(Window param0, String param1, ModalityType param2, GraphicsConfiguration param3) {
261         super(param0 ,param1 ,param2 ,param3);
262         $initialize();
263     }
264 
265     public EnterMelagWeightUI(JAXXContext parentContext, Window param1, String param2, ModalityType param3, GraphicsConfiguration param4) {
266         super(param1 ,param2 ,param3 ,param4);
267         JAXXUtil.initContext(this, parentContext);
268         $initialize();
269     }
270 
271     public EnterMelagWeightUI(Dialog param0, boolean param1) {
272         super(param0 ,param1);
273         $initialize();
274     }
275 
276     public EnterMelagWeightUI(JAXXContext parentContext, Dialog param1, boolean param2) {
277         super(param1 ,param2);
278         JAXXUtil.initContext(this, parentContext);
279         $initialize();
280     }
281 
282     public EnterMelagWeightUI(Dialog param0, String param1) {
283         super(param0 ,param1);
284         $initialize();
285     }
286 
287     public EnterMelagWeightUI(JAXXContext parentContext, Dialog param1, String param2) {
288         super(param1 ,param2);
289         JAXXUtil.initContext(this, parentContext);
290         $initialize();
291     }
292 
293     public EnterMelagWeightUI(Dialog param0, String param1, boolean param2) {
294         super(param0 ,param1 ,param2);
295         $initialize();
296     }
297 
298     public EnterMelagWeightUI(JAXXContext parentContext, Dialog param1, String param2, boolean param3) {
299         super(param1 ,param2 ,param3);
300         JAXXUtil.initContext(this, parentContext);
301         $initialize();
302     }
303 
304     public EnterMelagWeightUI(Dialog param0, String param1, boolean param2, GraphicsConfiguration param3) {
305         super(param0 ,param1 ,param2 ,param3);
306         $initialize();
307     }
308 
309     public EnterMelagWeightUI(JAXXContext parentContext, Dialog param1, String param2, boolean param3, GraphicsConfiguration param4) {
310         super(param1 ,param2 ,param3 ,param4);
311         JAXXUtil.initContext(this, parentContext);
312         $initialize();
313     }
314 
315     /*-----------------------------------------------------------------------*/
316     /*--------------------------- Statics methods ---------------------------*/
317     /*-----------------------------------------------------------------------*/
318 
319     public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
320         return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
321     }
322 
323     /*-----------------------------------------------------------------------*/
324     /*---------------------- JAXXObject implementation ----------------------*/
325     /*-----------------------------------------------------------------------*/
326 
327     @Override
328     public void applyDataBinding(String $binding) {
329         if (allComponentsCreated && $bindings.containsKey($binding)) {
330             getDataBinding($binding).applyDataBinding();
331         }
332         processDataBinding($binding);
333     }
334 
335     @Override
336     public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
337         super.firePropertyChange(propertyName, oldValue, newValue);
338     }
339 
340     @Override
341     public Map<String, Object> get$objectMap() {
342         return $objectMap;
343     }
344 
345     @Override
346     public JAXXBinding getDataBinding(String bindingId) {
347         return $bindings.get(bindingId);
348     }
349 
350     @Override
351     public JAXXBinding[] getDataBindings() {
352         return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
353     }
354 
355     @Override
356     public Object getObjectById(String id) {
357         return $objectMap.get(id);
358     }
359 
360     @Override
361     public void processDataBinding(String $binding, boolean $force) {
362         if (!$force && $activeBindings.contains($binding)) { 
363             return;
364         }
365         $activeBindings.add($binding);
366         try {
367             if (allComponentsCreated && $bindings.containsKey($binding)) {
368                 getDataBinding($binding).processDataBinding();
369             }
370         } finally {
371             $activeBindings.remove($binding);
372         }
373     }
374 
375     @Override
376     public void processDataBinding(String $binding) {
377         processDataBinding($binding, false);
378     }
379 
380     @Override
381     public void registerDataBinding(JAXXBinding binding) {
382         $bindings.put(binding.getId(), binding);
383     }
384 
385     @Override
386     public void removeDataBinding(String $binding) {
387         if (allComponentsCreated && $bindings.containsKey($binding)) {
388             getDataBinding($binding).removeDataBinding();
389         }
390     }
391 
392     /*-----------------------------------------------------------------------*/
393     /*--------------------- JAXXContext implementation  ---------------------*/
394     /*-----------------------------------------------------------------------*/
395 
396     @Override
397     public <T> T getContextValue(Class<T> clazz) {
398         return delegateContext.getContextValue(clazz, null);
399     }
400 
401     @Override
402     public <T> T getContextValue(Class<T> clazz, String name) {
403         return delegateContext.getContextValue(clazz, name);
404     }
405 
406     @Override
407     public JAXXContext getDelegateContext() {
408         return delegateContext;
409     }
410 
411     @Override
412     public <O extends Container> O getParentContainer(Class<O> clazz) {
413         return SwingUtil.getParentContainer(this, clazz);
414     }
415 
416     @Override
417     public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
418         return SwingUtil.getParentContainer(source, clazz);
419     }
420 
421     @Override
422     public <T> void removeContextValue(Class<T> clazz) {
423         delegateContext.removeContextValue(clazz, null);
424     }
425 
426     @Override
427     public <T> void removeContextValue(Class<T> clazz, String name) {
428         delegateContext.removeContextValue(clazz, name);
429     }
430 
431     @Override
432     public <T> void setContextValue(T o) {
433         delegateContext.setContextValue(o, null);
434     }
435 
436     @Override
437     public <T> void setContextValue(T o, String name) {
438         delegateContext.setContextValue(o, name);
439     }
440 
441     /*-----------------------------------------------------------------------*/
442     /*----------------------- Public acessor methods  -----------------------*/
443     /*-----------------------------------------------------------------------*/
444 
445     public JButton getCancelButton() {
446         return cancelButton;
447     }
448 
449     public NumberEditor getEditor() {
450         return editor;
451     }
452 
453     public EnterMelagWeightUIHandler getHandler() {
454         return handler;
455     }
456 
457     public JLabel getMessage() {
458         return message;
459     }
460 
461     public TuttiUIContext getModel() {
462         return model;
463     }
464 
465     public Table getTable() {
466         return table;
467     }
468 
469     public JButton getValidateButton() {
470         return validateButton;
471     }
472 
473     public WeightUnit getWeightUnit() {
474         return weightUnit;
475     }
476 
477     /*-----------------------------------------------------------------------*/
478     /*----------------------- Public mutator methods  -----------------------*/
479     /*-----------------------------------------------------------------------*/
480 
481     public void setWeightUnit(WeightUnit weightUnit) {
482         WeightUnit oldValue = this.weightUnit;
483         this.weightUnit = weightUnit;
484         firePropertyChange(PROPERTY_WEIGHT_UNIT, oldValue, weightUnit);
485     }
486 
487     /*-----------------------------------------------------------------------*/
488     /*--------------------- Protected acessors methods  ---------------------*/
489     /*-----------------------------------------------------------------------*/
490 
491     protected JPanel get$JPanel0() {
492         return $JPanel0;
493     }
494 
495     /*-----------------------------------------------------------------------*/
496     /*--------------------- Components creation methods ---------------------*/
497     /*-----------------------------------------------------------------------*/
498 
499     protected void addChildrenToDialog() {
500         if (!allComponentsCreated) {
501             return;
502         }
503         add(table, BorderLayout.CENTER);
504         add($JPanel0, BorderLayout.SOUTH);
505     }
506 
507     protected void addChildrenToTable() {
508         if (!allComponentsCreated) {
509             return;
510         }
511         table.add(message, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 10, 1, new Insets(10, 10, 5, 10), 0, 0));
512         table.add(editor, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 10, 1, new Insets(5, 10, 10, 10), 0, 0));
513     }
514 
515     protected void createCancelButton() {
516         $objectMap.put("cancelButton", cancelButton = new JButton());
517         
518         cancelButton.setName("cancelButton");
519         cancelButton.setText(t("tutti.createSpeciesMelag.action.cancel"));
520         cancelButton.setToolTipText(t("tutti.createSpeciesMelag.action.cancel.tip"));
521         cancelButton.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.util.species.actions.EnterMelagWeightCancelAction.class);
522     }
523 
524     protected void createEditor() {
525         $objectMap.put("editor", editor = new NumberEditor());
526         
527         editor.setName("editor");
528         editor.setAutoPopup(false);
529         editor.setUseSign(false);
530         editor.setShowPopupButton(true);
531         editor.setShowReset(true);
532     }
533 
534     protected EnterMelagWeightUIHandler createHandler() {
535         return new EnterMelagWeightUIHandler();
536     }
537 
538     protected void createMessage() {
539         $objectMap.put("message", message = new JLabel());
540         
541         message.setName("message");
542     }
543 
544     protected void createModel() {
545         $objectMap.put("model", model = getContextValue(TuttiUIContext.class));
546     }
547 
548     protected void createTable() {
549         $objectMap.put("table", table = new Table());
550         
551         table.setName("table");
552     }
553 
554     protected void createValidateButton() {
555         $objectMap.put("validateButton", validateButton = new JButton());
556         
557         validateButton.setName("validateButton");
558         validateButton.setText(t("tutti.createSpeciesMelag.action.validate"));
559         validateButton.setToolTipText(t("tutti.createSpeciesMelag.action.validate.tip"));
560         validateButton.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.util.species.actions.EnterMelagWeightValidateAction.class);
561     }
562 
563     protected void createWeightUnit() {
564         $objectMap.put("weightUnit", weightUnit = WeightUnit.KG);
565     }
566 
567     /*-----------------------------------------------------------------------*/
568     /*------------------------ Internal jaxx methods ------------------------*/
569     /*-----------------------------------------------------------------------*/
570 
571     private void $completeSetup() {
572         allComponentsCreated = true;
573         if (log.isDebugEnabled()) {
574             log.debug(this);
575         }
576         addChildrenToDialog();
577         addChildrenToTable();
578         // inline complete setup of $JPanel0
579         $JPanel0.add(cancelButton);
580         $JPanel0.add(validateButton);
581         
582         // apply 4 data bindings
583         JAXXUtil.applyDataBinding(this, $bindings.keySet());
584         
585         // apply 8 property setters
586         message.setHorizontalAlignment(JLabel.CENTER);
587         editor.setNumberType(Float.class);
588         cancelButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.createSpeciesMelag.action.cancel.mnemonic"),'Z'));
589         cancelButton.setIcon(SwingUtil.createActionIcon("cancel"));
590         validateButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.createSpeciesMelag.action.validate.mnemonic"),'Z'));
591         validateButton.setIcon(SwingUtil.createActionIcon("accept"));
592         // late initializer
593         dialog.pack();
594     }
595 
596     private void $initialize() {
597         if (allComponentsCreated) {
598             return;
599         }
600         if (log.isDebugEnabled()) {
601             log.debug(this);
602         }
603         handler.beforeInit(this);
604         $objectMap.put("dialog", dialog);
605         createModel();
606         createWeightUnit();
607         createTable();
608         createMessage();
609         createEditor();
610         // inline creation of $JPanel0
611         $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
612         
613         $JPanel0.setName("$JPanel0");
614         $JPanel0.setLayout(new GridLayout(1,0));
615         createCancelButton();
616         createValidateButton();
617         // inline creation of dialog
618         setName("dialog");
619         dialog.getContentPane().setLayout(new BorderLayout());
620         
621         // registers 4 data bindings
622         $registerDefaultBindings();
623         $completeSetup();
624         handler.afterInit(this);
625     }
626 
627     private void $registerDefaultBindings() {
628         // register 4 data bindings
629         registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_DIALOG_TITLE, true ,"weightUnit") {
630         
631             @Override
632             public void processDataBinding() {
633                 setTitle(t(handler.getTile(getWeightUnit())));
634             }
635         });
636         registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_MESSAGE_TEXT, true ,"weightUnit") {
637         
638             @Override
639             public void processDataBinding() {
640                 message.setText(t(handler.getMessage(getWeightUnit())));
641             }
642         });
643         registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_EDITOR_NUMBER_PATTERN, true ,"weightUnit") {
644         
645             @Override
646             public void processDataBinding() {
647                 if (getWeightUnit() != null) {
648                     editor.setNumberPattern(getWeightUnit().getNumberEditorPattern());
649                 }
650             }
651         });
652         registerDataBinding(new DefaultJAXXBinding(this, BINDING_VALIDATE_BUTTON_ENABLED, true) {
653         
654             @Override
655             public void applyDataBinding() {
656                 if (editor != null) {
657                     editor.addPropertyChangeListener("model", this);
658                 }
659             }
660         
661             @Override
662             public void processDataBinding() {
663                 if (editor != null) {
664                     validateButton.setEnabled(editor.getModel() != null);
665                 }
666             }
667         
668             @Override
669             public void removeDataBinding() {
670                 if (editor != null) {
671                     editor.removePropertyChangeListener("model", this);
672                 }
673             }
674         });
675     }
676 
677 }