package mildo.wiwo.components;

import mildo.wiwo.Session;
import mildo.wiwo.action.EditAction;
import mildo.wiwo.components.descriptors.IActionDescriptor;
import mildo.wiwo.components.descriptors.ObjectListTableDescriptor;
import mildo.wiwo.data.WiwoUser;

import com.webobjects.appserver.*;
import com.webobjects.foundation.NSArray;

// Generated by the WOLips Templateengine Plug-in at Apr 19, 2009 9:55:17 AM
public class UsersListTableComp 
	extends mildo.wiwo.components.BaseComp 
{
    
	public UsersListTableComp(WOContext context) {
        super(context);
    }
	
	public NSArray getUsers() {
		return WiwoUser.fetchAllWiwoUsers(session().defaultEditingContext());
	}
	
	private ObjectListTableDescriptor tableDescriptor;
	
	public void setTableDescriptor(ObjectListTableDescriptor aValue) {
		tableDescriptor = aValue;
	}
	
	public ObjectListTableDescriptor getTableDescriptor() {
		Session theSession = (Session) session(); 
		EditAction theAction = new EditAction(theSession, this);
		if (tableDescriptor == null) {
			tableDescriptor = new ObjectListTableDescriptor(TABLE_ATTRIBUTES_STRINGS, TABLE_HEADER_STRINGS, 
					new IActionDescriptor[]{theAction, theAction});
		}	
		return tableDescriptor;
	}
	
	public static final String[] TABLE_HEADER_STRINGS = {"Login", "User role"};
	public static final String[] TABLE_ATTRIBUTES_STRINGS = {"login", "userRole"};
	
}