Skip to content

Commit

Permalink
Merge 7a22307 into 8554d50
Browse files Browse the repository at this point in the history
  • Loading branch information
dukesun99 committed Apr 13, 2019
2 parents 8554d50 + 7a22307 commit 329ab5a
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 3 deletions.
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 @@ -236,6 +236,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 @@ -327,6 +327,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 @@ -307,6 +307,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 @@ -317,6 +317,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 @@ -331,6 +331,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

0 comments on commit 329ab5a

Please sign in to comment.