Skip to content

Commit

Permalink
Merge branch 'develop' into write-mark-as-important
Browse files Browse the repository at this point in the history
  • Loading branch information
Skaty committed Oct 19, 2016
2 parents c42b915 + aa6de9c commit a1d6455
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 36 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ allprojects {
mavenCentral()
maven { url "https://repo.eclipse.org/content/repositories/egit-releases/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://mvnrepository.com/artifact/joda-time/joda-time"}
}

// This part is similar to global variables
Expand All @@ -49,7 +48,8 @@ allprojects {
}

dependencies {
compile 'joda-time:joda-time:2.9.4'
compile "org.ocpsoft.prettytime:prettytime:4.0.0.Final"
compile "org.ocpsoft.prettytime:prettytime-nlp:4.0.0.Final"
compile "org.controlsfx:controlsfx:$controlsFxVersion"
compile "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonDataTypeVersion"
Expand Down
48 changes: 26 additions & 22 deletions src/main/java/seedu/task/model/task/DateTime.java
Original file line number Diff line number Diff line change
@@ -1,50 +1,55 @@
package seedu.task.model.task;
/**
package seedu.address.model.task;
import java.time.LocalDateTime;

import seedu.address.commons.exceptions.IllegalValueException;
**/
import java.time.Instant;
import java.util.Date;
import java.util.List;
import java.util.Optional;

import org.ocpsoft.prettytime.nlp.PrettyTimeParser;

import seedu.task.commons.exceptions.IllegalValueException;

/**
* Represents a Date and Time in the task list
* Guarantees: immutable; is valid as declared in {@link #isValidDateTime(String)}
*/
/**
public class DateTime {

public static final String MESSAGE_DATETIME_CONSTRAINTS = "Person date numbers should only contain numbers";
//TODO: Set Regex for DateTime
public static final String DATETIME_VALIDATION_REGEX = "\\d+";
public static final String MESSAGE_DATETIME_CONSTRAINTS = "Date entered should be in a relatively standard form (e.g. in X hours, tomorrow, 20 Jan 2016, 5pm)";

public final LocalDateTime value;
public final Optional<Instant> value;

/**
* Validates given Date and Time entered by the user.
*
* @throws IllegalValueException if given phone string is invalid.
* @throws IllegalValueException if given date/time string is invalid.
*/
/**
public DateTime(String dateTime) throws IllegalValueException {
assert dateTime != null;
dateTime = dateTime.trim();
if (!isValidDateTime(dateTime)) {
if (dateTime.equals("")) {
this.value = Optional.empty();
return;
}
List<Date> possibleDates = new PrettyTimeParser().parse(dateTime);
if (!isValidDateTime(possibleDates)) {
throw new IllegalValueException(MESSAGE_DATETIME_CONSTRAINTS);
}
//TODO: Parse DateTime?
//this.value = dateTime;

this.value = Optional.of(possibleDates.get(0).toInstant());
}

/**
* Returns true if a given string is a valid datetime in required format
* Returns true if a given string is a valid date/time that can be parsed
*
* @param test output from date/time parser
*/
/**
public static boolean isValidDateTime(String test) {
return test.matches(DATETIME_VALIDATION_REGEX);
public static boolean isValidDateTime(List<Date> test) {
return !test.isEmpty() && (test.size() == 1);
}

@Override
public String toString() {
return value;
return (value.isPresent()) ? value.get().toString() : "";
}

@Override
Expand All @@ -60,4 +65,3 @@ public int hashCode() {
}

}
**/
49 changes: 49 additions & 0 deletions src/main/java/seedu/task/ui/TagCard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package seedu.task.ui;

import javafx.fxml.FXML;

import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import seedu.task.model.tag.Tag;

public class TagCard extends UiPart{

private static final String FXML = "TagListCard.fxml";

@FXML
private VBox tagCardPane;
@FXML
private Label name;

private Tag tag;

public TagCard(){

}

public static TagCard load(Tag tag){
TagCard card = new TagCard();
card.tag = tag;
return UiPartLoader.loadUiPart(card);
}

@FXML
public void initialize() {
name.setText(tag.tagName);
}

public VBox getLayout() {
return tagCardPane;
}

@Override
public void setNode(Node node) {
tagCardPane = (VBox) node;
}

@Override
public String getFxmlPath() {
return FXML;
}
}
65 changes: 65 additions & 0 deletions src/main/java/seedu/task/ui/TagListPanel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package seedu.task.ui;

import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.control.SplitPane;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;
import seedu.task.commons.core.LogsCenter;
import seedu.task.model.tag.Tag;

import java.util.logging.Logger;

/**
* Panel for the tag list.
*/
public class TagListPanel extends UiPart {
private final Logger logger = LogsCenter.getLogger(TagListPanel.class);
private static final String FXML = "TagListPanel.fxml";
private FlowPane panel;
private AnchorPane placeHolderPane;

public TagListPanel() {
super();
}

@Override
public void setNode(Node node) {
panel = (FlowPane) node;
}

@Override
public String getFxmlPath() {
return FXML;
}

@Override
public void setPlaceholder(AnchorPane pane) {
this.placeHolderPane = pane;
}

public static TagListPanel load(Stage primaryStage, AnchorPane taskListPlaceholder,
ObservableList<Tag> tagList) {
TagListPanel tagListPanel =
UiPartLoader.loadUiPart(primaryStage, taskListPlaceholder, new TagListPanel());
tagListPanel.configure(tagList);
return tagListPanel;
}

private void configure(ObservableList<Tag> tagList) {
setConnections(tagList);
addToPlaceholder();
}

private void setConnections(ObservableList<Tag> taskList) {
for (Tag tg : taskList) {
panel.getChildren().add(TagCard.load(tg).getLayout());
}
}

private void addToPlaceholder() {
SplitPane.setResizableWithParent(placeHolderPane, false);
placeHolderPane.getChildren().add(panel);
}
}
15 changes: 4 additions & 11 deletions src/main/java/seedu/task/ui/TaskCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import seedu.task.model.task.ReadOnlyTask;

Expand All @@ -17,17 +18,12 @@ public class TaskCard extends UiPart{
private Label name;
@FXML
private Label id;
// @FXML
// private Label phone;
// @FXML
// private Label address;
// @FXML
// private Label email;
@FXML
private Label tags;
private AnchorPane tagsListPlaceholder;

private ReadOnlyTask task;
private int displayedIndex;
private TagListPanel tagListPanel;

public TaskCard(){

Expand All @@ -44,10 +40,7 @@ public static TaskCard load(ReadOnlyTask task, int displayedIndex){
public void initialize() {
name.setText(task.getName().taskName);
id.setText(displayedIndex + ". ");
// phone.setText(person.getPhone().value);
// address.setText(person.getAddress().value);
// email.setText(person.getEmail().value);
tags.setText(task.tagsString());
tagListPanel = TagListPanel.load(getPrimaryStage(), tagsListPlaceholder, task.getTags().getInternalList());
}

public HBox getLayout() {
Expand Down
13 changes: 13 additions & 0 deletions src/main/resources/view/DarkTheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,17 @@

#filterField, #taskListPanel, #taskWebpage {
-fx-effect: innershadow(gaussian, black, 10, 0, 0, 0);
}

#tagCardPane {
-fx-background-color: black;
-fx-border-color: black;
-fx-border-width: 1;
-fx-border-style: solid;
-fx-border-radius: 10 10 10 10;
-fx-background-radius: 10 10 10 10;
}

#tagCardPane #tagName {
-fx-text-fill: white;
}
11 changes: 11 additions & 0 deletions src/main/resources/view/TagListCard.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.*?>

<VBox id="tagCardPane" fx:id="tagCardPane" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label id="tagName" fx:id="name" text="sample text" style="-fx-padding: 0 2.5 0 2.5;" />
</children>
</VBox>

12 changes: 12 additions & 0 deletions src/main/resources/view/TagListPanel.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.layout.*?>
<?import java.net.URL?>
<FlowPane hgap="5" vgap="5" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seedu.task.ui.TagListPanel" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<stylesheets>
<URL value="@DarkTheme.css" />
<URL value="@Extensions.css" />
</stylesheets>
<children>
</children>
</FlowPane>
2 changes: 1 addition & 1 deletion src/main/resources/view/TaskListCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
<Label fx:id="id" styleClass="cell_big_label"></Label>
<Label fx:id="name" text="\$first" styleClass="cell_big_label"/>
</HBox>
<Label fx:id="tags" styleClass="cell_small_label" text="\$tags" />
</children>
</HBox>
<AnchorPane fx:id="tagsListPlaceholder" />
</children>
</VBox>
</children>
Expand Down

0 comments on commit a1d6455

Please sign in to comment.