Last change
on this file since 2512 was 2512, checked in by stoecker, 14 years ago |
i18n updated, fixed files to reduce problems when applying patches, fix #4017
|
File size:
1.4 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.util;
|
---|
3 |
|
---|
4 | import java.util.ArrayList;
|
---|
5 | import java.util.LinkedList;
|
---|
6 | import java.util.List;
|
---|
7 |
|
---|
8 | import javax.swing.event.CellEditorListener;
|
---|
9 | import javax.swing.event.ChangeEvent;
|
---|
10 |
|
---|
11 | public class TableCellEditorSupport {
|
---|
12 | private Object editor;
|
---|
13 | private LinkedList<CellEditorListener> listeners;
|
---|
14 |
|
---|
15 | public TableCellEditorSupport(Object editor) {
|
---|
16 | this.editor = editor;
|
---|
17 | listeners = new LinkedList<CellEditorListener>();
|
---|
18 | }
|
---|
19 |
|
---|
20 | protected List<CellEditorListener> getListeners() {
|
---|
21 | synchronized (this) {
|
---|
22 | return new ArrayList<CellEditorListener>(listeners);
|
---|
23 | }
|
---|
24 | }
|
---|
25 |
|
---|
26 | public void addCellEditorListener(CellEditorListener l) {
|
---|
27 | synchronized (this) {
|
---|
28 | if (l != null && ! listeners.contains(l)) {
|
---|
29 | listeners.add(l);
|
---|
30 | }
|
---|
31 | }
|
---|
32 | }
|
---|
33 | public void removeCellEditorListener(CellEditorListener l) {
|
---|
34 | synchronized (this) {
|
---|
35 | if (l != null &&listeners.contains(l)) {
|
---|
36 | listeners.remove(l);
|
---|
37 | }
|
---|
38 | }
|
---|
39 | }
|
---|
40 |
|
---|
41 | public void fireEditingCanceled() {
|
---|
42 | for (CellEditorListener listener: getListeners()) {
|
---|
43 | listener.editingCanceled(new ChangeEvent(editor));
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|
47 | public void fireEditingStopped() {
|
---|
48 | for (CellEditorListener listener: getListeners()) {
|
---|
49 | listener.editingStopped(new ChangeEvent(editor));
|
---|
50 | }
|
---|
51 | }
|
---|
52 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.