Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Calendar] ui update #117

Merged
merged 6 commits into from
Nov 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 93 additions & 43 deletions src/main/java/seedu/address/ui/CalendarPanel.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
//@@author SHININGGGG
package seedu.address.ui;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

import java.util.Calendar;
import java.util.logging.Logger;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.geometry.Pos;
import javafx.scene.layout.GridPane;

import javafx.scene.layout.Region;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;

import seedu.address.commons.core.LogsCenter;
import seedu.address.model.CalendarInfo;

Expand All @@ -24,22 +33,85 @@ public class CalendarPanel extends UiPart<Region> {
private int firstDay;

@FXML
private GridPane calendarView = new GridPane();
private Text currentDate;

@FXML
private Label date1;
private GridPane calendarView;

public CalendarPanel() {
super(FXML);
calendar = calendarInfo.getCalendar();
firstDay = calendarInfo.firstDay;
setGridPane(calendar);
firstDay = calendarInfo.firstDay - 1;
setCurrentDate();
setCalendar();
registerAsAnEventHandler(this);
}

private void setGridPane (Calendar calendar) {
private void setCurrentDate () {

//Text currentDate = new Text();
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDateTime now = LocalDateTime.now();
currentDate.setText("\n " + dtf.format(now));
currentDate.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 15));
currentDate.setFill(Color.ORANGE);
//currentDate.setLayoutY(20);
//currentDate.setLayoutX(0);
//currentDate.setLayoutY(0);
}

private void setOverview() {
//System.out.println("The first day of the whole month is " + firstDay);
calendarView.setMinSize(200, 200);
calendarView.setVgap(30);
calendarView.setHgap(20);
calendarView.setAlignment(Pos.CENTER);
//calendarView.add(currentDate, 3, 0);

for (int j = 0; j < 7; j++) {
if (j == 0) {
Text text = new Text("Sun");
text.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 20));
text.setFill(Color.WHEAT);
calendarView.add(text, 0, 0);
} else if (j == 1) {
Text text = new Text("Mon");
text.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 20));
text.setFill(Color.WHEAT);
calendarView.add(text, 1, 0);
} else if (j == 2) {
Text text = new Text("Tue");
text.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 20));
text.setFill(Color.WHEAT);
calendarView.add(text, 2, 0);
} else if (j == 3) {
Text text = new Text("Wed");
text.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 20));
text.setFill(Color.WHEAT);
calendarView.add(text, 3, 0);
} else if (j == 4) {
Text text = new Text("Thur");
text.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 20));
text.setFill(Color.WHEAT);
calendarView.add(text, 4, 0);
} else if (j == 5) {
Text text = new Text("Fri");
text.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 20));
text.setFill(Color.WHEAT);
calendarView.add(text, 5, 0);
} else {
Text text = new Text("Sat");
text.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 20));
text.setFill(Color.WHEAT);
calendarView.add(text, 6, 0);
}
}
}

