summaryrefslogblamecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/changemonitor/GenericControlWindow.java
blob: 2a9637b747fd701f96e60bff570c36240a15e323 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12

                                             









                                                                          
                                          
        
                            




                                                        

                                                                  
 
                                                                                             









                                                                 
                             


                                                 
package org.openslx.dozmod.gui.changemonitor;

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 GenericControlWindow<T> {
	
	public T getState();
	
	public void addChangeListener(ChangeListener l);

}

class GenericControlWrapper<T> extends AbstractControlWrapper<T> {
	private final GenericControlWindow<T> component;

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

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