package mildo.wiwo.components;

import mildo.wiwo.Session;
import mildo.wiwo.search.SearchHelper;
import mildo.wiwo.search.SimpleSearch;
import mildo.wiwo.search.dao.QuickSearch;

import and.wo.eof.SortOrderingKeyHelper;

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

// Generated by the WOLips Templateengine Plug-in at Apr 15, 2009 6:53:31 PM
public class LeftColComp 
	extends mildo.wiwo.components.BaseComp {
	
    public LeftColComp(WOContext context) {
        super(context);
    }
    
    private QuickSearch quickSearch;
    
    public void setQuickSearch(QuickSearch aValue) {
    	quickSearch = aValue;
    }
    
    public QuickSearch getQuickSearch() {
    	if (quickSearch == null) {
    		quickSearch = new QuickSearch();
    	}
    	return quickSearch;
    }
    
    public WOComponent quickSearchAction() {
    	System.out.println("Searching for : " + quickSearch.getName());
    	SearchHelper theHelper = ((Session)session()).getSearchHelper();
    	quickSearch.setSorts(SortOrderingKeyHelper.sortOrderingsFor("versionTag"));
    	NSArray theResults = theHelper.quickSearch(quickSearch);
    	SearchResultComp theResultPage = (SearchResultComp) pageWithName(SearchResultComp.class.getName());
    	theResultPage.setResults(theResults);
    	return theResultPage;
    }
    
    public boolean showMenu() {
    	return ((Session)session()).isEditorLoggedIn() || ((Session)session()).isAdminLoggedIn() || ((Session)session()).isDistributionEnabled();
    }
    
}