// Path: mvc-with-java-swing/src/main/java/com/link_intersystems/blog/mvc/data/Person.java
// public class Person {
// 
// 	private String firstname;
// 
// 	private String lastname;
// 
// 	private Address address;
// 
// 	public String getFirstname() {
// 		return firstname;
// 	}
// 
// 	public void setFirstname(String firstname) {
// 		this.firstname = firstname;
// 	}
// 
// 	public String getLastname() {
// 		return lastname;
// 	}
// 
// 	public void setLastname(String lastname) {
// 		this.lastname = lastname;
// 	}
// 
// 	public Address getAddress() {
// 		return address;
// 	}
// 
// 	public void setAddress(Address address) {
// 		this.address = address;
// 	}
// 
// }
// 
// Path: mvc-with-java-swing/src/main/java/com/link_intersystems/blog/mvc/model/list/ListAdapterListModel.java
// public class ListAdapterListModel<E> extends AbstractListModel<E> {
// 
// 	/**
// 	 *
// 	 */
// 	private static final long serialVersionUID = -3348705533107354297L;
// 
// 	private List<E> list = new ArrayList<E>();
// 
// 	public void setList(List<E> list) {
// 		this.list.clear();
// 		this.list.addAll(list);
// 		fireListDataChanged();
// 	}
// 
// 	public void clear() {
// 		this.list.clear();
// 		fireListDataChanged();
// 	}
// 
// 	private void fireListDataChanged() {
// 		fireContentsChanged(this, 0, Math.max(list.size() - 1, 0));
// 	}
// 
// 	public void addAll(List<E> elements) {
// 		if (this.list.addAll(elements)) {
// 			fireIntervalAdded(elements.size());
// 		}
// 	}
// 
// 	protected void fireIntervalAdded(int elementCOunt) {
// 		int index0 = list.size() - elementCOunt;
// 		fireIntervalAdded(this, Math.max(0, index0),
// 				Math.max(0, list.size() - 1));
// 	}
// 
// 	/**
// 	 * Returns the list that this {@link ListAdapterListModel} is backed by.
// 	 *
// 	 * @return
// 	 */
// 	public List<E> getList() {
// 		return Collections.unmodifiableList(list);
// 	}
// 
// 	public int getSize() {
// 		return list.size();
// 	}
// 
// 	public E getElementAt(int index) {
// 		E elementAt = list.get(index);
// 		return elementAt;
// 	}
// 
// 	public int indexOf(E element) {
// 		return list.indexOf(element);
// 	}
// 
// }


import java.awt.event.ActionEvent;
import java.util.Collection;
import java.util.HashSet;
import javax.swing.AbstractAction;
import javax.swing.BoundedRangeModel;
import javax.swing.DefaultBoundedRangeModel;
import javax.swing.KeyStroke;
import com.link_intersystems.blog.mvc.data.Person;
import com.link_intersystems.blog.mvc.model.list.ListAdapterListModel;
package com.link_intersystems.blog.mvc.controller;




/**
 * 
 * @author rene.link
 *
 */
public class LoadPersonsAction extends AbstractAction {

	private static final long serialVersionUID = 2636985714796751517L;
	
	private ListAdapterListModel<Person> personListModel;
	private Collection<SwingWorkerPropertyChangeListener> swingWorkerPropertyChangeListeners = new HashSet<SwingWorkerPropertyChangeListener>();
	private BoundedRangeModel loadPersonsSpeedModel = new DefaultBoundedRangeModel();

