package com.approximatrix.draco.main.ui;

import java.util.ArrayList;
import java.util.List;

import com.approximatrix.draco.application.ChildFrame;
import com.approximatrix.draco.datamodel.StatTableModel;

/** Test class that isolates some critical MainWindow behavior for
 * testing interactions with other classes.
 * 
 * @author jarmstrong
 */
public class SyntheticMainWindow implements WorksheetHandler {

	public ArrayList<ChildFrame> frames = null;
	public StatTableModel model = null;
	
	public SyntheticMainWindow() {
		frames = new ArrayList<ChildFrame>();
		model = new StatTableModel();
	}

	public Object[] getWindowsByClass(Class value) {
		ArrayList<Object> ret = new ArrayList<Object>();
		for(ChildFrame frame : frames) {
			if(value.isAssignableFrom(frame.getClass()))
				ret.add(frame);
		}
		return ret.toArray();
	}

	public <T> List<T> getWindows(Class<T> c) {
		ArrayList<T> ret = new ArrayList<T>();
		for(ChildFrame frame : frames) {
			if(c.isAssignableFrom(frame.getClass()))
				ret.add(c.cast(frame));
		}
		return ret;
	}

	public ChildFrame openWindow(ChildFrame new_window) {
		frames.add(new_window);
		return new_window;
	}

	public void setUpdatableTable(boolean value) {

	}

	public void setVisibleDesktop(boolean value) {

	}
	
	public StatTableModel getWindowTableModel() {
		return model;
	}

	public void setWindowTableModel(StatTableModel model, String filename) {
		// TODO Auto-generated method stub
		
	}

	public void setWindowTableModel(StatTableModel model) {
		// TODO Auto-generated method stub
		
	}

}
