1 package fr.ifremer.reefdb.ui.swing.content.manage.program.programs;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 import fr.ifremer.quadrige3.ui.swing.ApplicationUI;
28 import fr.ifremer.quadrige3.ui.swing.ApplicationUIUtil;
29 import fr.ifremer.quadrige3.ui.swing.table.SwingTable;
30 import fr.ifremer.reefdb.ui.swing.ReefDbHelpBroker;
31 import fr.ifremer.reefdb.ui.swing.ReefDbUIContext;
32 import fr.ifremer.reefdb.ui.swing.util.ReefDbUI;
33 import java.awt.BorderLayout;
34 import java.awt.Component;
35 import java.awt.Container;
36 import java.awt.FlowLayout;
37 import java.awt.GridBagConstraints;
38 import java.awt.Insets;
39 import java.awt.event.ActionEvent;
40 import java.awt.event.ActionListener;
41 import java.awt.event.MouseEvent;
42 import java.awt.event.MouseListener;
43 import java.util.ArrayList;
44 import java.util.HashMap;
45 import java.util.List;
46 import java.util.Map;
47 import java.util.TreeMap;
48 import javax.swing.BorderFactory;
49 import javax.swing.Box;
50 import javax.swing.BoxLayout;
51 import javax.swing.JButton;
52 import javax.swing.JComboBox;
53 import javax.swing.JLabel;
54 import javax.swing.JMenuItem;
55 import javax.swing.JPanel;
56 import javax.swing.JPopupMenu;
57 import javax.swing.JScrollPane;
58 import jaxx.runtime.JAXXBinding;
59 import jaxx.runtime.JAXXContext;
60 import jaxx.runtime.JAXXObject;
61 import jaxx.runtime.JAXXObjectDescriptor;
62 import jaxx.runtime.JAXXUtil;
63 import jaxx.runtime.JAXXValidator;
64 import jaxx.runtime.SwingUtil;
65 import jaxx.runtime.binding.DefaultJAXXBinding;
66 import jaxx.runtime.context.DefaultJAXXContext;
67 import jaxx.runtime.swing.Table;
68 import jaxx.runtime.swing.help.JAXXHelpUI;
69 import jaxx.runtime.validator.swing.SwingValidator;
70 import jaxx.runtime.validator.swing.SwingValidatorUtil;
71 import jaxx.runtime.validator.swing.meta.Validator;
72 import jaxx.runtime.validator.swing.meta.ValidatorField;
73 import jaxx.runtime.validator.swing.ui.ImageValidationUI;
74 import org.apache.commons.logging.Log;
75 import org.apache.commons.logging.LogFactory;
76 import static org.nuiton.i18n.I18n.t;
77
78 public class ProgramsTableUI extends Table implements JAXXHelpUI<ReefDbHelpBroker>, ReefDbUI<ProgramsTableUIModel, ProgramsTableUIHandler>, JAXXObject, JAXXValidator {
79
80
81
82
83
84 public static final String BINDING_ADD_PROGRAM_BUTTON_ENABLED = "addProgramButton.enabled";
85 public static final String BINDING_DELETE_PROGRAM_BOUTON_ENABLED = "deleteProgramBouton.enabled";
86 public static final String BINDING_EDIT_COMBOBOX_ENABLED = "editCombobox.enabled";
87 public static final String BINDING_EDIT_PROGRAM_CODE_ENABLED = "editProgramCode.enabled";
88 public static final String BINDING_SHOW_MANAGERS_BUTTON_ENABLED = "showManagersButton.enabled";
89 public static final String BINDING_SHOW_RECORDER_DEPARTMENTS_BUTTON_ENABLED = "showRecorderDepartmentsButton.enabled";
90 public static final String BINDING_SHOW_RECORDER_PERSONS_BUTTON_ENABLED = "showRecorderPersonsButton.enabled";
91
92
93
94
95
96 private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAK1Xz1MjRRRusgQW2HV3QVioZTX8WAyrTsQt9YAoC4ECCnYpghYlB+3MNGHWmenZnh4STKH+Cf4JevdilRf1ZO3Bswcvlgf/Acvy4NXydc8kk5nMJKOBw5C8fu/r975+/b3J13+grMPQzBNcqynMtbhuEmXn4dHR4/ITovIicVSm25wy5P31ZVDmGI1oTbvD0dzxrggv+OGFdWra1CJWS/TyLhp2+LlBnFNCOEd3wxGq4xRKzeXlmu2yBmozqTjUL//6M/OF9vlXGYRqNmQ3BqXkukUFlfTvooyucTQKO53hgoGtCqTBdKsC+V4XtnUDO84jbJKn6FM0uIsGbMwAjKPZ9CVLDBlfszka5rhskH1sEYOjnROm6CeMmIQpjJATray4uuJUIQNFpRYHQMXEFq4QxWa0wrDZ+O8o+/6HQ4H33rZtyz0GOMqaVBPgjy8PfE8gBjsMlBn9mDCOXu6wxQF8L5a3IG5NegfhQ2fY0DUMHAFC6LSaCz5GSTzfbxgDhOvzOyWVUcMQPL7G0W1xVjU/qGVJuA81o3zqqe3COUyEQqRxj1husMcNounc52Ed6udoPBQivLc5MYX7ZJCZ3cocR0oLQ09drDG9Qh4EJMmMvDJlgEAZb4Jdnd+RjQIVjobTFdZwcQ3fJfF9Tjxmmms3sab5lay5nMPZo7EQnmcV3vPNoGuifujrMi3TWrR4aV+jtXCIpKzomuZ5AJgPu4w6p7S6J7uOOYleU8LrgKiUaYTtgye1kp3vtjoXCdxQbkJvJweMQTMTThqMUDfercHo6zGMwtouLsecjLQKpzdt0KI7oe4GlVMClQtkqO8YZZkLZo4mj9uF8QCWPEmcjEiiAJSr/0yM/fLDb99uNnRwCvYej3VtkXHQJ2hWG+6xLra+4Ymgy3WjsIft5WM05ABPqqfx0zGJlfxlSA72uyXCFRGubGHnFCCyg7/++Gzio5+voMwmGjYo1jax8N9GQ/yUAQvU0Gr2u6syo2vVq/C8KXITAiMPk6ON+pr85AWeKyojmJNDnRtE81byPD/rS09ExRQu3GYXFy9qwN10DHfNAspDP/09VvpmtcFfH9QzlegecJj9AA3olqFbRE4Sf0jETo4R2yGuRoNhEDceUGg+2L4YrcpnsY2ofvAGXnRqbQs9R1fgmnOwkhoMqFs+KSo1TWopFqlyNMIpNQ51+1B6vJBAG7gCdSCRg8QSuQDm7bqcKYrulPAZ2fDMeUGsyGxLMiY+7aAYselWRhbu0IfYtg1dxaKYh7Ikju7Ui6331DMrqqDrIlL5gHejm8U/Hy6+sRqufyahfs87SsFKfcbjoEK41whEO6BVJ78IrGyYNj/PL+YWFnLpiYqToW5cZYLx/ln9FFuaAXMFDswjp6HKclznI2L8Sq5dej1brNCGl9pkdfGilZx79SRuHP0TAsSsrOSWYkkITZlu1V+BPc90R5eTNXuCDYdEGqFfwDXbYDTcBmItLofo2ErRsHGbtqfmp/FiQqOZ/llEG3Oui3+0Nf8/+zHT+LKLX0gohoWbLsrB/XRhl0dF8ivHZTPSrbSWuxZlRUkfennMdH6/+q9DKnxDk7qj7d07XXdEwqIcHLRwAG9rBmlhAhiYWclZrmEEKh7vB+L+iFQFfoKwR385dKNIvPAY+BwGAEfPvQ0/dXCurFsa7PxOG3yfeM52RRTm78Tj+3iEeylyGobfXRVLHPVRB6SXUuXyrAPC/Z4RCj0jLPWM8KBnhDd6PtW3Upxqv656v3YSMKZTZfF7zx3RCeHVnhHSdUQnhHQd0QkhXUd0QhAd8S8T5WW1oRMAAA==";
97 private static final Log log = LogFactory.getLog(ProgramsTableUI.class);
98 private static final long serialVersionUID = 1L;
99
100
101
102
103
104 protected List<Object> $activeBindings = new ArrayList<Object>();
105 protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
106 protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
107 protected Map<String, Object> $objectMap = new HashMap<String, Object>();
108 protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
109 private boolean allComponentsCreated;
110 protected final JAXXContext delegateContext = new DefaultJAXXContext();
111
112
113
114
115
116 protected JButton addProgramButton;
117 protected ReefDbHelpBroker broker;
118 protected JButton deleteProgramBouton;
119 @ValidatorField( validatorId = "validator", propertyName = "singleSelectedRow", editorName = "editCombobox")
120 protected JComboBox editCombobox;
121 protected JButton editDummyButton;
122 protected JMenuItem editProgramCode;
123 protected final ProgramsTableUIHandler handler = createHandler();
124 protected ProgramsTableUIModel model;
125 protected SwingTable programsTable;
126 protected JButton showManagersButton;
127 protected JButton showRecorderDepartmentsButton;
128 protected JButton showRecorderPersonsButton;
129 protected ProgramsTableUI tablePanel = this;
130 protected JPopupMenu tablePopup;
131 @Validator( validatorId = "validator")
132 protected SwingValidator<ProgramsTableUIModel> validator;
133 protected List<String> validatorIds = new ArrayList<String>();
134
135
136
137
138
139 private JLabel $JLabel0;
140 private JPanel $JPanel0;
141 private JPanel $JPanel1;
142 private JPanel $JPanel2;
143 private JScrollPane $JScrollPane0;
144
145
146
147
148
149 public ProgramsTableUI(ApplicationUI parentUI) {
150 ApplicationUIUtil.setParentUI(this, parentUI);
151 $initialize();
152 }
153
154 public ProgramsTableUI() {
155 $initialize();
156 }
157
158 public ProgramsTableUI(JAXXContext parentContext) {
159 JAXXUtil.initContext(this, parentContext);
160 $initialize();
161 }
162
163
164
165
166
167 public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
168 return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
169 }
170
171
172
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
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
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
310
311
312 public void doActionPerformed__on__addProgramButton(ActionEvent event) {
313 if (log.isDebugEnabled()) {
314 log.debug(event);
315 }
316 model.addNewRow();
317 }
318
319 public void doActionPerformed__on__editProgramCode(ActionEvent event) {
320 if (log.isDebugEnabled()) {
321 log.debug(event);
322 }
323 handler.editProgramCode();
324 }
325
326 public void doActionPerformed__on__showManagersButton(ActionEvent event) {
327 if (log.isDebugEnabled()) {
328 log.debug(event);
329 }
330 handler.showManagers();
331 }
332
333 public void doActionPerformed__on__showRecorderDepartmentsButton(ActionEvent event) {
334 if (log.isDebugEnabled()) {
335 log.debug(event);
336 }
337 handler.showRecorderDepartments();
338 }
339
340 public void doActionPerformed__on__showRecorderPersonsButton(ActionEvent event) {
341 if (log.isDebugEnabled()) {
342 log.debug(event);
343 }
344 handler.showRecorderPersons();
345 }
346
347 public void doMouseClicked__on__programsTable(MouseEvent event) {
348 if (log.isDebugEnabled()) {
349 log.debug(event);
350 }
351 handler.autoSelectRowInTable(event, tablePopup);
352 }
353
354
355
356
357
358 public JButton getAddProgramButton() {
359 return addProgramButton;
360 }
361
362 public ReefDbHelpBroker getBroker() {
363 return broker;
364 }
365
366 public JButton getDeleteProgramBouton() {
367 return deleteProgramBouton;
368 }
369
370 public JComboBox getEditCombobox() {
371 return editCombobox;
372 }
373
374 public JButton getEditDummyButton() {
375 return editDummyButton;
376 }
377
378 public JMenuItem getEditProgramCode() {
379 return editProgramCode;
380 }
381
382 public ProgramsTableUIHandler getHandler() {
383 return handler;
384 }
385
386 public ProgramsTableUIModel getModel() {
387 return model;
388 }
389
390 public SwingTable getProgramsTable() {
391 return programsTable;
392 }
393
394 public JButton getShowManagersButton() {
395 return showManagersButton;
396 }
397
398 public JButton getShowRecorderDepartmentsButton() {
399 return showRecorderDepartmentsButton;
400 }
401
402 public JButton getShowRecorderPersonsButton() {
403 return showRecorderPersonsButton;
404 }
405
406 public JPopupMenu getTablePopup() {
407 return tablePopup;
408 }
409
410 public SwingValidator<ProgramsTableUIModel> getValidator() {
411 return validator;
412 }
413
414
415
416
417
418 @Override
419 public void registerHelpId(ReefDbHelpBroker broker, Component component, String helpId) {
420 broker.installUI(component, helpId);
421 }
422
423 @Override
424 public void showHelp(String helpId) {
425 getBroker().showHelp(this, helpId);
426 }
427
428
429
430
431
432 protected JLabel get$JLabel0() {
433 return $JLabel0;
434 }
435
436 protected JPanel get$JPanel0() {
437 return $JPanel0;
438 }
439
440 protected JPanel get$JPanel1() {
441 return $JPanel1;
442 }
443
444 protected JPanel get$JPanel2() {
445 return $JPanel2;
446 }
447
448 protected JScrollPane get$JScrollPane0() {
449 return $JScrollPane0;
450 }
451
452
453
454
455
456 protected void addChildrenToTablePanel() {
457 if (!allComponentsCreated) {
458 return;
459 }
460 add($JScrollPane0, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
461 add($JPanel0, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
462 }
463
464 protected void addChildrenToTablePopup() {
465 if (!allComponentsCreated) {
466 return;
467 }
468 tablePopup.add(editProgramCode);
469 }
470
471 protected void addChildrenToValidator() {
472 if (!allComponentsCreated) {
473 return;
474 }
475 validator.setUiClass(ImageValidationUI.class);
476 validator.setBean(model);
477 }
478
479 protected void createAddProgramButton() {
480 $objectMap.put("addProgramButton", addProgramButton = new JButton());
481
482 addProgramButton.setName("addProgramButton");
483 addProgramButton.setText(t("reefdb.common.new"));
484 addProgramButton.setToolTipText(t("reefdb.program.program.new.tip"));
485 addProgramButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__addProgramButton"));
486 }
487
488 protected void createBroker() {
489 $objectMap.put("broker", broker = new ReefDbHelpBroker("reefdb.home.help"));
490 }
491
492 protected void createDeleteProgramBouton() {
493 $objectMap.put("deleteProgramBouton", deleteProgramBouton = new JButton());
494
495 deleteProgramBouton.setName("deleteProgramBouton");
496 deleteProgramBouton.setText(t("reefdb.common.delete"));
497 deleteProgramBouton.setToolTipText(t("reefdb.program.program.delete.tip"));
498 deleteProgramBouton.putClientProperty("applicationAction", DeleteProgramAction.class);
499 }
500
501 protected void createEditCombobox() {
502 $objectMap.put("editCombobox", editCombobox = new JComboBox());
503
504 editCombobox.setName("editCombobox");
505 }
506
507 protected void createEditDummyButton() {
508 $objectMap.put("editDummyButton", editDummyButton = new JButton());
509
510 editDummyButton.setName("editDummyButton");
511 editDummyButton.setVisible(false);
512 editDummyButton.setText(t("reefdb.common.edit"));
513 }
514
515 protected void createEditProgramCode() {
516 $objectMap.put("editProgramCode", editProgramCode = new JMenuItem());
517
518 editProgramCode.setName("editProgramCode");
519 editProgramCode.setText(t("reefdb.program.program.editProgramCode"));
520 editProgramCode.setToolTipText(t("reefdb.program.program.editProgramCode.tip"));
521 editProgramCode.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__editProgramCode"));
522 }
523
524 protected ProgramsTableUIHandler createHandler() {
525 return new ProgramsTableUIHandler();
526 }
527
528 protected void createModel() {
529 $objectMap.put("model", model = getContextValue(ProgramsTableUIModel.class));
530 }
531
532 protected void createProgramsTable() {
533 $objectMap.put("programsTable", programsTable = new SwingTable());
534
535 programsTable.setName("programsTable");
536 programsTable.addMouseListener(JAXXUtil.getEventListener(MouseListener.class, "mouseClicked", this, "doMouseClicked__on__programsTable"));
537 }
538
539 protected void createShowManagersButton() {
540 $objectMap.put("showManagersButton", showManagersButton = new JButton());
541
542 showManagersButton.setName("showManagersButton");
543 showManagersButton.setVisible(false);
544 showManagersButton.setText(t("reefdb.program.program.managers"));
545 showManagersButton.setToolTipText(t("reefdb.program.program.managers.tip"));
546 showManagersButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__showManagersButton"));
547 }
548
549 protected void createShowRecorderDepartmentsButton() {
550 $objectMap.put("showRecorderDepartmentsButton", showRecorderDepartmentsButton = new JButton());
551
552 showRecorderDepartmentsButton.setName("showRecorderDepartmentsButton");
553 showRecorderDepartmentsButton.setVisible(false);
554 showRecorderDepartmentsButton.setText(t("reefdb.program.program.recorderDepartments"));
555 showRecorderDepartmentsButton.setToolTipText(t("reefdb.program.program.recorderDepartments.tip"));
556 showRecorderDepartmentsButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__showRecorderDepartmentsButton"));
557 }
558
559 protected void createShowRecorderPersonsButton() {
560 $objectMap.put("showRecorderPersonsButton", showRecorderPersonsButton = new JButton());
561
562 showRecorderPersonsButton.setName("showRecorderPersonsButton");
563 showRecorderPersonsButton.setVisible(false);
564 showRecorderPersonsButton.setText(t("reefdb.program.program.recorderPersons"));
565 showRecorderPersonsButton.setToolTipText(t("reefdb.program.program.recorderPersons.tip"));
566 showRecorderPersonsButton.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__showRecorderPersonsButton"));
567 }
568
569 protected void createTablePopup() {
570 $objectMap.put("tablePopup", tablePopup = new JPopupMenu());
571
572 tablePopup.setName("tablePopup");
573 }
574
575 protected void createValidator() {
576 $objectMap.put("validator", validator = SwingValidator.newValidator(ProgramsTableUIModel.class, null));
577 }
578
579
580
581
582
583 private void $completeSetup() {
584 allComponentsCreated = true;
585 if (log.isDebugEnabled()) {
586 log.debug(this);
587 }
588 addChildrenToTablePanel();
589 addChildrenToValidator();
590
591 $JScrollPane0.getViewport().add(programsTable);
592 addChildrenToTablePopup();
593
594 $JPanel0.add($JPanel1, BorderLayout.LINE_START);
595 $JPanel0.add($JPanel2, BorderLayout.CENTER);
596
597 $JPanel1.add(addProgramButton);
598 $JPanel1.add(SwingUtil.boxComponentWithJxLayer(editCombobox));
599 $JPanel1.add(editDummyButton);
600 $JPanel1.add(showManagersButton);
601 $JPanel1.add(showRecorderPersonsButton);
602 $JPanel1.add(showRecorderDepartmentsButton);
603 $JPanel1.add(deleteProgramBouton);
604
605 $JPanel2.add($JLabel0);
606
607
608 JAXXUtil.applyDataBinding(this, $bindings.keySet());
609
610
611 addProgramButton.setAlignmentX(Component.CENTER_ALIGNMENT);
612 editCombobox.setAlignmentX(Component.CENTER_ALIGNMENT);
613 showManagersButton.setAlignmentX(Component.CENTER_ALIGNMENT);
614 showRecorderPersonsButton.setAlignmentX(Component.CENTER_ALIGNMENT);
615 showRecorderDepartmentsButton.setAlignmentX(Component.CENTER_ALIGNMENT);
616 deleteProgramBouton.setAlignmentX(Component.CENTER_ALIGNMENT);
617 setBorder(BorderFactory.createTitledBorder(t("reefdb.program.program.title")));
618 editProgramCode.setIcon(SwingUtil.createActionIcon("edit"));
619 addProgramButton.setIcon(SwingUtil.createActionIcon("add"));
620 editCombobox.setModel(handler.newActionComboBoxModel(editDummyButton, showManagersButton, showRecorderPersonsButton, showRecorderDepartmentsButton));
621 editDummyButton.setIcon(SwingUtil.createActionIcon("edit"));
622 showManagersButton.setIcon(SwingUtil.createActionIcon("edit"));
623 showRecorderPersonsButton.setIcon(SwingUtil.createActionIcon("edit"));
624 showRecorderDepartmentsButton.setIcon(SwingUtil.createActionIcon("edit"));
625 deleteProgramBouton.setIcon(SwingUtil.createActionIcon("delete"));
626
627
628 validatorIds = SwingValidatorUtil.detectValidators(this);
629 SwingValidatorUtil.installUI(this);
630 }
631
632 private void $initialize() {
633 if (allComponentsCreated) {
634 return;
635 }
636 if (log.isDebugEnabled()) {
637 log.debug(this);
638 }
639 handler.beforeInit(this);
640 $objectMap.put("tablePanel", tablePanel);
641 createModel();
642 createBroker();
643 createValidator();
644
645 $objectMap.put("$JScrollPane0", $JScrollPane0 = new JScrollPane());
646
647 $JScrollPane0.setName("$JScrollPane0");
648 createTablePopup();
649 createEditProgramCode();
650 createProgramsTable();
651
652 $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
653
654 $JPanel0.setName("$JPanel0");
655 $JPanel0.setLayout(new BorderLayout());
656
657 $objectMap.put("$JPanel1", $JPanel1 = new JPanel());
658
659 $JPanel1.setName("$JPanel1");
660 $JPanel1.setLayout(new FlowLayout());
661 createAddProgramButton();
662 createEditCombobox();
663 createEditDummyButton();
664 createShowManagersButton();
665 createShowRecorderPersonsButton();
666 createShowRecorderDepartmentsButton();
667 createDeleteProgramBouton();
668
669 $objectMap.put("$JPanel2", $JPanel2 = new JPanel());
670
671 $JPanel2.setName("$JPanel2");
672 $JPanel2.setLayout(new FlowLayout());
673
674 $objectMap.put("$JLabel0", $JLabel0 = new JLabel());
675
676 $JLabel0.setName("$JLabel0");
677
678 setName("tablePanel");
679
680
681 $registerDefaultBindings();
682 $completeSetup();
683 handler.afterInit(this);
684 }
685
686 private void $registerDefaultBindings() {
687
688 registerDataBinding(new DefaultJAXXBinding(this, BINDING_EDIT_PROGRAM_CODE_ENABLED, true) {
689
690 @Override
691 public void applyDataBinding() {
692 if (model != null) {
693 model.addPropertyChangeListener("singleSelectedRow", this);
694 }
695 }
696
697 @Override
698 public void processDataBinding() {
699 if (model != null && model.getSingleSelectedRow() != null) {
700 editProgramCode.setEnabled(model.getSingleSelectedRow() != null && model.getSingleSelectedRow().isNewCode());
701 }
702 }
703
704 @Override
705 public void removeDataBinding() {
706 if (model != null) {
707 model.removePropertyChangeListener("singleSelectedRow", this);
708 }
709 }
710 });
711 registerDataBinding(new DefaultJAXXBinding(this, BINDING_ADD_PROGRAM_BUTTON_ENABLED, true) {
712
713 @Override
714 public void applyDataBinding() {
715 if (model != null) {
716 model.addPropertyChangeListener("saveEnabled", this);
717 }
718 }
719
720 @Override
721 public void processDataBinding() {
722 if (model != null) {
723 addProgramButton.setEnabled(model.isSaveEnabled());
724 }
725 }
726
727 @Override
728 public void removeDataBinding() {
729 if (model != null) {
730 model.removePropertyChangeListener("saveEnabled", this);
731 }
732 }
733 });
734 registerDataBinding(new DefaultJAXXBinding(this, BINDING_EDIT_COMBOBOX_ENABLED, true) {
735
736 @Override
737 public void applyDataBinding() {
738 if (model != null) {
739 model.addPropertyChangeListener("selectedRows", this);
740 }
741 }
742
743 @Override
744 public void processDataBinding() {
745 if (model != null && model.getSelectedRows() != null) {
746 editCombobox.setEnabled(model.getSelectedRows().size() == 1);
747 }
748 }
749
750 @Override
751 public void removeDataBinding() {
752 if (model != null) {
753 model.removePropertyChangeListener("selectedRows", this);
754 }
755 }
756 });
757 registerDataBinding(new DefaultJAXXBinding(this, BINDING_SHOW_MANAGERS_BUTTON_ENABLED, true) {
758
759 @Override
760 public void applyDataBinding() {
761 if (model != null) {
762 model.addPropertyChangeListener("selectedRows", this);
763 }
764 }
765
766 @Override
767 public void processDataBinding() {
768 if (model != null && model.getSelectedRows() != null) {
769 showManagersButton.setEnabled(model.getSelectedRows().size() == 1);
770 }
771 }
772
773 @Override
774 public void removeDataBinding() {
775 if (model != null) {
776 model.removePropertyChangeListener("selectedRows", this);
777 }
778 }
779 });
780 registerDataBinding(new DefaultJAXXBinding(this, BINDING_SHOW_RECORDER_PERSONS_BUTTON_ENABLED, true) {
781
782 @Override
783 public void applyDataBinding() {
784 if (model != null) {
785 model.addPropertyChangeListener("selectedRows", this);
786 }
787 }
788
789 @Override
790 public void processDataBinding() {
791 if (model != null && model.getSelectedRows() != null) {
792 showRecorderPersonsButton.setEnabled(model.getSelectedRows().size() == 1);
793 }
794 }
795
796 @Override
797 public void removeDataBinding() {
798 if (model != null) {
799 model.removePropertyChangeListener("selectedRows", this);
800 }
801 }
802 });
803 registerDataBinding(new DefaultJAXXBinding(this, BINDING_SHOW_RECORDER_DEPARTMENTS_BUTTON_ENABLED, true) {
804
805 @Override
806 public void applyDataBinding() {
807 if (model != null) {
808 model.addPropertyChangeListener("selectedRows", this);
809 }
810 }
811
812 @Override
813 public void processDataBinding() {
814 if (model != null && model.getSelectedRows() != null) {
815 showRecorderDepartmentsButton.setEnabled(model.getSelectedRows().size() == 1);
816 }
817 }
818
819 @Override
820 public void removeDataBinding() {
821 if (model != null) {
822 model.removePropertyChangeListener("selectedRows", this);
823 }
824 }
825 });
826 registerDataBinding(new DefaultJAXXBinding(this, BINDING_DELETE_PROGRAM_BOUTON_ENABLED, true, true) {
827
828 @Override
829 public void applyDataBinding() {
830 if (model != null) {
831 model.addPropertyChangeListener("selectedRows", this);
832 }
833 if (model != null) {
834 model.addPropertyChangeListener("saveEnabled", this);
835 }
836 }
837
838 @Override
839 public void processDataBinding() {
840 if (model != null && model.getSelectedRows() != null) {
841 deleteProgramBouton.setEnabled(!model.getSelectedRows().isEmpty() && model.isSaveEnabled());
842 }
843 }
844
845 @Override
846 public void removeDataBinding() {
847 if (model != null) {
848 model.removePropertyChangeListener("selectedRows", this);
849 }
850 if (model != null) {
851 model.removePropertyChangeListener("saveEnabled", this);
852 }
853 }
854 });
855 }
856
857 }