1 package fr.ifremer.reefdb.ui.swing.content.manage.referential.user.menu;
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.core.dto.referential.StatusDTO;
28 import fr.ifremer.quadrige3.ui.swing.ApplicationUI;
29 import fr.ifremer.quadrige3.ui.swing.ApplicationUIUtil;
30 import fr.ifremer.quadrige3.ui.swing.component.bean.ExtendedComboBox;
31 import fr.ifremer.reefdb.dto.BooleanDTO;
32 import fr.ifremer.reefdb.dto.referential.DepartmentDTO;
33 import fr.ifremer.reefdb.dto.referential.PrivilegeDTO;
34 import fr.ifremer.reefdb.ui.swing.ReefDbHelpBroker;
35 import fr.ifremer.reefdb.ui.swing.ReefDbUIContext;
36 import fr.ifremer.reefdb.ui.swing.content.manage.filter.element.menu.ApplyFilterUI;
37 import fr.ifremer.reefdb.ui.swing.content.manage.referential.menu.ReferentialMenuUI;
38 import fr.ifremer.reefdb.ui.swing.util.ReefDbUI;
39 import java.awt.BorderLayout;
40 import java.awt.Component;
41 import java.awt.Container;
42 import java.awt.FlowLayout;
43 import java.awt.GridBagConstraints;
44 import java.awt.GridLayout;
45 import java.awt.Insets;
46 import java.awt.LayoutManager;
47 import java.awt.event.KeyEvent;
48 import java.awt.event.KeyListener;
49 import java.util.ArrayList;
50 import java.util.HashMap;
51 import java.util.List;
52 import java.util.Map;
53 import java.util.TreeMap;
54 import javax.swing.BorderFactory;
55 import javax.swing.Box;
56 import javax.swing.BoxLayout;
57 import javax.swing.JButton;
58 import javax.swing.JLabel;
59 import javax.swing.JPanel;
60 import javax.swing.JTextField;
61 import javax.swing.SwingConstants;
62 import jaxx.runtime.JAXXBinding;
63 import jaxx.runtime.JAXXContext;
64 import jaxx.runtime.JAXXObject;
65 import jaxx.runtime.JAXXObjectDescriptor;
66 import jaxx.runtime.JAXXUtil;
67 import jaxx.runtime.SwingUtil;
68 import jaxx.runtime.binding.DefaultJAXXBinding;
69 import jaxx.runtime.context.DefaultJAXXContext;
70 import jaxx.runtime.swing.Table;
71 import jaxx.runtime.swing.help.JAXXHelpUI;
72 import org.apache.commons.logging.Log;
73 import org.apache.commons.logging.LogFactory;
74 import static org.nuiton.i18n.I18n.t;
75
76 public class UserMenuUI extends JPanel implements JAXXHelpUI<ReefDbHelpBroker>, ReferentialMenuUI<UserMenuUIModel, UserMenuUIHandler>, JAXXObject {
77
78
79
80
81
82 public static final String BINDING_DEPARTMENT_COMBO_SELECTED_ITEM = "departmentCombo.selectedItem";
83 public static final String BINDING_FIRSTNAME_EDITOR_TEXT = "firstnameEditor.text";
84 public static final String BINDING_LASTNAME_EDITOR_TEXT = "lastnameEditor.text";
85 public static final String BINDING_LOCAL_COMBO_SELECTED_ITEM = "localCombo.selectedItem";
86 public static final String BINDING_PRIVILEGE_COMBO_SELECTED_ITEM = "privilegeCombo.selectedItem";
87 public static final String BINDING_STATUS_COMBO_SELECTED_ITEM = "statusCombo.selectedItem";
88
89
90
91
92
93 private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAK1XzW8bRRQfmySN89GvtCHQlqZpDwmVNi2l5ZAWmi+rKemHklSqCALGu2Nnynh3OztuHVlF/An8CXDngsSNE+LAmQMXxJ9AhTjAEfHe7HrXu57Ym5pK3dgzv/fe7719837jb1+S4UCSC09os2nJhqt4nVl3lx8/flB5wmy1xgJbcl95koT/CkVS3CXjTrweKHJxdxPNFyPzxVWv7nsuczuslzbJWKD2BQv2GFOKnEtb2EGwuB1vLzX9hmx7jUmZvH7915/Fr5wvvykS0vSB3RlIZbafVZLJ0CYpckeRkxDpGV0U1K0BDcndGvCdxLVVQYPgPq2zp+QLcmSTjPhUgjNF5vKnrH1o+6avyOiluw+py8QVRe5WpcWrktWZtCRjVadiNbgVPIf4lu25CtxZderSGoPtKsPAnAqrEQC+ztyG9Qg+3YMPjzZ8X0cYUWS47jlMKPLg/3N+Dz0mEUYq0vucSUUu9wixBd/XKnfAbkWjE/MSetclgMJjjZuRSVgXRJVi8CT1fbFf5kIx+WhDkQ/zZ1XVRhYTAMZVzGm50xuGOBlHOhoA0lbccyNuM6k+CkPs0Ipgabsx4dlUxNRP4WMms7tJK93Z6kWEncmgoZcqniK3OlJ92qCO5DV2rTPbqOOsCqOutd6E3B3maOMVr5l23G66qwaKk9CeyoUWjwmdx8fFpDJtwLrDoa8VmU7lscOaqsyZcNJW7ZDvGEIerXJpivl2jDgWI8KguLyQhrQDXDMEOOYwOKgKX3w6whUTRNcMl+fSkHaEdw0RxgNFVSNIe7+R3U57vtHl+bqpOL7kz7hgtUxxbhoQaf8J4nTczCsNpTw3SPdn0r3jtmBUhiBFplIvNlxF4EqMnwgAbu8lW+VoX5IzqfMCE91KJnoycgu7ZFg2YBkO2G63CGzBVjj+ZzLjHx3q3X+np3794ffvy+2ZPwuxTxuhHZIFs9iXng9Ti2PoY+HAbyguFu9Rf2mXlMKKaT07ayC2HW0DOYh3As0tNLfu0GAPXAwf+e3Hn6Y/++U1UizjOaZOmSJ+g5TUnoQqeMJp+h/c1owmno/C8zj8H4JDHw4qnCwKvssG/JkE/PM1ZnuS6hM3XKUigPUSrm+xACU0gg7h8VfkSEvP/RdNKN1ZQ+li/pXSz39PbX93u12+AqTzxoHwpITDH5ER7gruMi2akR4aRXLcD1jD8RLdMykhAS08np1akUrc18+trmoVUHw86aD4LLdW9KewzPuWLRlVbIcrwZxwZ17Nz0UaAdJQ5bVQAxRC5hYWoFQY5WNdA/z0CelSAb8PoSIcZYGntIxvaaKVzO8X+IJgMipyIeIQ6VH4Zz1SJW1gItIhHDlITIS0mbOhWF2RU2EzWDWmNoJNdDS/AIRGoyOwD+3Cw/WDQ+ssDpf/8VZaKZIanItq0CYQXjPaaBOJtCr141GII51IUseOnD/gNaeJHi7NE62MOCV5vmXMM4YbqaS1MH+m00mmZXTRI92smh4234xUJvm+mc03QRp5ZGT58J39epL0Wuwr29xjuVm8QpNPtjqkPanEdLYSIcoUv/PqcPgKTCUV2NZ+stmP9I38Skc7fefo1/Ix2tjy6RvO4WvQ0foP266yZSjlpJCrGCDTJz/FnyLcpigOy1oi8GWs4v0p/GrZKG/AYozq7xv4gwRuO2251uWajcoVQqzwOmXpW5glwp8J48rzxA73d1L1NRko7htfc8el7lUzO9Xa1pF6pTZU5a7TNQvSRI05zRihB2STunLmGI8jgu57ACZHbzpU0dkKkIT77Ptdvgv4nOrrEZf/wMdLs4ezOTiN4iVtZ99nPfxcGJjJpYE9XB7Yw9VcHv7p4eH6wBzeG5jD0sAcbg3MYXlgDqs5OnOMCl5zUQsf9/C0nodL4XwPD3fyXGy4Hf6oHIjFfB8W/wFv+w3g8hQAAA==";
94 private static final Log log = LogFactory.getLog(UserMenuUI.class);
95 private static final long serialVersionUID = 1L;
96
97
98
99
100
101 protected List<Object> $activeBindings = new ArrayList<Object>();
102 protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
103 protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
104 protected Map<String, Object> $objectMap = new HashMap<String, Object>();
105 protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
106 private boolean allComponentsCreated;
107 protected final JAXXContext delegateContext = new DefaultJAXXContext();
108
109
110
111
112
113 protected ApplyFilterUI applyFilterUI;
114 protected ReefDbHelpBroker broker;
115 protected JButton clearButton;
116 protected ExtendedComboBox<DepartmentDTO> departmentCombo;
117 protected JLabel departmentLabel;
118 protected JTextField firstnameEditor;
119 protected JLabel firstnameLabel;
120 protected final UserMenuUIHandler handler = createHandler();
121 protected JTextField lastnameEditor;
122 protected JLabel lastnameLabel;
123 protected ExtendedComboBox<BooleanDTO> localCombo;
124 protected JLabel localLabel;
125 protected JPanel localPanel;
126 protected JPanel menuPanel;
127 protected UserMenuUIModel model;
128 protected ExtendedComboBox<PrivilegeDTO> privilegeCombo;
129 protected JLabel privilegeLabel;
130 protected JButton searchButton;
131 protected JPanel selectionButtonsPanel;
132 protected Table selectionPanel;
133 protected ExtendedComboBox<StatusDTO> statusCombo;
134 protected JLabel statusLabel;
135
136
137
138
139
140 private UserMenuUI $JPanel0 = this;
141 private JPanel $JPanel1;
142 private JPanel $JPanel2;
143 private JPanel $JPanel3;
144 private JPanel $JPanel4;
145 private JPanel $JPanel5;
146
147
148
149
150
151 public UserMenuUI(ApplicationUI parentUI) {
152 ApplicationUIUtil.setParentUI(this, parentUI);
153 $initialize();
154 }
155
156 public UserMenuUI(LayoutManager param0, boolean param1) {
157 super(param0 ,param1);
158 $initialize();
159 }
160
161 public UserMenuUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
162 super(param1 ,param2);
163 JAXXUtil.initContext(this, parentContext);
164 $initialize();
165 }
166
167 public UserMenuUI(boolean param0) {
168 super(param0);
169 $initialize();
170 }
171
172 public UserMenuUI(JAXXContext parentContext, boolean param1) {
173 super(param1);
174 JAXXUtil.initContext(this, parentContext);
175 $initialize();
176 }
177
178 public UserMenuUI() {
179 $initialize();
180 }
181
182 public UserMenuUI(JAXXContext parentContext) {
183 JAXXUtil.initContext(this, parentContext);
184 $initialize();
185 }
186
187 public UserMenuUI(LayoutManager param0) {
188 super(param0);
189 $initialize();
190 }
191
192 public UserMenuUI(JAXXContext parentContext, LayoutManager param1) {
193 super(param1);
194 JAXXUtil.initContext(this, parentContext);
195 $initialize();
196 }
197
198
199
200
201
202 public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
203 return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
204 }
205
206
207
208
209
210 @Override
211 public void applyDataBinding(String $binding) {
212 if (allComponentsCreated && $bindings.containsKey($binding)) {
213 getDataBinding($binding).applyDataBinding();
214 }
215 processDataBinding($binding);
216 }
217
218 @Override
219 public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
220 super.firePropertyChange(propertyName, oldValue, newValue);
221 }
222
223 @Override
224 public Map<String, Object> get$objectMap() {
225 return $objectMap;
226 }
227
228 @Override
229 public JAXXBinding getDataBinding(String bindingId) {
230 return $bindings.get(bindingId);
231 }
232
233 @Override
234 public JAXXBinding[] getDataBindings() {
235 return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
236 }
237
238 @Override
239 public Object getObjectById(String id) {
240 return $objectMap.get(id);
241 }
242
243 @Override
244 public void processDataBinding(String $binding, boolean $force) {
245 if (!$force && $activeBindings.contains($binding)) {
246 return;
247 }
248 $activeBindings.add($binding);
249 try {
250 if (allComponentsCreated && $bindings.containsKey($binding)) {
251 getDataBinding($binding).processDataBinding();
252 }
253 } finally {
254 $activeBindings.remove($binding);
255 }
256 }
257
258 @Override
259 public void processDataBinding(String $binding) {
260 processDataBinding($binding, false);
261 }
262
263 @Override
264 public void registerDataBinding(JAXXBinding binding) {
265 $bindings.put(binding.getId(), binding);
266 }
267
268 @Override
269 public void removeDataBinding(String $binding) {
270 if (allComponentsCreated && $bindings.containsKey($binding)) {
271 getDataBinding($binding).removeDataBinding();
272 }
273 }
274
275
276
277
278
279 @Override
280 public <T> T getContextValue(Class<T> clazz) {
281 return delegateContext.getContextValue(clazz, null);
282 }
283
284 @Override
285 public <T> T getContextValue(Class<T> clazz, String name) {
286 return delegateContext.getContextValue(clazz, name);
287 }
288
289 @Override
290 public JAXXContext getDelegateContext() {
291 return delegateContext;
292 }
293
294 @Override
295 public <O extends Container> O getParentContainer(Class<O> clazz) {
296 return SwingUtil.getParentContainer(this, clazz);
297 }
298
299 @Override
300 public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
301 return SwingUtil.getParentContainer(source, clazz);
302 }
303
304 @Override
305 public <T> void removeContextValue(Class<T> clazz) {
306 delegateContext.removeContextValue(clazz, null);
307 }
308
309 @Override
310 public <T> void removeContextValue(Class<T> clazz, String name) {
311 delegateContext.removeContextValue(clazz, name);
312 }
313
314 @Override
315 public <T> void setContextValue(T o) {
316 delegateContext.setContextValue(o, null);
317 }
318
319 @Override
320 public <T> void setContextValue(T o, String name) {
321 delegateContext.setContextValue(o, name);
322 }
323
324
325
326
327
328 public void doKeyReleased__on__firstnameEditor(KeyEvent event) {
329 if (log.isDebugEnabled()) {
330 log.debug(event);
331 }
332 handler.setText(event, "firstName");
333 }
334
335 public void doKeyReleased__on__lastnameEditor(KeyEvent event) {
336 if (log.isDebugEnabled()) {
337 log.debug(event);
338 }
339 handler.setText(event, "name");
340 }
341
342
343
344
345
346 public ApplyFilterUI getApplyFilterUI() {
347 return applyFilterUI;
348 }
349
350 public ReefDbHelpBroker getBroker() {
351 return broker;
352 }
353
354 public JButton getClearButton() {
355 return clearButton;
356 }
357
358 public ExtendedComboBox<DepartmentDTO> getDepartmentCombo() {
359 return departmentCombo;
360 }
361
362 public JLabel getDepartmentLabel() {
363 return departmentLabel;
364 }
365
366 public JTextField getFirstnameEditor() {
367 return firstnameEditor;
368 }
369
370 public JLabel getFirstnameLabel() {
371 return firstnameLabel;
372 }
373
374 public UserMenuUIHandler getHandler() {
375 return handler;
376 }
377
378 public JTextField getLastnameEditor() {
379 return lastnameEditor;
380 }
381
382 public JLabel getLastnameLabel() {
383 return lastnameLabel;
384 }
385
386 public ExtendedComboBox<BooleanDTO> getLocalCombo() {
387 return localCombo;
388 }
389
390 public JLabel getLocalLabel() {
391 return localLabel;
392 }
393
394 public JPanel getLocalPanel() {
395 return localPanel;
396 }
397
398 public JPanel getMenuPanel() {
399 return menuPanel;
400 }
401
402 public UserMenuUIModel getModel() {
403 return model;
404 }
405
406 public ExtendedComboBox<PrivilegeDTO> getPrivilegeCombo() {
407 return privilegeCombo;
408 }
409
410 public JLabel getPrivilegeLabel() {
411 return privilegeLabel;
412 }
413
414 public JButton getSearchButton() {
415 return searchButton;
416 }
417
418 public JPanel getSelectionButtonsPanel() {
419 return selectionButtonsPanel;
420 }
421
422 public Table getSelectionPanel() {
423 return selectionPanel;
424 }
425
426 public ExtendedComboBox<StatusDTO> getStatusCombo() {
427 return statusCombo;
428 }
429
430 public JLabel getStatusLabel() {
431 return statusLabel;
432 }
433
434
435
436
437
438 @Override
439 public void registerHelpId(ReefDbHelpBroker broker, Component component, String helpId) {
440 broker.installUI(component, helpId);
441 }
442
443 @Override
444 public void showHelp(String helpId) {
445 getBroker().showHelp(this, helpId);
446 }
447
448
449
450
451
452 protected JPanel get$JPanel1() {
453 return $JPanel1;
454 }
455
456 protected JPanel get$JPanel2() {
457 return $JPanel2;
458 }
459
460 protected JPanel get$JPanel3() {
461 return $JPanel3;
462 }
463
464 protected JPanel get$JPanel4() {
465 return $JPanel4;
466 }
467
468 protected JPanel get$JPanel5() {
469 return $JPanel5;
470 }
471
472
473
474
475
476 protected void addChildrenToLocalPanel() {
477 if (!allComponentsCreated) {
478 return;
479 }
480 localPanel.add(localLabel, BorderLayout.PAGE_START);
481 localPanel.add(localCombo, BorderLayout.CENTER);
482 }
483
484 protected void addChildrenToMenuPanel() {
485 if (!allComponentsCreated) {
486 return;
487 }
488 menuPanel.add(applyFilterUI);
489 menuPanel.add(selectionPanel);
490 menuPanel.add(selectionButtonsPanel);
491 }
492
493 protected void addChildrenToSelectionButtonsPanel() {
494 if (!allComponentsCreated) {
495 return;
496 }
497 selectionButtonsPanel.add(clearButton);
498 selectionButtonsPanel.add(searchButton);
499 }
500
501 protected void addChildrenToSelectionPanel() {
502 if (!allComponentsCreated) {
503 return;
504 }
505 selectionPanel.add(localPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
506 selectionPanel.add($JPanel1, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
507 selectionPanel.add($JPanel2, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
508 selectionPanel.add($JPanel3, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
509 selectionPanel.add($JPanel4, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
510 selectionPanel.add($JPanel5, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
511 }
512
513 protected void createApplyFilterUI() {
514 $objectMap.put("applyFilterUI", applyFilterUI = new ApplyFilterUI(this));
515
516 applyFilterUI.setName("applyFilterUI");
517 }
518
519 protected void createBroker() {
520 $objectMap.put("broker", broker = new ReefDbHelpBroker("reefdb.home.help"));
521 }
522
523 protected void createClearButton() {
524 $objectMap.put("clearButton", clearButton = new JButton());
525
526 clearButton.setName("clearButton");
527 clearButton.setText(t("reefdb.action.search.clear.label"));
528 clearButton.setToolTipText(t("reefdb.action.search.clear.tip"));
529 clearButton.putClientProperty("applicationAction", ClearAction.class);
530 }
531
532 protected void createDepartmentCombo() {
533 $objectMap.put("departmentCombo", departmentCombo = new ExtendedComboBox<DepartmentDTO>(this));
534
535 departmentCombo.setName("departmentCombo");
536 departmentCombo.setFilterable(true);
537 departmentCombo.setShowDecorator(false);
538 departmentCombo.setProperty("department");
539 departmentCombo.setShowReset(true);
540 }
541
542 protected void createDepartmentLabel() {
543 $objectMap.put("departmentLabel", departmentLabel = new JLabel());
544
545 departmentLabel.setName("departmentLabel");
546 departmentLabel.setText(t("reefdb.property.department"));
547 }
548
549 protected void createFirstnameEditor() {
550 $objectMap.put("firstnameEditor", firstnameEditor = new JTextField());
551
552 firstnameEditor.setName("firstnameEditor");
553 firstnameEditor.setColumns(15);
554 firstnameEditor.addKeyListener(JAXXUtil.getEventListener(KeyListener.class, "keyReleased", this, "doKeyReleased__on__firstnameEditor"));
555 }
556
557 protected void createFirstnameLabel() {
558 $objectMap.put("firstnameLabel", firstnameLabel = new JLabel());
559
560 firstnameLabel.setName("firstnameLabel");
561 firstnameLabel.setText(t("reefdb.property.user.firstname"));
562 }
563
564 protected UserMenuUIHandler createHandler() {
565 return new UserMenuUIHandler();
566 }
567
568 protected void createLastnameEditor() {
569 $objectMap.put("lastnameEditor", lastnameEditor = new JTextField());
570
571 lastnameEditor.setName("lastnameEditor");
572 lastnameEditor.setColumns(15);
573 lastnameEditor.addKeyListener(JAXXUtil.getEventListener(KeyListener.class, "keyReleased", this, "doKeyReleased__on__lastnameEditor"));
574 }
575
576 protected void createLastnameLabel() {
577 $objectMap.put("lastnameLabel", lastnameLabel = new JLabel());
578
579 lastnameLabel.setName("lastnameLabel");
580 lastnameLabel.setText(t("reefdb.property.user.lastname"));
581 }
582
583 protected void createLocalCombo() {
584 $objectMap.put("localCombo", localCombo = new ExtendedComboBox<BooleanDTO>(this));
585
586 localCombo.setName("localCombo");
587 localCombo.setFilterable(true);
588 localCombo.setShowDecorator(false);
589 localCombo.setProperty("isLocal");
590 localCombo.setShowReset(true);
591 }
592
593 protected void createLocalLabel() {
594 $objectMap.put("localLabel", localLabel = new JLabel());
595
596 localLabel.setName("localLabel");
597 localLabel.setText(t("reefdb.filter.filterElement.local"));
598 }
599
600 protected void createLocalPanel() {
601 $objectMap.put("localPanel", localPanel = new JPanel());
602
603 localPanel.setName("localPanel");
604 localPanel.setLayout(new BorderLayout());
605 }
606
607 protected void createMenuPanel() {
608 $objectMap.put("menuPanel", menuPanel = new JPanel());
609
610 menuPanel.setName("menuPanel");
611 menuPanel.setLayout(new BoxLayout(menuPanel, BoxLayout.PAGE_AXIS));
612 }
613
614 protected void createModel() {
615 $objectMap.put("model", model = getContextValue(UserMenuUIModel.class));
616 }
617
618 protected void createPrivilegeCombo() {
619 $objectMap.put("privilegeCombo", privilegeCombo = new ExtendedComboBox<PrivilegeDTO>(this));
620
621 privilegeCombo.setName("privilegeCombo");
622 privilegeCombo.setFilterable(true);
623 privilegeCombo.setShowDecorator(false);
624 privilegeCombo.setProperty("privilege");
625 privilegeCombo.setShowReset(true);
626 }
627
628 protected void createPrivilegeLabel() {
629 $objectMap.put("privilegeLabel", privilegeLabel = new JLabel());
630
631 privilegeLabel.setName("privilegeLabel");
632 privilegeLabel.setText(t("reefdb.property.user.privilege"));
633 }
634
635 protected void createSearchButton() {
636 $objectMap.put("searchButton", searchButton = new JButton());
637
638 searchButton.setName("searchButton");
639 searchButton.setText(t("reefdb.action.search.label"));
640 searchButton.setToolTipText(t("reefdb.action.search.tip"));
641 searchButton.putClientProperty("applicationAction", SearchAction.class);
642 }
643
644 protected void createSelectionButtonsPanel() {
645 $objectMap.put("selectionButtonsPanel", selectionButtonsPanel = new JPanel());
646
647 selectionButtonsPanel.setName("selectionButtonsPanel");
648 selectionButtonsPanel.setLayout(new GridLayout(1,0));
649 }
650
651 protected void createSelectionPanel() {
652 $objectMap.put("selectionPanel", selectionPanel = new Table());
653
654 selectionPanel.setName("selectionPanel");
655 }
656
657 protected void createStatusCombo() {
658 $objectMap.put("statusCombo", statusCombo = new ExtendedComboBox<StatusDTO>(this));
659
660 statusCombo.setName("statusCombo");
661 statusCombo.setFilterable(true);
662 statusCombo.setShowDecorator(false);
663 statusCombo.setProperty("status");
664 statusCombo.setShowReset(true);
665 }
666
667 protected void createStatusLabel() {
668 $objectMap.put("statusLabel", statusLabel = new JLabel());
669
670 statusLabel.setName("statusLabel");
671 statusLabel.setText(t("reefdb.property.status"));
672 }
673
674
675
676
677
678 private void $completeSetup() {
679 allComponentsCreated = true;
680 if (log.isDebugEnabled()) {
681 log.debug(this);
682 }
683
684 add(menuPanel);
685 addChildrenToMenuPanel();
686 addChildrenToSelectionPanel();
687 addChildrenToLocalPanel();
688
689 $JPanel1.add(lastnameLabel, BorderLayout.PAGE_START);
690 $JPanel1.add(lastnameEditor);
691
692 $JPanel2.add(firstnameLabel, BorderLayout.PAGE_START);
693 $JPanel2.add(firstnameEditor);
694
695 $JPanel3.add(departmentLabel, BorderLayout.PAGE_START);
696 $JPanel3.add(departmentCombo, BorderLayout.CENTER);
697
698 $JPanel4.add(statusLabel, BorderLayout.PAGE_START);
699 $JPanel4.add(statusCombo, BorderLayout.CENTER);
700
701 $JPanel5.add(privilegeLabel, BorderLayout.PAGE_START);
702 $JPanel5.add(privilegeCombo, BorderLayout.CENTER);
703 addChildrenToSelectionButtonsPanel();
704
705
706 JAXXUtil.applyDataBinding(this, $bindings.keySet());
707
708
709 localCombo.setBeanType(BooleanDTO.class);
710 departmentCombo.setBeanType(DepartmentDTO.class);
711 statusCombo.setBeanType(StatusDTO.class);
712 privilegeCombo.setBeanType(PrivilegeDTO.class);
713 clearButton.setAlignmentX(Component.CENTER_ALIGNMENT);
714 searchButton.setAlignmentX(Component.CENTER_ALIGNMENT);
715 selectionPanel.setBorder(BorderFactory.createTitledBorder(t("reefdb.config.menu.title")));
716 localLabel.setLabelFor(localCombo);
717 localCombo.setBean(model);
718 lastnameLabel.setLabelFor(lastnameEditor);
719 firstnameLabel.setLabelFor(firstnameEditor);
720 departmentLabel.setLabelFor(departmentCombo);
721 departmentCombo.setBean(model);
722 statusLabel.setLabelFor(statusCombo);
723 statusCombo.setBean(model);
724 privilegeLabel.setLabelFor(privilegeCombo);
725 privilegeCombo.setBean(model);
726 clearButton.setIcon(SwingUtil.createActionIcon("reset"));
727 searchButton.setIcon(SwingUtil.createActionIcon("find"));
728 }
729
730 private void $initialize() {
731 if (allComponentsCreated) {
732 return;
733 }
734 if (log.isDebugEnabled()) {
735 log.debug(this);
736 }
737 handler.beforeInit(this);
738 $objectMap.put("$JPanel0", $JPanel0);
739 createModel();
740 createBroker();
741 createMenuPanel();
742 createApplyFilterUI();
743 createSelectionPanel();
744 createLocalPanel();
745 createLocalLabel();
746 createLocalCombo();
747
748 $objectMap.put("$JPanel1", $JPanel1 = new JPanel());
749
750 $JPanel1.setName("$JPanel1");
751 $JPanel1.setLayout(new BorderLayout());
752 createLastnameLabel();
753 createLastnameEditor();
754
755 $objectMap.put("$JPanel2", $JPanel2 = new JPanel());
756
757 $JPanel2.setName("$JPanel2");
758 $JPanel2.setLayout(new BorderLayout());
759 createFirstnameLabel();
760 createFirstnameEditor();
761
762 $objectMap.put("$JPanel3", $JPanel3 = new JPanel());
763
764 $JPanel3.setName("$JPanel3");
765 $JPanel3.setLayout(new BorderLayout());
766 createDepartmentLabel();
767 createDepartmentCombo();
768
769 $objectMap.put("$JPanel4", $JPanel4 = new JPanel());
770
771 $JPanel4.setName("$JPanel4");
772 $JPanel4.setLayout(new BorderLayout());
773 createStatusLabel();
774 createStatusCombo();
775
776 $objectMap.put("$JPanel5", $JPanel5 = new JPanel());
777
778 $JPanel5.setName("$JPanel5");
779 $JPanel5.setLayout(new BorderLayout());
780 createPrivilegeLabel();
781 createPrivilegeCombo();
782 createSelectionButtonsPanel();
783 createClearButton();
784 createSearchButton();
785
786 setName("$JPanel0");
787
788
789 $registerDefaultBindings();
790 $completeSetup();
791 handler.afterInit(this);
792 }
793
794 private void $registerDefaultBindings() {
795
796 registerDataBinding(new DefaultJAXXBinding(this, BINDING_LOCAL_COMBO_SELECTED_ITEM, true) {
797
798 @Override
799 public void applyDataBinding() {
800 if (model != null) {
801 model.addPropertyChangeListener("isLocal", this);
802 }
803 }
804
805 @Override
806 public void processDataBinding() {
807 if (model != null) {
808 localCombo.setSelectedItem(model.getIsLocal());
809 }
810 }
811
812 @Override
813 public void removeDataBinding() {
814 if (model != null) {
815 model.removePropertyChangeListener("isLocal", this);
816 }
817 }
818 });
819 registerDataBinding(new DefaultJAXXBinding(this, BINDING_LASTNAME_EDITOR_TEXT, true) {
820
821 @Override
822 public void applyDataBinding() {
823 if (model != null) {
824 model.addPropertyChangeListener("name", this);
825 }
826 }
827
828 @Override
829 public void processDataBinding() {
830 if (model != null) {
831 SwingUtil.setText(lastnameEditor, model.getName());
832 }
833 }
834
835 @Override
836 public void removeDataBinding() {
837 if (model != null) {
838 model.removePropertyChangeListener("name", this);
839 }
840 }
841 });
842 registerDataBinding(new DefaultJAXXBinding(this, BINDING_FIRSTNAME_EDITOR_TEXT, true) {
843
844 @Override
845 public void applyDataBinding() {
846 if (model != null) {
847 model.addPropertyChangeListener("firstName", this);
848 }
849 }
850
851 @Override
852 public void processDataBinding() {
853 if (model != null) {
854 SwingUtil.setText(firstnameEditor, model.getFirstName());
855 }
856 }
857
858 @Override
859 public void removeDataBinding() {
860 if (model != null) {
861 model.removePropertyChangeListener("firstName", this);
862 }
863 }
864 });
865 registerDataBinding(new DefaultJAXXBinding(this, BINDING_DEPARTMENT_COMBO_SELECTED_ITEM, true) {
866
867 @Override
868 public void applyDataBinding() {
869 if (model != null) {
870 model.addPropertyChangeListener("department", this);
871 }
872 }
873
874 @Override
875 public void processDataBinding() {
876 if (model != null) {
877 departmentCombo.setSelectedItem(model.getDepartment());
878 }
879 }
880
881 @Override
882 public void removeDataBinding() {
883 if (model != null) {
884 model.removePropertyChangeListener("department", this);
885 }
886 }
887 });
888 registerDataBinding(new DefaultJAXXBinding(this, BINDING_STATUS_COMBO_SELECTED_ITEM, true) {
889
890 @Override
891 public void applyDataBinding() {
892 if (model != null) {
893 model.addPropertyChangeListener("status", this);
894 }
895 }
896
897 @Override
898 public void processDataBinding() {
899 if (model != null) {
900 statusCombo.setSelectedItem(model.getStatus());
901 }
902 }
903
904 @Override
905 public void removeDataBinding() {
906 if (model != null) {
907 model.removePropertyChangeListener("status", this);
908 }
909 }
910 });
911 registerDataBinding(new DefaultJAXXBinding(this, BINDING_PRIVILEGE_COMBO_SELECTED_ITEM, true) {
912
913 @Override
914 public void applyDataBinding() {
915 if (model != null) {
916 model.addPropertyChangeListener("privilege", this);
917 }
918 }
919
920 @Override
921 public void processDataBinding() {
922 if (model != null) {
923 privilegeCombo.setSelectedItem(model.getPrivilege());
924 }
925 }
926
927 @Override
928 public void removeDataBinding() {
929 if (model != null) {
930 model.removePropertyChangeListener("privilege", this);
931 }
932 }
933 });
934 }
935
936 }