/*
 * JaamSim Discrete Event Simulation
 * Copyright (C) 2010-2011 Ausenco Engineering Canada Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
package com.sandwell.JavaSimulation;

import java.util.ArrayList;

public class EntityListInput<T extends Entity> extends ListInput<ArrayList<T>> {
	private Class<T> entClass;
	private boolean unique; // flag to determine if list must be unique or not
	private boolean even;  // flag to determine if there must be an even number of entries

	public EntityListInput(Class<T> aClass, String key, String cat, ArrayList<T> def) {
		super(key, cat, def);
		entClass = aClass;
		unique = true;
		even = false;
	}

	public void parse(StringVector input)
	throws InputErrorException {
		Input.assertCountRange(input, minCount, maxCount);
		if( even )
			Input.assertCountEven(input);

		value = Input.parseEntityList(input, entClass, unique);
		this.updateEditingFlags();
	}

	public void setUnique(boolean unique) {
		this.unique = unique;
	}
	public void setEven(boolean bool) {
		this.even = bool;
	}
}

@@ -665,16 +665,46 @@
 rayList;
+%0Aimport java.util.Collections;
 %0A%0Apublic
@@ -1525,11 +1525,302 @@
 bool;%0A%09%7D
+%0A%0A%09public ArrayList%3CString%3E getValidOptions() %7B%0A%09%09ArrayList%3CString%3E list = new ArrayList%3CString%3E();%0A%09%09for(T each: Simulation.getClonesOf(entClass) ) %7B%0A%09%09%09if(each.testFlag(Entity.FLAG_GENERATED))%0A%09%09%09%09continue;%0A%0A%09%09%09list.add(each.getInputName());%0A%09%09%7D%0A%09%09Collections.sort(list);%0A%09%09return list;%0A%09%7D
 %0A%7D%0A

add getValidOptions to EntityListInput so it uses ListEditor from Input Editor