Skip to content

Commit

Permalink
GUI For Duke$$$ (#223)
Browse files Browse the repository at this point in the history
* Updating javafx dependencies for Graphical User Interface.
* Implements the following GUI Elements:
- Task List Display
- Balance Chart

* Fixed a bug in PieChart and Parser.
* Fixed a bug in displaying of tasks.
* Implemented the bare-bones breakdownChart (stacked bar chart)
* Added in breakdownChart functionality for GUI
* Soft integration of GUI with Duke$$$.
More bugs to be researched on.

* GUI Partial Integration.
Requires:
 - Command Line Output Emulator
 - Balance Figure
 - Hover Over Concept

* PieChart bug fixed.
CommandLineDisplay in development.

* Implemented toggling between screens
* Resolved Merge Conflicts
* Near-complete integration of GUI with existing Features.
* Quality of Life adjustments to the Toast Msgs
* Resolved Checkstyle Violations
* Added the Home and CLI Commands so that the user can navigate between the two.
* Fixed Bugs found in CommandConvert with GUI.
* Amended the GUI to be compatible with the new Architecture.

WARNING: GUI Pulls Wallet AND TaskList into its layer for execution.

Signed-off-by: Mudaafi <[email protected]>
  • Loading branch information
Mudaafi authored Nov 7, 2019
1 parent 595c52f commit a719e86
Show file tree
Hide file tree
Showing 65 changed files with 1,477 additions and 121 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ src/main/resources/docs/
bin/

# Customized
savedData.txt
savedData.txt
savedWallet.txt
savedTask.txt
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'application'
id 'checkstyle'
id 'com.github.johnrengelman.shadow' version '5.1.0'
id 'org.openjfx.javafxplugin' version '0.0.7'
}

