View Javadoc
1   package fr.ifremer.tutti.ui.swing.util.attachment;
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.ui.swing.TuttiUIContext;
28  import fr.ifremer.tutti.ui.swing.util.TuttiUI;
29  import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
30  import java.awt.BorderLayout;
31  import java.awt.Container;
32  import java.awt.Dialog;
33  import java.awt.Dialog.ModalityType;
34  import java.awt.Frame;
35  import java.awt.GraphicsConfiguration;
36  import java.awt.GridBagConstraints;
37  import java.awt.GridLayout;
38  import java.awt.Insets;
39  import java.awt.Window;
40  import java.util.ArrayList;
41  import java.util.HashMap;
42  import java.util.List;
43  import java.util.Map;
44  import java.util.TreeMap;
45  import javax.swing.JButton;
46  import javax.swing.JComponent;
47  import javax.swing.JDialog;
48  import javax.swing.JLabel;
49  import javax.swing.JPanel;
50  import javax.swing.JScrollPane;
51  import javax.swing.JSeparator;
52  import javax.swing.JTextArea;
53  import javax.swing.JTextField;
54  import jaxx.runtime.JAXXBinding;
55  import jaxx.runtime.JAXXContext;
56  import jaxx.runtime.JAXXObject;
57  import jaxx.runtime.JAXXObjectDescriptor;
58  import jaxx.runtime.JAXXUtil;
59  import jaxx.runtime.SwingUtil;
60  import jaxx.runtime.context.DefaultJAXXContext;
61  import jaxx.runtime.swing.Table;
62  import jaxx.runtime.swing.editor.FileEditor;
63  import org.apache.commons.logging.Log;
64  import org.apache.commons.logging.LogFactory;
65  import org.jdesktop.swingx.JXTitledPanel;
66  import static org.nuiton.i18n.I18n.t;
67  
68  public class AttachmentEditorUI extends JDialog implements TuttiUI<TuttiUIContext, AttachmentEditorUIHandler>, JAXXObject {
69  
70      /*-----------------------------------------------------------------------*/
71      /*---------------- Constants for all javaBean properties ----------------*/
72      /*-----------------------------------------------------------------------*/
73  
74      public static final String PROPERTY_BEAN = "bean";
75      public static final String PROPERTY_EDITABLE = "editable";
76  
77      /*-----------------------------------------------------------------------*/
78      /*------------------------- Other static fields -------------------------*/
79      /*-----------------------------------------------------------------------*/
80  
81      private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAJ1WQU8kRRQuZmdYBpiVXQKL7hpZRYOa1GCi0QSCO6CThYBrZMgSOaw108VMYU1X2/1GmhCMP0ATf4LevZh482Q8ePbgxfgXjPHgdeN71TPd00MPw8qhw7z63ve+el3vq/7+L1YIfHbvWIQh9zsuqLbk25WDg4f1Y9mA92TQ8JUHxmfR31iO5Q7ZlBPHA2AvHe5QermbXt40bc+40u3LXt1hkwGcahm0pARgz6czGkFQ3ouXV0Ov4/dYY1FZrN/+83fuG+fL73KMhR6qu4lbWRyVlewkv8NyygF2Cyt9LspauE2U4Su3iXpLFNvUIgg+EG35GfuCXd9h457wkQzYi1ffsuWw+aEHbEYAiEarTVgltGkCWzvyuTryZVv6HDoAincUD05QBu+A0jzJ4JX43/cdhUX2tzzPco8Dm5AYEnUtgd0k7Zz2wzeM0VK4CSxfx5/A1v9P0V3jSF05wR4kfIU2BYEtDyes0c/9rU3jggwhSb2RFNkwzimwe8Zv8mM8XJ+C8aLkkG8f1BRo6XwoXKkpsxgTLKQJ9hq+0ZpwwG5TC8KugO1khTLnYoJiWyjXEiNZ6uB0lVM/CbsQp0wlNfHs30qViSXeieHTS9t7Ek+NwLe1Amw+Lau3ks4pHiktd0SdVKUL2GAanCcwsKUM9dKeEV5FQHRcBsoIx9nAV4Ovhc2mykTRNLpEdWgUYg2vpAETPcDgLmv40qtKaieNnyE8Dg51chhnaanv1a1Q8Lk0YKqPBNjchboVXwqCvumhNdxJ9QhNhyemk7jC2CEr+B0M45E4vOhTH+FS5FALAw5FhHb1yfzs7z/9+WO1Z0vTWHsuE9rnqmgXnm886YOi0s9EnkSzWN4V3uohKwZSoyVby72bIWyvu4zisF5kAXaUH4ighRSF63/8/Mv8J79dY7kqm9RGOFVB+C1WhJaPXTDaCb1371tF0ycT+JwhbTinj/GkPJKq2YJ9V2Gfb5/ZoedNCUl4+dXzELtyN6MrsbR68dd/Z/d+uN/rzBgqfXYoPOlO4WM2rlytXGktu+vGmRY95QWy45jEdbN8mHkeenFJ07F7pKBF+u3aun1uZHVhvGW3Ciz31krYIVjV7oD+exARTtXt4FgbuJQuh9iO68iGwfGXeAXlwe9IMhd9Ik6Dh27NeN3gxVIZl4jXNdVL5BeAXBSPTmTOYuAm4XY5q9iAS48qhVubsH2tGh+bdkYDek57wWlEhx9S/Yj8gRM2S0JiiE9XffKs50mJgpdHKiB8loq0Az6dktJZn1ElYpZHiummZJ6CQQMdJSmP15F64x1315Vt46oGsNeG1EdjUMblOPa8HYMno+hWgy6Ma7iG5xXw86KmvNqlre1jA0Vz9zhQbU/Lio0D2z27+sdIxBXwiuMk3yUREW/QhJ9nHqD4qrvCpIxrcWoQzG6sOQLEYl25DkpZv0A8Rs/JkYwU/ooeX2czvHAFTXnfnNDnxlrkgovYEV+h28ghqt6+CqdqRJf8EF2vI8d/pA3PhSAMAAA=";
82      private static final Log log = LogFactory.getLog(AttachmentEditorUI.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 addButton;
102     protected JXTitledPanel attachmentBody;
103     protected JScrollPane attachmentBodyScrollPane;
104     protected AttachmentEditorUI attachmentDialog = this;
105     protected JPanel attachments;
106     protected AttachmentModelAware bean;
107     protected Boolean editable;
108     protected FileEditor file;
109     protected JTextArea fileComment;
110     protected JLabel fileCommentLabel;
111     protected JLabel fileLabel;
112     protected JTextField fileName;
113     protected JLabel fileNameLabel;
114     protected final AttachmentEditorUIHandler handler = createHandler();
115     protected Table mainPanel;
116     protected TuttiUIContext model;
117 
118     /*-----------------------------------------------------------------------*/
119     /*------------------------- Private components  -------------------------*/
120     /*-----------------------------------------------------------------------*/
121 
122     private JScrollPane $JScrollPane0;
123     private JSeparator $JSeparator0;
124 
125     /*-----------------------------------------------------------------------*/
126     /*---------------------- Raw body code from script ----------------------*/
127     /*-----------------------------------------------------------------------*/
128     
129     
130     public void openEditor(JComponent component) {
131        handler.openEditor(component);
132     }
133     
134     public void closeEditor() {
135        handler.closeEditor();
136     }
137 
138     /*-----------------------------------------------------------------------*/
139     /*---------------------------- Constructors  ----------------------------*/
140     /*-----------------------------------------------------------------------*/
141 
142     public AttachmentEditorUI(TuttiUIContext context) {
143         super(context.getMainUI());
144             TuttiUIUtil.setApplicationContext(this, context);
145             $initialize();
146     }
147 
148     public AttachmentEditorUI(Frame param0, String param1, boolean param2, GraphicsConfiguration param3) {
149         super(param0 ,param1 ,param2 ,param3);
150         $initialize();
151     }
152 
153     public AttachmentEditorUI(JAXXContext parentContext, Frame param1, String param2, boolean param3, GraphicsConfiguration param4) {
154         super(param1 ,param2 ,param3 ,param4);
155         JAXXUtil.initContext(this, parentContext);
156         $initialize();
157     }
158 
159     public AttachmentEditorUI(Dialog param0) {
160         super(param0);
161         $initialize();
162     }
163 
164     public AttachmentEditorUI(JAXXContext parentContext, Dialog param1) {
165         super(param1);
166         JAXXUtil.initContext(this, parentContext);
167         $initialize();
168     }
169 
170     public AttachmentEditorUI(Frame param0, String param1, boolean param2) {
171         super(param0 ,param1 ,param2);
172         $initialize();
173     }
174 
175     public AttachmentEditorUI(JAXXContext parentContext, Frame param1, String param2, boolean param3) {
176         super(param1 ,param2 ,param3);
177         JAXXUtil.initContext(this, parentContext);
178         $initialize();
179     }
180 
181     public AttachmentEditorUI() {
182         $initialize();
183     }
184 
185     public AttachmentEditorUI(JAXXContext parentContext) {
186         JAXXUtil.initContext(this, parentContext);
187         $initialize();
188     }
189 
190     public AttachmentEditorUI(Frame param0) {
191         super(param0);
192         $initialize();
193     }
194 
195     public AttachmentEditorUI(JAXXContext parentContext, Frame param1) {
196         super(param1);
197         JAXXUtil.initContext(this, parentContext);
198         $initialize();
199     }
200 
201     public AttachmentEditorUI(Frame param0, boolean param1) {
202         super(param0 ,param1);
203         $initialize();
204     }
205 
206     public AttachmentEditorUI(JAXXContext parentContext, Frame param1, boolean param2) {
207         super(param1 ,param2);
208         JAXXUtil.initContext(this, parentContext);
209         $initialize();
210     }
211 
212     public AttachmentEditorUI(Frame param0, String param1) {
213         super(param0 ,param1);
214         $initialize();
215     }
216 
217     public AttachmentEditorUI(JAXXContext parentContext, Frame param1, String param2) {
218         super(param1 ,param2);
219         JAXXUtil.initContext(this, parentContext);
220         $initialize();
221     }
222 
223     public AttachmentEditorUI(Window param0) {
224         super(param0);
225         $initialize();
226     }
227 
228     public AttachmentEditorUI(JAXXContext parentContext, Window param1) {
229         super(param1);
230         JAXXUtil.initContext(this, parentContext);
231         $initialize();
232     }
233 
234     public AttachmentEditorUI(Window param0, ModalityType param1) {
235         super(param0 ,param1);
236         $initialize();
237     }
238 
239     public AttachmentEditorUI(JAXXContext parentContext, Window param1, ModalityType param2) {
240         super(param1 ,param2);
241         JAXXUtil.initContext(this, parentContext);
242         $initialize();
243     }
244 
245     public AttachmentEditorUI(Window param0, String param1) {
246         super(param0 ,param1);
247         $initialize();
248     }
249 
250     public AttachmentEditorUI(JAXXContext parentContext, Window param1, String param2) {
251         super(param1 ,param2);
252         JAXXUtil.initContext(this, parentContext);
253         $initialize();
254     }
255 
256     public AttachmentEditorUI(Window param0, String param1, ModalityType param2) {
257         super(param0 ,param1 ,param2);
258         $initialize();
259     }
260 
261     public AttachmentEditorUI(JAXXContext parentContext, Window param1, String param2, ModalityType param3) {
262         super(param1 ,param2 ,param3);
263         JAXXUtil.initContext(this, parentContext);
264         $initialize();
265     }
266 
267     public AttachmentEditorUI(Window param0, String param1, ModalityType param2, GraphicsConfiguration param3) {
268         super(param0 ,param1 ,param2 ,param3);
269         $initialize();
270     }
271 
272     public AttachmentEditorUI(JAXXContext parentContext, Window param1, String param2, ModalityType param3, GraphicsConfiguration param4) {
273         super(param1 ,param2 ,param3 ,param4);
274         JAXXUtil.initContext(this, parentContext);
275         $initialize();
276     }
277 
278     public AttachmentEditorUI(Dialog param0, boolean param1) {
279         super(param0 ,param1);
280         $initialize();
281     }
282 
283     public AttachmentEditorUI(JAXXContext parentContext, Dialog param1, boolean param2) {
284         super(param1 ,param2);
285         JAXXUtil.initContext(this, parentContext);
286         $initialize();
287     }
288 
289     public AttachmentEditorUI(Dialog param0, String param1) {
290         super(param0 ,param1);
291         $initialize();
292     }
293 
294     public AttachmentEditorUI(JAXXContext parentContext, Dialog param1, String param2) {
295         super(param1 ,param2);
296         JAXXUtil.initContext(this, parentContext);
297         $initialize();
298     }
299 
300     public AttachmentEditorUI(Dialog param0, String param1, boolean param2) {
301         super(param0 ,param1 ,param2);
302         $initialize();
303     }
304 
305     public AttachmentEditorUI(JAXXContext parentContext, Dialog param1, String param2, boolean param3) {
306         super(param1 ,param2 ,param3);
307         JAXXUtil.initContext(this, parentContext);
308         $initialize();
309     }
310 
311     public AttachmentEditorUI(Dialog param0, String param1, boolean param2, GraphicsConfiguration param3) {
312         super(param0 ,param1 ,param2 ,param3);
313         $initialize();
314     }
315 
316     public AttachmentEditorUI(JAXXContext parentContext, Dialog param1, String param2, boolean param3, GraphicsConfiguration param4) {
317         super(param1 ,param2 ,param3 ,param4);
318         JAXXUtil.initContext(this, parentContext);
319         $initialize();
320     }
321 
322     /*-----------------------------------------------------------------------*/
323     /*--------------------------- Statics methods ---------------------------*/
324     /*-----------------------------------------------------------------------*/
325 
326     public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
327         return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
328     }
329 
330     /*-----------------------------------------------------------------------*/
331     /*---------------------- JAXXObject implementation ----------------------*/
332     /*-----------------------------------------------------------------------*/
333 
334     @Override
335     public void applyDataBinding(String $binding) {
336         if (allComponentsCreated && $bindings.containsKey($binding)) {
337             getDataBinding($binding).applyDataBinding();
338         }
339         processDataBinding($binding);
340     }
341 
342     @Override
343     public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
344         super.firePropertyChange(propertyName, oldValue, newValue);
345     }
346 
347     @Override
348     public Map<String, Object> get$objectMap() {
349         return $objectMap;
350     }
351 
352     @Override
353     public JAXXBinding getDataBinding(String bindingId) {
354         return $bindings.get(bindingId);
355     }
356 
357     @Override
358     public JAXXBinding[] getDataBindings() {
359         return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
360     }
361 
362     @Override
363     public Object getObjectById(String id) {
364         return $objectMap.get(id);
365     }
366 
367     @Override
368     public void processDataBinding(String $binding, boolean $force) {
369         if (!$force && $activeBindings.contains($binding)) { 
370             return;
371         }
372         $activeBindings.add($binding);
373         try {
374             if (allComponentsCreated && $bindings.containsKey($binding)) {
375                 getDataBinding($binding).processDataBinding();
376             }
377         } finally {
378             $activeBindings.remove($binding);
379         }
380     }
381 
382     @Override
383     public void processDataBinding(String $binding) {
384         processDataBinding($binding, false);
385     }
386 
387     @Override
388     public void registerDataBinding(JAXXBinding binding) {
389         $bindings.put(binding.getId(), binding);
390     }
391 
392     @Override
393     public void removeDataBinding(String $binding) {
394         if (allComponentsCreated && $bindings.containsKey($binding)) {
395             getDataBinding($binding).removeDataBinding();
396         }
397     }
398 
399     /*-----------------------------------------------------------------------*/
400     /*--------------------- JAXXContext implementation  ---------------------*/
401     /*-----------------------------------------------------------------------*/
402 
403     @Override
404     public <T> T getContextValue(Class<T> clazz) {
405         return delegateContext.getContextValue(clazz, null);
406     }
407 
408     @Override
409     public <T> T getContextValue(Class<T> clazz, String name) {
410         return delegateContext.getContextValue(clazz, name);
411     }
412 
413     @Override
414     public JAXXContext getDelegateContext() {
415         return delegateContext;
416     }
417 
418     @Override
419     public <O extends Container> O getParentContainer(Class<O> clazz) {
420         return SwingUtil.getParentContainer(this, clazz);
421     }
422 
423     @Override
424     public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
425         return SwingUtil.getParentContainer(source, clazz);
426     }
427 
428     @Override
429     public <T> void removeContextValue(Class<T> clazz) {
430         delegateContext.removeContextValue(clazz, null);
431     }
432 
433     @Override
434     public <T> void removeContextValue(Class<T> clazz, String name) {
435         delegateContext.removeContextValue(clazz, name);
436     }
437 
438     @Override
439     public <T> void setContextValue(T o) {
440         delegateContext.setContextValue(o, null);
441     }
442 
443     @Override
444     public <T> void setContextValue(T o, String name) {
445         delegateContext.setContextValue(o, name);
446     }
447 
448     /*-----------------------------------------------------------------------*/
449     /*----------------------- Public acessor methods  -----------------------*/
450     /*-----------------------------------------------------------------------*/
451 
452     public JButton getAddButton() {
453         return addButton;
454     }
455 
456     public JXTitledPanel getAttachmentBody() {
457         return attachmentBody;
458     }
459 
460     public JScrollPane getAttachmentBodyScrollPane() {
461         return attachmentBodyScrollPane;
462     }
463 
464     public JPanel getAttachments() {
465         return attachments;
466     }
467 
468     public AttachmentModelAware getBean() {
469         return bean;
470     }
471 
472     public Boolean getEditable() {
473         return editable;
474     }
475 
476     public FileEditor getFile() {
477         return file;
478     }
479 
480     public JTextArea getFileComment() {
481         return fileComment;
482     }
483 
484     public JLabel getFileCommentLabel() {
485         return fileCommentLabel;
486     }
487 
488     public JLabel getFileLabel() {
489         return fileLabel;
490     }
491 
492     public JTextField getFileName() {
493         return fileName;
494     }
495 
496     public JLabel getFileNameLabel() {
497         return fileNameLabel;
498     }
499 
500     public AttachmentEditorUIHandler getHandler() {
501         return handler;
502     }
503 
504     public Table getMainPanel() {
505         return mainPanel;
506     }
507 
508     public TuttiUIContext getModel() {
509         return model;
510     }
511 
512     public Boolean isEditable() {
513         return editable !=null && editable;
514     }
515 
516     /*-----------------------------------------------------------------------*/
517     /*----------------------- Public mutator methods  -----------------------*/
518     /*-----------------------------------------------------------------------*/
519 
520     public void setBean(AttachmentModelAware bean) {
521         AttachmentModelAware oldValue = this.bean;
522         this.bean = bean;
523         firePropertyChange(PROPERTY_BEAN, oldValue, bean);
524     }
525 
526     public void setEditable(Boolean editable) {
527         Boolean oldValue = this.editable;
528         this.editable = editable;
529         firePropertyChange(PROPERTY_EDITABLE, oldValue, editable);
530     }
531 
532     /*-----------------------------------------------------------------------*/
533     /*--------------------- Protected acessors methods  ---------------------*/
534     /*-----------------------------------------------------------------------*/
535 
536     protected JScrollPane get$JScrollPane0() {
537         return $JScrollPane0;
538     }
539 
540     protected JSeparator get$JSeparator0() {
541         return $JSeparator0;
542     }
543 
544     /*-----------------------------------------------------------------------*/
545     /*--------------------- Components creation methods ---------------------*/
546     /*-----------------------------------------------------------------------*/
547 
548     protected void addChildrenToAttachmentBody() {
549         if (!allComponentsCreated) {
550             return;
551         }
552         attachmentBody.add(attachmentBodyScrollPane);
553     }
554 
555     protected void addChildrenToAttachmentBodyScrollPane() {
556         if (!allComponentsCreated) {
557             return;
558         }
559         attachmentBodyScrollPane.getViewport().add(mainPanel);
560     }
561 
562     protected void addChildrenToAttachmentDialog() {
563         if (!allComponentsCreated) {
564             return;
565         }
566         add(attachmentBody, BorderLayout.CENTER);
567     }
568 
569     protected void addChildrenToMainPanel() {
570         if (!allComponentsCreated) {
571             return;
572         }
573         mainPanel.add(attachments, new GridBagConstraints(0, 0, 3, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
574         mainPanel.add($JSeparator0, new GridBagConstraints(0, 1, 3, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
575         mainPanel.add(fileLabel, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
576         mainPanel.add(file, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
577         mainPanel.add(addButton, new GridBagConstraints(2, 2, 1, 3, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
578         mainPanel.add(fileNameLabel, new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
579         mainPanel.add(fileName, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
580         mainPanel.add(fileCommentLabel, new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
581         mainPanel.add($JScrollPane0, new GridBagConstraints(1, 4, 1, 1, 1.0, 1.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
582     }
583 
584     protected void createAddButton() {
585         $objectMap.put("addButton", addButton = new JButton());
586         
587         addButton.setName("addButton");
588         addButton.setToolTipText(t("tutti.attachmentEditor.action.add.tip"));
589         addButton.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.util.attachment.actions.AddAttachmentAction.class);
590     }
591 
592     protected void createAttachmentBody() {
593         $objectMap.put("attachmentBody", attachmentBody = new JXTitledPanel());
594         
595         attachmentBody.setName("attachmentBody");
596         attachmentBody.setTitle(t("tutti.attachmentEditor.title"));
597     }
598 
599     protected void createAttachmentBodyScrollPane() {
600         $objectMap.put("attachmentBodyScrollPane", attachmentBodyScrollPane = new JScrollPane());
601         
602         attachmentBodyScrollPane.setName("attachmentBodyScrollPane");
603     }
604 
605     protected void createAttachments() {
606         $objectMap.put("attachments", attachments = new JPanel());
607         
608         attachments.setName("attachments");
609         attachments.setLayout(new GridLayout(0, 1));
610     }
611 
612     protected void createBean() {
613         $objectMap.put("bean", bean = null);
614     }
615 
616     protected void createEditable() {
617         $objectMap.put("editable", editable = true);
618     }
619 
620     protected void createFile() {
621         $objectMap.put("file", file = new FileEditor());
622         
623         file.setName("file");
624     }
625 
626     protected void createFileComment() {
627         $objectMap.put("fileComment", fileComment = new JTextArea());
628         
629         fileComment.setName("fileComment");
630         fileComment.setColumns(15);
631         fileComment.setLineWrap(true);
632         fileComment.setWrapStyleWord(true);
633         fileComment.setRows(3);
634     }
635 
636     protected void createFileCommentLabel() {
637         $objectMap.put("fileCommentLabel", fileCommentLabel = new JLabel());
638         
639         fileCommentLabel.setName("fileCommentLabel");
640         fileCommentLabel.setText(t("tutti.attachmentEditor.field.fileComment"));
641     }
642 
643     protected void createFileLabel() {
644         $objectMap.put("fileLabel", fileLabel = new JLabel());
645         
646         fileLabel.setName("fileLabel");
647         fileLabel.setText(t("tutti.attachmentEditor.field.file"));
648     }
649 
650     protected void createFileName() {
651         $objectMap.put("fileName", fileName = new JTextField());
652         
653         fileName.setName("fileName");
654         fileName.setColumns(15);
655     }
656 
657     protected void createFileNameLabel() {
658         $objectMap.put("fileNameLabel", fileNameLabel = new JLabel());
659         
660         fileNameLabel.setName("fileNameLabel");
661         fileNameLabel.setText(t("tutti.attachmentEditor.field.fileName"));
662     }
663 
664     protected AttachmentEditorUIHandler createHandler() {
665         return new AttachmentEditorUIHandler();
666     }
667 
668     protected void createMainPanel() {
669         $objectMap.put("mainPanel", mainPanel = new Table());
670         
671         mainPanel.setName("mainPanel");
672     }
673 
674     protected void createModel() {
675         $objectMap.put("model", model = getContextValue(TuttiUIContext.class));
676     }
677 
678     /*-----------------------------------------------------------------------*/
679     /*------------------------ Internal jaxx methods ------------------------*/
680     /*-----------------------------------------------------------------------*/
681 
682     private void $completeSetup() {
683         allComponentsCreated = true;
684         if (log.isDebugEnabled()) {
685             log.debug(this);
686         }
687         addChildrenToAttachmentDialog();
688         addChildrenToAttachmentBody();
689         addChildrenToAttachmentBodyScrollPane();
690         addChildrenToMainPanel();
691         // inline complete setup of $JScrollPane0
692         $JScrollPane0.getViewport().add(fileComment);
693         
694         // apply 7 property setters
695         fileLabel.setLabelFor(file);
696         addButton.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.attachmentEditor.action.add.mnemonic"),'Z'));
697         addButton.setIcon(SwingUtil.createActionIcon("add"));
698         fileNameLabel.setLabelFor(fileName);
699         fileCommentLabel.setLabelFor(fileComment);
700         // late initializer
701         attachmentDialog.pack();
702     }
703 
704     private void $initialize() {
705         if (allComponentsCreated) {
706             return;
707         }
708         if (log.isDebugEnabled()) {
709             log.debug(this);
710         }
711         handler.beforeInit(this);
712         $objectMap.put("attachmentDialog", attachmentDialog);
713         createEditable();
714         createBean();
715         createModel();
716         createAttachmentBody();
717         createAttachmentBodyScrollPane();
718         createMainPanel();
719         createAttachments();
720         // inline creation of $JSeparator0
721         $objectMap.put("$JSeparator0", $JSeparator0 = new JSeparator());
722         
723         $JSeparator0.setName("$JSeparator0");
724         createFileLabel();
725         createFile();
726         createAddButton();
727         createFileNameLabel();
728         createFileName();
729         createFileCommentLabel();
730         // inline creation of $JScrollPane0
731         $objectMap.put("$JScrollPane0", $JScrollPane0 = new JScrollPane());
732         
733         $JScrollPane0.setName("$JScrollPane0");
734         createFileComment();
735         // inline creation of attachmentDialog
736         setName("attachmentDialog");
737         attachmentDialog.getContentPane().setLayout(new BorderLayout());
738         setUndecorated(true);
739         setAlwaysOnTop(true);
740         
741         $completeSetup();
742         handler.afterInit(this);
743     }
744 
745 }