private void setDays () {

int numOfDays;
int week;
int week = 1;
int day = firstDay;
if (calendar.get(Calendar.MONTH) == Calendar.JANUARY
|| calendar.get(Calendar.MONTH) == Calendar.MARCH
Expand All @@ -54,43 +126,21 @@ private void setGridPane (Calendar calendar) {
} else {
numOfDays = 30;
}
//for (int i = 0; i < numOfDays; i++) {
week = calendar.get(Calendar.WEEK_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH, 1);
date1.setText(Integer.toString(1));
calendarView.add(date1, (day % 7), week);
day++;
//}
}
/*
private void setEventHandlerForSelectionChangeEvent() {
calendarView.getSelectionModel().selectedItemProperty()
.addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
logger.fine("Selection in person list panel changed to : '" + newValue + "'");
raise(new PersonPanelSelectionChangedEvent(newValue));
}
});
}
*/

/**
* Custom {@code ListCell} that displays the graphics of a {@code Person} using a {@code PersonCard}.
*/
/*
class PersonListViewCell extends ListCell<Person> {
@Override
protected void updateItem(Person person, boolean empty) {
super.updateItem(person, empty);

if (empty || person == null) {
setGraphic(null);
setText(null);
} else {
setGraphic(new PersonCard(person, getIndex() + 1).getRoot());

for (int i = 1; i <= numOfDays; i++) {
Text text = new Text(Integer.toString(i));
text.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 20));
text.setFill(Color.WHEAT);
calendarView.add(text, day, week);
day = (day + 1) % 7;
if (day == 0) {
week++;
}
}
}
*/

private void setCalendar () {
setOverview();
setDays();
}
}
11 changes: 8 additions & 3 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TextInputControl;
import javafx.scene.input.KeyCombination;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import seedu.address.commons.core.Config;
Expand Down Expand Up @@ -53,7 +53,7 @@ public class MainWindow extends UiPart<Stage> {
private StackPane browserPlaceholder;

@FXML
private GridPane calendarPlaceholder;
private StackPane calendarPlaceholder;

@FXML
private StackPane commandBoxPlaceholder;
Expand Down Expand Up @@ -141,7 +141,8 @@ void fillInnerParts() {
//browserPlaceholder.getChildren().add(browserPanel.getRoot());

calendarPanel = new CalendarPanel();
calendarPlaceholder.getChildren().add(calendarPanel.getRoot());
Node x = calendarPanel.getRoot();
calendarPlaceholder.getChildren().add(x);

expenditureListPanel = new ExpenditureListPanel(logic.getFilteredExpenditureList());
expenditureListPanelPlaceholder.getChildren().add(expenditureListPanel.getRoot());
Expand Down Expand Up @@ -228,6 +229,10 @@ public ExpenditureListPanel getExpenditureListPanel() {
return expenditureListPanel;
}

public CalendarPanel getCalendarPanel() {
return calendarPanel;
}

void releaseResources() {
browserPanel.freeResources();
}
Expand Down
121 changes: 6 additions & 115 deletions src/main/resources/view/CalendarPanel.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -8,118 +8,9 @@
<?import javafx.geometry.Insets?>

<?import javafx.scene.layout.GridPane?>

<GridPane xmlns:fx="http://javafx.com/fxml" hgap="30" vgap="30">
<padding><Insets top="25" right="25" bottom="10" left="25"/></padding>

<Label text="Sun"
GridPane.columnIndex="0" GridPane.rowIndex="0"/>
<Label text="Mon"
GridPane.columnIndex="1" GridPane.rowIndex="0"/>
<Label text="Tue"
GridPane.columnIndex="2" GridPane.rowIndex="0"/>
<Label text="Wed"
GridPane.columnIndex="3" GridPane.rowIndex="0"/>
<Label text="Thur"
GridPane.columnIndex="4" GridPane.rowIndex="0"/>
<Label text="Fri"
GridPane.columnIndex="5" GridPane.rowIndex="0"/>
<Label text="Sat"
GridPane.columnIndex="6" GridPane.rowIndex="0"/>


<Label text="1"
GridPane.columnIndex="0" GridPane.rowIndex="2"
GridPane.columnSpan="2"/>

<Label text="2"
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
<Label text="3"
GridPane.columnIndex="2" GridPane.rowIndex="2"
GridPane.columnSpan="2"/>

<Label text="4"
GridPane.columnIndex="3" GridPane.rowIndex="2"/>
<Label text="5"
GridPane.columnIndex="4" GridPane.rowIndex="2"
GridPane.columnSpan="2"/>

<Label text="6"
GridPane.columnIndex="5" GridPane.rowIndex="2"/>
<Label text="7"
GridPane.columnIndex="6" GridPane.rowIndex="2"
GridPane.columnSpan="2"/>

<Label text="8"
GridPane.columnIndex="0" GridPane.rowIndex="3"/>
<Label text="9"
GridPane.columnIndex="1" GridPane.rowIndex="3"
GridPane.columnSpan="2"/>

<Label text="10"
GridPane.columnIndex="2" GridPane.rowIndex="3"/>
<Label text="11"
GridPane.columnIndex="3" GridPane.rowIndex="3"
GridPane.columnSpan="2"/>

<Label text="12"
GridPane.columnIndex="4" GridPane.rowIndex="3"/>
<Label text="13"
GridPane.columnIndex="5" GridPane.rowIndex="3"
GridPane.columnSpan="2"/>

<Label text="14"
GridPane.columnIndex="6" GridPane.rowIndex="3"/>
<Label text="15"
GridPane.columnIndex="0" GridPane.rowIndex="4"
GridPane.columnSpan="2"/>

<Label text="16"
GridPane.columnIndex="1" GridPane.rowIndex="4"/>
<Label text="17"
GridPane.columnIndex="2" GridPane.rowIndex="4"
GridPane.columnSpan="2"/>

<Label text="18"
GridPane.columnIndex="3" GridPane.rowIndex="4"/>
<Label text="19"
GridPane.columnIndex="4" GridPane.rowIndex="4"
GridPane.columnSpan="2"/>

<Label text="20"
GridPane.columnIndex="5" GridPane.rowIndex="4"/>
<Label text="21"
GridPane.columnIndex="6" GridPane.rowIndex="4"
GridPane.columnSpan="2"/>

<Label text="22"
GridPane.columnIndex="0" GridPane.rowIndex="5"/>
<Label text="23"
GridPane.columnIndex="1" GridPane.rowIndex="5"
GridPane.columnSpan="2"/>

<Label text="24"
GridPane.columnIndex="2" GridPane.rowIndex="5"/>
<Label text="25"
GridPane.columnIndex="3" GridPane.rowIndex="5"
GridPane.columnSpan="2"/>

<Label text="26"
GridPane.columnIndex="4" GridPane.rowIndex="5"/>
<Label text="27"
GridPane.columnIndex="5" GridPane.rowIndex="5"
GridPane.columnSpan="2"/>

<Label text="28"
GridPane.columnIndex="6" GridPane.rowIndex="5"/>
<Label text="29"
GridPane.columnIndex="0" GridPane.rowIndex="6"
GridPane.columnSpan="2"/>

<Label text="30"
GridPane.columnIndex="1" GridPane.rowIndex="6"/>
<Label fx:id="date1" styleClass="cell_small_label" text="\$phone" />



</GridPane>
<?import javafx.scene.text.Text?>
<VBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<Label text="Calendar"/>
<Text fx:id="currentDate" />
<GridPane fx:id="calendarView" VBox.vgrow="ALWAYS" />
</VBox>
10 changes: 5 additions & 5 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@
</StackPane>

<SplitPane id="splitPane" fx:id="splitPane" dividerPositions="0.4" VBox.vgrow="ALWAYS">
<VBox fx:id="taskList" minWidth="340" prefWidth="340" SplitPane.resizableWithParent="false">
<VBox fx:id="taskList" minWidth="340" maxWidth="340" prefWidth="340" SplitPane.resizableWithParent="false">
<padding>
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
<StackPane fx:id="taskListPanelPlaceholder" VBox.vgrow="ALWAYS"/>
</VBox>

<GridPane fx:id="calendarPlaceholder" prefWidth="340" >
<VBox fx:id="calendar" minWidth="340" prefWidth="340" SplitPane.resizableWithParent="false">
<padding>
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
<StackPane fx:id="calendarPlaceholder" VBox.vgrow="ALWAYS"/>
</VBox>

</GridPane>

<VBox fx:id="expenditureList" minWidth="340" prefWidth="340" SplitPane.resizableWithParent="false">
<VBox fx:id="expenditureList" minWidth="340" maxWidth="340" prefWidth="340" SplitPane.resizableWithParent="false">
<padding>
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
Expand Down