group 'seedu.duke'
Expand All @@ -19,7 +20,7 @@ dependencies {

application {
// Change this to your main class.
mainClassName = "Duke"
mainClassName = "main.Duke"
}

run {
Expand All @@ -39,4 +40,9 @@ shadowJar {

test {
useJUnitPlatform()
}

javafx {
version = "11.0.2"
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
5 changes: 4 additions & 1 deletion savedWallet.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
out $5.0 /date 2019-02-01 /tags food
1000.0
out $250.0 /date 2019-11-07 /tags
out $100.0 /date 2019-11-07 /tags
in $100.0 /date 2019-11-07 /tags
23 changes: 0 additions & 23 deletions src/main/java/Duke.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
package executor.command;
package executor;

import duke.exception.DukeException;
import executor.accessors.AccessDeny;
import executor.accessors.Accessor;
import executor.command.Command;
import executor.command.CommandError;
import executor.command.CommandType;
import storage.StorageManager;
import utils.AccessType;
import utils.InfoCapsule;

public class Executor {
Expand All @@ -15,7 +22,6 @@ public Executor(String taskPath, String walletPath) {

/**
* Parses the user input and executes the Command specified.
*
* @param userInput User input from the CLI
* @return True if the Command executed calls for an ExitRequest, false otherwise
*/
Expand All @@ -42,7 +48,33 @@ public static Command createCommand(CommandType commandType, String userInput) {
return c;
}

public void saveAllData() {
this.storageLayer.saveAllData();
public InfoCapsule access(AccessType accessType, String argsStr) {
Accessor accessor = Executor.createAccessor(accessType, argsStr);
accessor.execute(this.storageLayer);
return accessor.getInfoCapsule();
}

public static Accessor createAccessor(AccessType accessType, String argsStr) {
Accessor accessor;
try {
accessor = (Accessor) accessType.getAccessClass().getDeclaredConstructor().newInstance();
} catch (Exception e) {
accessor = new AccessDeny(argsStr);
}
return accessor;
}

public InfoCapsule saveAllData() {
InfoCapsule infoCapsule = new InfoCapsule();
try {
this.storageLayer.saveAllData();
} catch (DukeException e) {
infoCapsule.setCodeError();
infoCapsule.setOutputStr(e.getMessage());
return infoCapsule;
}
infoCapsule.setCodeToast();
infoCapsule.setOutputStr("Saved All Data Succesfully.\n");
return infoCapsule;
}
}
21 changes: 21 additions & 0 deletions src/main/java/executor/accessors/AccessDeny.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package executor.accessors;

import storage.StorageManager;
import ui.UiCode;
import utils.AccessType;

public class AccessDeny extends Accessor {

public AccessDeny(String argsStr) {
super();
this.accessType = AccessType.DENY;
this.argsStr = argsStr;
}

@Override
public void execute(StorageManager storageManager) {
this.infoCapsule.setCodeError();
this.infoCapsule.setOutputStr("Access Denied");

}
}
41 changes: 41 additions & 0 deletions src/main/java/executor/accessors/AccessPieChartData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package executor.accessors;

import duke.exception.DukeException;
import javafx.collections.FXCollections;
import javafx.scene.chart.PieChart;
import storage.StorageManager;
import ui.UiCode;
import utils.AccessType;

public class AccessPieChartData extends Accessor {

/**
* Constructor for AccessPieChartData
*/
public AccessPieChartData() {
super();
this.accessType = AccessType.PIE_CHART_DATA;
}

@Override
public void execute(StorageManager storageManager) {
this.infoCapsule.setUiCode(UiCode.UPDATE);
Double walletBalance;
Double walletExpenses;
try {
walletBalance = storageManager.getWalletBalance();
walletExpenses = storageManager.getWalletExpenses();
} catch (DukeException e) {
e.printStackTrace();
walletBalance = 0.0;
walletExpenses = 0.0;
this.infoCapsule.setUiCode(UiCode.ERROR);
this.infoCapsule.setOutputStr(e.getMessage());
}
this.infoCapsule.setPieChartData(FXCollections.observableArrayList(
new PieChart.Data("Expenses",
walletExpenses),
new PieChart.Data("Balance",
walletBalance - walletExpenses)));
}
}
22 changes: 22 additions & 0 deletions src/main/java/executor/accessors/AccessTaskList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package executor.accessors;

import storage.StorageManager;
import ui.UiCode;
import utils.AccessType;

public class AccessTaskList extends Accessor {

/**
* Constructor for AccessTaskList Class
*/
public AccessTaskList() {
super();
this.accessType = AccessType.TASKLIST;
}

@Override
public void execute(StorageManager storageManager) {
infoCapsule.setUiCode(UiCode.UPDATE);
infoCapsule.setTaskList(storageManager.getTaskList());
}
}
23 changes: 23 additions & 0 deletions src/main/java/executor/accessors/AccessWallet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package executor.accessors;

import duke.exception.DukeException;
import storage.StorageManager;
import ui.UiCode;
import utils.AccessType;

public class AccessWallet extends Accessor {

/**
* Constructor for AccessWallet Class
*/
public AccessWallet() {
super();
this.accessType = AccessType.WALLET;
}

@Override
public void execute(StorageManager storageManager) {
this.infoCapsule.setUiCode(UiCode.UPDATE);
this.infoCapsule.setWallet(storageManager.getWallet());
}
}
27 changes: 27 additions & 0 deletions src/main/java/executor/accessors/AccessWalletBalance.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package executor.accessors;

import duke.exception.DukeException;
import storage.StorageManager;
import ui.UiCode;

public class AccessWalletBalance extends Accessor {

/**
* Constructor for AccessWalletBalance Class
*/
public AccessWalletBalance() {
super();
}

@Override
public void execute(StorageManager storageManager) {
try {
Double walletBalance = storageManager.getWalletBalance();
this.infoCapsule.setUiCode(UiCode.UPDATE);
this.infoCapsule.setOutputDouble(walletBalance);
} catch (DukeException e) {
this.infoCapsule.setUiCode(UiCode.ERROR);
this.infoCapsule.setOutputStr(e.getMessage());
}
}
}
31 changes: 31 additions & 0 deletions src/main/java/executor/accessors/AccessWalletExpenses.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package executor.accessors;

import duke.exception.DukeException;
import storage.StorageManager;
import ui.UiCode;
import utils.AccessType;

public class AccessWalletExpenses extends Accessor {

/**
* Constructor for AccessExpenses
*/
public AccessWalletExpenses() {
super();
this.accessType = AccessType.EXPENSES;
}

@Override
public void execute(StorageManager storageManager) {
this.infoCapsule.setUiCode(UiCode.UPDATE);
Double expenses;
try {
expenses = storageManager.getWalletExpenses();
} catch (DukeException e) {
this.infoCapsule.setUiCode(UiCode.ERROR);
this.infoCapsule.setOutputStr(e.getMessage());
return;
}
this.infoCapsule.setOutputDouble(expenses);
}
}
39 changes: 39 additions & 0 deletions src/main/java/executor/accessors/Accessor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package executor.accessors;

import storage.StorageManager;
import ui.UiCode;
import utils.AccessType;
import utils.InfoCapsule;

public abstract class Accessor {
protected AccessType accessType;
protected String argsStr;
protected InfoCapsule infoCapsule;

public Accessor() {
this.accessType = AccessType.DENY;
this.infoCapsule = new InfoCapsule();
infoCapsule.setUiCode(UiCode.ERROR);
infoCapsule.setOutputStr("Command was not executed.\n");
}

/**
* Executes the Accessor Method to Obtain Information for the UI
* @return InfoCapsule containing the desired information
*/
public abstract void execute(StorageManager storageManager);

// Setters & Getters

public InfoCapsule getInfoCapsule() {
return this.infoCapsule;
}

public AccessType getAccessType() {
return this.accessType;
}

public String getArgsStr() {
return this.argsStr;
}
}
5 changes: 3 additions & 2 deletions src/main/java/executor/command/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import executor.task.TaskList;
import storage.StorageManager;
import ui.Wallet;
import ui.UiCode;
import utils.InfoCapsule;

import java.util.ArrayList;
Expand All @@ -15,6 +15,7 @@ public abstract class Command {
protected String userInput = null;
protected CommandType commandType;
protected String description = "NO DESCRIPTION";
protected TaskList taskList;


// Constructor
Expand All @@ -24,7 +25,7 @@ public abstract class Command {
*/
public Command() {
this.infoCapsule = new InfoCapsule();
infoCapsule.setCodeError();
infoCapsule.setUiCode(UiCode.ERROR);
infoCapsule.setOutputStr("Command was not executed.\n");
}

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/executor/command/CommandAdd.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ public class CommandAdd extends Command {
private double entryOne;
private double entryTwo;

//Constructor

/**
* Constructor for CommandListMonYear subCommand Class.
* @param userInput String is the user input from the CLI
Expand Down
1 change: 0 additions & 1 deletion src/main/java/executor/command/CommandAddReceipt.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package executor.command;

import interpreter.Parser;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/executor/command/CommandBlank.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class CommandBlank extends Command {
public CommandBlank(String userInput) {
super();
this.userInput = userInput;
this.description = "Prints a line separator";
this.description = "Does Nothing";
this.commandType = CommandType.BLANK;
}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/executor/command/CommandBye.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public CommandBye(String userInput) {
this.commandType = CommandType.BYE;
}

@Override
public void execute(StorageManager storageManager) {
this.infoCapsule.setCodeExit();
}
Expand Down
Loading

0 comments on commit a719e86

Please sign in to comment.