View Javadoc

1   package at.ac.tuwien.ifs.bpse.basic.gui;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   
6   import org.apache.commons.logging.Log;
7   import org.apache.commons.logging.LogFactory;
8   
9   import at.ac.tuwien.ifs.bpse.basic.export_import.Export;
10  
11  /**
12   * This class contains the Export-Classes, used by the "Export"-Menu. New Exporters can be
13   * added by adding them to the Bean-Config file ({@value at.ac.tuwien.ifs.bpse.basic.helper.Constants#SPRINGBEANS})
14   * 
15   * @author The SE-Team
16   * @version 1.2
17   * @since 1.2
18   * @see Export
19   * 
20   */
21  public class ExportMenuModel {
22  
23  	/**
24  	 * Retrieves the logger for this class.
25  	 */
26  	private static Log log = LogFactory.getLog(ExportMenuModel.class);
27  
28  	/**
29  	 * List of available exportfilters.
30  	 */
31  	private List<Export> exportFilter;
32  
33  	/**
34  	 * Initialized by the Springframework after setter injection
35  	 */
36  	private Export selectedItem;
37  
38  	public ExportMenuModel() {
39  		super();
40  		exportFilter = new ArrayList<Export>();
41  	}
42  
43  	/**
44  	 * Initialise Method called by Springframework after setter injection
45  	 */
46  	public void init() {
47  
48  	}
49  
50  	public List<Export> getExportFilter() {
51  		return exportFilter;
52  	}
53  
54  	public void setExportFilter(List<Export> exportFilter) {
55  		StringBuffer regfilters = new StringBuffer("" + exportFilter.size()
56  				+ " Export Filters are registered (");
57  		for (Export ex : exportFilter) {
58  			regfilters.append(ex.toString() + ", ");
59  		}
60  		regfilters.append(")");
61  		log.info(regfilters.toString());
62  		this.exportFilter = exportFilter;
63  	}
64  
65  	public Export getSelectedItem() {
66  		return selectedItem;
67  	}
68  
69  	/**
70  	 * Searches for the Export-Class with the provided name.
71  	 * @param object the name of the Export-Class as String.
72  	 */
73  	public void setSelectedItem(Object object) {
74  		for (Export export : exportFilter) {
75  			if (export.toString().equals((String) object)) {
76  				log.info("Export with name " + (String) object + " found.");
77  				selectedItem = export;
78  			}
79  		}
80  	}
81  
82  	public Object getElementAt(int index) {
83  		return exportFilter.get(index);
84  	}
85  
86  	public int getSize() {
87  		return exportFilter.size();
88  	}
89  
90  }