1 package fr.ifremer.dali.ui.swing.content.manage.rule.controlrule.precondition;
2
3 import fr.ifremer.dali.dto.referential.pmfm.PmfmDTO;
4 import fr.ifremer.dali.dto.referential.pmfm.QualitativeValueDTO;
5 import fr.ifremer.dali.ui.swing.DaliUIContext;
6 import fr.ifremer.dali.ui.swing.util.DaliUI;
7 import fr.ifremer.quadrige3.ui.swing.ApplicationUI;
8 import fr.ifremer.quadrige3.ui.swing.ApplicationUIUtil;
9 import fr.ifremer.quadrige3.ui.swing.component.bean.ExtendedBeanDoubleList;
10 import fr.ifremer.quadrige3.ui.swing.table.SwingTable;
11 import java.awt.BorderLayout;
12 import java.awt.Component;
13 import java.awt.Container;
14 import java.awt.Dialog;
15 import java.awt.Dialog.ModalityType;
16 import java.awt.Frame;
17 import java.awt.GraphicsConfiguration;
18 import java.awt.GridLayout;
19 import java.awt.Window;
20 import java.awt.event.ActionEvent;
21 import java.awt.event.ActionListener;
22 import java.util.ArrayList;
23 import java.util.HashMap;
24 import java.util.List;
25 import java.util.Map;
26 import java.util.TreeMap;
27 import javax.swing.BorderFactory;
28 import javax.swing.JButton;
29 import javax.swing.JDialog;
30 import javax.swing.JLabel;
31 import javax.swing.JList;
32 import javax.swing.JPanel;
33 import javax.swing.JScrollPane;
34 import javax.swing.SwingConstants;
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.CardLayout2Ext;
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 RulePreconditionUI extends JDialog implements DaliUI<RulePreconditionUIModel, RulePreconditionUIHandler>, JAXXObject, JAXXValidator {
55
56
57
58
59
60 public static final String BINDING_VALID_BUTTON_ENABLED = "validButton.enabled";
61
62
63
64
65
66 private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAL1WS28cRRBub7x+xjF+xI5JIjmOQUag3jwQDxmRxGtbOKxDkl0sCwuJ3pn2uqPenklPTzwbK4ifwE8ACW5ckLhxQhy4cOHAJeIvIMSBK6K657WzO2uvZAVLnt3tqvrqq+rur+a7P1HRk+jKIxIEWPpCsSbFd+/s7n5Uf0QttU49SzJXORKFfwMFVNhD43ay7il0da+iw0tReKnsNF1HUNEWvVpBY55qceodUKoUupyNsDyvVE3Mq4Hryxg1IZWH+tXffxW+tL/4uoBQ4AK7GShl8aSotJLBCiowW6FpyPSElDgRDaAhmWgA3wm9VubE8+6RJn2MPkfDFTTkEglgCi31X7LBMPGBC7mkz+l9SS1H2EwxR3y8pdDuvsRsX9ImldgmnGGfYe8QeGBwUwCLm0SQBsU62KxJh5vvbhsSftgF7bom85BCxaZjU67Qpy8q1bbGT/ONPgFwm0AjFHo9syWJIcpb1c+deDFFGFm+e58Iyq9B0/ReBJF/uKqdRhPfiTrxqOEU22b1YzpxWIgdHuzUSJ3TqgVlce2t0HwGPbXo0PMJwmQHgkK4rZWPfWJL1qA3034q7RVWZwI0znwCNwVOyjowfCuk5fhwqLK3MEQpE2mH9hsbgUq7M+F71D6u4knb8SFrhXkq67LY1eHriW0psZ2DnjCueVdIXR+c7B6YRe26nDLyKAfJoHZiW8k6zMaUH+ysJ9wUKh/fRiu+WrhOicDQBCpsaq/BjxQly31iuW0Xr+nFhWzh51ImIYepbHERIu7q1I2kU+nZO2sRYVG+BjsItwXNZKDCVe15MwkYNzcgtbwdmSW6mDkAoIo4VcVUtgb2UFHfSJDeC3vdQqrrCiX0QoeEakBj/Xdu5vcf//hhM9bNWch9Pte1TfZBz1zpuFQqplNPhqLpK8ZL28Rd3UOj4QEwM+FSDrFqZAZykM+0HOtw/AHxDgCiOPz8p5/nPvvtDCpsojHuEHuTaP8tNKoOJHTB4Xbg3rptGJ09HIHnS/B/BsQGrOxpeCsHlfTho6iY0j8XjcgZAetUXhy5aGkkPIoMoG+XcvqWkK+P/vLPTPX723HvBqCWhZ7uaf+Kn6AhJjgT1EydaKDkTplx16O+7aSDI2+UoNxZ4kYKccs8y13NGlBoqO5IG3YRvXq0Zr6FXW5hS1KiaE03xQ4tK0tLrz0LfA31oSlVf9tGnXr7fyXNSN5JSQtwFQ8cyZ7CpST8DmcN0TSje/7IaHLZEZ4iQnm4vHGvtvHwmT4ANACHi+bI7DOuQJESGcRcy1oerw6pfHHEXm4nFqttb15ZQT6JVlGhsRA6c48m4NodrsMRk+Esj5anCT8kLa8KS9UoS2IbiWSiBa2JKcB897VqDGoRV2j4yLyO5G5z7pjo44gNU6GZA4/iPuEezd2qrPCfhDoI6s6uvyO2BW06glnx2YCZBL9xKPy4mVjH4FDDNdzSr01oKDQnuzfdHQqzQDkOrzG31sslr4rMxOljXztquNyeJXoboz2rIJZFXZVUMZsX3FlHD6d0h6bC/cfMMy9+K/kXvn1Q9qMxPHqPOvce5COLdQayKBrvd0EP6OfYiYh6+Rv9+DYfYebUCHOnRrhyaoSrp0Z4pY+9GdH3vtZy6TE4b/Q/R45BKZ26njf74DHIrPDlrQfGW32x+PUYhHcB4T9+z3Pang8AAA==";
67 private static final Log log = LogFactory.getLog(RulePreconditionUI.class);
68 private static final long serialVersionUID = 1L;
69
70
71
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
84
85
86 protected JLabel availableLabel;
87 protected JPanel baseRulePanel;
88 protected SwingTable baseRuleQVTable;
89 @ValidatorField( validatorId = "validator", propertyName = "rulePreconditionValid", editorName = "baseRuleQVTableScrollPane")
90 protected JScrollPane baseRuleQVTableScrollPane;
91 protected JButton cancelButton;
92 protected JPanel doubleListPanel;
93 protected final RulePreconditionUIHandler handler = createHandler();
94 protected RulePreconditionUIModel model;
95 protected RulePreconditionUI rulePreconditionUI = this;
96 protected JLabel selectedLabel;
97 protected CardLayout2Ext switchPanelLayout;
98 protected JPanel usedRulePanel;
99 protected ExtendedBeanDoubleList<QualitativeValueDTO> usedRuleQVDoubleList;
100 protected JList<QualitativeValueDTO> usedRuleQVList;
101 protected JButton validButton;
102 @Validator( validatorId = "validator")
103 protected SwingValidator<RulePreconditionUIModel> validator;
104 protected List<String> validatorIds = new ArrayList<String>();
105
106
107
108
109
110 private JPanel $JPanel0;
111 private JPanel $JPanel1;
112 private JPanel $JPanel2;
113 private JScrollPane $JScrollPane0;
114
115
116
117
118
119 public RulePreconditionUI(DaliUIContext context) {
120 super(context.getMainUI());
121 ApplicationUIUtil.setApplicationContext(this, context);
122 $initialize();
123 }
124
125 public RulePreconditionUI(Window param0) {
126 super(param0);
127 $initialize();
128 }
129
130 public RulePreconditionUI(JAXXContext parentContext, Window param1) {
131 super(param1);
132 JAXXUtil.initContext(this, parentContext);
133 $initialize();
134 }
135
136 public RulePreconditionUI(Dialog param0, String param1, boolean param2, GraphicsConfiguration param3) {
137 super(param0 ,param1 ,param2 ,param3);
138 $initialize();
139 }
140
141 public RulePreconditionUI(JAXXContext parentContext, Dialog param1, String param2, boolean param3, GraphicsConfiguration param4) {
142 super(param1 ,param2 ,param3 ,param4);
143 JAXXUtil.initContext(this, parentContext);
144 $initialize();
145 }
146
147 public RulePreconditionUI(Dialog param0, String param1, boolean param2) {
148 super(param0 ,param1 ,param2);
149 $initialize();
150 }
151
152 public RulePreconditionUI(JAXXContext parentContext, Dialog param1, String param2, boolean param3) {
153 super(param1 ,param2 ,param3);
154 JAXXUtil.initContext(this, parentContext);
155 $initialize();
156 }
157
158 public RulePreconditionUI(Dialog param0, String param1) {
159 super(param0 ,param1);
160 $initialize();
161 }
162
163 public RulePreconditionUI(JAXXContext parentContext, Dialog param1, String param2) {
164 super(param1 ,param2);
165 JAXXUtil.initContext(this, parentContext);
166 $initialize();
167 }
168
169 public RulePreconditionUI(Window param0, String param1, ModalityType param2, GraphicsConfiguration param3) {
170 super(param0 ,param1 ,param2 ,param3);
171 $initialize();
172 }
173
174 public RulePreconditionUI(JAXXContext parentContext, Window param1, String param2, ModalityType param3, GraphicsConfiguration param4) {
175 super(param1 ,param2 ,param3 ,param4);
176 JAXXUtil.initContext(this, parentContext);
177 $initialize();
178 }
179
180 public RulePreconditionUI(Window param0, String param1, ModalityType param2) {
181 super(param0 ,param1 ,param2);
182 $initialize();
183 }
184
185 public RulePreconditionUI(JAXXContext parentContext, Window param1, String param2, ModalityType param3) {
186 super(param1 ,param2 ,param3);
187 JAXXUtil.initContext(this, parentContext);
188 $initialize();
189 }
190
191 public RulePreconditionUI(Window param0, String param1) {
192 super(param0 ,param1);
193 $initialize();
194 }
195
196 public RulePreconditionUI(JAXXContext parentContext, Window param1, String param2) {
197 super(param1 ,param2);
198 JAXXUtil.initContext(this, parentContext);
199 $initialize();
200 }
201
202 public RulePreconditionUI(Window param0, ModalityType param1) {
203 super(param0 ,param1);
204 $initialize();
205 }
206
207 public RulePreconditionUI(JAXXContext parentContext, Window param1, ModalityType param2) {
208 super(param1 ,param2);
209 JAXXUtil.initContext(this, parentContext);
210 $initialize();
211 }
212
213 public RulePreconditionUI(Frame param0, String param1) {
214 super(param0 ,param1);
215 $initialize();
216 }
217
218 public RulePreconditionUI(JAXXContext parentContext, Frame param1, String param2) {
219 super(param1 ,param2);
220 JAXXUtil.initContext(this, parentContext);
221 $initialize();
222 }
223
224 public RulePreconditionUI(Frame param0, boolean param1) {
225 super(param0 ,param1);
226 $initialize();
227 }
228
229 public RulePreconditionUI(JAXXContext parentContext, Frame param1, boolean param2) {
230 super(param1 ,param2);
231 JAXXUtil.initContext(this, parentContext);
232 $initialize();
233 }
234
235 public RulePreconditionUI(Frame param0) {
236 super(param0);
237 $initialize();
238 }
239
240 public RulePreconditionUI(JAXXContext parentContext, Frame param1) {
241 super(param1);
242 JAXXUtil.initContext(this, parentContext);
243 $initialize();
244 }
245
246 public RulePreconditionUI() {
247 $initialize();
248 }
249
250 public RulePreconditionUI(JAXXContext parentContext) {
251 JAXXUtil.initContext(this, parentContext);
252 $initialize();
253 }
254
255 public RulePreconditionUI(Dialog param0, boolean param1) {
256 super(param0 ,param1);
257 $initialize();
258 }
259
260 public RulePreconditionUI(JAXXContext parentContext, Dialog param1, boolean param2) {
261 super(param1 ,param2);
262 JAXXUtil.initContext(this, parentContext);
263 $initialize();
264 }
265
266 public RulePreconditionUI(Dialog param0) {
267 super(param0);
268 $initialize();
269 }
270
271 public RulePreconditionUI(JAXXContext parentContext, Dialog param1) {
272 super(param1);
273 JAXXUtil.initContext(this, parentContext);
274 $initialize();
275 }
276
277 public RulePreconditionUI(Frame param0, String param1, boolean param2, GraphicsConfiguration param3) {
278 super(param0 ,param1 ,param2 ,param3);
279 $initialize();
280 }
281
282 public RulePreconditionUI(JAXXContext parentContext, Frame param1, String param2, boolean param3, GraphicsConfiguration param4) {
283 super(param1 ,param2 ,param3 ,param4);
284 JAXXUtil.initContext(this, parentContext);
285 $initialize();
286 }
287
288 public RulePreconditionUI(Frame param0, String param1, boolean param2) {
289 super(param0 ,param1 ,param2);
290 $initialize();
291 }
292
293 public RulePreconditionUI(JAXXContext parentContext, Frame param1, String param2, boolean param3) {
294 super(param1 ,param2 ,param3);
295 JAXXUtil.initContext(this, parentContext);
296 $initialize();
297 }
298
299
300
301
302
303 public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
304 return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
305 }
306
307
308
309
310
311 @Override
312 public void applyDataBinding(String $binding) {
313 if (allComponentsCreated && $bindings.containsKey($binding)) {
314 getDataBinding($binding).applyDataBinding();
315 }
316 processDataBinding($binding);
317 }
318
319 @Override
320 public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
321 super.firePropertyChange(propertyName, oldValue, newValue);
322 }
323
324 @Override
325 public Map<String, Object> get$objectMap() {
326 return $objectMap;
327 }
328
329 @Override
330 public JAXXBinding getDataBinding(String bindingId) {
331 return $bindings.get(bindingId);
332 }
333
334 @Override
335 public JAXXBinding[] getDataBindings() {
336 return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
337 }
338
339 @Override
340 public Object getObjectById(String id) {
341 return $objectMap.get(id);
342 }
343
344 @Override
345 public void processDataBinding(String $binding, boolean $force) {
346 if (!$force && $activeBindings.contains($binding)) {
347 return;
348 }
349 $activeBindings.add($binding);
350 try {
351 if (allComponentsCreated && $bindings.containsKey($binding)) {
352 getDataBinding($binding).processDataBinding();
353 }
354 } finally {
355 $activeBindings.remove($binding);
356 }
357 }
358
359 @Override
360 public void processDataBinding(String $binding) {
361 processDataBinding($binding, false);
362 }
363
364 @Override
365 public void registerDataBinding(JAXXBinding binding) {
366 $bindings.put(binding.getId(), binding);
367 }
368
369 @Override
370 public void removeDataBinding(String $binding) {
371 if (allComponentsCreated && $bindings.containsKey($binding)) {
372 getDataBinding($binding).removeDataBinding();
373 }
374 }
375
376
377
378
379
380 @Override
381 public <T> T getContextValue(Class<T> clazz) {
382 return delegateContext.getContextValue(clazz, null);
383 }
384
385 @Override
386 public <T> T getContextValue(Class<T> clazz, String name) {
387 return delegateContext.getContextValue(clazz, name);
388 }
389
390 @Override
391 public JAXXContext getDelegateContext() {
392 return delegateContext;
393 }
394
395 @Override
396 public <O extends Container> O getParentContainer(Class<O> clazz) {
397 return SwingUtil.getParentContainer(this, clazz);
398 }
399
400 @Override
401 public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
402 return SwingUtil.getParentContainer(source, clazz);
403 }
404
405 @Override
406 public <T> void removeContextValue(Class<T> clazz) {
407 delegateContext.removeContextValue(clazz, null);
408 }
409
410 @Override
411 public <T> void removeContextValue(Class<T> clazz, String name) {
412 delegateContext.removeContextValue(clazz, name);
413 }
414
415 @Override
416 public <T> void setContextValue(T o) {
417 delegateContext.setContextValue(o, null);
418 }
419
420 @Override
421 public <T> void setContextValue(T o, String name) {
422 delegateContext.setContextValue(o, name);
423 }
424
425
426
427
428
429 @Override
430 public SwingValidator<?> getValidator(String validatorId) {
431 return (SwingValidator<?>) (validatorIds.contains(validatorId) ? getObjectById(validatorId) : null);
432 }
433
434 @Override
435 public List<String> getValidatorIds() {
436 return validatorIds;
437 }
438
439 @Override
440 public void registerValidatorFields() {
441 SwingValidatorUtil.detectValidatorFields(this);
442 }
443
444
445
446
447
448 public void doActionPerformed__on__cancelButton(ActionEvent event) {
449 if (log.isDebugEnabled()) {
450 log.debug(event);
451 }
452 handler.cancel();
453 }
454
455 public void doActionPerformed__on__validButton(ActionEvent event) {
456 if (log.isDebugEnabled()) {
457 log.debug(event);
458 }
459 handler.valid();
460 }
461
462
463
464
465
466 public JLabel getAvailableLabel() {
467 return availableLabel;
468 }
469
470 public JPanel getBaseRulePanel() {
471 return baseRulePanel;
472 }
473
474 public SwingTable getBaseRuleQVTable() {
475 return baseRuleQVTable;
476 }
477
478 public JScrollPane getBaseRuleQVTableScrollPane() {
479 return baseRuleQVTableScrollPane;
480 }
481
482 public JButton getCancelButton() {
483 return cancelButton;
484 }
485
486 public JPanel getDoubleListPanel() {
487 return doubleListPanel;
488 }
489
490 public RulePreconditionUIHandler getHandler() {
491 return handler;
492 }
493
494 public RulePreconditionUIModel getModel() {
495 return model;
496 }
497
498 public JLabel getSelectedLabel() {
499 return selectedLabel;
500 }
501
502 public CardLayout2Ext getSwitchPanelLayout() {
503 return switchPanelLayout;
504 }
505
506 public JPanel getUsedRulePanel() {
507 return usedRulePanel;
508 }
509
510 public ExtendedBeanDoubleList<QualitativeValueDTO> getUsedRuleQVDoubleList() {
511 return usedRuleQVDoubleList;
512 }
513
514 public JList<QualitativeValueDTO> getUsedRuleQVList() {
515 return usedRuleQVList;
516 }
517
518 public JButton getValidButton() {
519 return validButton;
520 }
521
522 public SwingValidator<RulePreconditionUIModel> getValidator() {
523 return validator;
524 }
525
526
527
528
529
530 protected JPanel get$JPanel0() {
531 return $JPanel0;
532 }
533
534 protected JPanel get$JPanel1() {
535 return $JPanel1;
536 }
537
538 protected JPanel get$JPanel2() {
539 return $JPanel2;
540 }
541
542 protected JScrollPane get$JScrollPane0() {
543 return $JScrollPane0;
544 }
545
546
547
548
549
550 protected void addChildrenToBaseRulePanel() {
551 if (!allComponentsCreated) {
552 return;
553 }
554 baseRulePanel.add(SwingUtil.boxComponentWithJxLayer(baseRuleQVTableScrollPane));
555 }
556
557 protected void addChildrenToBaseRuleQVTableScrollPane() {
558 if (!allComponentsCreated) {
559 return;
560 }
561 baseRuleQVTableScrollPane.getViewport().add(baseRuleQVTable);
562 }
563
564 protected void addChildrenToDoubleListPanel() {
565 if (!allComponentsCreated) {
566 return;
567 }
568 doubleListPanel.add($JPanel1, BorderLayout.PAGE_START);
569 doubleListPanel.add(usedRuleQVDoubleList, BorderLayout.CENTER);
570 }
571
572 protected void addChildrenToRulePreconditionUI() {
573 if (!allComponentsCreated) {
574 return;
575 }
576 add($JPanel0, BorderLayout.CENTER);
577 add($JPanel2, BorderLayout.PAGE_END);
578 }
579
580 protected void addChildrenToUsedRulePanel() {
581 if (!allComponentsCreated) {
582 return;
583 }
584 usedRulePanel.add(doubleListPanel, RulePreconditionUIHandler.DOUBLE_LIST);
585 usedRulePanel.add($JScrollPane0, RulePreconditionUIHandler.LIST);
586 }
587
588 protected void addChildrenToValidator() {
589 if (!allComponentsCreated) {
590 return;
591 }
592 validator.setUiClass(ImageValidationUI.class);
593 validator.setBean(model);
594 }
595
596 protected void createAvailableLabel() {
597 $objectMap.put("availableLabel", availableLabel = new JLabel());
598
599 availableLabel.setName("availableLabel");
600 availableLabel.setText(t("dali.filter.available.label"));
601 }
602
603 protected void createBaseRulePanel() {
604 $objectMap.put("baseRulePanel", baseRulePanel = new JPanel());
605
606 baseRulePanel.setName("baseRulePanel");
607 baseRulePanel.setLayout(new BorderLayout());
608 }
609
610 protected void createBaseRuleQVTable() {
611 $objectMap.put("baseRuleQVTable", baseRuleQVTable = new SwingTable());
612
613 baseRuleQVTable.setName("baseRuleQVTable");
614 }
615
616 protected void createBaseRuleQVTableScrollPane() {
617 $objectMap.put("baseRuleQVTableScrollPane", baseRuleQVTableScrollPane = new JScrollPane());
618
619 baseRuleQVTableScrollPane.setName("baseRuleQVTableScrollPane");
620 }
621
622 protected void createCancelButton() {
623 $objectMap.put("cancelButton", cancelButton = new JButton());
624
625 cancelButton.setName("cancelButton");
626 cancelButton.setText(t("dali.common.cancel"));
627 cancelButton.setToolTipText(t("dali.common.cancel"));
628 cancelButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__cancelButton"));
629 }
630
631 protected void createDoubleListPanel() {
632 $objectMap.put("doubleListPanel", doubleListPanel = new JPanel());
633
634 doubleListPanel.setName("doubleListPanel");
635 doubleListPanel.setLayout(new BorderLayout());
636 }
637
638 protected RulePreconditionUIHandler createHandler() {
639 return new RulePreconditionUIHandler();
640 }
641
642 protected void createModel() {
643 $objectMap.put("model", model = getContextValue(RulePreconditionUIModel.class));
644 }
645
646 protected void createSelectedLabel() {
647 $objectMap.put("selectedLabel", selectedLabel = new JLabel());
648
649 selectedLabel.setName("selectedLabel");
650 selectedLabel.setText(t("dali.filter.selected.label"));
651 }
652
653 protected void createSwitchPanelLayout() {
654 $objectMap.put("switchPanelLayout", switchPanelLayout = new CardLayout2Ext(this, "usedRulePanel"));
655 }
656
657 protected void createUsedRulePanel() {
658 $objectMap.put("usedRulePanel", usedRulePanel = new JPanel());
659
660 usedRulePanel.setName("usedRulePanel");
661 usedRulePanel.setLayout(switchPanelLayout);
662 }
663
664 protected void createUsedRuleQVDoubleList() {
665 $objectMap.put("usedRuleQVDoubleList", usedRuleQVDoubleList = new ExtendedBeanDoubleList<QualitativeValueDTO>());
666
667 usedRuleQVDoubleList.setName("usedRuleQVDoubleList");
668 usedRuleQVDoubleList.setFilterable(true);
669 usedRuleQVDoubleList.setShowDecorator(true);
670 usedRuleQVDoubleList.setAlwaysSortSelected(true);
671 usedRuleQVDoubleList.setProperty("selectedValues");
672 }
673
674 protected void createUsedRuleQVList() {
675 $objectMap.put("usedRuleQVList", usedRuleQVList = new JList<QualitativeValueDTO>());
676
677 usedRuleQVList.setName("usedRuleQVList");
678 usedRuleQVList.setEnabled(false);
679 }
680
681 protected void createValidButton() {
682 $objectMap.put("validButton", validButton = new JButton());
683
684 validButton.setName("validButton");
685 validButton.setText(t("dali.common.validate"));
686 validButton.setToolTipText(t("dali.common.validate"));
687 validButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__validButton"));
688 }
689
690 protected void createValidator() {
691 $objectMap.put("validator", validator = SwingValidator.newValidator(RulePreconditionUIModel.class, null));
692 }
693
694
695
696
697
698 private void $completeSetup() {
699 allComponentsCreated = true;
700 if (log.isDebugEnabled()) {
701 log.debug(this);
702 }
703 addChildrenToRulePreconditionUI();
704 addChildrenToValidator();
705
706 $JPanel0.add(baseRulePanel, BorderLayout.CENTER);
707 $JPanel0.add(usedRulePanel, BorderLayout.PAGE_END);
708 addChildrenToBaseRulePanel();
709 addChildrenToBaseRuleQVTableScrollPane();
710 addChildrenToUsedRulePanel();
711 addChildrenToDoubleListPanel();
712
713 $JPanel1.add(availableLabel);
714 $JPanel1.add(selectedLabel);
715
716 $JScrollPane0.getViewport().add(usedRuleQVList);
717
718 $JPanel2.add(cancelButton);
719 $JPanel2.add(validButton);
720
721
722 JAXXUtil.applyDataBinding(this, $bindings.keySet());
723
724
725 usedRuleQVDoubleList.setBeanType(QualitativeValueDTO.class);
726 $JScrollPane0.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
727 baseRulePanel.setBorder(BorderFactory.createTitledBorder(""));
728 usedRulePanel.setBorder(BorderFactory.createTitledBorder(""));
729 availableLabel.setHorizontalAlignment(SwingConstants.CENTER);
730 selectedLabel.setHorizontalAlignment(SwingConstants.CENTER);
731 usedRuleQVDoubleList.setBean(model);
732 cancelButton.setMnemonic(SwingUtil.getFirstCharAt(t("dali.common.cancel.mnemonic"),'Z'));
733 cancelButton.setIcon(SwingUtil.createActionIcon("cancel"));
734 validButton.setMnemonic(SwingUtil.getFirstCharAt(t("dali.common.validate.mnemonic"),'Z'));
735 validButton.setIcon(SwingUtil.createActionIcon("accept"));
736
737 rulePreconditionUI.pack();
738
739 validatorIds = SwingValidatorUtil.detectValidators(this);
740 SwingValidatorUtil.installUI(this);
741 }
742
743 private void $initialize() {
744 if (allComponentsCreated) {
745 return;
746 }
747 if (log.isDebugEnabled()) {
748 log.debug(this);
749 }
750 handler.beforeInit(this);
751 $objectMap.put("rulePreconditionUI", rulePreconditionUI);
752 createModel();
753 createValidator();
754
755 $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
756
757 $JPanel0.setName("$JPanel0");
758 $JPanel0.setLayout(new GridLayout(2,1));
759 createBaseRulePanel();
760 createBaseRuleQVTableScrollPane();
761 createBaseRuleQVTable();
762 createSwitchPanelLayout();
763 createUsedRulePanel();
764 createDoubleListPanel();
765
766 $objectMap.put("$JPanel1", $JPanel1 = new JPanel());
767
768 $JPanel1.setName("$JPanel1");
769 $JPanel1.setLayout(new GridLayout(1,0));
770 createAvailableLabel();
771 createSelectedLabel();
772 createUsedRuleQVDoubleList();
773
774 $objectMap.put("$JScrollPane0", $JScrollPane0 = new JScrollPane());
775
776 $JScrollPane0.setName("$JScrollPane0");
777 createUsedRuleQVList();
778
779 $objectMap.put("$JPanel2", $JPanel2 = new JPanel());
780
781 $JPanel2.setName("$JPanel2");
782 $JPanel2.setLayout(new GridLayout(1,0));
783 createCancelButton();
784 createValidButton();
785
786 setName("rulePreconditionUI");
787 rulePreconditionUI.getContentPane().setLayout(new BorderLayout());
788 setResizable(true);
789 setTitle(t("dali.rule.rulePrecondition.title"));
790 setModal(true);
791
792
793 $registerDefaultBindings();
794 $completeSetup();
795 handler.afterInit(this);
796 }
797
798 private void $registerDefaultBindings() {
799
800 registerDataBinding(new DefaultJAXXBinding(this, BINDING_VALID_BUTTON_ENABLED, true) {
801
802 @Override
803 public void applyDataBinding() {
804 if (model != null) {
805 model.addPropertyChangeListener("valid", this);
806 }
807 }
808
809 @Override
810 public void processDataBinding() {
811 if (model != null) {
812 validButton.setEnabled(model.isValid());
813 }
814 }
815
816 @Override
817 public void removeDataBinding() {
818 if (model != null) {
819 model.removePropertyChangeListener("valid", this);
820 }
821 }
822 });
823 }
824
825 }