Skip to content

Commit

Permalink
Merge branch 'master' into client-equipments
Browse files Browse the repository at this point in the history
 Conflicts:
	src/main/java/seedu/equipment/model/Model.java
	src/test/java/seedu/equipment/logic/commands/AddClientCommandTest.java

 Changes to be committed:
	modified:   src/main/java/seedu/equipment/logic/commands/DisplayCommand.java
	modified:   src/main/java/seedu/equipment/logic/commands/RouteCommand.java
	modified:   src/main/java/seedu/equipment/model/Model.java
	modified:   src/main/java/seedu/equipment/model/ModelManager.java
	modified:   src/main/java/seedu/equipment/ui/BrowserPanel.java
	modified:   src/test/java/seedu/equipment/logic/commands/AddCommandTest.java
	modified:   src/test/java/seedu/equipment/logic/commands/AddWorkListCommandTest.java
	modified:   src/test/java/systemtests/DisplayCommandSystemTest.java
	modified:   src/test/java/systemtests/RouteCommandSystemTest.java
  • Loading branch information
dukesun99 committed Apr 13, 2019
2 parents 7cdd415 + 45e204b commit 0bc7399
Show file tree
Hide file tree
Showing 9 changed files with 51 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
6 changes: 6 additions & 0 deletions src/main/java/seedu/equipment/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ public interface Model {
*/
void setSelectedClient(Name 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 @@ -349,6 +349,11 @@ public void setSelectedClient(Name equipment) {
selectedClient.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 @@ -328,6 +328,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 @@ -347,6 +347,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 0bc7399

Please sign in to comment.