View Javadoc
1   package fr.ifremer.dali.ui.swing.content.manage.rule;
2   
3   import fr.ifremer.dali.ui.swing.DaliHelpBroker;
4   import fr.ifremer.dali.ui.swing.DaliUIContext;
5   import fr.ifremer.dali.ui.swing.content.manage.rule.controlrule.ControlRuleTableUI;
6   import fr.ifremer.dali.ui.swing.content.manage.rule.department.ControlDepartmentTableUI;
7   import fr.ifremer.dali.ui.swing.content.manage.rule.menu.RulesMenuUI;
8   import fr.ifremer.dali.ui.swing.content.manage.rule.pmfm.ControlPmfmTableUI;
9   import fr.ifremer.dali.ui.swing.content.manage.rule.program.ControlProgramTableUI;
10  import fr.ifremer.dali.ui.swing.content.manage.rule.rulelist.RuleListUI;
11  import fr.ifremer.dali.ui.swing.util.DaliUI;
12  import fr.ifremer.quadrige3.ui.swing.ApplicationUI;
13  import fr.ifremer.quadrige3.ui.swing.ApplicationUIUtil;
14  import java.awt.BorderLayout;
15  import java.awt.Component;
16  import java.awt.Container;
17  import java.awt.GridLayout;
18  import java.awt.LayoutManager;
19  import java.awt.event.FocusEvent;
20  import java.awt.event.FocusListener;
21  import java.awt.event.KeyEvent;
22  import java.awt.event.KeyListener;
23  import java.util.ArrayList;
24  import java.util.HashMap;
25  import java.util.List;
26  import java.util.Map;
27  import java.util.TreeMap;
28  import javax.swing.BorderFactory;
29  import javax.swing.Box;
30  import javax.swing.BoxLayout;
31  import javax.swing.JButton;
32  import javax.swing.JPanel;
33  import javax.swing.JScrollPane;
34  import javax.swing.JTextArea;
35  import jaxx.runtime.JAXXBinding;
36  import jaxx.runtime.JAXXContext;
37  import jaxx.runtime.JAXXObject;
38  import jaxx.runtime.JAXXObjectDescriptor;
39  import jaxx.runtime.JAXXUtil;
40  import jaxx.runtime.JAXXValidator;
41  import jaxx.runtime.SwingUtil;
42  import jaxx.runtime.binding.DefaultJAXXBinding;
43  import jaxx.runtime.context.DefaultJAXXContext;
44  import jaxx.runtime.swing.help.JAXXHelpUI;
45  import jaxx.runtime.validator.swing.SwingValidator;
46  import jaxx.runtime.validator.swing.SwingValidatorUtil;
47  import jaxx.runtime.validator.swing.meta.Validator;
48  import jaxx.runtime.validator.swing.meta.ValidatorField;
49  import jaxx.runtime.validator.swing.ui.ImageValidationUI;
50  import org.apache.commons.logging.Log;
51  import org.apache.commons.logging.LogFactory;
52  import static org.nuiton.i18n.I18n.t;
53  
54  public class RulesUI extends JPanel implements JAXXHelpUI<DaliHelpBroker>, DaliUI<RulesUIModel, RulesUIHandler>, JAXXObject, JAXXValidator {
55  
56      /*-----------------------------------------------------------------------*/
57      /*------------------ Constants for all public bindings ------------------*/
58      /*-----------------------------------------------------------------------*/
59  
60      public static final String BINDING_SAVE_BUTTON_ENABLED = "saveButton.enabled";
61  
62      /*-----------------------------------------------------------------------*/
63      /*------------------------- Other static fields -------------------------*/
64      /*-----------------------------------------------------------------------*/
65  
66      private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAKVXz28bRRSemMRpEn60CQ4JTSGkVUmEtAaSSJS0aRw7UZM6JcJuFJFDGe9Oki2zO8vuOLEVBXGDI38CXODCBYkDEqeKQ88cuCD+BYQ4cEW8N7ve9dZrx8Y5jLzz3vve996bN2/y/Z9kyHPJG49praa5VVuaFtO2c/v7H1QeM10WmKe7piOFS/y/gRRJHZAxI9z3JLl+UETzbGCezQvLETazm6xXimTUk3XOvGPGpCTX4ha652VLoXil5lTdBmpIKgn167//Sn1lfP5NipCaA+ymIJTZi6yiSAaLJGUakoyDpxOa5dQ+AhquaR8B3xdwL8+p5z2gFvuUfEaGiyTtUBfAJJnrPmSFoexrjiSXbmzvUpvxtyVZOnQ189BlFnM1g3JTq5qadwreNV3YEsA0i9r0iEEwnGkfwuI93HIchZWWZMgSBuOS3Po/MDtoG2GlK674hLmSvNkWrABf98BmXWlGpiMnIDAoRCzJW7Hch4IAoYTrXmMzQhhDYt4Os6sPtyS501M4Flj5Mfn2CDkSIo9CMQTnmHBJXsGC1gKs7VIoiZs06vMOHIuYgdpFpalIVwon3L6Gy9XINdIrmp7EmNZ6igkXDpYqLh8CQV9r4fhu6DeSZRARQtt1xZFLrTKtcIYUtnui4PjW0D4JYOjpeuhwKnBYYNAbEuohQ5+7Pfk0QoCG2xbIuOfxwDOmKfR5vyefAYL6nW9Bi1d0rCKkFFa7gjfY7FqHUdYLvWUdTMOURzDoQGsp/mLIIZJlEGaHeR5Axg/4q7gshopXmhQ3DFM1byZ23MusJnMuo2iwHNpNo13jjjOF3dFJ5hll3xEKb+HyfktIS2FIrf24HMpWo4roXHhsvQplsSWZiPH3d1Fxrek6oCcsEhQCqUuuxu4tmEZaNI2icTFwQIbUVQWH/qB1gOHB8UfX1DOjCwGV9N/Jid9+/uPHzca8ehl8ZxJVm8YtzBFoRwduZxNdv+QPq6o0eXaHOisHZMRjHGa1msUzCcRKgRjIgb8raK6huXaPescAMTT8+5NfJj/+9TmS2iSjXFBjk6L+FhmRxy5kQXCj5txdU4yeP70E62XkBlfqI2Hz+h5S0yn3DwOeWUkGpVtlNcjFTEIuQkKVkaf/TJR+WGvkYwD4TbdVj3Iy9BFJmzY3baYmeDCcEyf2mOOxqiGiIZw0lklsVDjBaCqqdbcl8EFo9kfUcTgEjec6p+MKB/Asj+fR/9R0xD8HYKq+t7DhSVqnto5DO9MKcJ/VJVk+a3tjqJLhFAZFeKXAFPa0fO5BfqN4jvmGfoW+Via6sCzFANjUqhhEWSUXf+2ReN9cFGy6TbDjZyVopk6xDmK3tY90sbdIS7m9jSjOy81x+n7GpBC8bDplpTCpFHw6SkELOneY2XhC4dW3eqYeUJrpwWPIPKzPL8zevDnb2FPvlPgWBrzhW88vnCcltumCuSivA/joEq6Bj661s3X1y2+7uqbDvStZ2ZTgyZfMy/k5FVHw6FEXtyZRY24hmUvyLOiFVqFHWkZ01Xem1n6KdEOP07qAFJMXb8M7ks5WTNuAQ7Pa4mgA19HuA0b5l8ko0xei4PYXHRBm+kZ4vW+EG30jZPtGWOqiHoOuOIVOHb/tX/GzVML/ZJWqZG1q/F5XrL7F5btkhDt9x3W3b4RcF5kZhV47svFBvN8BKd8Vl586IGx2UyVT959RfbF4cgGL/wDLANWEoBAAAA==";
67      private static final Log log = LogFactory.getLog(RulesUI.class);
68      private static final long serialVersionUID = 1L;
69  
70      /*-----------------------------------------------------------------------*/
71      /*--------------------------- Internal states ---------------------------*/
72      /*-----------------------------------------------------------------------*/
73  
74      protected List<Object> $activeBindings = new ArrayList<Object>();
75      protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
76      protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
77      protected Map<String, Object> $objectMap = new HashMap<String, Object>();
78      protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
79      private boolean allComponentsCreated;
80      protected final JAXXContext delegateContext = new DefaultJAXXContext();
81  
82      /*-----------------------------------------------------------------------*/
83      /*------------------------ Protected components  ------------------------*/
84      /*-----------------------------------------------------------------------*/
85  
86      protected JPanel bottomPanel;
87      protected DaliHelpBroker broker;
88      protected JButton closeButton;
89      @ValidatorField( validatorId = "validator",  propertyName = "departmentsUIModel",  editorName = "controlDepartmentTableUI")
90      protected ControlDepartmentTableUI controlDepartmentTableUI;
91      @ValidatorField( validatorId = "validator",  propertyName = "pmfmUIModel",  editorName = "controlPmfmTableUI")
92      protected ControlPmfmTableUI controlPmfmTableUI;
93      @ValidatorField( validatorId = "validator",  propertyName = "programsUIModel",  editorName = "controlProgramTableUI")
94      protected ControlProgramTableUI controlProgramTableUI;
95      @ValidatorField( validatorId = "validator",  propertyName = "controlRuleUIModel",  editorName = "controlRuleTableUI")
96      protected ControlRuleTableUI controlRuleTableUI;
97      protected final RulesUIHandler handler = createHandler();
98      protected RulesUIModel model;
99      protected JTextArea ruleDescriptionEditor;
100     protected JScrollPane ruleDescriptionScrollPane;
101     @ValidatorField( validatorId = "validator",  propertyName = "ruleListUIModel",  editorName = "ruleListUI")
102     protected RuleListUI ruleListUI;
103     protected JTextArea ruleMessageEditor;
104     protected JScrollPane ruleMessageScrollPane;
105     protected RulesMenuUI rulesMenuUI;
106     protected JButton saveButton;
107     protected JScrollPane scrollPane;
108     protected JPanel topPanel;
109     @Validator( validatorId = "validator")
110     protected SwingValidator<RulesUIModel> validator;
111     protected List<String> validatorIds = new ArrayList<String>();
112 
113     /*-----------------------------------------------------------------------*/
114     /*------------------------- Private components  -------------------------*/
115     /*-----------------------------------------------------------------------*/
116 
117     private RulesUI $JPanel0 = this;
118     private JPanel $JPanel1;
119     private JPanel $JPanel2;
120     private JPanel $JPanel3;
121     private JPanel $JPanel4;
122     private JPanel $JPanel5;
123 
124     /*-----------------------------------------------------------------------*/
125     /*---------------------------- Constructors  ----------------------------*/
126     /*-----------------------------------------------------------------------*/
127 
128     public RulesUI(ApplicationUI parentUI) {
129         ApplicationUIUtil.setParentUI(this, parentUI);
130             $initialize();
131     }
132 
133     public RulesUI() {
134         $initialize();
135     }
136 
137     public RulesUI(JAXXContext parentContext) {
138         JAXXUtil.initContext(this, parentContext);
139         $initialize();
140     }
141 
142     public RulesUI(boolean param0) {
143         super(param0);
144         $initialize();
145     }
146 
147     public RulesUI(JAXXContext parentContext, boolean param1) {
148         super(param1);
149         JAXXUtil.initContext(this, parentContext);
150         $initialize();
151     }
152 
153     public RulesUI(LayoutManager param0) {
154         super(param0);
155         $initialize();
156     }
157 
158     public RulesUI(JAXXContext parentContext, LayoutManager param1) {
159         super(param1);
160         JAXXUtil.initContext(this, parentContext);
161         $initialize();
162     }
163 
164     public RulesUI(LayoutManager param0, boolean param1) {
165         super(param0 ,param1);
166         $initialize();
167     }
168 
169     public RulesUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
170         super(param1 ,param2);
171         JAXXUtil.initContext(this, parentContext);
172         $initialize();
173     }
174 
175     /*-----------------------------------------------------------------------*/
176     /*--------------------------- Statics methods ---------------------------*/
177     /*-----------------------------------------------------------------------*/
178 
179     public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
180         return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
181     }
182 
183     /*-----------------------------------------------------------------------*/
184     /*---------------------- JAXXObject implementation ----------------------*/
185     /*-----------------------------------------------------------------------*/
186 
187     @Override
188     public void applyDataBinding(String $binding) {
189         if (allComponentsCreated && $bindings.containsKey($binding)) {
190             getDataBinding($binding).applyDataBinding();
191         }
192         processDataBinding($binding);
193     }
194 
195     @Override
196     public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
197         super.firePropertyChange(propertyName, oldValue, newValue);
198     }
199 
200     @Override
201     public Map<String, Object> get$objectMap() {
202         return $objectMap;
203     }
204 
205     @Override
206     public JAXXBinding getDataBinding(String bindingId) {
207         return $bindings.get(bindingId);
208     }
209 
210     @Override
211     public JAXXBinding[] getDataBindings() {
212         return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
213     }
214 
215     @Override
216     public Object getObjectById(String id) {
217         return $objectMap.get(id);
218     }
219 
220     @Override
221     public void processDataBinding(String $binding, boolean $force) {
222         if (!$force && $activeBindings.contains($binding)) { 
223             return;
224         }
225         $activeBindings.add($binding);
226         try {
227             if (allComponentsCreated && $bindings.containsKey($binding)) {
228                 getDataBinding($binding).processDataBinding();
229             }
230         } finally {
231             $activeBindings.remove($binding);
232         }
233     }
234 
235     @Override
236     public void processDataBinding(String $binding) {
237         processDataBinding($binding, false);
238     }
239 
240     @Override
241     public void registerDataBinding(JAXXBinding binding) {
242         $bindings.put(binding.getId(), binding);
243     }
244 
245     @Override
246     public void removeDataBinding(String $binding) {
247         if (allComponentsCreated && $bindings.containsKey($binding)) {
248             getDataBinding($binding).removeDataBinding();
249         }
250     }
251 
252     /*-----------------------------------------------------------------------*/
253     /*--------------------- JAXXContext implementation  ---------------------*/
254     /*-----------------------------------------------------------------------*/
255 
256     @Override
257     public <T> T getContextValue(Class<T> clazz) {
258         return delegateContext.getContextValue(clazz, null);
259     }
260 
261     @Override
262     public <T> T getContextValue(Class<T> clazz, String name) {
263         return delegateContext.getContextValue(clazz, name);
264     }
265 
266     @Override
267     public JAXXContext getDelegateContext() {
268         return delegateContext;
269     }
270 
271     @Override
272     public <O extends Container> O getParentContainer(Class<O> clazz) {
273         return SwingUtil.getParentContainer(this, clazz);
274     }
275 
276     @Override
277     public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
278         return SwingUtil.getParentContainer(source, clazz);
279     }
280 
281     @Override
282     public <T> void removeContextValue(Class<T> clazz) {
283         delegateContext.removeContextValue(clazz, null);
284     }
285 
286     @Override
287     public <T> void removeContextValue(Class<T> clazz, String name) {
288         delegateContext.removeContextValue(clazz, name);
289     }
290 
291     @Override
292     public <T> void setContextValue(T o) {
293         delegateContext.setContextValue(o, null);
294     }
295 
296     @Override
297     public <T> void setContextValue(T o, String name) {
298         delegateContext.setContextValue(o, name);
299     }
300 
301     /*-----------------------------------------------------------------------*/
302     /*-------------------- JAXXValidator implementation  --------------------*/
303     /*-----------------------------------------------------------------------*/
304 
305     @Override
306     public SwingValidator<?> getValidator(String validatorId) {
307         return (SwingValidator<?>) (validatorIds.contains(validatorId) ? getObjectById(validatorId) : null);
308     }
309 
310     @Override
311     public List<String> getValidatorIds() {
312         return validatorIds;
313     }
314 
315     @Override
316     public void registerValidatorFields() {
317         SwingValidatorUtil.detectValidatorFields(this);
318     }
319 
320     /*-----------------------------------------------------------------------*/
321     /*---------------------------- Event methods ----------------------------*/
322     /*-----------------------------------------------------------------------*/
323 
324     public void doFocusGained__on__ruleDescriptionScrollPane(FocusEvent event) {
325         if (log.isDebugEnabled()) {
326             log.debug(event);
327         }
328         ruleDescriptionEditor.requestFocus();
329     }
330 
331     public void doFocusGained__on__ruleMessageScrollPane(FocusEvent event) {
332         if (log.isDebugEnabled()) {
333             log.debug(event);
334         }
335         ruleMessageEditor.requestFocus();
336     }
337 
338     public void doKeyReleased__on__ruleDescriptionEditor(KeyEvent event) {
339         if (log.isDebugEnabled()) {
340             log.debug(event);
341         }
342         handler.setRuleDescription();
343     }
344 
345     public void doKeyReleased__on__ruleMessageEditor(KeyEvent event) {
346         if (log.isDebugEnabled()) {
347             log.debug(event);
348         }
349         handler.setRuleErrorMessage();
350     }
351 
352     /*-----------------------------------------------------------------------*/
353     /*----------------------- Public acessor methods  -----------------------*/
354     /*-----------------------------------------------------------------------*/
355 
356     public JPanel getBottomPanel() {
357         return bottomPanel;
358     }
359 
360     public DaliHelpBroker getBroker() {
361         return broker;
362     }
363 
364     public JButton getCloseButton() {
365         return closeButton;
366     }
367 
368     public ControlDepartmentTableUI getControlDepartmentTableUI() {
369         return controlDepartmentTableUI;
370     }
371 
372     public ControlPmfmTableUI getControlPmfmTableUI() {
373         return controlPmfmTableUI;
374     }
375 
376     public ControlProgramTableUI getControlProgramTableUI() {
377         return controlProgramTableUI;
378     }
379 
380     public ControlRuleTableUI getControlRuleTableUI() {
381         return controlRuleTableUI;
382     }
383 
384     public RulesUIHandler getHandler() {
385         return handler;
386     }
387 
388     public RulesUIModel getModel() {
389         return model;
390     }
391 
392     public JTextArea getRuleDescriptionEditor() {
393         return ruleDescriptionEditor;
394     }
395 
396     public JScrollPane getRuleDescriptionScrollPane() {
397         return ruleDescriptionScrollPane;
398     }
399 
400     public RuleListUI getRuleListUI() {
401         return ruleListUI;
402     }
403 
404     public JTextArea getRuleMessageEditor() {
405         return ruleMessageEditor;
406     }
407 
408     public JScrollPane getRuleMessageScrollPane() {
409         return ruleMessageScrollPane;
410     }
411 
412     public RulesMenuUI getRulesMenuUI() {
413         return rulesMenuUI;
414     }
415 
416     public JButton getSaveButton() {
417         return saveButton;
418     }
419 
420     public JScrollPane getScrollPane() {
421         return scrollPane;
422     }
423 
424     public JPanel getTopPanel() {
425         return topPanel;
426     }
427 
428     public SwingValidator<RulesUIModel> getValidator() {
429         return validator;
430     }
431 
432     /*-----------------------------------------------------------------------*/
433     /*---------------------------- Other methods ----------------------------*/
434     /*-----------------------------------------------------------------------*/
435 
436     @Override
437     public void registerHelpId(DaliHelpBroker broker, Component component, String helpId) {
438         broker.installUI(component, helpId);
439     }
440 
441     @Override
442     public void showHelp(String helpId) {
443         getBroker().showHelp(this, helpId);
444     }
445 
446     /*-----------------------------------------------------------------------*/
447     /*--------------------- Protected acessors methods  ---------------------*/
448     /*-----------------------------------------------------------------------*/
449 
450     protected JPanel get$JPanel1() {
451         return $JPanel1;
452     }
453 
454     protected JPanel get$JPanel2() {
455         return $JPanel2;
456     }
457 
458     protected JPanel get$JPanel3() {
459         return $JPanel3;
460     }
461 
462     protected JPanel get$JPanel4() {
463         return $JPanel4;
464     }
465 
466     protected JPanel get$JPanel5() {
467         return $JPanel5;
468     }
469 
470     /*-----------------------------------------------------------------------*/
471     /*--------------------- Components creation methods ---------------------*/
472     /*-----------------------------------------------------------------------*/
473 
474     protected void addChildrenToBottomPanel() {
475         if (!allComponentsCreated) {
476             return;
477         }
478         bottomPanel.add(SwingUtil.boxComponentWithJxLayer(controlPmfmTableUI));
479         bottomPanel.add($JPanel3);
480     }
481 
482     protected void addChildrenToRuleDescriptionScrollPane() {
483         if (!allComponentsCreated) {
484             return;
485         }
486         ruleDescriptionScrollPane.getViewport().add(ruleDescriptionEditor);
487     }
488 
489     protected void addChildrenToRuleMessageScrollPane() {
490         if (!allComponentsCreated) {
491             return;
492         }
493         ruleMessageScrollPane.getViewport().add(ruleMessageEditor);
494     }
495 
496     protected void addChildrenToScrollPane() {
497         if (!allComponentsCreated) {
498             return;
499         }
500         scrollPane.getViewport().add($JPanel1);
501     }
502 
503     protected void addChildrenToTopPanel() {
504         if (!allComponentsCreated) {
505             return;
506         }
507         topPanel.add(SwingUtil.boxComponentWithJxLayer(ruleListUI));
508         topPanel.add($JPanel2);
509     }
510 
511     protected void addChildrenToValidator() {
512         if (!allComponentsCreated) {
513             return;
514         }
515         validator.setUiClass(ImageValidationUI.class);
516         validator.setBean(model);
517     }
518 
519     protected void createBottomPanel() {
520         $objectMap.put("bottomPanel", bottomPanel = new JPanel());
521         
522         bottomPanel.setName("bottomPanel");
523         bottomPanel.setLayout(new GridLayout(1,0));
524     }
525 
526     protected void createBroker() {
527         $objectMap.put("broker", broker = new DaliHelpBroker("dali.home.help"));
528     }
529 
530     protected void createCloseButton() {
531         $objectMap.put("closeButton", closeButton = new JButton());
532         
533         closeButton.setName("closeButton");
534         closeButton.setText(t("dali.common.close"));
535         closeButton.putClientProperty("applicationActionKey", fr.ifremer.dali.ui.swing.util.DaliKeyStrokes.CANCEL);
536         closeButton.putClientProperty("applicationAction", CloseAction.class);
537     }
538 
539     protected void createControlDepartmentTableUI() {
540         $objectMap.put("controlDepartmentTableUI", controlDepartmentTableUI = new ControlDepartmentTableUI(this));
541         
542         controlDepartmentTableUI.setName("controlDepartmentTableUI");
543     }
544 
545     protected void createControlPmfmTableUI() {
546         $objectMap.put("controlPmfmTableUI", controlPmfmTableUI = new ControlPmfmTableUI(this));
547         
548         controlPmfmTableUI.setName("controlPmfmTableUI");
549     }
550 
551     protected void createControlProgramTableUI() {
552         $objectMap.put("controlProgramTableUI", controlProgramTableUI = new ControlProgramTableUI(this));
553         
554         controlProgramTableUI.setName("controlProgramTableUI");
555     }
556 
557     protected void createControlRuleTableUI() {
558         $objectMap.put("controlRuleTableUI", controlRuleTableUI = new ControlRuleTableUI(this));
559         
560         controlRuleTableUI.setName("controlRuleTableUI");
561     }
562 
563     protected RulesUIHandler createHandler() {
564         return new RulesUIHandler();
565     }
566 
567     protected void createModel() {
568         $objectMap.put("model", model = getContextValue(RulesUIModel.class));
569     }
570 
571     protected void createRuleDescriptionEditor() {
572         $objectMap.put("ruleDescriptionEditor", ruleDescriptionEditor = new JTextArea());
573         
574         ruleDescriptionEditor.setName("ruleDescriptionEditor");
575         ruleDescriptionEditor.setColumns(15);
576         ruleDescriptionEditor.setLineWrap(true);
577         ruleDescriptionEditor.setWrapStyleWord(true);
578         ruleDescriptionEditor.setRows(2);
579         ruleDescriptionEditor.addKeyListener(JAXXUtil.getEventListener(KeyListener.class, "keyReleased", this, "doKeyReleased__on__ruleDescriptionEditor"));
580     }
581 
582     protected void createRuleDescriptionScrollPane() {
583         $objectMap.put("ruleDescriptionScrollPane", ruleDescriptionScrollPane = new JScrollPane());
584         
585         ruleDescriptionScrollPane.setName("ruleDescriptionScrollPane");
586         ruleDescriptionScrollPane.addFocusListener(JAXXUtil.getEventListener(FocusListener.class, "focusGained", this, "doFocusGained__on__ruleDescriptionScrollPane"));
587     }
588 
589     protected void createRuleListUI() {
590         $objectMap.put("ruleListUI", ruleListUI = new RuleListUI(this));
591         
592         ruleListUI.setName("ruleListUI");
593     }
594 
595     protected void createRuleMessageEditor() {
596         $objectMap.put("ruleMessageEditor", ruleMessageEditor = new JTextArea());
597         
598         ruleMessageEditor.setName("ruleMessageEditor");
599         ruleMessageEditor.setColumns(15);
600         ruleMessageEditor.setLineWrap(true);
601         ruleMessageEditor.setWrapStyleWord(true);
602         ruleMessageEditor.setRows(2);
603         ruleMessageEditor.addKeyListener(JAXXUtil.getEventListener(KeyListener.class, "keyReleased", this, "doKeyReleased__on__ruleMessageEditor"));
604     }
605 
606     protected void createRuleMessageScrollPane() {
607         $objectMap.put("ruleMessageScrollPane", ruleMessageScrollPane = new JScrollPane());
608         
609         ruleMessageScrollPane.setName("ruleMessageScrollPane");
610         ruleMessageScrollPane.addFocusListener(JAXXUtil.getEventListener(FocusListener.class, "focusGained", this, "doFocusGained__on__ruleMessageScrollPane"));
611     }
612 
613     protected void createRulesMenuUI() {
614         $objectMap.put("rulesMenuUI", rulesMenuUI = new RulesMenuUI(this));
615         
616         rulesMenuUI.setName("rulesMenuUI");
617     }
618 
619     protected void createSaveButton() {
620         $objectMap.put("saveButton", saveButton = new JButton());
621         
622         saveButton.setName("saveButton");
623         saveButton.setText(t("dali.common.save"));
624         saveButton.setToolTipText(t("dali.action.save.rules"));
625         saveButton.putClientProperty("applicationActionKey", fr.ifremer.dali.ui.swing.util.DaliKeyStrokes.SAVE);
626         saveButton.putClientProperty("applicationAction", SaveAction.class);
627     }
628 
629     protected void createScrollPane() {
630         $objectMap.put("scrollPane", scrollPane = new JScrollPane());
631         
632         scrollPane.setName("scrollPane");
633         scrollPane.putClientProperty("onlyVerticalScrollable", true);
634     }
635 
636     protected void createTopPanel() {
637         $objectMap.put("topPanel", topPanel = new JPanel());
638         
639         topPanel.setName("topPanel");
640         topPanel.setLayout(new GridLayout(0,1));
641     }
642 
643     protected void createValidator() {
644         $objectMap.put("validator", validator = SwingValidator.newValidator(RulesUIModel.class, null));
645     }
646 
647     /*-----------------------------------------------------------------------*/
648     /*------------------------ Internal jaxx methods ------------------------*/
649     /*-----------------------------------------------------------------------*/
650 
651     private void $completeSetup() {
652         allComponentsCreated = true;
653         if (log.isDebugEnabled()) {
654             log.debug(this);
655         }
656         // inline complete setup of $JPanel0
657         add(rulesMenuUI, BorderLayout.LINE_START);
658         add(scrollPane);
659         add($JPanel4, BorderLayout.PAGE_END);
660         addChildrenToValidator();
661         addChildrenToScrollPane();
662         // inline complete setup of $JPanel1
663         $JPanel1.add(topPanel, BorderLayout.PAGE_START);
664         $JPanel1.add(SwingUtil.boxComponentWithJxLayer(controlRuleTableUI), BorderLayout.CENTER);
665         $JPanel1.add(bottomPanel, BorderLayout.PAGE_END);
666         addChildrenToTopPanel();
667         // inline complete setup of $JPanel2
668         $JPanel2.add(SwingUtil.boxComponentWithJxLayer(controlProgramTableUI));
669         $JPanel2.add(SwingUtil.boxComponentWithJxLayer(controlDepartmentTableUI));
670         addChildrenToBottomPanel();
671         // inline complete setup of $JPanel3
672         $JPanel3.add(ruleMessageScrollPane);
673         $JPanel3.add(ruleDescriptionScrollPane);
674         addChildrenToRuleMessageScrollPane();
675         addChildrenToRuleDescriptionScrollPane();
676         // inline complete setup of $JPanel4
677         $JPanel4.add($JPanel5, BorderLayout.CENTER);
678         // inline complete setup of $JPanel5
679         $JPanel5.add(closeButton);
680         $JPanel5.add(saveButton);
681         
682         // apply 1 data bindings
683         JAXXUtil.applyDataBinding(this, $bindings.keySet());
684         
685         // apply 15 property setters
686         scrollPane.setBorder(null);
687         closeButton.setAlignmentX(Component.CENTER_ALIGNMENT);
688         saveButton.setAlignmentX(Component.CENTER_ALIGNMENT);
689         ruleMessageScrollPane.setBorder(BorderFactory.createTitledBorder(t("dali.rule.message.title")));
690         ruleDescriptionScrollPane.setBorder(BorderFactory.createTitledBorder(t("dali.rule.description.title")));
691         closeButton.setIcon(SwingUtil.createActionIcon("cancel"));
692         saveButton.setIcon(SwingUtil.createActionIcon("save"));
693         // late initializer
694         // register 1 validator(s)
695         validatorIds = SwingValidatorUtil.detectValidators(this);
696         SwingValidatorUtil.installUI(this);
697     }
698 
699     private void $initialize() {
700         if (allComponentsCreated) {
701             return;
702         }
703         if (log.isDebugEnabled()) {
704             log.debug(this);
705         }
706         handler.beforeInit(this);
707         $objectMap.put("$JPanel0", $JPanel0);
708         createModel();
709         createBroker();
710         createValidator();
711         createRulesMenuUI();
712         createScrollPane();
713         // inline creation of $JPanel1
714         $objectMap.put("$JPanel1", $JPanel1 = new JPanel());
715         
716         $JPanel1.setName("$JPanel1");
717         $JPanel1.setLayout(new BorderLayout());
718         createTopPanel();
719         createRuleListUI();
720         // inline creation of $JPanel2
721         $objectMap.put("$JPanel2", $JPanel2 = new JPanel());
722         
723         $JPanel2.setName("$JPanel2");
724         $JPanel2.setLayout(new GridLayout(1,0));
725         createControlProgramTableUI();
726         createControlDepartmentTableUI();
727         createControlRuleTableUI();
728         createBottomPanel();
729         createControlPmfmTableUI();
730         // inline creation of $JPanel3
731         $objectMap.put("$JPanel3", $JPanel3 = new JPanel());
732         
733         $JPanel3.setName("$JPanel3");
734         $JPanel3.setLayout(new GridLayout(0,1));
735         createRuleMessageScrollPane();
736         createRuleMessageEditor();
737         createRuleDescriptionScrollPane();
738         createRuleDescriptionEditor();
739         // inline creation of $JPanel4
740         $objectMap.put("$JPanel4", $JPanel4 = new JPanel());
741         
742         $JPanel4.setName("$JPanel4");
743         $JPanel4.setLayout(new BorderLayout());
744         // inline creation of $JPanel5
745         $objectMap.put("$JPanel5", $JPanel5 = new JPanel());
746         
747         $JPanel5.setName("$JPanel5");
748         $JPanel5.setLayout(new GridLayout(1,0));
749         createCloseButton();
750         createSaveButton();
751         // inline creation of $JPanel0
752         setName("$JPanel0");
753         setLayout(new BorderLayout());
754         
755         // registers 1 data bindings
756         $registerDefaultBindings();
757         $completeSetup();
758         handler.afterInit(this);
759     }
760 
761     private void $registerDefaultBindings() {
762         // register 1 data bindings
763         registerDataBinding(new DefaultJAXXBinding(this, BINDING_SAVE_BUTTON_ENABLED, true, true) {
764         
765             @Override
766             public void applyDataBinding() {
767                 if (model != null) {
768                     model.addPropertyChangeListener("modify", this);
769                 }
770                 if (model != null) {
771                     model.addPropertyChangeListener("valid", this);
772                 }
773                 if (model != null) {
774                     model.addPropertyChangeListener("saveEnabled", this);
775                 }
776             }
777         
778             @Override
779             public void processDataBinding() {
780                 if (model != null) {
781                     saveButton.setEnabled(model.isModify() && model.isValid() && model.isSaveEnabled());
782                 }
783             }
784         
785             @Override
786             public void removeDataBinding() {
787                 if (model != null) {
788                     model.removePropertyChangeListener("modify", this);
789                 }
790                 if (model != null) {
791                     model.removePropertyChangeListener("valid", this);
792                 }
793                 if (model != null) {
794                     model.removePropertyChangeListener("saveEnabled", this);
795                 }
796             }
797         });
798     }
799 
800 }