View Javadoc
1   package fr.ifremer.tutti.ui.swing.content.protocol.zones;
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.content.protocol.EditProtocolUIModel;
28  import fr.ifremer.tutti.ui.swing.content.protocol.zones.tree.ZoneEditorTreeCellRenderer;
29  import fr.ifremer.tutti.ui.swing.util.TuttiUI;
30  import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
31  import java.awt.Container;
32  import java.awt.GridBagConstraints;
33  import java.awt.GridLayout;
34  import java.awt.Insets;
35  import java.awt.event.FocusEvent;
36  import java.awt.event.FocusListener;
37  import java.awt.event.KeyEvent;
38  import java.awt.event.KeyListener;
39  import java.awt.event.MouseEvent;
40  import java.awt.event.MouseListener;
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.JLabel;
48  import javax.swing.JMenuItem;
49  import javax.swing.JPanel;
50  import javax.swing.JPopupMenu;
51  import javax.swing.JScrollPane;
52  import javax.swing.JToolBar;
53  import javax.swing.JTree;
54  import javax.swing.event.TreeSelectionEvent;
55  import javax.swing.event.TreeSelectionListener;
56  import jaxx.runtime.JAXXBinding;
57  import jaxx.runtime.JAXXContext;
58  import jaxx.runtime.JAXXObject;
59  import jaxx.runtime.JAXXObjectDescriptor;
60  import jaxx.runtime.JAXXUtil;
61  import jaxx.runtime.JAXXValidator;
62  import jaxx.runtime.SwingUtil;
63  import jaxx.runtime.binding.DefaultJAXXBinding;
64  import jaxx.runtime.context.DefaultJAXXContext;
65  import jaxx.runtime.swing.Table;
66  import jaxx.runtime.validator.swing.SwingValidator;
67  import jaxx.runtime.validator.swing.SwingValidatorUtil;
68  import jaxx.runtime.validator.swing.meta.Validator;
69  import jaxx.runtime.validator.swing.meta.ValidatorField;
70  import jaxx.runtime.validator.swing.ui.ImageValidationUI;
71  import org.apache.commons.logging.Log;
72  import org.apache.commons.logging.LogFactory;
73  import static org.nuiton.i18n.I18n.t;
74  
75  public class ZoneEditorUI extends Table implements TuttiUI<EditProtocolUIModel, ZoneEditorUIHandler>, JAXXObject, JAXXValidator {
76  
77      /*-----------------------------------------------------------------------*/
78      /*---------------- Constants for all javaBean properties ----------------*/
79      /*-----------------------------------------------------------------------*/
80  
81      public static final String PROPERTY_MODEL = "model";
82  
83      /*-----------------------------------------------------------------------*/
84      /*------------------ Constants for all public bindings ------------------*/
85      /*-----------------------------------------------------------------------*/
86  
87      public static final String BINDING_AVAILABLE_STRATAS_TREE_MODEL = "availableStratasTree.model";
88      public static final String BINDING_ZONES_TREE_MODEL = "zonesTree.model";
89  
90      /*-----------------------------------------------------------------------*/
91      /*------------------------- Other static fields -------------------------*/
92      /*-----------------------------------------------------------------------*/
93  
94      private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAK1XzW8bRRQfu7Eb56Mp+WzaUNJQREph3fIhPgKlaZpQRwkNsdNGySGMdyfxVOudYXecuIlA/An8CXDngsSNE+LAmQMXhMSFK0IcuCLezK53vfbGG3cdKStr3nu/9zXzmzff/oUyjo2uPcH1umbXLEGrRFtd3N5+WH5CdHGfOLpNuWA2cv9SaZTeRYOGv+4I9OLumjTPe+b5JVblzCJWk/XCGhpwxFOTOBVChEDPhy10x8kXffFCndfsBqofVBTq1//8nf7K+PKbNEJ1DtFNQCqzcVZBJn1rKE0NgUbB0yHOm9g6gDBsah1AvMNybcnEjvMxrpLP0Bfo/BrKcmwDmEBzZ09ZYSj7OhdonBhUbNhMMJ2ZJcY3sEVMgT7YtzW6b5MqsTVRE4JqNao5RxCKpjNLALLGPSPtGDw52g58lwGL2VsFzpWDrECZKjMk3p0u8JabItoqrEuAADB3iE1qYHAj0M1QaX2Bh1uU30eNxQBhWMa7wXiNrxOrJtCkLGzdM1r1BYHBKARABJEJSkFBkKpAEyGrxrq0GA0MoTfQq2ZDKZkKa10BIGriskmg11hgp2QTUmLMvIchx/GQH29ZWuZ8gMukzrFlLEbACDQWsr8HpWeWtLvsm89AmU3MHRIFIHVeCOv3X19dw2Vi3oIEQ+BqNRzaRbU3mhKS6zNhnQHdJtgtr+/tJV864ia308CJUHmukUAnpeHrq0XdBkW5wSH0qVDogSgc23hUb8BjuCmex9eaS6TOUVuJ1GrYRQ4bRtAWFfUbvnAITgw7JKfKQ1ndlov5FvTj5pq8Lj/vcWClK6GjA3ynBXwXEFJqF2XsGiwLdGm3nSI3QeSS46UWcpSASvrf5NivP/z+/UqDEafB90SkahOhA1MBGXBiCypdj7h0WBPUzK9jvrCLcg6cSN1l+5mIwIqeGIIDf6pbmjTXHmCnAhCZ87/9+NPkp7+cQ+kVNGAybKxgqV9AOVGxoQrMNOr8w7sqoqGjfvhehP+MQIO4JpijSg6++4Rdg3oN6cQ0N4llEBtiRnMnFjmaDfhQVn+pSWP+xudwMsDJkbPJmHgA21uV2EMbd3e84yZBjA0sKoF0xHP+0FpWap6gDk2YiWiCX4ly7ud/x4rf3W00IgWFmT5VPWhGZgdlqWVSi6jLybt3Ii+jQTiCNYMF90vUjYPgzsmoI+MR7JL6ftRW7BRs3n1ojZCnD2z2selAmlK5qOKXv7YkXH+DFuMRL+zBaXtM6EFFbFkU7s2pE3VBaQdEBMvQoAhHHFwNm5LjHlNRkXpx3rIVBSlQ+q1bpwAOltXRVrzQES4NRAl7lDKrIC9MdA4SgXj2HFrlJllUEoE+Oen63nZBHW3JZ2EXTNNl1yIKEWJsHlNzyWH09jvWugVEZlFdoJfdsI794+FFoLm3rFb1NUP5Zl2x3O6kDiW92hkGNsxeBeYG8HcyF+NR6s3BkRwUsI1KlJeUgzgrQXlP63/fHzJi6x8xkPSwD+7Qclof+uS8GN8FF+RMXfD8ddkFz6rXXdj0J7b4LrRPd3FdSAUD8c0ToBw1287fkOwTNXx54kjvkZNJF/5nW/z7s1Mnp8E0Eeepla6yxLutWnv16Nl7tRyeDGMb1jpKdptDf2PObM9iOwHvtg6vsXm0z7s96wZO2o2obRybUIcHTA97pCfv0TNl1/F91W1+GdudKHpIeYuG4QUUm0rwVuk27j6T7EeEXUrC1PJldNbIQw+pM9Bk1sRPGSijC+8b4GC2TC0DgrrThp2S3zfPgNhHdfcJ90c0xmQshlz+swPCdGKEq4kRriVGmE+M8EpihFcTI7ydGOFdQPgfEgyy9g4VAAA=";
95      private static final Log log = LogFactory.getLog(ZoneEditorUI.class);
96      private static final long serialVersionUID = 1L;
97  
98      /*-----------------------------------------------------------------------*/
99      /*--------------------------- Internal states ---------------------------*/
100     /*-----------------------------------------------------------------------*/
101 
102     protected List<Object> $activeBindings = new ArrayList<Object>();
103     protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
104     protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
105     protected Map<String, Object> $objectMap = new HashMap<String, Object>();
106     protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
107     private boolean allComponentsCreated;
108     protected final JAXXContext delegateContext = new DefaultJAXXContext();
109 
110     /*-----------------------------------------------------------------------*/
111     /*------------------------ Protected components  ------------------------*/
112     /*-----------------------------------------------------------------------*/
113 
114     protected JButton addButton;
115     protected JTree availableStratasTree;
116     protected JToolBar availableStratasTreeToolBar;
117     protected JButton collapseAvailableStratasTree;
118     protected JButton collapseZonesTree;
119     protected JButton createZone;
120     protected JMenuItem deleteZoneMenuItem;
121     @ValidatorField( validatorId = "validator",  propertyName = "availableStratas",  editorName = "editProtocolTopPanel")
122     protected ZoneEditorUI editProtocolTopPanel = this;
123     protected JButton expandAvailableStratasTree;
124     protected JButton expandZonesTree;
125     protected final ZoneEditorUIHandler handler = createHandler();
126     protected EditProtocolUIModel model;
127     protected JButton removeButton;
128     protected JMenuItem renameZoneMenuItem;
129     @Validator( validatorId = "validator")
130     protected SwingValidator<EditProtocolUIModel> validator;
131     protected List<String> validatorIds = new ArrayList<String>();
132     protected JPopupMenu zonePopupMenu;
133     protected JTree zonesTree;
134     protected JToolBar zonesTreeToolBar;
135 
136     /*-----------------------------------------------------------------------*/
137     /*------------------------- Private components  -------------------------*/
138     /*-----------------------------------------------------------------------*/
139 
140     private JLabel $JLabel0;
141     private JPanel $JPanel0;
142     private JScrollPane $JScrollPane0;
143     private JScrollPane $JScrollPane1;
144 
145     /*-----------------------------------------------------------------------*/
146     /*---------------------------- Constructors  ----------------------------*/
147     /*-----------------------------------------------------------------------*/
148 
149     public ZoneEditorUI(TuttiUI parentUI) {
150         TuttiUIUtil.setParentUI(this, parentUI);
151             $initialize();
152     }
153 
154     public ZoneEditorUI() {
155         $initialize();
156     }
157 
158     public ZoneEditorUI(JAXXContext parentContext) {
159         JAXXUtil.initContext(this, parentContext);
160         $initialize();
161     }
162 
163     /*-----------------------------------------------------------------------*/
164     /*--------------------------- Statics methods ---------------------------*/
165     /*-----------------------------------------------------------------------*/
166 
167     public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
168         return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
169     }
170 
171     /*-----------------------------------------------------------------------*/
172     /*---------------------- JAXXObject implementation ----------------------*/
173     /*-----------------------------------------------------------------------*/
174 
175     @Override
176     public void applyDataBinding(String $binding) {
177         if (allComponentsCreated && $bindings.containsKey($binding)) {
178             getDataBinding($binding).applyDataBinding();
179         }
180         processDataBinding($binding);
181     }
182 
183     @Override
184     public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
185         super.firePropertyChange(propertyName, oldValue, newValue);
186     }
187 
188     @Override
189     public Map<String, Object> get$objectMap() {
190         return $objectMap;
191     }
192 
193     @Override
194     public JAXXBinding getDataBinding(String bindingId) {
195         return $bindings.get(bindingId);
196     }
197 
198     @Override
199     public JAXXBinding[] getDataBindings() {
200         return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
201     }
202 
203     @Override
204     public Object getObjectById(String id) {
205         return $objectMap.get(id);
206     }
207 
208     @Override
209     public void processDataBinding(String $binding, boolean $force) {
210         if (!$force && $activeBindings.contains($binding)) { 
211             return;
212         }
213         $activeBindings.add($binding);
214         try {
215             if (allComponentsCreated && $bindings.containsKey($binding)) {
216                 getDataBinding($binding).processDataBinding();
217             }
218         } finally {
219             $activeBindings.remove($binding);
220         }
221     }
222 
223     @Override
224     public void processDataBinding(String $binding) {
225         processDataBinding($binding, false);
226     }
227 
228     @Override
229     public void registerDataBinding(JAXXBinding binding) {
230         $bindings.put(binding.getId(), binding);
231     }
232 
233     @Override
234     public void removeDataBinding(String $binding) {
235         if (allComponentsCreated && $bindings.containsKey($binding)) {
236             getDataBinding($binding).removeDataBinding();
237         }
238     }
239 
240     /*-----------------------------------------------------------------------*/
241     /*--------------------- JAXXContext implementation  ---------------------*/
242     /*-----------------------------------------------------------------------*/
243 
244     @Override
245     public <T> T getContextValue(Class<T> clazz) {
246         return delegateContext.getContextValue(clazz, null);
247     }
248 
249     @Override
250     public <T> T getContextValue(Class<T> clazz, String name) {
251         return delegateContext.getContextValue(clazz, name);
252     }
253 
254     @Override
255     public JAXXContext getDelegateContext() {
256         return delegateContext;
257     }
258 
259     @Override
260     public <O extends Container> O getParentContainer(Class<O> clazz) {
261         return SwingUtil.getParentContainer(this, clazz);
262     }
263 
264     @Override
265     public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
266         return SwingUtil.getParentContainer(source, clazz);
267     }
268 
269     @Override
270     public <T> void removeContextValue(Class<T> clazz) {
271         delegateContext.removeContextValue(clazz, null);
272     }
273 
274     @Override
275     public <T> void removeContextValue(Class<T> clazz, String name) {
276         delegateContext.removeContextValue(clazz, name);
277     }
278 
279     @Override
280     public <T> void setContextValue(T o) {
281         delegateContext.setContextValue(o, null);
282     }
283 
284     @Override
285     public <T> void setContextValue(T o, String name) {
286         delegateContext.setContextValue(o, name);
287     }
288 
289     /*-----------------------------------------------------------------------*/
290     /*-------------------- JAXXValidator implementation  --------------------*/
291     /*-----------------------------------------------------------------------*/
292 
293     @Override
294     public SwingValidator<?> getValidator(String validatorId) {
295         return (SwingValidator<?>) (validatorIds.contains(validatorId) ? getObjectById(validatorId) : null);
296     }
297 
298     @Override
299     public List<String> getValidatorIds() {
300         return validatorIds;
301     }
302 
303     @Override
304     public void registerValidatorFields() {
305         SwingValidatorUtil.detectValidatorFields(this);
306     }
307 
308     /*-----------------------------------------------------------------------*/
309     /*---------------------------- Event methods ----------------------------*/
310     /*-----------------------------------------------------------------------*/
311 
312     public void doFocusGained__on__$JScrollPane0(FocusEvent event) {
313         if (log.isDebugEnabled()) {
314             log.debug(event);
315         }
316         availableStratasTree.requestFocus();
317     }
318 
319     public void doFocusGained__on__$JScrollPane1(FocusEvent event) {
320         if (log.isDebugEnabled()) {
321             log.debug(event);
322         }
323         zonesTree.requestFocus();
324     }
325 
326     public void doKeyPressed__on__availableStratasTree(KeyEvent event) {
327         if (log.isDebugEnabled()) {
328             log.debug(event);
329         }
330         handler.onKeyPressedOnAvailableStratas(event);
331     }
332 
333     public void doKeyPressed__on__zonesTree(KeyEvent event) {
334         if (log.isDebugEnabled()) {
335             log.debug(event);
336         }
337         handler.onKeyPressedOnZones(event);
338     }
339 
340     public void doMouseClicked__on__availableStratasTree(MouseEvent event) {
341         if (log.isDebugEnabled()) {
342             log.debug(event);
343         }
344         handler.onMouseClickedOnAvailableStratas(event);
345     }
346 
347     public void doMouseClicked__on__zonesTree(MouseEvent event) {
348         if (log.isDebugEnabled()) {
349             log.debug(event);
350         }
351         handler.onMouseClickedPressedOnZones(event, zonePopupMenu);
352     }
353 
354     public void doValueChanged__on__availableStratasTree(TreeSelectionEvent event) {
355         if (log.isDebugEnabled()) {
356             log.debug(event);
357         }
358         availableStratasTree.expandPath(event.getNewLeadSelectionPath());
359     }
360 
361     /*-----------------------------------------------------------------------*/
362     /*----------------------- Public acessor methods  -----------------------*/
363     /*-----------------------------------------------------------------------*/
364 
365     public JButton getAddButton() {
366         return addButton;
367     }
368 
369     public JTree getAvailableStratasTree() {
370         return availableStratasTree;
371     }
372 
373     public JToolBar getAvailableStratasTreeToolBar() {
374         return availableStratasTreeToolBar;
375     }
376 
377     public JButton getCollapseAvailableStratasTree() {
378         return collapseAvailableStratasTree;
379     }
380 
381     public JButton getCollapseZonesTree() {
382         return collapseZonesTree;
383     }
384 
385     public JButton getCreateZone() {
386         return createZone;
387     }
388 
389     public JMenuItem getDeleteZoneMenuItem() {
390         return deleteZoneMenuItem;
391     }
392 
393     public JButton getExpandAvailableStratasTree() {
394         return expandAvailableStratasTree;
395     }
396 
397     public JButton getExpandZonesTree() {
398         return expandZonesTree;
399     }
400 
401     public ZoneEditorUIHandler getHandler() {
402         return handler;
403     }
404 
405     public EditProtocolUIModel getModel() {
406         return model;
407     }
408 
409     public JButton getRemoveButton() {
410         return removeButton;
411     }
412 
413     public JMenuItem getRenameZoneMenuItem() {
414         return renameZoneMenuItem;
415     }
416 
417     public SwingValidator<EditProtocolUIModel> getValidator() {
418         return validator;
419     }
420 
421     public JPopupMenu getZonePopupMenu() {
422         return zonePopupMenu;
423     }
424 
425     public JTree getZonesTree() {
426         return zonesTree;
427     }
428 
429     public JToolBar getZonesTreeToolBar() {
430         return zonesTreeToolBar;
431     }
432 
433     /*-----------------------------------------------------------------------*/
434     /*----------------------- Public mutator methods  -----------------------*/
435     /*-----------------------------------------------------------------------*/
436 
437     public void setModel(EditProtocolUIModel model) {
438         EditProtocolUIModel oldValue = this.model;
439         this.model = model;
440         firePropertyChange(PROPERTY_MODEL, oldValue, model);
441     }
442 
443     /*-----------------------------------------------------------------------*/
444     /*--------------------- Protected acessors methods  ---------------------*/
445     /*-----------------------------------------------------------------------*/
446 
447     protected JLabel get$JLabel0() {
448         return $JLabel0;
449     }
450 
451     protected JPanel get$JPanel0() {
452         return $JPanel0;
453     }
454 
455     protected JScrollPane get$JScrollPane0() {
456         return $JScrollPane0;
457     }
458 
459     protected JScrollPane get$JScrollPane1() {
460         return $JScrollPane1;
461     }
462 
463     /*-----------------------------------------------------------------------*/
464     /*--------------------- Components creation methods ---------------------*/
465     /*-----------------------------------------------------------------------*/
466 
467     protected void addChildrenToAvailableStratasTreeToolBar() {
468         if (!allComponentsCreated) {
469             return;
470         }
471         availableStratasTreeToolBar.add(expandAvailableStratasTree);
472         availableStratasTreeToolBar.add(collapseAvailableStratasTree);
473     }
474 
475     protected void addChildrenToEditProtocolTopPanel() {
476         if (!allComponentsCreated) {
477             return;
478         }
479         add(availableStratasTreeToolBar, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
480         add($JLabel0, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
481         add(zonesTreeToolBar, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
482         add($JScrollPane0, new GridBagConstraints(0, 1, 1, 1, 0.5, 1.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
483         add($JPanel0, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, 11, 1, new Insets(3, 3, 3, 3), 0, 0));
484         add($JScrollPane1, new GridBagConstraints(2, 1, 1, 1, 0.5, 1.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
485     }
486 
487     protected void addChildrenToValidator() {
488         if (!allComponentsCreated) {
489             return;
490         }
491         validator.setUiClass(ImageValidationUI.class);
492         validator.setBean(model);
493     }
494 
495     protected void addChildrenToZonePopupMenu() {
496         if (!allComponentsCreated) {
497             return;
498         }
499         zonePopupMenu.add(deleteZoneMenuItem);
500         zonePopupMenu.add(renameZoneMenuItem);
501     }
502 
503     protected void addChildrenToZonesTreeToolBar() {
504         if (!allComponentsCreated) {
505             return;
506         }
507         zonesTreeToolBar.add(createZone);
508         zonesTreeToolBar.add(expandZonesTree);
509         zonesTreeToolBar.add(collapseZonesTree);
510     }
511 
512     protected void createAddButton() {
513         $objectMap.put("addButton", addButton = new JButton());
514         
515         addButton.setName("addButton");
516         addButton.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.protocol.zones.actions.AddStratasAction.class);
517     }
518 
519     protected void createAvailableStratasTree() {
520         $objectMap.put("availableStratasTree", availableStratasTree = new JTree());
521         
522         availableStratasTree.setName("availableStratasTree");
523         availableStratasTree.setAutoscrolls(true);
524         availableStratasTree.setShowsRootHandles(true);
525         availableStratasTree.setExpandsSelectedPaths(true);
526         availableStratasTree.setScrollsOnExpand(true);
527         availableStratasTree.addKeyListener(JAXXUtil.getEventListener(KeyListener.class, "keyPressed", this, "doKeyPressed__on__availableStratasTree"));
528         availableStratasTree.addMouseListener(JAXXUtil.getEventListener(MouseListener.class, "mouseClicked", this, "doMouseClicked__on__availableStratasTree"));
529         availableStratasTree.addTreeSelectionListener(JAXXUtil.getEventListener(TreeSelectionListener.class, "valueChanged", this, "doValueChanged__on__availableStratasTree"));
530     }
531 
532     protected void createAvailableStratasTreeToolBar() {
533         $objectMap.put("availableStratasTreeToolBar", availableStratasTreeToolBar = new JToolBar());
534         
535         availableStratasTreeToolBar.setName("availableStratasTreeToolBar");
536         availableStratasTreeToolBar.setFloatable(false);
537     }
538 
539     protected void createCollapseAvailableStratasTree() {
540         $objectMap.put("collapseAvailableStratasTree", collapseAvailableStratasTree = new JButton());
541         
542         collapseAvailableStratasTree.setName("collapseAvailableStratasTree");
543         collapseAvailableStratasTree.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.protocol.zones.actions.CollapseAvailableStratasTreeAction.class);
544     }
545 
546     protected void createCollapseZonesTree() {
547         $objectMap.put("collapseZonesTree", collapseZonesTree = new JButton());
548         
549         collapseZonesTree.setName("collapseZonesTree");
550         collapseZonesTree.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.protocol.zones.actions.CollapseZonesTreeAction.class);
551     }
552 
553     protected void createCreateZone() {
554         $objectMap.put("createZone", createZone = new JButton());
555         
556         createZone.setName("createZone");
557         createZone.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.protocol.zones.actions.CreateZoneAction.class);
558     }
559 
560     protected void createDeleteZoneMenuItem() {
561         $objectMap.put("deleteZoneMenuItem", deleteZoneMenuItem = new JMenuItem());
562         
563         deleteZoneMenuItem.setName("deleteZoneMenuItem");
564         deleteZoneMenuItem.setText(t("tutti.zoneEditor.action.delete"));
565         deleteZoneMenuItem.setToolTipText(t("tutti.zoneEditor.action.delete.tip"));
566         deleteZoneMenuItem.putClientProperty("help", "tutti.zoneEditor.action.delete.help");
567         deleteZoneMenuItem.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.protocol.zones.actions.DeleteZoneAction.class);
568     }
569 
570     protected void createExpandAvailableStratasTree() {
571         $objectMap.put("expandAvailableStratasTree", expandAvailableStratasTree = new JButton());
572         
573         expandAvailableStratasTree.setName("expandAvailableStratasTree");
574         expandAvailableStratasTree.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.protocol.zones.actions.ExpandAvailableStratasTreeAction.class);
575     }
576 
577     protected void createExpandZonesTree() {
578         $objectMap.put("expandZonesTree", expandZonesTree = new JButton());
579         
580         expandZonesTree.setName("expandZonesTree");
581         expandZonesTree.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.protocol.zones.actions.ExpandZonesTreeAction.class);
582     }
583 
584     protected ZoneEditorUIHandler createHandler() {
585         return new ZoneEditorUIHandler();
586     }
587 
588     protected void createModel() {
589         $objectMap.put("model", model = getContextValue(EditProtocolUIModel.class));
590     }
591 
592     protected void createRemoveButton() {
593         $objectMap.put("removeButton", removeButton = new JButton());
594         
595         removeButton.setName("removeButton");
596         removeButton.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.protocol.zones.actions.RemoveStratasAction.class);
597     }
598 
599     protected void createRenameZoneMenuItem() {
600         $objectMap.put("renameZoneMenuItem", renameZoneMenuItem = new JMenuItem());
601         
602         renameZoneMenuItem.setName("renameZoneMenuItem");
603         renameZoneMenuItem.setText(t("tutti.zoneEditor.action.rename"));
604         renameZoneMenuItem.setToolTipText(t("tutti.zoneEditor.action.rename.tip"));
605         renameZoneMenuItem.putClientProperty("help", "tutti.zoneEditor.action.rename.help");
606         renameZoneMenuItem.putClientProperty("simpleAction", fr.ifremer.tutti.ui.swing.content.protocol.zones.actions.RenameZoneAction.class);
607     }
608 
609     protected void createValidator() {
610         $objectMap.put("validator", validator = SwingValidator.newValidator(EditProtocolUIModel.class, null));
611     }
612 
613     protected void createZonePopupMenu() {
614         $objectMap.put("zonePopupMenu", zonePopupMenu = new JPopupMenu());
615         
616         zonePopupMenu.setName("zonePopupMenu");
617     }
618 
619     protected void createZonesTree() {
620         $objectMap.put("zonesTree", zonesTree = new JTree());
621         
622         zonesTree.setName("zonesTree");
623         zonesTree.setAutoscrolls(true);
624         zonesTree.setShowsRootHandles(true);
625         zonesTree.setExpandsSelectedPaths(true);
626         zonesTree.setScrollsOnExpand(true);
627         zonesTree.addKeyListener(JAXXUtil.getEventListener(KeyListener.class, "keyPressed", this, "doKeyPressed__on__zonesTree"));
628         zonesTree.addMouseListener(JAXXUtil.getEventListener(MouseListener.class, "mouseClicked", this, "doMouseClicked__on__zonesTree"));
629     }
630 
631     protected void createZonesTreeToolBar() {
632         $objectMap.put("zonesTreeToolBar", zonesTreeToolBar = new JToolBar());
633         
634         zonesTreeToolBar.setName("zonesTreeToolBar");
635         zonesTreeToolBar.setFloatable(false);
636     }
637 
638     /*-----------------------------------------------------------------------*/
639     /*------------------------ Internal jaxx methods ------------------------*/
640     /*-----------------------------------------------------------------------*/
641 
642     private void $completeSetup() {
643         allComponentsCreated = true;
644         if (log.isDebugEnabled()) {
645             log.debug(this);
646         }
647         addChildrenToEditProtocolTopPanel();
648         addChildrenToValidator();
649         addChildrenToZonePopupMenu();
650         addChildrenToAvailableStratasTreeToolBar();
651         addChildrenToZonesTreeToolBar();
652         // inline complete setup of $JScrollPane0
653         $JScrollPane0.getViewport().add(availableStratasTree);
654         // inline complete setup of $JPanel0
655         $JPanel0.add(addButton);
656         $JPanel0.add(removeButton);
657         // inline complete setup of $JScrollPane1
658         $JScrollPane1.getViewport().add(zonesTree);
659         
660         // apply 2 data bindings
661         JAXXUtil.applyDataBinding(this, $bindings.keySet());
662         
663         // apply 14 property setters
664         deleteZoneMenuItem.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.zoneEditor.action.delete.mnemonic"),'Z'));
665         deleteZoneMenuItem.setIcon(SwingUtil.createActionIcon("delete"));
666         renameZoneMenuItem.setMnemonic(SwingUtil.getFirstCharAt(t("tutti.zoneEditor.action.rename.mnemonic"),'Z'));
667         renameZoneMenuItem.setIcon(SwingUtil.createActionIcon("edit"));
668         expandAvailableStratasTree.setIcon(SwingUtil.createActionIcon("expand"));
669         collapseAvailableStratasTree.setIcon(SwingUtil.createActionIcon("collapse"));
670         createZone.setIcon(SwingUtil.createActionIcon("add"));
671         expandZonesTree.setIcon(SwingUtil.createActionIcon("expand"));
672         collapseZonesTree.setIcon(SwingUtil.createActionIcon("collapse"));
673         availableStratasTree.setCellRenderer(new ZoneEditorTreeCellRenderer());
674         addButton.setIcon(SwingUtil.createActionIcon("right"));
675         removeButton.setIcon(SwingUtil.createActionIcon("left"));
676         zonesTree.setCellRenderer(new ZoneEditorTreeCellRenderer());
677         // late initializer
678         // register 1 validator(s)
679         validatorIds = SwingValidatorUtil.detectValidators(this);
680         SwingValidatorUtil.installUI(this);
681     }
682 
683     private void $initialize() {
684         if (allComponentsCreated) {
685             return;
686         }
687         if (log.isDebugEnabled()) {
688             log.debug(this);
689         }
690         handler.beforeInit(this);
691         $objectMap.put("editProtocolTopPanel", editProtocolTopPanel);
692         createModel();
693         createValidator();
694         createZonePopupMenu();
695         createDeleteZoneMenuItem();
696         createRenameZoneMenuItem();
697         createAvailableStratasTreeToolBar();
698         createExpandAvailableStratasTree();
699         createCollapseAvailableStratasTree();
700         // inline creation of $JLabel0
701         $objectMap.put("$JLabel0", $JLabel0 = new JLabel());
702         
703         $JLabel0.setName("$JLabel0");
704         createZonesTreeToolBar();
705         createCreateZone();
706         createExpandZonesTree();
707         createCollapseZonesTree();
708         // inline creation of $JScrollPane0
709         $objectMap.put("$JScrollPane0", $JScrollPane0 = new JScrollPane());
710         
711         $JScrollPane0.setName("$JScrollPane0");
712         $JScrollPane0.addFocusListener(JAXXUtil.getEventListener(FocusListener.class, "focusGained", this, "doFocusGained__on__$JScrollPane0"));
713         createAvailableStratasTree();
714         // inline creation of $JPanel0
715         $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
716         
717         $JPanel0.setName("$JPanel0");
718         $JPanel0.setLayout(new GridLayout(0,1));
719         createAddButton();
720         createRemoveButton();
721         // inline creation of $JScrollPane1
722         $objectMap.put("$JScrollPane1", $JScrollPane1 = new JScrollPane());
723         
724         $JScrollPane1.setName("$JScrollPane1");
725         $JScrollPane1.addFocusListener(JAXXUtil.getEventListener(FocusListener.class, "focusGained", this, "doFocusGained__on__$JScrollPane1"));
726         createZonesTree();
727         // inline creation of editProtocolTopPanel
728         setName("editProtocolTopPanel");
729         
730         // registers 2 data bindings
731         $registerDefaultBindings();
732         $completeSetup();
733         handler.afterInit(this);
734     }
735 
736     private void $registerDefaultBindings() {
737         // register 2 data bindings
738         registerDataBinding(new DefaultJAXXBinding(this, BINDING_AVAILABLE_STRATAS_TREE_MODEL, true, true) {
739         
740             @Override
741             public void applyDataBinding() {
742                 addPropertyChangeListener("model", this);
743                 if (getModel() != null) {
744                     getModel().addPropertyChangeListener("availableStratasTreeModel", this);
745                 }
746             }
747         
748             @Override
749             public void processDataBinding() {
750                 if (getModel() != null) {
751                     availableStratasTree.setModel(getModel().getAvailableStratasTreeModel());
752                 }
753             }
754         
755             @Override
756             public void removeDataBinding() {
757                 removePropertyChangeListener("model", this);
758                 if (getModel() != null) {
759                     getModel().removePropertyChangeListener("availableStratasTreeModel", this);
760                 }
761             }
762         });
763         registerDataBinding(new DefaultJAXXBinding(this, BINDING_ZONES_TREE_MODEL, true, true) {
764         
765             @Override
766             public void applyDataBinding() {
767                 addPropertyChangeListener("model", this);
768                 if (getModel() != null) {
769                     getModel().addPropertyChangeListener("zonesTreeModel", this);
770                 }
771             }
772         
773             @Override
774             public void processDataBinding() {
775                 if (getModel() != null) {
776                     zonesTree.setModel(getModel().getZonesTreeModel());
777                 }
778             }
779         
780             @Override
781             public void removeDataBinding() {
782                 removePropertyChangeListener("model", this);
783                 if (getModel() != null) {
784                     getModel().removePropertyChangeListener("zonesTreeModel", this);
785                 }
786             }
787         });
788     }
789 
790 }