Skip to content

Commit

Permalink
Merge pull request nus-cs2103-AY1718S2#43 from Robert-Peng/Major1.1
Browse files Browse the repository at this point in the history
Use CalendarFX to display Calendar View
  • Loading branch information
wynonaK authored Mar 23, 2018
2 parents 1eed293 + 5f11068 commit c6b29cd
Show file tree
Hide file tree
Showing 18 changed files with 213 additions and 34 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ jacocoTestReport {

dependencies {
String testFxVersion = '4.0.7-alpha'

compile fileTree(dir: 'lib', include: '*.jar')
compile group: 'org.fxmisc.easybind', name: 'easybind', version: '1.0.3'
compile group: 'org.controlsfx', name: 'controlsfx', version: '8.40.11'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.7.0'
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.7.4'
compile group: 'com.google.guava', name: 'guava', version: '19.0'

//compile 'com.calendarfx:calendar:8.4.2'
//compile "org.jfxtras:jfxtras-all:8.0-r6-SNAPSHOT"
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.testfx', name: 'testfx-core', version: testFxVersion
testCompile group: 'org.testfx', name: 'testfx-junit', version: testFxVersion
Expand Down
20 changes: 20 additions & 0 deletions lib/README-EXT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
This directory contains third-party jar files that are required
by CalendarFX. The framework can not work without these.

- controlsfx-xxx.jar

Custom controls developed as part of the open source project ControlsFX.

- fontawesomefx-commons-xxx.jar

Common support code for web fonts in JavaFX.

- fontawesomefx-fontawesome-xxx.jar

The fontawesome font for JavaFX.

- license4j-1.4.0.jar

Support for licensing keys.

Updated by Robert
Binary file added lib/calendarfx-recurrence-8.4.0.jar
Binary file not shown.
Binary file added lib/calendarfx-view-8.4.0.jar
Binary file not shown.
Binary file added lib/controlsfx-8.40.11.jar
Binary file not shown.
Binary file added lib/fontawesomefx-commons-8.13.jar
Binary file not shown.
Binary file added lib/fontawesomefx-fontawesome-4.7.0-1.jar
Binary file not shown.
Binary file added lib/license4j-1.4.0.jar
Binary file not shown.
1 change: 1 addition & 0 deletions src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.logging.Logger;

import com.google.common.eventbus.Subscribe;
//import com.calendarfx.view.CalendarView;

import javafx.application.Application;
import javafx.application.Platform;
Expand Down
106 changes: 106 additions & 0 deletions src/main/java/seedu/address/ui/CalendarWindow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package seedu.address.ui;

import java.time.LocalDate;
import java.time.LocalTime;

import com.calendarfx.model.Calendar;
//import com.calendarfx.model.CalendarEvent;
import com.calendarfx.model.CalendarSource;
//import com.calendarfx.model.Entry;
//import com.calendarfx.model.Interval;
import com.calendarfx.view.CalendarView;

import javafx.application.Platform;
import javafx.collections.ObservableList;
//import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.layout.Region;
import seedu.address.model.person.Person;
//import javafx.application.Application;
//import javafx.application.Platform;
//import javafx.scene.Scene;
//import javafx.stage.Stage;

//import java.time.Duration;

//import java.time.LocalDateTime;

//import java.time.ZoneId;
//import java.util.List;

//import seedu.address.MainApp;
//import seedu.address.commons.core.LogsCenter;
//import seedu.address.commons.events.ui.PersonPanelSelectionChangedEvent;




/**
*
*/
public class CalendarWindow extends UiPart<Region> {

public static final String DEFAULT_PAGE = "CalendarPanel.fxml";

private ObservableList<Person> ownerList;
private Calendar calendar;

@FXML
private CalendarView calendarView;

/**
*
* @param OwnerList
*/
public CalendarWindow(ObservableList<Person> ownerList) {
super(DEFAULT_PAGE);
this.ownerList = ownerList;
calendarView = new CalendarView();

CalendarSource newCalendarSource = new CalendarSource("My Calendars");

calendarView.getCalendarSources().add(newCalendarSource);

calendarView.setRequestedTime(LocalTime.now());

calendar = new Calendar("Appointments");


CalendarSource mycalendarSource = new CalendarSource("My Appointments");
mycalendarSource.getCalendars().addAll(calendar);

calendarView.getCalendarSources().add(mycalendarSource);

Thread updateTimeThread = new Thread("Calendar: Update Time Thread") {
@Override
public void run() {
while (true) {
Platform.runLater(() -> {
calendarView.setToday(LocalDate.now());
calendarView.setTime(LocalTime.now());
});

try {
// update every 10 seconds
sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}

}
};
};

updateTimeThread.setPriority(Thread.MIN_PRIORITY);
updateTimeThread.setDaemon(true);
updateTimeThread.start();

}

public CalendarView getRoot() {
return this.calendarView;
}

}


16 changes: 10 additions & 6 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.logging.Logger;

import com.google.common.eventbus.Subscribe;
//import com.calendarfx.view.CalendarView;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
Expand Down Expand Up @@ -35,13 +36,14 @@ public class MainWindow extends UiPart<Stage> {
private Logic logic;

// Independent Ui parts residing in this Ui container
private BrowserPanel browserPanel;
private CalendarWindow calendarWindow;
//private BrowserPanel browserPanel;
private PersonListPanel personListPanel;
private Config config;
private UserPrefs prefs;

@FXML
private StackPane browserPlaceholder;
private StackPane calendarPlaceholder;

@FXML
private StackPane commandBoxPlaceholder;
Expand Down Expand Up @@ -117,8 +119,9 @@ private void setAccelerator(MenuItem menuItem, KeyCombination keyCombination) {
* Fills up all the placeholders of this window.
*/
void fillInnerParts() {
browserPanel = new BrowserPanel();
browserPlaceholder.getChildren().add(browserPanel.getRoot());
//browserPanel = new BrowserPanel();
calendarWindow = new CalendarWindow(logic.getFilteredPersonList());
this.calendarPlaceholder.getChildren().add(calendarWindow.getRoot());

personListPanel = new PersonListPanel(logic.getFilteredPersonList());
personListPanelPlaceholder.getChildren().add(personListPanel.getRoot());
Expand Down Expand Up @@ -186,9 +189,10 @@ public PersonListPanel getPersonListPanel() {
return this.personListPanel;
}

void releaseResources() {

/*void releaseResources() {
browserPanel.freeResources();
}
}*/

@Subscribe
private void handleShowHelpEvent(ShowHelpRequestEvent event) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/ui/UiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void start(Stage primaryStage) {
public void stop() {
prefs.updateLastUsedGuiSetting(mainWindow.getCurrentGuiSetting());
mainWindow.hide();
mainWindow.releaseResources();
//mainWindow.releaseResources();
}

private void showFileOperationAlertAndWait(String description, String details, Throwable cause) {
Expand Down
16 changes: 16 additions & 0 deletions src/main/resources/view/CalendarPanel.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>

<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.web.WebView?>

<StackPane xmlns = "http://javafx.com/javafx/">
<children>
<BorderPane prefHeight="200.0" prefWidth="200.0" />
</children>
</StackPane>
2 changes: 1 addition & 1 deletion src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<StackPane fx:id="personListPanelPlaceholder" VBox.vgrow="ALWAYS"/>
</VBox>

<StackPane fx:id="browserPlaceholder" prefWidth="340" >
<StackPane fx:id="calendarPlaceholder" prefWidth="200" >
<padding>
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
Expand Down
15 changes: 15 additions & 0 deletions src/test/java/guitests/guihandles/CalendarPanelHandle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package guitests.guihandles;

import javafx.scene.Node;

/**
*
*/
public class CalendarPanelHandle extends NodeHandle<Node> {

public static final String CALENDARPANEL_ID = "#calendarPlaceholder";

protected CalendarPanelHandle(Node calendarPanelNode) {
super(calendarPanelNode);
}
}
16 changes: 12 additions & 4 deletions src/test/java/guitests/guihandles/MainWindowHandle.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ public class MainWindowHandle extends StageHandle {
private final CommandBoxHandle commandBox;
private final StatusBarFooterHandle statusBarFooter;
private final MainMenuHandle mainMenu;
private final BrowserPanelHandle browserPanel;
private final CalendarPanelHandle calendarPanel;
//private final BrowserPanelHandle browserPanel;


public MainWindowHandle(Stage stage) {
super(stage);
Expand All @@ -22,7 +24,8 @@ public MainWindowHandle(Stage stage) {
commandBox = new CommandBoxHandle(getChildNode(CommandBoxHandle.COMMAND_INPUT_FIELD_ID));
statusBarFooter = new StatusBarFooterHandle(getChildNode(StatusBarFooterHandle.STATUS_BAR_PLACEHOLDER));
mainMenu = new MainMenuHandle(getChildNode(MainMenuHandle.MENU_BAR_ID));
browserPanel = new BrowserPanelHandle(getChildNode(BrowserPanelHandle.BROWSER_ID));
calendarPanel = new CalendarPanelHandle(getChildNode(CalendarPanelHandle.CALENDARPANEL_ID));
//browserPanel = new BrowserPanelHandle(getChildNode(BrowserPanelHandle.BROWSER_ID));
}

public PersonListPanelHandle getPersonListPanel() {
Expand All @@ -45,7 +48,12 @@ public MainMenuHandle getMainMenu() {
return mainMenu;
}

public BrowserPanelHandle getBrowserPanel() {
return browserPanel;
public CalendarPanelHandle getCalendarPanel() {
return calendarPanel;
}

//public BrowserPanelHandle getBrowserPanel() {
// return browserPanel;
//}

}
Loading

0 comments on commit c6b29cd

Please sign in to comment.