Skip to content
Snippets Groups Projects
Commit f60c3821 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

implemented date picker for chart categories

parent 972c92c6
No related branches found
No related tags found
2 merge requests!104merge v_1_2_0 into master,!100merge charts into v_1_2_0
package de.deadlocker8.budgetmaster.ui;
import java.time.LocalDate;
import java.util.ArrayList;
import org.joda.time.DateTime;
import de.deadlocker8.budgetmaster.logic.CategoryInOutSum;
import de.deadlocker8.budgetmaster.logic.ServerConnection;
import de.deadlocker8.budgetmaster.logic.chartGenerators.PieChartGenerator;
import fontAwesome.FontIcon;
import fontAwesome.FontIconType;
import javafx.fxml.FXML;
import javafx.scene.control.Accordion;
import javafx.scene.control.Button;
import javafx.scene.control.DateCell;
import javafx.scene.control.DatePicker;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.util.Callback;
import logger.Logger;
public class ChartController implements Refreshable
......@@ -20,6 +29,7 @@ public class ChartController implements Refreshable
@FXML private HBox hboxChartCategories;
@FXML private DatePicker datePickerEnd;
@FXML private AnchorPane anchorPaneChartMonth;
@FXML private Button buttonChartCategoriesShow;
private Controller controller;
......@@ -27,22 +37,46 @@ public class ChartController implements Refreshable
{
this.controller = controller;
// TODO design, chart chooser
anchorPaneMain.setStyle("-fx-background-color: #F4F4F4;");
hboxChartCategories.setStyle("-fx-background-color: #F4F4F4;");
anchorPaneChartMonth.setStyle("-fx-background-color: #F4F4F4;");
}
FontIcon iconShow = new FontIcon(FontIconType.CHECK);
iconShow.setSize(16);
iconShow.setColor(Color.WHITE);
buttonChartCategoriesShow.setStyle("-fx-background-color: #2E79B9;");
buttonChartCategoriesShow.setGraphic(iconShow);
datePickerEnd.setDayCellFactory(new Callback<DatePicker, DateCell>()
{
@Override
public void refresh()
public DateCell call(DatePicker param)
{
return new DateCell()
{
@Override
public void updateItem(LocalDate item, boolean empty)
{
super.updateItem(item, empty);
if (item.isBefore(datePickerStart.getValue().plusDays(1)))
{
setDisable(true);
setStyle("-fx-background-color: #ffc0cb;");
}
}
};
}
});
}
public void chartCategoriesShow()
{
// TODO example
// TODO date range chooser
// TODO check wether starDate and EndDate are included and are working correctly
DateTime startDate = DateTime.parse(datePickerStart.getValue().toString());
DateTime endDate = DateTime.parse(datePickerEnd.getValue().toString());
try
{
ServerConnection connection = new ServerConnection(controller.getSettings());
ArrayList<CategoryInOutSum> sums = connection.getCategoryInOutSumForMonth(controller.getCurrentDate().withDayOfMonth(1), controller.getCurrentDate().dayOfMonth().withMaximumValue());
ArrayList<CategoryInOutSum> sums = connection.getCategoryInOutSumForMonth(startDate, endDate);
hboxChartCategories.getChildren().clear();
......@@ -56,6 +90,21 @@ public class ChartController implements Refreshable
catch(Exception e)
{
Logger.error(e);
//TODO
//controller.showConnectionErrorAlert(e.getMessage());
}
}
@Override
public void refresh()
{
//chart categories
LocalDate startDate = LocalDate.parse(controller.getCurrentDate().withDayOfMonth(1).toString("yyyy-MM-dd"));
LocalDate endDate = LocalDate.parse(controller.getCurrentDate().dayOfMonth().withMaximumValue().toString("yyy-MM-dd"));
datePickerStart.setValue(startDate);
datePickerEnd.setValue(endDate);
chartCategoriesShow();
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Accordion?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.DatePicker?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TitledPane?>
......@@ -41,6 +42,14 @@
</font>
</Label>
<DatePicker fx:id="datePickerEnd" />
<Button fx:id="buttonChartCategoriesShow" mnemonicParsing="false" onAction="#chartCategoriesShow">
<font>
<Font name="System Bold" size="12.0" />
</font>
<HBox.margin>
<Insets left="15.0" />
</HBox.margin>
</Button>
</children>
<HBox.margin>
<Insets left="15.0" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment