forked from se-edu/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from lixinze777/master
Update Calendar switch feature and fix minor bugs
- Loading branch information
Showing
4 changed files
with
153 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/seedu/address/logic/commands/ModeCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import seedu.address.logic.CommandHistory; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.AddressBookModel; | ||
|
||
/* | ||
* Switch between Patient Mode and Calender Mode | ||
*/ | ||
public class ModeCommand extends Command{ | ||
|
||
public static final String COMMAND_WORD = "mode"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD | ||
+": Switch between the patient mode and the appointment mode.\n" | ||
+"Parameters: MODE\n" | ||
+"Example: "+ COMMAND_WORD + " patient"; | ||
|
||
public static final String MESSAGE_CANNOT_SWITCH = "You are already in this mode.\n"; | ||
|
||
@Override | ||
public CommandResult execute(AddressBookModel addressBookModel, CommandHistory history) { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package seedu.address.model; | ||
|
||
import javafx.collections.ObservableList; | ||
import seedu.address.model.event.CalendarEvent; | ||
import seedu.address.model.event.UniqueCalendarEventList; | ||
import java.util.Calendar; | ||
import java.util.List; | ||
import static java.util.Objects.requireNonNull; | ||
|
||
public class ModelCalendar implements ReadOnlyCalendar { | ||
|
||
private final UniqueCalendarEventList events; | ||
|
||
{ | ||
events = new UniqueCalendarEventList(); | ||
} | ||
|
||
public ModelCalendar() {} | ||
|
||
/** | ||
* Creates a Calender using the CalendarEvents in the {@code toBeCopied} | ||
*/ | ||
public ModelCalendar(ReadOnlyCalendar toBeCopied) { | ||
this(); | ||
resetData(toBeCopied); | ||
} | ||
|
||
/** | ||
* Replaces the contents of the person list with {@code persons}. | ||
* {@code persons} must not contain duplicate persons. | ||
*/ | ||
public void setEvents(List<CalendarEvent> events) { | ||
this.events.setCalendarEvents(events); | ||
} | ||
|
||
/** | ||
* Resets the existing data of this {@code AddressBook} with {@code newData}. | ||
*/ | ||
public void resetData(ReadOnlyCalendar newData) { | ||
requireNonNull(newData); | ||
|
||
setEvents(newData.getAllEventList()); | ||
} | ||
|
||
/** | ||
* Returns true if an event with the same identity as {@code event} exists in the calendar. | ||
*/ | ||
public boolean hasEvent(CalendarEvent event) { | ||
requireNonNull(event); | ||
return events.contains(event); | ||
} | ||
|
||
/** | ||
* Adds an event to the Calendar. | ||
* The event must not already exist in the calendar. | ||
*/ | ||
public void addEvent(CalendarEvent e) { | ||
events.add(e); | ||
} | ||
|
||
/** | ||
* Replaces the given event {@code target} in the list with {@code editedEvent}. | ||
* {@code target} must exist in the Calendar. | ||
* The event identity of {@code editedEvent} must not be the same as another existing event in the calendar. | ||
*/ | ||
public void updateEvent(CalendarEvent target, CalendarEvent editedEvent) { | ||
requireNonNull(editedEvent); | ||
events.setCalendarEvent(target, editedEvent); | ||
} | ||
|
||
/** | ||
* Removes {@code key} from this {@code Calendar}. | ||
* {@code key} must exist in the Calendar. | ||
* | ||
* Note: Calendar removal is done via soft-delete | ||
*/ | ||
public void removeEvent(CalendarEvent key) { | ||
events.remove(key); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getAllEventList().size() + " events\n"; | ||
} | ||
|
||
@Override | ||
public ObservableList<CalendarEvent> getAllEventList() { | ||
return events.asUnmodifiableObservableList(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return events.hashCode(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,5 @@ | |
</AnchorPane> | ||
</items> | ||
</SplitPane> | ||
<Label text="Label" /> | ||
</children> | ||
</AnchorPane> |