Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find command #31

Merged
merged 24 commits into from Oct 13, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
af73025
added some images and changed AboutUs.adoc
CowSaysBaa Sep 29, 2019
a1954ad
updated photos and AboutUs.adoc
CowSaysBaa Sep 29, 2019
c56dff4
Added all photos and updated AboutUs.adoc
CowSaysBaa Sep 29, 2019
f3728b9
Merge branch 'master' of https://github.com/AY1920S1-CS2103T-W13-1/main
CowSaysBaa Sep 30, 2019
97f6e74
Merge branch 'master' of https://github.com/AY1920S1-CS2103T-W13-1/main
CowSaysBaa Oct 9, 2019
6e04c0b
Merge branch 'master' of https://github.com/AY1920S1-CS2103T-W13-1/main
CowSaysBaa Oct 9, 2019
87d2ac4
Merge branch 'master' of https://github.com/CowSaysBaa/main
CowSaysBaa Oct 12, 2019
9676c5a
Changed the logic for the find command to search within ArchivedModul…
CowSaysBaa Oct 12, 2019
fb7501b
Added some fullstops to javadocs.
CowSaysBaa Oct 12, 2019
fbfc56a
Updated ModuleBook to copy ArchiveModuleList as well.
CowSaysBaa Oct 12, 2019
4bf410d
Renamed: Module -> TrackedModule.
CowSaysBaa Oct 12, 2019
e3d07f4
Added: Module.java interface.
CowSaysBaa Oct 12, 2019
80710d3
Type migrated TrackedModule to Module in NameContainsKeywordsPredicat…
CowSaysBaa Oct 12, 2019
b0864d2
Deleted ArchivedNameContainsKeywordsPredicate.java.
CowSaysBaa Oct 12, 2019
3a34e62
Added displayedList to ModelManager.java.
CowSaysBaa Oct 12, 2019
bd178cc
Changed how displayedList works to dislay ArchivedList and TrackedList.
CowSaysBaa Oct 12, 2019
7a460c9
Reverted checkstyle.xml.
CowSaysBaa Oct 12, 2019
4f20570
Reverted unintentional renames.
CowSaysBaa Oct 12, 2019
3a22742
Reverted unintentional renames.
CowSaysBaa Oct 12, 2019
601d446
Fixed checkstyle.
CowSaysBaa Oct 12, 2019
c19fa80
Fixed checkstyles.
CowSaysBaa Oct 12, 2019
ff4e1b8
Fixed typing issues.
CowSaysBaa Oct 13, 2019
a3cd432
Split changeDisplayedList to displayArchivedList and displayTrackedList.
CowSaysBaa Oct 13, 2019
3629d8e
Fixed naming issue.
CowSaysBaa Oct 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/seedu/module/logic/commands/FindCommand.java
Expand Up @@ -30,7 +30,7 @@ public FindCommand(NameContainsKeywordsPredicate predicate) {
public CommandResult execute(Model model) {
requireNonNull(model);
model.updateFilteredArchivedModuleList(predicate);
model.changeDisplayedList("ArchivedList");
model.displayArchivedList();
return new CommandResult(
String.format(Messages.MESSAGE_MODULES_LISTED_OVERVIEW, model.getFilteredArchivedModuleList().size()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/module/logic/commands/ListCommand.java
Expand Up @@ -19,7 +19,7 @@ public class ListCommand extends Command {
public CommandResult execute(Model model) {
requireNonNull(model);
model.updateFilteredModuleList(PREDICATE_SHOW_ALL_MODULES);
model.changeDisplayedList("TrackedList");
model.displayTrackedList();
return new CommandResult(MESSAGE_SUCCESS);
}
}
13 changes: 9 additions & 4 deletions src/main/java/seedu/module/model/Model.java
Expand Up @@ -16,7 +16,7 @@ public interface Model {
/**
* {@code Predicate} that always evaluate to true.
*/
Predicate<TrackedModule> PREDICATE_SHOW_ALL_MODULES = unused -> true;
Predicate<Module> PREDICATE_SHOW_ALL_MODULES = unused -> true;

/**
* Replaces user prefs data with the data in {@code userPrefs}.
Expand Down Expand Up @@ -97,16 +97,21 @@ public interface Model {
*
* @throws NullPointerException if {@code predicate} is null.
*/
void updateFilteredModuleList(Predicate<TrackedModule> predicate);
void updateFilteredModuleList(Predicate<Module> predicate);

/**
* Returns an unmodifiable view of the current shown list.
*/
ObservableList<Module> getDisplayedList();

/**
* Changes the current list to be shown.
* Changes the current list to be shown to the ArchivedModuleList.
*/
void changeDisplayedList(String list);
void displayArchivedList();

/**
* Changes the current list to be shown to the TrackedModuleList.
*/
void displayTrackedList();
}

32 changes: 14 additions & 18 deletions src/main/java/seedu/module/model/ModelManager.java
Expand Up @@ -41,7 +41,7 @@ public ModelManager(ReadOnlyModuleBook moduleBook, ReadOnlyUserPrefs userPrefs)
this.userPrefs = new UserPrefs(userPrefs);
filteredTrackedModules = new FilteredList<>(this.moduleBook.getModuleList());
filteredArchivedModules = new FilteredList<>(this.moduleBook.getArchivedModuleList());
changeDisplayedList("TrackedList");
displayTrackedList();
}

public ModelManager() {
Expand Down Expand Up @@ -124,7 +124,7 @@ public ObservableList<TrackedModule> getFilteredModuleList() {
}

@Override
public void updateFilteredModuleList(Predicate<TrackedModule> predicate) {
public void updateFilteredModuleList(Predicate<Module> predicate) {
requireNonNull(predicate);
filteredTrackedModules.setPredicate(predicate);
}
Expand Down Expand Up @@ -157,22 +157,18 @@ public ObservableList<Module> getDisplayedList() {
}

@Override
public void changeDisplayedList(String list) {
switch (list) {
case "ArchivedList":
this.displayedList.clear();
for (Module i : filteredArchivedModules) {
displayedList.add(i);
}
break;
case "TrackedList":
this.displayedList.clear();
for (Module i : filteredTrackedModules) {
displayedList.add(i);
}
break;
default:
break;
public void displayArchivedList() {
this.displayedList.clear();
for (Module i : filteredArchivedModules) {
displayedList.add(i);
}
}

@Override
public void displayTrackedList() {
this.displayedList.clear();
for (Module i : filteredTrackedModules) {
displayedList.add(i);
}
}

Expand Down
Expand Up @@ -16,9 +16,9 @@ public NameContainsKeywordsPredicate(List<String> keywords) {
}

@Override
public boolean test(Module trackedModule) {
public boolean test(Module Module) {
return keywords.stream()
.anyMatch(keyword -> StringUtil.containsWordIgnoreCase(trackedModule.getModuleCode(), keyword));
.anyMatch(keyword -> StringUtil.containsWordIgnoreCase(Module.getModuleCode(), keyword));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/module/storage/JsonAdaptedModule.java
Expand Up @@ -29,7 +29,7 @@ public JsonAdaptedModule(@JsonProperty("moduleCode") String moduleCode, @JsonPro
}

/**
* Converts a given {@code Module} into this class for Jackson use.
* Converts a given {@code TrackedModule} into this class for Jackson use.
*/
public JsonAdaptedModule(TrackedModule source) {
moduleCode = source.getModuleCode();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/view/MainWindow.fxml
Expand Up @@ -45,7 +45,7 @@
</padding>
</StackPane>

<VBox fx:id="trackedModuleList" styleClass="pane-with-border" minWidth="340" prefWidth="340"
<VBox fx:id="ModuleList" styleClass="pane-with-border" minWidth="340" prefWidth="340"
CowSaysBaa marked this conversation as resolved.
Show resolved Hide resolved
VBox.vgrow="ALWAYS">
<padding>
<Insets top="10" right="10" bottom="10" left="10"/>
Expand Down
22 changes: 13 additions & 9 deletions src/test/java/seedu/module/logic/commands/CommandTestUtil.java
@@ -1,15 +1,19 @@
package seedu.module.logic.commands;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.module.testutil.Assert.assertThrows;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import seedu.module.commons.core.index.Index;
import seedu.module.logic.commands.exceptions.CommandException;
import seedu.module.model.Model;
import seedu.module.model.ModuleBook;
import seedu.module.model.module.TrackedModule;
import seedu.module.model.module.Module;
import seedu.module.model.module.NameContainsKeywordsPredicate;

/**
* Contains helper methods for testing commands.
Expand Down Expand Up @@ -51,7 +55,7 @@ public static void assertCommandFailure(Command command, Model actualModel, Stri
// we are unable to defensively copy the model for comparison later, so we can
// only do so by copying its components.
ModuleBook expectedAddressBook = new ModuleBook(actualModel.getModuleBook());
List<TrackedModule> expectedFilteredList = new ArrayList<>(actualModel.getFilteredModuleList());
List<Module> expectedFilteredList = new ArrayList<>(actualModel.getFilteredModuleList());

assertThrows(CommandException.class, expectedMessage, () -> command.execute(actualModel));
assertEquals(expectedAddressBook, actualModel.getModuleBook());
Expand All @@ -62,14 +66,14 @@ public static void assertCommandFailure(Command command, Model actualModel, Stri
* Updates {@code model}'s filtered list to show only the module at the given {@code targetIndex} in the
* {@code model}'s address book.
*/
//public static void showModuleAtIndex(Model model, Index targetIndex) {
//assertTrue(targetIndex.getZeroBased() < model.getFilteredModuleList().size());
public static void showModuleAtIndex(Model model, Index targetIndex) {
assertTrue(targetIndex.getZeroBased() < model.getFilteredModuleList().size());

//TrackedModule trackedModule = model.getFilteredModuleList().get(targetIndex.getZeroBased());
//final String[] splitName = trackedModule.getTitle().split("\\s+");
//model.updateFilteredModuleList(new NameContainsKeywordsPredicate(Arrays.asList(splitName[0])));
Module trackedModule = model.getFilteredModuleList().get(targetIndex.getZeroBased());
final String[] splitName = trackedModule.getTitle().split("\\s+");
model.updateFilteredModuleList(new NameContainsKeywordsPredicate(Arrays.asList(splitName[0])));

//assertEquals(1, model.getFilteredModuleList().size());
//}
assertEquals(1, model.getFilteredModuleList().size());
}

}
Expand Up @@ -9,7 +9,7 @@
import seedu.module.model.module.ArchivedModuleList;


class JsonArchivedTrackedModuleListTest {
class JsonArchivedModuleListTest {
private static final String VALID_ARCHIVED_MODULES_FILE_PATH = "data/archivedModules.json";
private static final String INVALID_ARCHIVED_MODULES_FILE_PATH = "data/doesntexist.json";
// To trigger URISyntaxException
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/seedu/module/testutil/TestUtil.java
Expand Up @@ -33,23 +33,23 @@ public static Path getFilePathInSandboxFolder(String fileName) {
}

/**
* Returns the middle index of the person in the {@code model}'s person list.
* Returns the middle index of the tracked module in the {@code model}'s tracked module list.
*/
public static Index getMidIndex(Model model) {
return Index.fromOneBased(model.getFilteredModuleList().size() / 2);
}

/**
* Returns the last index of the person in the {@code model}'s person list.
* Returns the last index of the tracked module in the {@code model}'s tracked module list.
*/
public static Index getLastIndex(Model model) {
return Index.fromOneBased(model.getFilteredModuleList().size());
}

/**
* Returns the person in the {@code model}'s person list at {@code index}.
* Returns the tracked module in the {@code model}'s tracked module list at {@code index}.
*/
public static TrackedModule getPerson(Model model, Index index) {
public static TrackedModule getModule(Model model, Index index) {
return model.getFilteredModuleList().get(index.getZeroBased());
}
}