Skip to content

Commit

Permalink
Merge pull request #89 from CS2103-AY1819S2-W10-3/display_worklist
Browse files Browse the repository at this point in the history
List worklist shows a list containing all the worklists, with the information like date, WorklistId, and assignee. Equipments inside the worklist not done yet.
  • Loading branch information
racheltanxueqi committed Apr 1, 2019
2 parents 196fd16 + 6db2952 commit d0de8d7
Show file tree
Hide file tree
Showing 30 changed files with 899 additions and 13 deletions.
19 changes: 19 additions & 0 deletions src/main/java/seedu/equipment/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import seedu.equipment.logic.parser.exceptions.ParseException;
import seedu.equipment.model.Model;
import seedu.equipment.model.ReadOnlyEquipmentManager;
import seedu.equipment.model.WorkList;
import seedu.equipment.model.equipment.Equipment;

/**
Expand All @@ -35,6 +36,9 @@ public interface Logic {
/** Returns an unmodifiable view of the filtered list of persons */
ObservableList<Equipment> getFilteredPersonList();

/** Returns an unmodifiable view of the filtered list of WorkLists */
ObservableList<WorkList> getFilteredWorkListList();

/**
* Returns an unmodifiable view of the list of commands entered by the user.
* The list is ordered from the least recent command to the most recent command.
Expand Down Expand Up @@ -64,10 +68,25 @@ public interface Logic {
*/
ReadOnlyProperty<Equipment> selectedEquipmentProperty();

/**
* Selected WorkList in the filtered WorkList list.
* null if no WorkList is selected.
*
* @see Model#selectedWorkListProperty()
*/
ReadOnlyProperty<WorkList> selectedWorkListProperty();

/**
* Sets the selected equipment in the filtered equipment list.
*
* @see Model#setSelectedEquipment(Equipment)
*/
void setSelectedPerson(Equipment equipment);

/**
* Sets the selected WorkList in the filtered WorkList list.
*
* @see Model#setSelectedWorkList(WorkList)
*/
void setSelectedWorkList(WorkList workList);
}
16 changes: 16 additions & 0 deletions src/main/java/seedu/equipment/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import seedu.equipment.logic.parser.exceptions.ParseException;
import seedu.equipment.model.Model;
import seedu.equipment.model.ReadOnlyEquipmentManager;
import seedu.equipment.model.WorkList;
import seedu.equipment.model.equipment.Equipment;
import seedu.equipment.storage.Storage;

Expand Down Expand Up @@ -76,6 +77,11 @@ public ObservableList<Equipment> getFilteredPersonList() {
return model.getFilteredPersonList();
}

@Override
public ObservableList<WorkList> getFilteredWorkListList() {
return model.getFilteredWorkListList();
}

@Override
public ObservableList<String> getHistory() {
return history.getHistory();
Expand All @@ -101,8 +107,18 @@ public ReadOnlyProperty<Equipment> selectedEquipmentProperty() {
return model.selectedEquipmentProperty();
}

@Override
public ReadOnlyProperty<WorkList> selectedWorkListProperty() {
return model.selectedWorkListProperty();
}

@Override
public void setSelectedPerson(Equipment equipment) {
model.setSelectedEquipment(equipment);
}

@Override
public void setSelectedWorkList(WorkList workList) {
model.setSelectedWorkList(workList);
}
}
1 change: 1 addition & 0 deletions src/main/java/seedu/equipment/model/EquipmentManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public ObservableList<Equipment> getPersonList() {
return equipment.asUnmodifiableObservableList();
}

