Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/CS2103AUG2016-F11-C1/main
Browse files Browse the repository at this point in the history
…into listByDiffTypeUpdated

Update list controller to use with renderer

* 'master' of https://github.com/CS2103AUG2016-F11-C1/main: (74 commits)
  Make final var static.
  TodoListDB curly braces.
  Extract UNMATCHED_QUOTES_MESSAGE constant.
  Tokenizer curly braces.
  AddController curly braces.
  Set everything to final.
  Update Codacy badge.
  Add javadoc in ConfigController
  Abstract renderConfig into concern
  Cleanup everyone's unused imports.
  UpdateController renderIndex
  UndoController renderIndex
  UncompleteTaskController renderIndex
  RedoController renderIndex
  ListController renderIndex
  DestroyController renderIndex
  CompleteTaskController renderIndex
  AddController renderIndex.
  Renderer concern.
  Tokenizer is a concern.
  ...

# Conflicts:
#	src/main/java/seedu/todo/controllers/ListController.java
  • Loading branch information
ChaseTiong committed Oct 18, 2016
2 parents ebb6cc8 + 14c0e4f commit 2b941ea
Show file tree
Hide file tree
Showing 40 changed files with 1,242 additions and 277 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# GetShitDone
[![Build Status](https://travis-ci.org/CS2103AUG2016-F11-C1/main.svg?branch=master)](https://travis-ci.org/CS2103AUG2016-F11-C1/main)
[![Coverage Status](https://coveralls.io/repos/github/CS2103AUG2016-F11-C1/main/badge.svg?branch=master)](https://coveralls.io/github/CS2103AUG2016-F11-C1/main?branch=master)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/e68fd3dd0c0249aa98cd52186c3fdcd7)](https://www.codacy.com/app/louietyj/main?utm_source=github.com&utm_medium=referral&utm_content=CS2103AUG2016-F11-C1/main&utm_campaign=Badge_Grade)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/bb54debec79f4383924b89c9131865fc)](https://www.codacy.com/app/CS2103AUG2016-F11-C1/main?utm_source=github.com&utm_medium=referral&utm_content=CS2103AUG2016-F11-C1/main&utm_campaign=Badge_Grade)

<img src="docs/images/GetShitDone-Ui.png" width="600">

Expand Down
30 changes: 23 additions & 7 deletions src/main/java/seedu/todo/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,37 @@ public class MainApp extends Application {

private static final String MESSAGE_WELCOME = "Welcome! What would like to get done today?";

private static Config config;
private static String configFilePath;

protected UiManager ui;
protected Config config;

public MainApp() {}

@Override
public void init() throws Exception {
super.init();

// Read app param
configFilePath = getApplicationParameter("config");

// Initialize config from config file, or create a new one.
config = initConfig(getApplicationParameter("config"));
config = initConfig();

// Initialize logging
initLogging(config);
initLogging(getConfig());

// Initialize events center
initEventsCenter();

// Initialize UI config
UiManager.initialize(config);
UiManager.initialize(getConfig());
ui = UiManager.getInstance();

// Load DB
if (!TodoListDB.getInstance().load())
if (!TodoListDB.getInstance().load()) {
TodoListDB.getInstance().save();
}
}

@Override
Expand Down Expand Up @@ -97,16 +103,18 @@ private void initLogging(Config config) {
LogsCenter.init(config);
}

private Config initConfig(String configFilePath) {
private Config initConfig() {
Config initializedConfig;
String configFilePathUsed;

configFilePathUsed = Config.DEFAULT_CONFIG_FILE;

if(configFilePath != null) {
if (configFilePath != null) {
logger.info("Custom Config file specified " + configFilePath);
configFilePathUsed = configFilePath;
}

configFilePath = configFilePathUsed;

logger.info("Using config file : " + configFilePathUsed);

Expand All @@ -128,6 +136,14 @@ private Config initConfig(String configFilePath) {

return initializedConfig;
}

public static String getConfigFilePath() {
return configFilePath;
}

public static Config getConfig() {
return config;
}

private void initEventsCenter() {
EventsCenter.getInstance().registerHandler(this);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/seedu/todo/commons/EphemeralDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ protected EphemeralDB() {
// Prevent instantiation.
}

/**
* Gets the singleton instance of the EphemeralDB.
*
* @return EphemeralDB
*/
public static EphemeralDB getInstance() {
if (instance == null) {
instance = new EphemeralDB();
Expand Down
59 changes: 29 additions & 30 deletions src/main/java/seedu/todo/commons/core/Config.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package seedu.todo.commons.core;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.logging.Level;

Expand All @@ -13,9 +16,7 @@ public class Config {
// Config values customizable through config file
private String appTitle = "GetShitDone";
private Level logLevel = Level.INFO;
private String userPrefsFilePath = "preferences.json";
private String addressBookFilePath = "data/todo.xml";
private String addressBookName = "MyTodos";
private String databaseFilePath = "database.json";


public Config() {
Expand All @@ -37,28 +38,12 @@ public void setLogLevel(Level logLevel) {
this.logLevel = logLevel;
}

public String getUserPrefsFilePath() {
return userPrefsFilePath;
public String getDatabaseFilePath() {
return databaseFilePath;
}

public void setUserPrefsFilePath(String userPrefsFilePath) {
this.userPrefsFilePath = userPrefsFilePath;
}

public String getAddressBookFilePath() {
return addressBookFilePath;
}

public void setAddressBookFilePath(String addressBookFilePath) {
this.addressBookFilePath = addressBookFilePath;
}

public String getAddressBookName() {
return addressBookName;
}

public void setAddressBookName(String addressBookName) {
this.addressBookName = addressBookName;
public void setDatabaseFilePath(String databaseFilePath) {
this.databaseFilePath = databaseFilePath;
}


Expand All @@ -75,25 +60,39 @@ public boolean equals(Object other) {

return Objects.equals(appTitle, o.appTitle)
&& Objects.equals(logLevel, o.logLevel)
&& Objects.equals(userPrefsFilePath, o.userPrefsFilePath)
&& Objects.equals(addressBookFilePath, o.addressBookFilePath)
&& Objects.equals(addressBookName, o.addressBookName);
&& Objects.equals(databaseFilePath, o.databaseFilePath);
}

@Override
public int hashCode() {
return Objects.hash(appTitle, logLevel, userPrefsFilePath, addressBookFilePath, addressBookName);
return Objects.hash(appTitle, logLevel, databaseFilePath);
}

@Override
public String toString(){
StringBuilder sb = new StringBuilder();
sb.append("App title : " + appTitle);
sb.append("\nCurrent log level : " + logLevel);
sb.append("\nPreference file Location : " + userPrefsFilePath);
sb.append("\nLocal data file location : " + addressBookFilePath);
sb.append("\nAddressBook name : " + addressBookName);
sb.append("\nLocal data file location : " + databaseFilePath);
return sb.toString();
}

public List<ConfigDefinition> getDefinitions() {
ConfigDefinition configAppTitle = new ConfigDefinition("appTitle", "App Title", appTitle);
ConfigDefinition configDatabaseFilePath = new ConfigDefinition("databaseFilePath", "Database File Path", databaseFilePath);

return Arrays.asList(configAppTitle, configDatabaseFilePath);
}

public List<String> getDefinitionsNames() {
List<ConfigDefinition> definitions = getDefinitions();
List<String> names = new ArrayList<>();

for (ConfigDefinition definition : definitions) {
names.add(definition.getConfigName());
}

return names;
}

}
25 changes: 25 additions & 0 deletions src/main/java/seedu/todo/commons/core/ConfigDefinition.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package seedu.todo.commons.core;

public class ConfigDefinition {
private String configName;
private String configDescription;
private String configValue;

public ConfigDefinition(String configName, String configDescription, String configValue) {
this.configName = configName;
this.configDescription = configDescription;
this.configValue = configValue;
}

public String getConfigName() {
return configName;
}

public String getConfigDescription() {
return configDescription;
}

public String getConfigValue() {
return configValue;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package seedu.todo.commons.exceptions;

public class CannotConfigureException extends Exception {
public CannotConfigureException(String message) {
super(message);
}
}

0 comments on commit 2b941ea

Please sign in to comment.