forked from nus-cs2103-AY2021S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
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 nus-cs2103-AY2021S1#56 from ryanlimjr/branch-viewg…
…rp-cmd Branch viewgrp cmd
- Loading branch information
Showing
39 changed files
with
1,055 additions
and
64 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
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
title: "Serenity" | ||
theme: minima | ||
|
||
|
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
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
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
40 changes: 40 additions & 0 deletions
40
src/main/java/seedu/address/logic/commands/ViewGrpCommand.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,40 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_GRP; | ||
|
||
import seedu.address.commons.core.Messages; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.group.GrpContainsKeywordPredicate; | ||
|
||
/** | ||
* Finds and lists all students and lessons in the group specifeied. Keyword matching is case insensitive. | ||
*/ | ||
public class ViewGrpCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "viewgrp"; | ||
public static final Object MESSAGE_USAGE = COMMAND_WORD | ||
+ ": Finds all students who are part of " | ||
+ "the specified group and displays them as a list with index numbers.\n" | ||
+ "Parameters: GROUP \n" | ||
+ "Example: " + COMMAND_WORD + " " + PREFIX_GRP + " G04"; | ||
|
||
private final GrpContainsKeywordPredicate predicate; | ||
|
||
public ViewGrpCommand(GrpContainsKeywordPredicate predicate) { | ||
this.predicate = predicate; | ||
} | ||
|
||
private String getMessage(Model model) { | ||
return model.getFilteredGroupList().isEmpty() | ||
? Messages.MESSAGE_GROUP_EMPTY | ||
: String.format(Messages.MESSAGE_GROUP_LISTED_OVERVIEW, model.getFilteredGroupList().get(0).getName()); | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model) { | ||
requireNonNull(model); | ||
model.updateFilteredGroupList(predicate); | ||
return new CommandResult(this.getMessage(model)); | ||
} | ||
} |
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
42 changes: 42 additions & 0 deletions
42
src/main/java/seedu/address/logic/parser/ViewGrpCommandParser.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,42 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_GRP; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import seedu.address.logic.commands.ViewGrpCommand; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
import seedu.address.model.group.GrpContainsKeywordPredicate; | ||
|
||
public class ViewGrpCommandParser implements Parser<ViewGrpCommand> { | ||
|
||
private final ParseException viewGrpCommandParserException = new ParseException( | ||
String.format(MESSAGE_INVALID_COMMAND_FORMAT, ViewGrpCommand.MESSAGE_USAGE)); | ||
|
||
@Override | ||
public ViewGrpCommand parse(String args) throws ParseException { | ||
|
||
ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_GRP); | ||
|
||
if (!arePrefixesPresent(argMultimap, PREFIX_GRP) || !argMultimap.getPreamble().isEmpty()) { | ||
throw viewGrpCommandParserException; | ||
} | ||
|
||
String[] grpKeyword = argMultimap.getValue(PREFIX_GRP).get().split("\\s+"); | ||
|
||
if (grpKeyword.length > 1) { | ||
throw viewGrpCommandParserException; | ||
} | ||
|
||
return new ViewGrpCommand(new GrpContainsKeywordPredicate(grpKeyword[0])); | ||
} | ||
|
||
/** | ||
* Returns true if none of the prefixes contains empty {@code Optional} values in the given {@code | ||
* ArgumentMultimap}. | ||
*/ | ||
private static boolean arePrefixesPresent(ArgumentMultimap argumentMultimap, Prefix... prefixes) { | ||
return Stream.of(prefixes).allMatch(prefix -> argumentMultimap.getValue(prefix).isPresent()); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/seedu/address/model/ArrayObservableList.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,46 @@ | ||
package seedu.address.model; | ||
|
||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javafx.collections.ModifiableObservableListBase; | ||
import javafx.collections.ObservableList; | ||
|
||
/** | ||
* A modifiable observable list to support rendering of different | ||
* set of information when navigating to different groups | ||
*/ | ||
public class ArrayObservableList<E> extends ModifiableObservableListBase<E> { | ||
|
||
private final List<E> delegate = new ArrayList<>(); | ||
|
||
/** | ||
* Creates a generic ArrayObservableList | ||
*/ | ||
public ArrayObservableList(ObservableList<E> list) { | ||
for (E e : list) { | ||
delegate.add(e); | ||
} | ||
} | ||
|
||
public E get(int index) { | ||
return delegate.get(index); | ||
} | ||
|
||
public int size() { | ||
return delegate.size(); | ||
} | ||
|
||
protected void doAdd(int index, E element) { | ||
delegate.add(index, element); | ||
} | ||
|
||
protected E doSet(int index, E element) { | ||
return delegate.set(index, element); | ||
} | ||
|
||
protected E doRemove(int index) { | ||
return delegate.remove(index); | ||
} | ||
} |
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
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
Oops, something went wrong.