1 package fr.ifremer.dali.ui.swing.content.manage.referential.pmfm.menu;
2
3 import fr.ifremer.dali.dto.referential.UnitDTO;
4 import fr.ifremer.dali.dto.referential.pmfm.FractionDTO;
5 import fr.ifremer.dali.dto.referential.pmfm.MatrixDTO;
6 import fr.ifremer.dali.dto.referential.pmfm.MethodDTO;
7 import fr.ifremer.dali.dto.referential.pmfm.ParameterDTO;
8 import fr.ifremer.dali.ui.swing.DaliHelpBroker;
9 import fr.ifremer.dali.ui.swing.DaliUIContext;
10 import fr.ifremer.dali.ui.swing.content.manage.filter.element.menu.ApplyFilterUI;
11 import fr.ifremer.dali.ui.swing.content.manage.referential.menu.ReferentialMenuUI;
12 import fr.ifremer.dali.ui.swing.util.DaliUI;
13 import fr.ifremer.quadrige3.ui.core.dto.referential.StatusDTO;
14 import fr.ifremer.quadrige3.ui.swing.ApplicationUI;
15 import fr.ifremer.quadrige3.ui.swing.ApplicationUIUtil;
16 import fr.ifremer.quadrige3.ui.swing.component.bean.ExtendedComboBox;
17 import java.awt.BorderLayout;
18 import java.awt.Component;
19 import java.awt.Container;
20 import java.awt.GridBagConstraints;
21 import java.awt.GridLayout;
22 import java.awt.Insets;
23 import java.awt.LayoutManager;
24 import java.awt.event.KeyEvent;
25 import java.awt.event.KeyListener;
26 import java.util.ArrayList;
27 import java.util.HashMap;
28 import java.util.List;
29 import java.util.Map;
30 import java.util.TreeMap;
31 import javax.swing.BorderFactory;
32 import javax.swing.Box;
33 import javax.swing.BoxLayout;
34 import javax.swing.JButton;
35 import javax.swing.JLabel;
36 import javax.swing.JPanel;
37 import javax.swing.JTextField;
38 import javax.swing.SwingConstants;
39 import jaxx.runtime.JAXXBinding;
40 import jaxx.runtime.JAXXContext;
41 import jaxx.runtime.JAXXObject;
42 import jaxx.runtime.JAXXObjectDescriptor;
43 import jaxx.runtime.JAXXUtil;
44 import jaxx.runtime.SwingUtil;
45 import jaxx.runtime.binding.DefaultJAXXBinding;
46 import jaxx.runtime.context.DefaultJAXXContext;
47 import jaxx.runtime.swing.Table;
48 import jaxx.runtime.swing.help.JAXXHelpUI;
49 import org.apache.commons.logging.Log;
50 import org.apache.commons.logging.LogFactory;
51 import static org.nuiton.i18n.I18n.t;
52
53 public class PmfmMenuUI extends JPanel implements JAXXHelpUI<DaliHelpBroker>, ReferentialMenuUI<PmfmMenuUIModel, PmfmMenuUIHandler>, JAXXObject {
54
55
56
57
58
59 public static final String BINDING_FRACTIONS_COMBO_SELECTED_ITEM = "fractionsCombo.selectedItem";
60 public static final String BINDING_MATRICES_COMBO_SELECTED_ITEM = "matricesCombo.selectedItem";
61 public static final String BINDING_METHODS_COMBO_SELECTED_ITEM = "methodsCombo.selectedItem";
62 public static final String BINDING_NAME_EDITOR_TEXT = "nameEditor.text";
63 public static final String BINDING_PARAMETERS_COMBO_SELECTED_ITEM = "parametersCombo.selectedItem";
64 public static final String BINDING_STATUS_COMBO_SELECTED_ITEM = "statusCombo.selectedItem";
65 public static final String BINDING_UNITS_COMBO_SELECTED_ITEM = "unitsCombo.selectedItem";
66
67
68
69
70
71 private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAK1YTW8bRRgem8SJnc/mi1QJpaRFpCBNUkrLISltvkxcklI1rhSRA4x3x86U9e52dkwcWUX8BH4C3LkgceOEOHDmwAXxFxDiwBXxzqy9611P4k2WSNnGM+887/O8OzPP6373Jxr0OHrjOWk2MW/YgtUpfrRxePhx5Tk1xDb1DM5c4XDk/2SyKHuERsxg3BPoxtGeXL7SXr6y5dRdx6Z21+q1PVTwxKlFvWNKhUCvRVcYnrdyEEyvNd0G76AGpHSo3/z9V/Zr86tvswg1XWB3DaRc77cqVDKwh7LMFGgKMn1BVixi14AGZ3YN+I7JsS2LeN5jUqcv0JdoaA/lXMIBTKCl5JIVhlrfdAUquPVqfZ/ajWclgXarHLMqp3XKsUkshhsMeyeQHxuOLQAO14lNahRzWqUyMSMWlgC4Dgj4SQDluipDTqDBumNSS6D9/wt6X+KF+LkKdz6nXKC3zkywDZ92Yc2migyX5iXyE2JLelOyus32gkdqUEblg+Ax4rrWaZFZgnJZqlJSPVW1BFMLQuWoVLPRjSUTTAV5xj2INARz7Daz+cj+8VOUScWi0XV5G3ZFwHtGPuajk3uk0qtUDcqohSC4IIN3TAZ7RqC5SHSZNkWRUcuMrhi+6VdsVZN6AnYo4IFSL8j1unzc0IXAvq04At3vKu6LBjE5q9E73RVu725cocTGO02ot0lNtXjTaUbRO+Rua8iN1QkcL4PGqL3dG6Cw5eCtaEAH/V0N+niVE/UmY/Crmogo/moP/h0N/ijU7NgxY+j3euaj2Pd6sN/TYBcaNhMx5PXYbBR3vQf3rgZ3xBNENGLAm/HpKHI4PRscjs2GEFC26IYPT8OIYVHC/SCBpiOb2B+VgbthqTwIN47Dqb32PEcLkfMHzoBDZwiv7swRGuQNGIYDe9RrJk9hyreR+ZiNSEA1++/c9G8//vFDseMdb0LuWW1ol/XBne5yx4X7j8nUE75xNASzVvaJu3aE8n7FlC8uaogdtKeBHOS7IpdjuRzvEu8YIAaHfv/p57nPfn0FZYuoYDnELBIZX0J5ccyhCo5lNt0HDxWj0ZNheE7C7wDsEf/ikzeVgM+8Af+MQfzJNjUcTtTtMlgllgfjeTn+lHrSituhA/JoCzTUUv7xsgmlW9SULuBfyf/yz/TB9w875cuAnKtnhoclHPwE5ZhtMZsq8237qtZsR1yPNkwn9E+doyLw1Mn4jdT2nLJ6HvZUKyNtzOGmtLEHrU31l1/mU2xwSgQtM2FR059ZFstLynHAaKqs5juKkAFLt25BoWSOiqqA/MtEPZ7i9qGThSNsyQNalO9otBX6wUv5esADwEUUg/beO8UyRJc5NJ5+STMB9BX/leMaFbL4y3pNXS51MT1XWjG7CUUtRkWp7iMI1pGIm1sCJqP+u6BmSdA6+Gso9kkHCxQD4w4NKGJSDkrOxaox0Yo4XFiLq5paqNCmjkTUSC9ehumwDPsqSbwGuQS5LyF/shV14FD/gkZ/J1Z7xqJmf/ESzIYlKLah4kUYTkbgEnUYb3X3Cn12gYrUUYg0JOk2gQLq3QR9U19C+2gr7GZC5a9qlMs47V0UNksXV9113T0DmLjmgfOTXkLvWKuryQoFz0QF+zG6xN0tXKqXfKBwel5y38yJNEMHMvWp/M7GDCJPxYY6GzL/lmwN/Y/YkM4N+Qv+0SnJ727QyHU6EVWYa6owfgD2+0Ss2kts+d+oRoTjWGXmlrtMRBcumKtV1dWrXlbVTOtAZTpP1kCV2Wagal5DU6tnThN4hpJIF53A8HMWOXUgGI2vm0SQ6xUgCC36Bz3YGfmc7osIw5mcfAzpERZTI9xMoGpYdq7lU5eeg7Ocmsk7iRBmzkFYSc3hdmoOd1NzeD81h7XUHO6n5rCRmsNWag4fpuZQSnA6CnCb1Gz5X2GH5yB9lIjLzjkIj5N84WCG+rafjsXjPiz+A//KkEXTFgAA";
72 private static final Log log = LogFactory.getLog(PmfmMenuUI.class);
73 private static final long serialVersionUID = 1L;
74
75
76
77
78
79 protected List<Object> $activeBindings = new ArrayList<Object>();
80 protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
81 protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
82 protected Map<String, Object> $objectMap = new HashMap<String, Object>();
83 protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
84 private boolean allComponentsCreated;
85 protected final JAXXContext delegateContext = new DefaultJAXXContext();
86
87
88
89
90
91 protected ApplyFilterUI applyFilterUI;
92 protected DaliHelpBroker broker;
93 protected JButton clearButton;
94 protected ExtendedComboBox<FractionDTO> fractionsCombo;
95 protected JLabel fractionsLabel;
96 protected final PmfmMenuUIHandler handler = createHandler();
97 protected ExtendedComboBox<MatrixDTO> matricesCombo;
98 protected JLabel matricesLabel;
99 protected JPanel menuPanel;
100 protected ExtendedComboBox<MethodDTO> methodsCombo;
101 protected JLabel methodsLabel;
102 protected PmfmMenuUIModel model;
103 protected JTextField nameEditor;
104 protected JLabel nameLabel;
105 protected JPanel namePanel;
106 protected ExtendedComboBox<ParameterDTO> parametersCombo;
107 protected JLabel parametersLabel;
108 protected PmfmMenuUI pmfmMenuUI = this;
109 protected JButton searchButton;
110 protected JPanel selectionButtonsPanel;
111 protected Table selectionPanel;
112 protected ExtendedComboBox<StatusDTO> statusCombo;
113 protected JLabel statusLabel;
114 protected ExtendedComboBox<UnitDTO> unitsCombo;
115 protected JLabel unitsLabel;
116
117
118
119
120
121 private JPanel $JPanel0;
122 private JPanel $JPanel1;
123 private JPanel $JPanel2;
124 private JPanel $JPanel3;
125 private JPanel $JPanel4;
126 private JPanel $JPanel5;
127
128
129
130
131
132 public PmfmMenuUI(ApplicationUI parentUI) {
133 ApplicationUIUtil.setParentUI(this, parentUI);
134 $initialize();
135 }
136
137 public PmfmMenuUI() {
138 $initialize();
139 }
140
141 public PmfmMenuUI(JAXXContext parentContext) {
142 JAXXUtil.initContext(this, parentContext);
143 $initialize();
144 }
145
146 public PmfmMenuUI(boolean param0) {
147 super(param0);
148 $initialize();
149 }
150
151 public PmfmMenuUI(JAXXContext parentContext, boolean param1) {
152 super(param1);
153 JAXXUtil.initContext(this, parentContext);
154 $initialize();
155 }
156
157 public PmfmMenuUI(LayoutManager param0) {
158 super(param0);
159 $initialize();
160 }
161
162 public PmfmMenuUI(JAXXContext parentContext, LayoutManager param1) {
163 super(param1);
164 JAXXUtil.initContext(this, parentContext);
165 $initialize();
166 }
167
168 public PmfmMenuUI(LayoutManager param0, boolean param1) {
169 super(param0 ,param1);
170 $initialize();
171 }
172
173 public PmfmMenuUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
174 super(param1 ,param2);
175 JAXXUtil.initContext(this, parentContext);
176 $initialize();
177 }
178
179
180
181
182
183 public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
184 return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
185 }
186
187
188
189
190
191 @Override
192 public void applyDataBinding(String $binding) {
193 if (allComponentsCreated && $bindings.containsKey($binding)) {
194 getDataBinding($binding).applyDataBinding();
195 }
196 processDataBinding($binding);
197 }
198
199 @Override
200 public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
201 super.firePropertyChange(propertyName, oldValue, newValue);
202 }
203
204 @Override
205 public Map<String, Object> get$objectMap() {
206 return $objectMap;
207 }
208
209 @Override
210 public JAXXBinding getDataBinding(String bindingId) {
211 return $bindings.get(bindingId);
212 }
213
214 @Override
215 public JAXXBinding[] getDataBindings() {
216 return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
217 }
218
219 @Override
220 public Object getObjectById(String id) {
221 return $objectMap.get(id);
222 }
223
224 @Override
225 public void processDataBinding(String $binding, boolean $force) {
226 if (!$force && $activeBindings.contains($binding)) {
227 return;
228 }
229 $activeBindings.add($binding);
230 try {
231 if (allComponentsCreated && $bindings.containsKey($binding)) {
232 getDataBinding($binding).processDataBinding();
233 }
234 } finally {
235 $activeBindings.remove($binding);
236 }
237 }
238
239 @Override
240 public void processDataBinding(String $binding) {
241 processDataBinding($binding, false);
242 }
243
244 @Override
245 public void registerDataBinding(JAXXBinding binding) {
246 $bindings.put(binding.getId(), binding);
247 }
248
249 @Override
250 public void removeDataBinding(String $binding) {
251 if (allComponentsCreated && $bindings.containsKey($binding)) {
252 getDataBinding($binding).removeDataBinding();
253 }
254 }
255
256
257
258
259
260 @Override
261 public <T> T getContextValue(Class<T> clazz) {
262 return delegateContext.getContextValue(clazz, null);
263 }
264
265 @Override
266 public <T> T getContextValue(Class<T> clazz, String name) {
267 return delegateContext.getContextValue(clazz, name);
268 }
269
270 @Override
271 public JAXXContext getDelegateContext() {
272 return delegateContext;
273 }
274
275 @Override
276 public <O extends Container> O getParentContainer(Class<O> clazz) {
277 return SwingUtil.getParentContainer(this, clazz);
278 }
279
280 @Override
281 public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
282 return SwingUtil.getParentContainer(source, clazz);
283 }
284
285 @Override
286 public <T> void removeContextValue(Class<T> clazz) {
287 delegateContext.removeContextValue(clazz, null);
288 }
289
290 @Override
291 public <T> void removeContextValue(Class<T> clazz, String name) {
292 delegateContext.removeContextValue(clazz, name);
293 }
294
295 @Override
296 public <T> void setContextValue(T o) {
297 delegateContext.setContextValue(o, null);
298 }
299
300 @Override
301 public <T> void setContextValue(T o, String name) {
302 delegateContext.setContextValue(o, name);
303 }
304
305
306
307
308
309 public void doKeyReleased__on__nameEditor(KeyEvent event) {
310 if (log.isDebugEnabled()) {
311 log.debug(event);
312 }
313 handler.setText(event, "name");
314 }
315
316
317
318
319
320 public ApplyFilterUI getApplyFilterUI() {
321 return applyFilterUI;
322 }
323
324 public DaliHelpBroker getBroker() {
325 return broker;
326 }
327
328 public JButton getClearButton() {
329 return clearButton;
330 }
331
332 public ExtendedComboBox<FractionDTO> getFractionsCombo() {
333 return fractionsCombo;
334 }
335
336 public JLabel getFractionsLabel() {
337 return fractionsLabel;
338 }
339
340 public PmfmMenuUIHandler getHandler() {
341 return handler;
342 }
343
344 public ExtendedComboBox<MatrixDTO> getMatricesCombo() {
345 return matricesCombo;
346 }
347
348 public JLabel getMatricesLabel() {
349 return matricesLabel;
350 }
351
352 public JPanel getMenuPanel() {
353 return menuPanel;
354 }
355
356 public ExtendedComboBox<MethodDTO> getMethodsCombo() {
357 return methodsCombo;
358 }
359
360 public JLabel getMethodsLabel() {
361 return methodsLabel;
362 }
363
364 public PmfmMenuUIModel getModel() {
365 return model;
366 }
367
368 public JTextField getNameEditor() {
369 return nameEditor;
370 }
371
372 public JLabel getNameLabel() {
373 return nameLabel;
374 }
375
376 public JPanel getNamePanel() {
377 return namePanel;
378 }
379
380 public ExtendedComboBox<ParameterDTO> getParametersCombo() {
381 return parametersCombo;
382 }
383
384 public JLabel getParametersLabel() {
385 return parametersLabel;
386 }
387
388 public JButton getSearchButton() {
389 return searchButton;
390 }
391
392 public JPanel getSelectionButtonsPanel() {
393 return selectionButtonsPanel;
394 }
395
396 public Table getSelectionPanel() {
397 return selectionPanel;
398 }
399
400 public ExtendedComboBox<StatusDTO> getStatusCombo() {
401 return statusCombo;
402 }
403
404 public JLabel getStatusLabel() {
405 return statusLabel;
406 }
407
408 public ExtendedComboBox<UnitDTO> getUnitsCombo() {
409 return unitsCombo;
410 }
411
412 public JLabel getUnitsLabel() {
413 return unitsLabel;
414 }
415
416
417
418
419
420 @Override
421 public void registerHelpId(DaliHelpBroker broker, Component component, String helpId) {
422 broker.installUI(component, helpId);
423 }
424
425 @Override
426 public void showHelp(String helpId) {
427 getBroker().showHelp(this, helpId);
428 }
429
430
431
432
433
434 protected JPanel get$JPanel0() {
435 return $JPanel0;
436 }
437
438 protected JPanel get$JPanel1() {
439 return $JPanel1;
440 }
441
442 protected JPanel get$JPanel2() {
443 return $JPanel2;
444 }
445
446 protected JPanel get$JPanel3() {
447 return $JPanel3;
448 }
449
450 protected JPanel get$JPanel4() {
451 return $JPanel4;
452 }
453
454 protected JPanel get$JPanel5() {
455 return $JPanel5;
456 }
457
458
459
460
461
462 protected void addChildrenToMenuPanel() {
463 if (!allComponentsCreated) {
464 return;
465 }
466 menuPanel.add(applyFilterUI);
467 menuPanel.add(selectionPanel);
468 menuPanel.add(selectionButtonsPanel);
469 }
470
471 protected void addChildrenToNamePanel() {
472 if (!allComponentsCreated) {
473 return;
474 }
475 namePanel.add(nameLabel, BorderLayout.PAGE_START);
476 namePanel.add(nameEditor, BorderLayout.CENTER);
477 }
478
479 protected void addChildrenToPmfmMenuUI() {
480 if (!allComponentsCreated) {
481 return;
482 }
483 add(menuPanel);
484 }
485
486 protected void addChildrenToSelectionButtonsPanel() {
487 if (!allComponentsCreated) {
488 return;
489 }
490 selectionButtonsPanel.add(clearButton);
491 selectionButtonsPanel.add(searchButton);
492 }
493
494 protected void addChildrenToSelectionPanel() {
495 if (!allComponentsCreated) {
496 return;
497 }
498 selectionPanel.add(namePanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
499 selectionPanel.add($JPanel0, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
500 selectionPanel.add($JPanel1, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
501 selectionPanel.add($JPanel2, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
502 selectionPanel.add($JPanel3, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
503 selectionPanel.add($JPanel4, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
504 selectionPanel.add($JPanel5, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0));
505 }
506
507 protected void createApplyFilterUI() {
508 $objectMap.put("applyFilterUI", applyFilterUI = new ApplyFilterUI(this));
509
510 applyFilterUI.setName("applyFilterUI");
511 }
512
513 protected void createBroker() {
514 $objectMap.put("broker", broker = new DaliHelpBroker("dali.home.help"));
515 }
516
517 protected void createClearButton() {
518 $objectMap.put("clearButton", clearButton = new JButton());
519
520 clearButton.setName("clearButton");
521 clearButton.setText(t("dali.action.search.clear.label"));
522 clearButton.setToolTipText(t("dali.action.search.clear.tip"));
523 clearButton.putClientProperty("applicationAction", ClearAction.class);
524 }
525
526 protected void createFractionsCombo() {
527 $objectMap.put("fractionsCombo", fractionsCombo = new ExtendedComboBox<FractionDTO>(this));
528
529 fractionsCombo.setName("fractionsCombo");
530 fractionsCombo.setFilterable(true);
531 fractionsCombo.setShowDecorator(false);
532 fractionsCombo.setProperty("fraction");
533 fractionsCombo.setShowReset(true);
534 }
535
536 protected void createFractionsLabel() {
537 $objectMap.put("fractionsLabel", fractionsLabel = new JLabel());
538
539 fractionsLabel.setName("fractionsLabel");
540 fractionsLabel.setText(t("dali.property.pmfm.fraction"));
541 }
542
543 protected PmfmMenuUIHandler createHandler() {
544 return new PmfmMenuUIHandler();
545 }
546
547 protected void createMatricesCombo() {
548 $objectMap.put("matricesCombo", matricesCombo = new ExtendedComboBox<MatrixDTO>(this));
549
550 matricesCombo.setName("matricesCombo");
551 matricesCombo.setFilterable(true);
552 matricesCombo.setShowDecorator(false);
553 matricesCombo.setProperty("matrix");
554 matricesCombo.setShowReset(true);
555 }
556
557 protected void createMatricesLabel() {
558 $objectMap.put("matricesLabel", matricesLabel = new JLabel());
559
560 matricesLabel.setName("matricesLabel");
561 matricesLabel.setText(t("dali.property.pmfm.matrix"));
562 }
563
564 protected void createMenuPanel() {
565 $objectMap.put("menuPanel", menuPanel = new JPanel());
566
567 menuPanel.setName("menuPanel");
568 menuPanel.setLayout(new BoxLayout(menuPanel, BoxLayout.PAGE_AXIS));
569 }
570
571 protected void createMethodsCombo() {
572 $objectMap.put("methodsCombo", methodsCombo = new ExtendedComboBox<MethodDTO>(this));
573
574 methodsCombo.setName("methodsCombo");
575 methodsCombo.setFilterable(true);
576 methodsCombo.setShowDecorator(false);
577 methodsCombo.setProperty("method");
578 methodsCombo.setShowReset(true);
579 }
580
581 protected void createMethodsLabel() {
582 $objectMap.put("methodsLabel", methodsLabel = new JLabel());
583
584 methodsLabel.setName("methodsLabel");
585 methodsLabel.setText(t("dali.property.pmfm.method"));
586 }
587
588 protected void createModel() {
589 $objectMap.put("model", model = getContextValue(PmfmMenuUIModel.class));
590 }
591
592 protected void createNameEditor() {
593 $objectMap.put("nameEditor", nameEditor = new JTextField());
594
595 nameEditor.setName("nameEditor");
596 nameEditor.setColumns(15);
597 nameEditor.addKeyListener(JAXXUtil.getEventListener(KeyListener.class, "keyReleased", this, "doKeyReleased__on__nameEditor"));
598 }
599
600 protected void createNameLabel() {
601 $objectMap.put("nameLabel", nameLabel = new JLabel());
602
603 nameLabel.setName("nameLabel");
604 nameLabel.setText(t("dali.property.name"));
605 }
606
607 protected void createNamePanel() {
608 $objectMap.put("namePanel", namePanel = new JPanel());
609
610 namePanel.setName("namePanel");
611 namePanel.setLayout(new BorderLayout());
612 }
613
614 protected void createParametersCombo() {
615 $objectMap.put("parametersCombo", parametersCombo = new ExtendedComboBox<ParameterDTO>(this));
616
617 parametersCombo.setName("parametersCombo");
618 parametersCombo.setFilterable(true);
619 parametersCombo.setShowDecorator(false);
620 parametersCombo.setProperty("parameter");
621 parametersCombo.setShowReset(true);
622 }
623
624 protected void createParametersLabel() {
625 $objectMap.put("parametersLabel", parametersLabel = new JLabel());
626
627 parametersLabel.setName("parametersLabel");
628 parametersLabel.setText(t("dali.property.pmfm.parameter"));
629 }
630
631 protected void createSearchButton() {
632 $objectMap.put("searchButton", searchButton = new JButton());
633
634 searchButton.setName("searchButton");
635 searchButton.setText(t("dali.action.search.label"));
636 searchButton.setToolTipText(t("dali.action.search.tip"));
637 searchButton.putClientProperty("applicationAction", SearchAction.class);
638 }
639
640 protected void createSelectionButtonsPanel() {
641 $objectMap.put("selectionButtonsPanel", selectionButtonsPanel = new JPanel());
642
643 selectionButtonsPanel.setName("selectionButtonsPanel");
644 selectionButtonsPanel.setLayout(new GridLayout(1,0));
645 }
646
647 protected void createSelectionPanel() {
648 $objectMap.put("selectionPanel", selectionPanel = new Table());
649
650 selectionPanel.setName("selectionPanel");
651 }
652
653 protected void createStatusCombo() {
654 $objectMap.put("statusCombo", statusCombo = new ExtendedComboBox<StatusDTO>(this));
655
656 statusCombo.setName("statusCombo");
657 statusCombo.setFilterable(true);
658 statusCombo.setShowDecorator(false);
659 statusCombo.setProperty("status");
660 statusCombo.setShowReset(true);
661 }
662
663 protected void createStatusLabel() {
664 $objectMap.put("statusLabel", statusLabel = new JLabel());
665
666 statusLabel.setName("statusLabel");
667 statusLabel.setText(t("dali.property.status"));
668 }
669
670 protected void createUnitsCombo() {
671 $objectMap.put("unitsCombo", unitsCombo = new ExtendedComboBox<UnitDTO>(this));
672
673 unitsCombo.setName("unitsCombo");
674 unitsCombo.setFilterable(true);
675 unitsCombo.setShowDecorator(false);
676 unitsCombo.setProperty("unit");
677 unitsCombo.setShowReset(true);
678 }
679
680 protected void createUnitsLabel() {
681 $objectMap.put("unitsLabel", unitsLabel = new JLabel());
682
683 unitsLabel.setName("unitsLabel");
684 unitsLabel.setText(t("dali.property.pmfm.unit"));
685 }
686
687
688
689
690
691 private void $completeSetup() {
692 allComponentsCreated = true;
693 if (log.isDebugEnabled()) {
694 log.debug(this);
695 }
696 addChildrenToPmfmMenuUI();
697 addChildrenToMenuPanel();
698 addChildrenToSelectionPanel();
699 addChildrenToNamePanel();
700
701 $JPanel0.add(parametersLabel, BorderLayout.PAGE_START);
702 $JPanel0.add(parametersCombo, BorderLayout.CENTER);
703
704 $JPanel1.add(matricesLabel, BorderLayout.PAGE_START);
705 $JPanel1.add(matricesCombo, BorderLayout.CENTER);
706
707 $JPanel2.add(fractionsLabel, BorderLayout.PAGE_START);
708 $JPanel2.add(fractionsCombo, BorderLayout.CENTER);
709
710 $JPanel3.add(methodsLabel, BorderLayout.PAGE_START);
711 $JPanel3.add(methodsCombo, BorderLayout.CENTER);
712
713 $JPanel4.add(unitsLabel, BorderLayout.PAGE_START);
714 $JPanel4.add(unitsCombo, BorderLayout.CENTER);
715
716 $JPanel5.add(statusLabel, BorderLayout.PAGE_START);
717 $JPanel5.add(statusCombo, BorderLayout.CENTER);
718 addChildrenToSelectionButtonsPanel();
719
720
721 JAXXUtil.applyDataBinding(this, $bindings.keySet());
722
723
724 parametersCombo.setBeanType(ParameterDTO.class);
725 matricesCombo.setBeanType(MatrixDTO.class);
726 fractionsCombo.setBeanType(FractionDTO.class);
727 methodsCombo.setBeanType(MethodDTO.class);
728 unitsCombo.setBeanType(UnitDTO.class);
729 statusCombo.setBeanType(StatusDTO.class);
730 clearButton.setAlignmentX(Component.CENTER_ALIGNMENT);
731 searchButton.setAlignmentX(Component.CENTER_ALIGNMENT);
732 selectionPanel.setBorder(BorderFactory.createTitledBorder(t("dali.config.menu.title")));
733 nameLabel.setLabelFor(nameEditor);
734 parametersLabel.setLabelFor(parametersCombo);
735 parametersCombo.setBean(model);
736 matricesLabel.setLabelFor(matricesCombo);
737 matricesCombo.setBean(model);
738 fractionsLabel.setLabelFor(fractionsCombo);
739 fractionsCombo.setBean(model);
740 methodsLabel.setLabelFor(methodsCombo);
741 methodsCombo.setBean(model);
742 unitsLabel.setLabelFor(unitsCombo);
743 unitsCombo.setBean(model);
744 statusLabel.setLabelFor(statusCombo);
745 statusCombo.setBean(model);
746 clearButton.setIcon(SwingUtil.createActionIcon("reset"));
747 searchButton.setIcon(SwingUtil.createActionIcon("find"));
748 }
749
750 private void $initialize() {
751 if (allComponentsCreated) {
752 return;
753 }
754 if (log.isDebugEnabled()) {
755 log.debug(this);
756 }
757 handler.beforeInit(this);
758 $objectMap.put("pmfmMenuUI", pmfmMenuUI);
759 createModel();
760 createBroker();
761 createMenuPanel();
762 createApplyFilterUI();
763 createSelectionPanel();
764 createNamePanel();
765 createNameLabel();
766 createNameEditor();
767
768 $objectMap.put("$JPanel0", $JPanel0 = new JPanel());
769
770 $JPanel0.setName("$JPanel0");
771 $JPanel0.setLayout(new BorderLayout());
772 createParametersLabel();
773 createParametersCombo();
774
775 $objectMap.put("$JPanel1", $JPanel1 = new JPanel());
776
777 $JPanel1.setName("$JPanel1");
778 $JPanel1.setLayout(new BorderLayout());
779 createMatricesLabel();
780 createMatricesCombo();
781
782 $objectMap.put("$JPanel2", $JPanel2 = new JPanel());
783
784 $JPanel2.setName("$JPanel2");
785 $JPanel2.setLayout(new BorderLayout());
786 createFractionsLabel();
787 createFractionsCombo();
788
789 $objectMap.put("$JPanel3", $JPanel3 = new JPanel());
790
791 $JPanel3.setName("$JPanel3");
792 $JPanel3.setLayout(new BorderLayout());
793 createMethodsLabel();
794 createMethodsCombo();
795
796 $objectMap.put("$JPanel4", $JPanel4 = new JPanel());
797
798 $JPanel4.setName("$JPanel4");
799 $JPanel4.setLayout(new BorderLayout());
800 createUnitsLabel();
801 createUnitsCombo();
802
803 $objectMap.put("$JPanel5", $JPanel5 = new JPanel());
804
805 $JPanel5.setName("$JPanel5");
806 $JPanel5.setLayout(new BorderLayout());
807 createStatusLabel();
808 createStatusCombo();
809 createSelectionButtonsPanel();
810 createClearButton();
811 createSearchButton();
812
813 setName("pmfmMenuUI");
814
815
816 $registerDefaultBindings();
817 $completeSetup();
818 handler.afterInit(this);
819 }
820
821 private void $registerDefaultBindings() {
822
823 registerDataBinding(new DefaultJAXXBinding(this, BINDING_NAME_EDITOR_TEXT, true) {
824
825 @Override
826 public void applyDataBinding() {
827 if (model != null) {
828 model.addPropertyChangeListener("name", this);
829 }
830 }
831
832 @Override
833 public void processDataBinding() {
834 if (model != null) {
835 SwingUtil.setText(nameEditor, model.getName());
836 }
837 }
838
839 @Override
840 public void removeDataBinding() {
841 if (model != null) {
842 model.removePropertyChangeListener("name", this);
843 }
844 }
845 });
846 registerDataBinding(new DefaultJAXXBinding(this, BINDING_PARAMETERS_COMBO_SELECTED_ITEM, true) {
847
848 @Override
849 public void applyDataBinding() {
850 if (model != null) {
851 model.addPropertyChangeListener("parameter", this);
852 }
853 }
854
855 @Override
856 public void processDataBinding() {
857 if (model != null) {
858 parametersCombo.setSelectedItem(model.getParameter());
859 }
860 }
861
862 @Override
863 public void removeDataBinding() {
864 if (model != null) {
865 model.removePropertyChangeListener("parameter", this);
866 }
867 }
868 });
869 registerDataBinding(new DefaultJAXXBinding(this, BINDING_MATRICES_COMBO_SELECTED_ITEM, true) {
870
871 @Override
872 public void applyDataBinding() {
873 if (model != null) {
874 model.addPropertyChangeListener("matrix", this);
875 }
876 }
877
878 @Override
879 public void processDataBinding() {
880 if (model != null) {
881 matricesCombo.setSelectedItem(model.getMatrix());
882 }
883 }
884
885 @Override
886 public void removeDataBinding() {
887 if (model != null) {
888 model.removePropertyChangeListener("matrix", this);
889 }
890 }
891 });
892 registerDataBinding(new DefaultJAXXBinding(this, BINDING_FRACTIONS_COMBO_SELECTED_ITEM, true) {
893
894 @Override
895 public void applyDataBinding() {
896 if (model != null) {
897 model.addPropertyChangeListener("fraction", this);
898 }
899 }
900
901 @Override
902 public void processDataBinding() {
903 if (model != null) {
904 fractionsCombo.setSelectedItem(model.getFraction());
905 }
906 }
907
908 @Override
909 public void removeDataBinding() {
910 if (model != null) {
911 model.removePropertyChangeListener("fraction", this);
912 }
913 }
914 });
915 registerDataBinding(new DefaultJAXXBinding(this, BINDING_METHODS_COMBO_SELECTED_ITEM, true) {
916
917 @Override
918 public void applyDataBinding() {
919 if (model != null) {
920 model.addPropertyChangeListener("method", this);
921 }
922 }
923
924 @Override
925 public void processDataBinding() {
926 if (model != null) {
927 methodsCombo.setSelectedItem(model.getMethod());
928 }
929 }
930
931 @Override
932 public void removeDataBinding() {
933 if (model != null) {
934 model.removePropertyChangeListener("method", this);
935 }
936 }
937 });
938 registerDataBinding(new DefaultJAXXBinding(this, BINDING_UNITS_COMBO_SELECTED_ITEM, true) {
939
940 @Override
941 public void applyDataBinding() {
942 if (model != null) {
943 model.addPropertyChangeListener("unit", this);
944 }
945 }
946
947 @Override
948 public void processDataBinding() {
949 if (model != null) {
950 unitsCombo.setSelectedItem(model.getUnit());
951 }
952 }
953
954 @Override
955 public void removeDataBinding() {
956 if (model != null) {
957 model.removePropertyChangeListener("unit", this);
958 }
959 }
960 });
961 registerDataBinding(new DefaultJAXXBinding(this, BINDING_STATUS_COMBO_SELECTED_ITEM, true) {
962
963 @Override
964 public void applyDataBinding() {
965 if (model != null) {
966 model.addPropertyChangeListener("status", this);
967 }
968 }
969
970 @Override
971 public void processDataBinding() {
972 if (model != null) {
973 statusCombo.setSelectedItem(model.getStatus());
974 }
975 }
976
977 @Override
978 public void removeDataBinding() {
979 if (model != null) {
980 model.removePropertyChangeListener("status", this);
981 }
982 }
983 });
984 }
985
986 }