summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/changemonitor/ListEditorWindow.java
blob: ebefd32611a748d5c2b62d27ec653eba2db87261 (plain) (blame)
1
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
28
29
30
31
32
33
34
35
36
37
38
39
40
package org.openslx.dozmod.gui.changemonitor;

import java.util.List;

import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

/**
 * For wrapping editors that contain controls to edit a list of some kind.
 * When implementing inside a pop-up window, it should be sufficient to
 * trigger the change event only once, when the user cancels or saves the
 * changes, since the main window that's interested in the changes will
 * be covered anyways during editing. 
 */
public interface ListEditorWindow<T> {
	
	public List<T> getState();
	
	public void addChangeListener(ChangeListener l);

}

class ListEditorWindowWrapper<T> extends AbstractControlWrapper<List<T>> {
	private final ListEditorWindow<T> component;

	public ListEditorWindowWrapper(DialogChangeMonitor dcm, ListEditorWindow<T> comp) {
		super(dcm, null);
		this.component = comp;

		comp.addChangeListener(new ChangeListener() {
			public void stateChanged(ChangeEvent e) {
				contentChanged();
			}
		});
	}
	
	List<T> getCurrentValue() {
		return this.component.getState();
	}
}