@Override
public ObservableList<WorkList> getWorkListList() {
return worklist.asUnmodifiableObservableList();
}
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/seedu/equipment/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ public interface Model {
*/
void deleteEquipment(Equipment target);

/**
* Deletes the given WorkList.
* The WorkList must exist in the Equipment Manager.
*/
void deleteWorkList(WorkList target);

/**
* Adds the given equipment.
* {@code equipment} must not already exist in the equipment manager.
Expand Down Expand Up @@ -145,17 +151,34 @@ public interface Model {
*/
ReadOnlyProperty<Equipment> selectedEquipmentProperty();

/**
* Selected WorkList in the filtered WorkList list.
* null if no WorkList is selected.
*/
ReadOnlyProperty<WorkList> selectedWorkListProperty();

/**
* Returns the selected equipment in the filtered equipment list.
* null if no equipment is selected.
*/
Equipment getSelectedEquipment();

/**
* Returns the selected WorkList in the filtered WorkList list.
* null if no WorkList is selected.
*/
WorkList getSelectedWorkList();

/**
* Sets the selected equipment in the filtered equipment list.
*/
void setSelectedEquipment(Equipment equipment);

/**
* Sets the selected WorkList in the filtered WorkList list.
*/
void setSelectedWorkList(WorkList workList);

/** Removes the given {@code tag} from all {@code Equipment}s. */
void deleteTag(Tag tag);

Expand Down
27 changes: 26 additions & 1 deletion src/main/java/seedu/equipment/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class ModelManager implements Model {
private final FilteredList<Equipment> filteredEquipments;
private final FilteredList<WorkList> filteredWorkList;
private final SimpleObjectProperty<Equipment> selectedEquipment = new SimpleObjectProperty<>();
private final SimpleObjectProperty<WorkList> selectedWorkList = new SimpleObjectProperty<>();

/**
* Initializes a ModelManager with the given equipmentManager and userPrefs.
Expand Down Expand Up @@ -116,6 +117,11 @@ public void deleteEquipment(Equipment target) {
versionedEquipmentManager.removePerson(target);
}

@Override
public void deleteWorkList(WorkList target) {
versionedEquipmentManager.removeWorkList(target);
}

@Override
public void addEquipment(Equipment equipment) {
versionedEquipmentManager.addPerson(equipment);
Expand Down Expand Up @@ -206,6 +212,26 @@ public void commitEquipmentManager() {
versionedEquipmentManager.commit();
}

//=========== Selected WorkList ===========================================================================

@Override
public ReadOnlyProperty<WorkList> selectedWorkListProperty() {
return selectedWorkList;
}

@Override
public WorkList getSelectedWorkList() {
return selectedWorkList.getValue();
}

@Override
public void setSelectedWorkList(WorkList workList) {
if (workList != null && !filteredWorkList.contains(workList)) {
throw new EquipmentNotFoundException();
}
selectedWorkList.setValue(workList);
}

//=========== Selected equipment ===========================================================================

@Override
Expand Down Expand Up @@ -260,7 +286,6 @@ private void ensureSelectedPersonIsValid(ListChangeListener.Change<? extends Equ
}
}


@Override
public boolean equals(Object obj) {
// short circuit if same object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ public interface ReadOnlyEquipmentManager extends Observable {
*/
ObservableList<Equipment> getPersonList();

/**
* Returns an unmodifiable view of the WorkList list.
* This list will not contain any duplicate WorkLists.
*/
ObservableList<WorkList> getWorkListList();

}
3 changes: 2 additions & 1 deletion src/main/java/seedu/equipment/model/UniqueWorkListList.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public boolean areWorkListUnique(List<WorkList> workListList) {
* Returns the backing list as an unmodifiable {@code ObservableList}.
*/
public ObservableList<WorkList> asUnmodifiableObservableList() {
return internalUnmodifiableList;
internalList.add(new WorkList("12 May 2019", "Mei Yen"));
return FXCollections.unmodifiableObservableList(internalList);
}

@Override
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/seedu/equipment/model/WorkList.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,27 @@ public void deleteEquipment(Equipment e) {
// return (Equipment[]) this.equipments.toArray();
//}

/**
* Returns true if both WorkLists have the same identity and data fields.
* This defines a stronger notion of equality between two WorkLists.
*/
@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

if (!(other instanceof WorkList)) {
return false;
}

WorkList otherWorkList = (WorkList) other;
return otherWorkList.getAssignee().equals(getAssignee())
&& otherWorkList.getDate().equals(getDate())
&& otherWorkList.getId().equals(getId())
&& otherWorkList.getEquipments().equals(getEquipments());
}

/**
* Returns true if both worklists have the same WorkListId.
*/
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/seedu/equipment/model/WorkListId.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@ public class WorkListId {
*/
public WorkListId() {
thisId = idHist + 1;
idHist++;
}

/**
* Returns true if both WorkListIds have the same id.
* This defines a stronger notion of equality between two WorkListIds.
*/
@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

if (!(other instanceof WorkListId)) {
return false;
}

WorkListId otherWorkListId = (WorkListId) other;
return otherWorkListId.getId() == getId();
}

public int getId() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package seedu.equipment.model.equipment.exceptions;

/**
* Signals that the operation will result in duplicate Persons (Persons are considered duplicates if they have the same
* identity).
* Signals that the operation will result in duplicate Equipments (Equipments are considered duplicates
* if they have the same identity).
*/
public class DuplicateEquipmentException extends RuntimeException {
public DuplicateEquipmentException() {
super("Operation would result in duplicate persons");
super("Operation would result in duplicate equipments");
}
}
1 change: 1 addition & 0 deletions src/main/java/seedu/equipment/ui/EquipmentListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class EquipmentListPanel extends UiPart<Region> {
public EquipmentListPanel(ObservableList<Equipment> equipmentList, ObservableValue<Equipment> selectedPerson,
Consumer<Equipment> onSelectedPersonChange) {
super(FXML);
//System.out.println(personListView.getEditingIndex());
personListView.setItems(equipmentList);
personListView.setCellFactory(listView -> new PersonListViewCell());
personListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/seedu/equipment/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class MainWindow extends UiPart<Stage> {
// Independent Ui parts residing in this Ui container
private BrowserPanel browserPanel;
private EquipmentListPanel equipmentListPanel;
private WorkListListPanel workListListPanel;
private ResultDisplay resultDisplay;
private HelpWindow helpWindow;

Expand All @@ -50,6 +51,9 @@ public class MainWindow extends UiPart<Stage> {
@FXML
private StackPane personListPanelPlaceholder;

@FXML
private StackPane workListPanelPlaceholder;

@FXML
private StackPane resultDisplayPlaceholder;

Expand Down Expand Up @@ -120,6 +124,10 @@ void fillInnerParts() {
logic::setSelectedPerson);
personListPanelPlaceholder.getChildren().add(equipmentListPanel.getRoot());

workListListPanel = new WorkListListPanel(logic.getFilteredWorkListList(), logic.selectedWorkListProperty(),
logic::setSelectedWorkList);
workListPanelPlaceholder.getChildren().add(workListListPanel.getRoot());

resultDisplay = new ResultDisplay();
resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot());

Expand Down Expand Up @@ -193,6 +201,10 @@ public EquipmentListPanel getEquipmentListPanel() {
return equipmentListPanel;
}

public WorkListListPanel getWorkListListPanel() {
return workListListPanel;
}

/**
* Executes the command and returns the result.
*
Expand Down
Loading

0 comments on commit d0de8d7

Please sign in to comment.