Skip to content

Commit

Permalink
Merge pull request #224 from tiuweehan/ppp
Browse files Browse the repository at this point in the history
Tests, Assertions, Logging, Cleanup and Documentation for UiLogic
  • Loading branch information
tiuweehan authored Nov 8, 2019
2 parents 671e5db + 212a1b2 commit 7b90544
Show file tree
Hide file tree
Showing 50 changed files with 1,181 additions and 292 deletions.
8 changes: 6 additions & 2 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ NOTE: The lifeline for `DeleteCommandParser` should end at the destroy marker (X
//@@author

//@@author tiuweehan
// tag::uilogic[]
[[Design-UiLogic]]
=== UiLogic Component

Expand All @@ -142,7 +143,7 @@ link:{repoURL}/src/main/java/seedu/algobase/ui/action/UiLogic.java[`UiLogic.java
image::EditSequenceDiagram.png[]

NOTE: The lifeline for `EditProblemUiActionParser` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram.

// end::uilogic[]
//@@author

//@@author le0tan
Expand Down Expand Up @@ -537,8 +538,9 @@ Since AlgoBase is forked from AddressBook 3, it also inherits AB3's design choic
//@@author

//@@author tiuweehan
// tag::gui
// tag::gui[]
=== GUI Enhancements
// end::gui[]

An intuitive GUI facilitates the overall user friendliness of the application.
The user should be able to navigate around the application easily to facilitate a smooth experience using AlgoBase.
Expand All @@ -548,6 +550,8 @@ In this case, having a GUI will be more beneficial to the user and facilitates a
Additionally, multitasking is important as a user may be tackling multiple algorithmic questions at a single time.
This, we introduced tabbing, which facilitates multitasking in AlgoBase, which is an important requirement for competitive programmers.

// tag::gui[]

==== Editing Problems from GUI

===== Current Implementation
Expand Down
49 changes: 45 additions & 4 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,45 @@ endif::[]

By: `Team CS2103T-W11-1` Since: `Sep 2019` Licence: `MIT`

// tag::intro[]
== Introduction

AlgoBase (AB) is for those who prefer to use a desktop app for managing algorithm problems. AlgoBase can let you establish and modify your own training plan for algorithm problems flexibly and it can save several training plans at the same time on your local storage! Also, you can use diverse tags and search to manage your questions and training plans conveniently. More importantly, AlgoBase is optimized for those who prefer to work with a Command Line Interface (CLI) while still having the benefits of a Graphical User Interface (GUI). If you can type fast, ALgoBase can get your problem management tasks done faster than traditional GUI apps. Interested? Jump to the Section 2, “Quick Start” to get started. Enjoy! :-))
AlgoBase (AB) is a one-stop management platform for Computer Science students preparing for technical interviews.
**With AlgoBase, say goodbye to tough interview days!**

Tired of having to manually track your progress across multiple websites like Kattis, Hackerrank and Leetcode?
AlgoBase allows you to pull practice questions from these online repositories (and more!)
and consolidates them into a single application.

Do you have to prepare for mutliple interviews, and want to customize your preparations for each of them?
We got you covered! AlgoBase also allows you to create highly flexible training plans to tailor to your individual needs.

Are you a guru that has completed many problems, and want a powerful way to filter through your problems? No worries!
AlgoBase comes equipped with a comprehensive tag system and a flexible filtering mechanism for your needs.

Are you used to the speed of Command Line tools and find that GUI applications are too slow? Not a problem! AlgoBase is designed for those who prefer to use a desktop app for managing algorithm problems,
equipped with a robust Command Line Interface (CLI) while still maintaining the benefits of a Graphical User Interface (GUI).

Interested? Jump to the Section 2 to get an "Overview" of the AlgoBase, or Section 3 “Quick Start” to get started with AlgoBase!

== Overview

AlgoBase is primarily a problem management application, where users can add different algorithm problems from all kinds of sources.
Within the application, users can create training plans consisting of tasks, where each task is a problem that the user has to complete.
Upon completing a task, users can mark it as done, which contributes to the progress of their plan.

The figure below illustrates the layout of the AlgoBase application:

.Layout of AlgoBase
image::gui/AlgoBaseLayout.png[]

AlgoBase is split into following 3 panes:

** _Display Tabs_ – displays a list of items (problem, tag, plan or findrule)
** _Display Tabs_ – shows details of a specific item
** _Plan Tab_ – shows details of the current plan

// end::intro[]

== Quick Start

Expand Down Expand Up @@ -452,7 +488,8 @@ Examples:
* `setplan 10`
// end::task[]

=== Editing from GUI
// tag::gui[]
=== Editing and Deleting from the Graphical User Interface

AlgoBase currently supports editing Problems and Plans from the GUI with an intuitive layout.

Expand Down Expand Up @@ -485,14 +522,17 @@ Step 1: Select the problem / plan you want to delete by double clicking on it.
image::gui/DeleteProblemUiAction1.png[width="70%"]

Step 2: Click on the red _"Delete Problem"_ / _"Delete Plan"_ button at the bottom right.

Step 3: For _Problems_, select whether you want the problem to be removed from all existing plans.
To prevent accidental deletion, a warning dialog will appear to confirm if you would like to delete the item.
Click on the _"confirm"_ button.

.The problem is successfully deleted.
image::gui/DeleteProblemUiAction2.png[width="70%"]

Step 4: Click on _Confirm_.

// end::gui[]

// tag::tab[]
=== Tabs

There are 2 types of tabs in AlgoBase: Display and Details tabs, as seen in the figure below.
Expand Down Expand Up @@ -556,6 +596,7 @@ Examples:

* `closetab i/3` – Closes the third **details** tab
* `ct i/1` – Same effects as the previous command but in a shorter format.
// end::tab[]

=== Data Management

Expand Down
Binary file added docs/images/gui/AlgoBaseLayout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/gui/DeleteProblemUiAction1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 62 additions & 27 deletions docs/team/tiuweehan.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,57 +9,92 @@

== Overview

AlgoBase is a desktop address book application used for teaching Software Engineering principles. The user interacts with it using a CLI, and it has a GUI created with JavaFX. It is written in Java, and has about 10 kLoC.
AlgoBase is a desktop algorithmic problem manager.
The user interacts with it using a CLI, and it has a GUI created with JavaFX.
It is written in Java, and has about 20 kLoC.

== Summary of contributions

* *Code contributed*:
https://nus-cs2103-ay1920s1.github.io/tp-dashboard/#=undefined&search=tiuweehan[Code contributed]
* *Major enhancement*: added *the ability to undo/redo previous commands*
** What it does: allows the user to undo all previous commands one at a time. Preceding undo commands can be reversed by using the redo command.
** Justification: This feature improves the product significantly because a user can make mistakes in commands and the app should provide a convenient way to rectify them.
** Highlights: This enhancement affects existing commands and commands to be added in future. It required an in-depth analysis of design alternatives. The implementation too was challenging as it required changes to existing commands.
** Credits: _{mention here if you reused any code/ideas from elsewhere or if a third-party library is heavily used in the feature so that a reader can make a more accurate judgement of how much effort went into the feature}_
* *Major enhancement*: Implemented *features for the Graphical User Interface*

* *Minor enhancement*: added a history command that allows the user to navigate to previous commands using up/down keys.
** What it does: allows the user to open problems & plans in their own separate tabs,
where they can edit and delete said items in the GUI in a user-friendly manner.

* *Code contributed*: [https://github.com[Functional code]] [https://github.com[Test code]] _{give links to collated code files}_
** Justifications:

*** As our target users are Computer Science students preparing for technical interviews, they would likely want to manage multiple plans and problems concurrently.
Hence, it is important to provide an avenue for them to multitask and to switch between tasks easily. After much consideration, we decided to introduce tabbing to address this need,
as it is a convenient, intuitive and user-friendly solution – Every problem and plan is just a click away, and is self-explanatory given its prevalent in many applications today.

*** Furthermore, while the command line is fast for typing short commands, it might not be ideal in certain cases.
For example, if the user is editing large amounts of text (e.g. The description of a problem), it would be extremely tedious and time consuming to edit from the command line.
Hence, I implemented the ability to edit a problem / plan from within the tabs. Not having to deal with cumbersome details tremendously improves the overall user experience our user – it reduces their frustration and maximises the time they spend practicing for their interviews.

** Highlights: This enhancement introduces a new high level component `UiLogic`, which handle events, or `UiActions`, triggered by the user in the GUI.
It was challenging as logic of the Command line is primarily synchronous while the GUI is event-driven, and integrating the 2 architectural styles required an in-depth evaluation of design alternatives.

** Relevant pull requests:
https://github.com/AY1920S1-CS2103T-W11-1/main/pull/37[#37]
https://github.com/AY1920S1-CS2103T-W11-1/main/pull/85[#85]
https://github.com/AY1920S1-CS2103T-W11-1/main/pull/215[#215]
https://github.com/AY1920S1-CS2103T-W11-1/main/pull/200[#200]
https://github.com/AY1920S1-CS2103T-W11-1/main/pull/224[#224]

* *Minor enhancement*: Command Line Tab management.

** What it does: allows the user to manage (i.e. switch, open and close) tabs from the Command Line.

** Justification: While a GUI would make sense for tedious actions like editing, the command line is arguably faster for simpler actions like switching tabs.
Furthermore, our target users are Computer Science students who are used to command line window / tab management (through vim and emacs).
Hence, I decided to implement a command line version for tab management to optimize for these users, which will help improve their user experience.

** Relevant pull requests:
https://github.com/AY1920S1-CS2103T-W11-1/main/pull/66[#66]
https://github.com/AY1920S1-CS2103T-W11-1/main/pull/106[#106]
https://github.com/AY1920S1-CS2103T-W11-1/main/pull/147[#147]

* *Other contributions*:

** Project management:
*** Managed releases `v1.3` - `v1.5rc` (3 releases) on GitHub
*** Managed releases `v1.2` - `v1.2.1` (2 releases) on GitHub
** Enhancements to existing features:
*** Updated the GUI color scheme (Pull requests https://github.com[#33], https://github.com[#34])
*** Wrote additional tests for existing features to increase coverage from 88% to 92% (Pull requests https://github.com[#36], https://github.com[#38])

*** Enhanced GUI color scheme: Pull request
https://github.com/AY1920S1-CS2103T-W11-1/main/pull/85[#85]

*** Wrote additional tests for existing features to increase coverage from 33% to 40%: Pull request
https://github.com/AY1920S1-CS2103T-W11-1/main/pull/200[#200]

** Documentation:
*** Did cosmetic tweaks to existing contents of the User Guide: https://github.com[#14]
** Community:
*** PRs reviewed (with non-trivial review comments): https://github.com[#12], https://github.com[#32], https://github.com[#19], https://github.com[#42]
*** Contributed to forum discussions (examples: https://github.com[1], https://github.com[2], https://github.com[3], https://github.com[4])
*** Reported bugs and suggestions for other teams in the class (examples: https://github.com[1], https://github.com[2], https://github.com[3])
*** Some parts of the history feature I added was adopted by several other class mates (https://github.com[1], https://github.com[2])
** Tools:
*** Integrated a third party library (Natty) to the project (https://github.com[#42])
*** Integrated a new Github plugin (CircleCI) to the team repo
*** Added images to the User Guide that serves as visual aids.
https://github.com/AY1920S1-CS2103T-W11-1/main/pull/200[#200]
https://github.com/AY1920S1-CS2103T-W11-1/main/pull/224[#224]

_{you can add/remove categories in the list above}_
** Community:
*** PRs reviewed (with non-trivial review comments):
https://github.com/AY1920S1-CS2103T-W11-1/main/pull/24[#24]
https://github.com/AY1920S1-CS2103T-W11-1/main/pull/34[#34]
https://github.com/AY1920S1-CS2103T-W11-1/main/pull/90[#90]
https://github.com/AY1920S1-CS2103T-W11-1/main/pull/116[#116]
https://github.com/AY1920S1-CS2103T-W11-1/main/pull/117[#117]

== Contributions to the User Guide


|===
|_Given below are sections I contributed to the User Guide. They showcase my ability to write documentation targeting end-users._
|===

include::../UserGuide.adoc[tag=intro]
include::../UserGuide.adoc[tag=gui]
include::../UserGuide.adoc[tag=tab]

== Contributions to the Developer Guide

|===
|_Given below are sections I contributed to the Developer Guide. They showcase my ability to write technical documentation and the technical depth of my contributions to the project._
|===

== PROJECT: PowerPointLabs

---

_{Optionally, you may include other projects in your portfolio.}_
include::../DeveloperGuide.adoc[tag=uilogic]
include::../DeveloperGuide.adoc[tag=gui]
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,36 @@ private Id retrieveId(Model model, ModelType modelType, Index modelIndex)
}
}

/**
* Checks if a model item exists within a {@code Model}.
*/
public boolean isModelItemPresent(Model model, Id modelId) {
switch (modelType) {
case PROBLEM:
return model.getFilteredProblemList()
.stream()
.map(problem -> problem.getId())
.anyMatch((id) -> id.equals(modelId));
case PLAN:
return model.getFilteredPlanList()
.stream()
.map(plan -> plan.getId())
.anyMatch((id) -> id.equals(modelId));
default:
return false;
}
}

@Override
public CommandResult execute(Model model, CommandHistory history) throws CommandException {
WriteOnlyTabManager tabManager = model.getGuiState().getTabManager();
try {
Id modelId = retrieveId(model, modelType, modelIndex);

if (!isModelItemPresent(model, modelId)) {
throw new CommandException(String.format(MESSAGE_INVALID_INDEX, modelIndex.getOneBased()));
}

TabData tabData = new TabData(modelType, modelId);
TabCommandType result = tabManager.openDetailsTab(tabData);
switch(result) {
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/seedu/algobase/ui/PlanCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,22 @@ public void handle(MouseEvent mouseEvent) {
if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {
if (mouseEvent.getClickCount() == 2) {
logger.info("Double Clicked on Problem card with name " + plan.getPlanName());
logger.info("Opening new plan tab");
logger.info(
"Creating new UiActionDetails with type " + UiActionType.OPEN_DETAILS_TAB
+ " with a ModelType of " + ModelType.PLAN
+ " with ID of " + plan.getId()
);

uiActionExecutor.execute(new UiActionDetails(
UiActionType.OPEN_DETAILS_TAB,
ModelType.PLAN,
plan.getId()
));

logger.info(
"Creating new UiActionDetails with type " + UiActionType.SET_PLAN
+ " with ID of " + plan.getId()
);
uiActionExecutor.execute(new UiActionDetails(
UiActionType.SET_PLAN,
plan.getId()
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/seedu/algobase/ui/ProblemCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ public void handle(MouseEvent mouseEvent) {
if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {
if (mouseEvent.getClickCount() == 2) {
logger.info("Double Clicked on Problem card with name " + problem.getName());

logger.info(
"Creating new UiActionDetails with type " + UiActionType.OPEN_DETAILS_TAB
+ " with a ModelType of " + ModelType.PROBLEM
+ " with ID of " + problem.getId()
);

uiActionExecutor.execute(new UiActionDetails(
UiActionType.OPEN_DETAILS_TAB,
ModelType.PROBLEM,
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/seedu/algobase/ui/action/UiAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,28 @@

import seedu.algobase.model.Model;
import seedu.algobase.ui.UiActionException;
import seedu.algobase.ui.action.actions.CloseDetailsTabUiAction;
import seedu.algobase.ui.action.actions.DeletePlanUiAction;
import seedu.algobase.ui.action.actions.DeleteProblemUiAction;
import seedu.algobase.ui.action.actions.EditPlanUiAction;
import seedu.algobase.ui.action.actions.EditProblemUiAction;
import seedu.algobase.ui.action.actions.OpenDetailsTabUiAction;
import seedu.algobase.ui.action.actions.SetPlanUiAction;
import seedu.algobase.ui.action.actions.SwitchDetailsTabUiAction;

/**
* A class representing details of actions that take place in the UI.
*/
public abstract class UiAction {
public static final Class[] UI_ACTION_LIST = {
OpenDetailsTabUiAction.class,
CloseDetailsTabUiAction.class,
SwitchDetailsTabUiAction.class,
EditProblemUiAction.class,
DeleteProblemUiAction.class,
EditPlanUiAction.class,
DeletePlanUiAction.class,
SetPlanUiAction.class
};

/**
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/seedu/algobase/ui/action/UiActionDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,26 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Logger;

import seedu.algobase.commons.core.LogsCenter;

/**
* Stores the details of a {@code UiAction}.
*/
public class UiActionDetails {

private final Logger logger = LogsCenter.getLogger(UiActionDetails.class);
private final UiActionType actionType;
private final List<Object> internalList;

public UiActionDetails(UiActionType uiActionType, Object... objects) {
this.actionType = uiActionType;
this.internalList = new ArrayList<Object>();
add(objects);

logger.info("Created UI Action Details of type " + this.actionType
+ " and size " + this.internalList.size());
}

public void add(Object... objects) {
Expand All @@ -25,6 +33,10 @@ public Object get(int index) {
return internalList.get(index);
}

public int size() {
return internalList.size();
}

/**
* Getter for the word of the action.
*/
Expand All @@ -39,4 +51,9 @@ public UiActionDetails copy() {
UiActionDetails uiActionDetails = new UiActionDetails(actionType, internalList);
return uiActionDetails;
}

@Override
public String toString() {
return actionType.toString();
}
}
Loading

0 comments on commit 7b90544

Please sign in to comment.