1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.xulux.guilayer.swing.listeners;
17
18 import javax.swing.JTable;
19
20 import org.xulux.api.gui.IWidget;
21 import org.xulux.api.gui.XuluxEvent;
22 import org.xulux.gui.XuluxListener;
23 import org.xulux.gui.events.XuluxValueChangedEvent;
24 import org.xulux.gui.utils.XuluxEventQueue;
25 import org.xulux.guilayer.swing.widgets.Table;
26
27
28
29
30
31
32 public class ValueChangedListener extends XuluxListener {
33
34
35
36
37 private boolean isProcessing = false;
38
39
40
41 public ValueChangedListener() {
42 super();
43 }
44
45
46
47
48 public ValueChangedListener(IWidget widget) {
49 super(widget);
50 }
51
52
53
54
55 public void processEvent(XuluxEvent event) {
56 if (isProcessing) {
57 isProcessing = false;
58 return;
59 }
60 isProcessing = true;
61 if (event instanceof XuluxValueChangedEvent) {
62
63 XuluxEventQueue.getInstance().holdEvents(false);
64 Object value = ((XuluxValueChangedEvent) event).getValue();
65 JTable table = (JTable) ((Table) widget).getJTable();
66 if (table.isEditing()) {
67
68 table.getModel().setValueAt(value, table.getEditingRow(), table.getEditingColumn());
69 }
70
71 }
72 isProcessing = false;
73 }
74
75 }