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

Fix select display select bug #186

Merged
merged 2 commits into from
Apr 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public DisplayCommand() {

@Override
public CommandResult execute(Model model, CommandHistory history) {
model.unsetSelectedEquipment();
return new CommandResult(
Messages.MESSAGE_EQUIPMENT_DISPLAYED_OVERVIEW, false, false, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
throw new CommandException(MESSAGE_TOO_MANY_EQUIPMENTS_TO_ROUTE);
}

model.unsetSelectedEquipment();
return new CommandResult(MESSAGE_ROUTE_EQUIPMENT_SUCCESS, false, false, false, true, startendAddress);

}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/seedu/equipment/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ public interface Model {
*/
void setSelectedEquipment(Equipment equipment);

/**
* Unset the selected equipment in the filtered equipment list.
*/
void unsetSelectedEquipment();

/**
* Sets the selected WorkList in the filtered WorkList list.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/seedu/equipment/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,11 @@ public void setSelectedEquipment(Equipment equipment) {
selectedEquipment.setValue(equipment);
}

@Override
public void unsetSelectedEquipment() {
selectedEquipment.setValue(null);
}

@Override
public void deleteTag(Tag tag) {
versionedEquipmentManager.removeTag(tag);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/equipment/ui/BrowserPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ public class BrowserPanel extends UiPart<Region> {
@FXML
private WebView browser;

public BrowserPanel(ObservableValue<Equipment> selectedPerson) {
public BrowserPanel(ObservableValue<Equipment> selectedEquipment) {
super(FXML);

// To prevent triggering events for typing inside the loaded Web page.
getRoot().setOnKeyPressed(Event::consume);

// Load equipment page when selected equipment changes.
selectedPerson.addListener((observable, oldValue, newValue) -> {
selectedEquipment.addListener((observable, oldValue, newValue) -> {
if (newValue == null) {
loadDefaultPage();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@ public void setSelectedEquipment(Equipment equipment) {
throw new AssertionError("This method should not be called.");
}

@Override
public void unsetSelectedEquipment() {
throw new AssertionError("This method should not be called.");
}

@Override
public void setSelectedWorkList(WorkList workList) {
throw new AssertionError("This method should not be called.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ public void setSelectedEquipment(Equipment equipment) {
throw new AssertionError("This method should not be called.");
}

@Override
public void unsetSelectedEquipment() {
throw new AssertionError("This method should not be called.");
}

@Override
public void setSelectedWorkList(WorkList workList) {
throw new AssertionError("This method should not be called.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ public void setSelectedEquipment(Equipment equipment) {
throw new AssertionError("This method should not be called.");
}

@Override
public void unsetSelectedEquipment() {
throw new AssertionError("This method should not be called.");
}

@Override
public void setSelectedWorkList(WorkList workList) {
throw new AssertionError("This method should not be called.");
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/systemtests/DisplayCommandSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import seedu.equipment.commons.core.Messages;
import seedu.equipment.logic.commands.DisplayCommand;
import seedu.equipment.logic.commands.SelectCommand;
import seedu.equipment.model.Model;
import seedu.equipment.ui.BrowserPanel;

Expand All @@ -22,6 +23,18 @@ public void display() {
Model expectedModel = getModel();
assertCommandSuccess(command, expectedModel);

/* ----------------------- Perform select operations and then display and select ---------------------------- */

/* Case: Select some equipment, display, and then select the same equipment. The browser panel should change.
*/
String selectCommand = "" + SelectCommand.COMMAND_WORD + " 1";
URL oldUrl = getBrowserPanel().getLoadedUrl();
executeCommand(selectCommand);
assertNotEquals(oldUrl.toString(), getBrowserPanel().getLoadedUrl().toString());
assertCommandSuccess(command, expectedModel);
oldUrl = getBrowserPanel().getLoadedUrl();
executeCommand(selectCommand);
assertNotEquals(oldUrl.toString(), getBrowserPanel().getLoadedUrl().toString());
}

/**
Expand Down
14 changes: 13 additions & 1 deletion src/test/java/systemtests/RouteCommandSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.junit.Test;

import seedu.equipment.logic.commands.RouteCommand;
import seedu.equipment.logic.commands.SelectCommand;
import seedu.equipment.model.Model;
import seedu.equipment.ui.BrowserPanel;

Expand All @@ -21,6 +22,18 @@ public void route() {
Model expectedModel = getModel();
assertCommandSuccess(command, expectedModel);

/* ----------------------- Perform select operations and then route and select ---------------------------- */

/* Case: Select some equipment, route, and then select the same equipment. The browser panel should change.
*/
String selectCommand = "" + SelectCommand.COMMAND_WORD + " 1";
URL oldUrl = getBrowserPanel().getLoadedUrl();
executeCommand(selectCommand);
assertNotEquals(oldUrl.toString(), getBrowserPanel().getLoadedUrl().toString());
assertCommandSuccess(command, expectedModel);
oldUrl = getBrowserPanel().getLoadedUrl();
executeCommand(selectCommand);
assertNotEquals(oldUrl.toString(), getBrowserPanel().getLoadedUrl().toString());
}

/**
Expand All @@ -40,7 +53,6 @@ private void assertCommandSuccess(String command, Model expectedModel) {
assertApplicationDisplaysExpected("", expectedResultMessage, expectedModel);
assertCommandBoxShowsDefaultStyle();
assertStatusBarUnchanged();
assertSelectedPersonCardUnchanged();
assertNotEquals(oldUrl.toString(), getBrowserPanel().getLoadedUrl().toString());
assertNotEquals(BrowserPanel.DEFAULT_PAGE, getBrowserPanel().getLoadedUrl().toString());
assertNotEquals(BrowserPanel.MAP_MULTIPLE_POINT_BASE_URL, getBrowserPanel().getLoadedUrl().toString());
Expand Down