	public LoadPersonsAction(ListAdapterListModel<Person> personListModel) {
		this.personListModel = personListModel;

		putValue(NAME, "Load");
		putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('L'));
	}

	public void actionPerformed(ActionEvent e) {
		LoadPersonsWorker loadPersonsWorker = new LoadPersonsWorker(personListModel);
		loadPersonsWorker.setLoadSpeedModel(loadPersonsSpeedModel);
		for (SwingWorkerPropertyChangeListener swingWorkerPropertyChangeListener : swingWorkerPropertyChangeListeners) {
			swingWorkerPropertyChangeListener.attachPropertyChangeListener(loadPersonsWorker);
		}
		loadPersonsWorker.execute();
	}

	public void addSwingWorkerPropertyChangeListener(
// Path: mvc-with-java-swing/src/main/java/com/link_intersystems/blog/mvc/data/Person.java
// public class Person {
// 
// 	private String firstname;
// 
// 	private String lastname;
// 
// 	private Address address;
// 
// 	public String getFirstname() {
// 		return firstname;
// 	}
// 
// 	public void setFirstname(String firstname) {
// 		this.firstname = firstname;
// 	}
// 
// 	public String getLastname() {
// 		return lastname;
// 	}
// 
// 	public void setLastname(String lastname) {
// 		this.lastname = lastname;
// 	}
// 
// 	public Address getAddress() {
// 		return address;
// 	}
// 
// 	public void setAddress(Address address) {
// 		this.address = address;
// 	}
// 
// }
// 
// Path: mvc-with-java-swing/src/main/java/com/link_intersystems/blog/mvc/model/list/ListAdapterListModel.java
// public class ListAdapterListModel<E> extends AbstractListModel<E> {
// 
// 	/**
// 	 *
// 	 */
// 	private static final long serialVersionUID = -3348705533107354297L;
// 
// 	private List<E> list = new ArrayList<E>();
// 
// 	public void setList(List<E> list) {
// 		this.list.clear();
// 		this.list.addAll(list);
// 		fireListDataChanged();
// 	}
// 
// 	public void clear() {
// 		this.list.clear();
// 		fireListDataChanged();
// 	}
// 
// 	private void fireListDataChanged() {
// 		fireContentsChanged(this, 0, Math.max(list.size() - 1, 0));
// 	}
// 
// 	public void addAll(List<E> elements) {
// 		if (this.list.addAll(elements)) {
// 			fireIntervalAdded(elements.size());
// 		}
// 	}
// 
// 	protected void fireIntervalAdded(int elementCOunt) {
// 		int index0 = list.size() - elementCOunt;
// 		fireIntervalAdded(this, Math.max(0, index0),
// 				Math.max(0, list.size() - 1));
// 	}
// 
// 	/**
// 	 * Returns the list that this {@link ListAdapterListModel} is backed by.
// 	 *
// 	 * @return
// 	 */
// 	public List<E> getList() {
// 		return Collections.unmodifiableList(list);
// 	}
// 
// 	public int getSize() {
// 		return list.size();
// 	}
// 
// 	public E getElementAt(int index) {
// 		E elementAt = list.get(index);
// 		return elementAt;
// 	}
// 
// 	public int indexOf(E element) {
// 		return list.indexOf(element);
// 	}
// 
// }


// Path: mvc-with-java-swing/src/main/java/com/link_intersystems/blog/mvc/controller/LoadPersonsAction.java
import java.awt.event.ActionEvent;
import java.util.Collection;
import java.util.HashSet;
import javax.swing.AbstractAction;
import javax.swing.BoundedRangeModel;
import javax.swing.DefaultBoundedRangeModel;
import javax.swing.KeyStroke;
import com.link_intersystems.blog.mvc.data.Person;
import com.link_intersystems.blog.mvc.model.list.ListAdapterListModel;

package com.link_intersystems.blog.mvc.controller;




/**
 * 
 * @author rene.link
 *
 */
public class LoadPersonsAction extends AbstractAction {

	private static final long serialVersionUID = 2636985714796751517L;
	
	private ListAdapterListModel<Person> personListModel;
	private Collection<SwingWorkerPropertyChangeListener> swingWorkerPropertyChangeListeners = new HashSet<SwingWorkerPropertyChangeListener>();
	private BoundedRangeModel loadPersonsSpeedModel = new DefaultBoundedRangeModel();

	public LoadPersonsAction(ListAdapterListModel<Person> personListModel) {
		this.personListModel = personListModel;

		putValue(NAME, "Load");
		putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('L'));
	}

	public void actionPerformed(ActionEvent e) {
		LoadPersonsWorker loadPersonsWorker = new LoadPersonsWorker(personListModel);
		loadPersonsWorker.setLoadSpeedModel(loadPersonsSpeedModel);
		for (SwingWorkerPropertyChangeListener swingWorkerPropertyChangeListener : swingWorkerPropertyChangeListeners) {
			swingWorkerPropertyChangeListener.attachPropertyChangeListener(loadPersonsWorker);
		}
		loadPersonsWorker.execute();
	}

	public void addSwingWorkerPropertyChangeListener(
	        SwingWorkerPropertyChangeListener swingWorkerPropertyChangeListener) {