package seedu.jimi.logic.commands;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

import seedu.jimi.model.ModelManager;

/**
 * Shows certain sections of the task panel to the user.
 * @author zexuan
 *
 */
public class ShowCommand extends Command {

    public static final String COMMAND_WORD = "show";
    
    public static final List<String> VALID_KEYWORDS = Arrays.asList(
            "floating", 
            "incomplete", 
            "complete",
            "today", 
            "tomorrow", 
            "monday", 
            "tuesday", 
            "wednesday", 
            "thursday", 
            "friday", 
            "saturday", 
            "sunday" 
    );
    
    public static final String MESSAGE_USAGE = 
            COMMAND_WORD + ": Shows certain sections of the task panel in the agenda panel. \n"
            + "Parameters: NAME_OF_SECTION_TO_DISPLAY\n" 
            + "Example: " + COMMAND_WORD + " floating tasks\n"
            + "> Valid Keywords: Floating, Complete, Incompletes, Today, Tomorrow, {day of week displayed}";

    public static final String MESSAGE_SUCCESS = "Displayed tasks and events.";
    
    private final String sectionToShow; //section name from user input
    
    public ShowCommand() {
        this.sectionToShow = "";
    }
    
    public ShowCommand(String args) {
        this.sectionToShow = args;
    }
    
    /**
     * Updates the agenda lists with new relevant predicates to update lists show to user.
     */
    @Override
    public CommandResult execute() {
        ((ModelManager) model).showTaskPanelSection(sectionToShow);
        
        model.updateFilteredAgendaTaskList(new HashSet<>(Arrays.asList(sectionToShow)));
        model.updateFilteredAgendaEventList(new HashSet<>(Arrays.asList(sectionToShow)));
        
        return new CommandResult(MESSAGE_SUCCESS);
    }

    @Override
    public boolean isValidCommandWord(String commandWord) {
        for (int i = 1; i <= COMMAND_WORD.length(); i++) {
            if (commandWord.equals(COMMAND_WORD.substring(0, i))) {
                return true;
            }
        }
        return false;
    }

}

@@ -45,107 +45,322 @@
 ava.
-util.Arrays;%0Aimport java.util.HashSet;%0Aimport java.util.List;%0A%0Aimport seedu.jimi.model.ModelManager
+time.DayOfWeek;%0Aimport java.time.LocalDateTime;%0Aimport java.time.format.TextStyle;%0Aimport java.util.Arrays;%0Aimport java.util.HashSet;%0Aimport java.util.List;%0Aimport java.util.Locale;%0A%0Aimport seedu.jimi.model.FilteredListManager.ListId;%0Aimport seedu.jimi.model.ModelManager;%0Aimport seedu.jimi.model.datetime.DateTime
 ;%0A%0A/
@@ -1404,29 +1404,29 @@
  String 
-sectionToShow
+userSelection
 ; //sect
@@ -1495,29 +1495,29 @@
    this.
-sectionToShow
+userSelection
  = %22%22;%0A 
@@ -1581,28 +1581,49 @@
 his.
-sectionToShow = args
+userSelection = args.toLowerCase().trim()
 ;%0A  
@@ -1841,16 +1841,56 @@
 Section(
+userSelection);%0A        %0A        ListId 
 sectionT
@@ -1894,17 +1894,23 @@
 onToShow
-)
+ = null
 ;%0A      
@@ -1924,88 +1924,801 @@
     
-model.updateFilteredAgendaTaskList(new HashSet%3C%3E(Arrays.asList(sectionToShow)));
+switch(userSelection) %7B%0A        case %22floating%22:%0A            sectionToShow = ListId.FLOATING_TASKS;%0A            break;%0A        case %22incomplete%22:%0A            sectionToShow = ListId.INCOMPLETE;%0A            break;%0A        case %22complete%22:%0A            sectionToShow = ListId.COMPLETED;%0A            break;%0A        case %22today%22:%0A            sectionToShow = ListId.DAY_AHEAD_0;%0A            break;%0A        case %22tomorrow%22:%0A            sectionToShow = ListId.DAY_AHEAD_1;%0A            break;%0A        case %22monday%22:%0A        case %22tuesday%22: %0A        case %22wednesday%22:%0A        case %22thursday%22:%0A        case %22friday%22:%0A        case %22saturday%22: %0A        case %22sunday%22:%0A            sectionToShow = findSectionToShow(userSelection);%0A            break;%0A        default:%0A                break;%0A        %7D%0A        
 %0A   
@@ -2752,46 +2752,89 @@
 enda
-Event
+Task
 List(n
-ew HashSet%3C%3E(Arrays.asList(
+ull, sectionToShow);%0A        model.updateFilteredAgendaEventList(null, 
 sect
@@ -2843,18 +2843,16 @@
 nToShow)
-))
 ;%0A      
@@ -2912,16 +2912,536 @@
 %0A    %7D%0A%0A
+    private ListId findSectionToShow(String userSelection) %7B%0A        ListId sectionToShow = null;%0A        %0A        LocalDateTime dateTime = new DateTime().getLocalDateTime();%0A        %0A        for(int i=0; i%3C7; i++) %7B%0A            String dayOfWeek = dateTime.getDayOfWeek().plus(i).getDisplayName(TextStyle.FULL, Locale.ENGLISH);%0A            if(dayOfWeek.toLowerCase().contains(userSelection)) %7B%0A                sectionToShow = ListId.values()%5Bi%5D;%0A            %7D%0A        %7D%0A        %0A        return sectionToShow;%0A    %7D%0A    %0A
     @Ove

fix lists not loading properly