protected Node getTaskView() { if (taskTableView == null) { taskTableView = new TreeTableView<>(new TreeItem<>()); taskTableView.setShowRoot(false); } if (taskDescriptionTreeTableColumn == null) { taskDescriptionTreeTableColumn = new TaskDescriptionTreeTableColumn(); taskDescriptionTreeTableColumn.setPrefWidth(300); taskDescriptionTreeTableColumn.setMinWidth(300); } if (taskStatusTreeTableColumn == null) { taskStatusTreeTableColumn = new TaskStatusTreeTableColumn(); taskStatusTreeTableColumn.setPrefWidth(30); taskStatusTreeTableColumn.setMinWidth(30); } AnchorPane anchorPane = new AnchorPane(taskTableView); anchorPane.setPadding(new Insets(6)); AnchorPane.setTopAnchor(taskTableView, 0d); AnchorPane.setRightAnchor(taskTableView, 0d); AnchorPane.setBottomAnchor(taskTableView, 0d); AnchorPane.setLeftAnchor(taskTableView, 0d); return anchorPane; }
public void writeDataToExcel(Sheet sheet) { LOGGER.debug("[{}] Exporting data to excel", getText()); List<ExcelColumnRenderer> columnRendererList = new ArrayList<>(); columnRendererList.add(new TaskStatusExcelColumn()); columnRendererList.add(new TaskDescriptionExcelColumn()); TimerangeProvider timerangeProvider = fetchTimereportContext.get().getTimerangeProvider(); LocalDate startDate = timerangeProvider.getStartDate(); LocalDate endDate = timerangeProvider.getEndDate(); long amountOfDaysToDisplay = ChronoUnit.DAYS.between(startDate, endDate); for (int days = 0; days <= amountOfDaysToDisplay; days++) { LocalDate currentColumnDate = timerangeProvider.getStartDate().plus(days, ChronoUnit.DAYS); String displayDate = FormattingUtil.formatDate(currentColumnDate); columnRendererList.add(new WorklogExcelColumn(displayDate, currentColumnDate)); } columnRendererList.add(new TaskWorklogSummaryExcelColumn()); TreeItem<DisplayRow> root = taskTableView.getRoot(); ObservableList<TreeItem<DisplayRow>> children = root.getChildren(); for (int columnIndex = 0; columnIndex < columnRendererList.size(); columnIndex++) { ExcelColumnRenderer excelColumnRenderer = columnRendererList.get(columnIndex); excelColumnRenderer.renderCells( columnIndex, sheet, children, fetchTimereportContext.get().getGroupByCategory().isPresent()); } // autosize column widths for (int i = 0; i < columnRendererList.size(); i++) { sheet.autoSizeColumn(i); } }
protected void refreshWorklogTableViewAndResults() { // return early if no data present or still the same data // as the last time this tab was active Optional<FetchTimereportContext> reportContextOptional = this.fetchTimereportContext; if (!reportContextOptional.isPresent() || !reportContextOptional.get().getResult().isPresent() || !resultToDisplayChangedSinceLastRender) { LOGGER.debug( "[{}] No results to display or data not changed. Not refreshing TableView and data", getText()); return; } SettingsUtil.Settings settings = SettingsUtil.loadSettings(); if (settings.isShowStatistics() && statisticsView == null || !settings.isShowStatistics() && statisticsView != null) { // statistics are disabled and were previously rendered // or statistics are enabled and weren't rendered before // update content view LOGGER.debug("Updating contentView since settings for statistics seemed to have changed"); setContent(getContentNode()); } FetchTimereportContext timereportContext = reportContextOptional.get(); TimerangeProvider timerangeProvider = timereportContext.getTimerangeProvider(); // render the table columns if the timerange changed from last result if (!lastUsedTimerangeProvider.isPresent() || !lastUsedTimerangeProvider.get().equals(timerangeProvider) || (lastCollapseState.isPresent() && lastCollapseState.get() != settings.getCollapseState()) || (lastHighlightState.isPresent() && lastHighlightState.get() != settings.getHighlightState())) { LOGGER.debug( "[{}] Regenerating columns for timerange {}", getText(), timerangeProvider.getReportTimerange().name()); taskTableView.getColumns().clear(); taskTableView.getColumns().add(taskStatusTreeTableColumn); taskTableView.getColumns().add(taskDescriptionTreeTableColumn); // render tables for all days in the selected timerange // e.g. timerange current month renders a column for // each day of the current month long amountOfDaysToDisplay = ChronoUnit.DAYS.between(timerangeProvider.getStartDate(), timerangeProvider.getEndDate()); for (int days = 0; days <= amountOfDaysToDisplay; days++) { LocalDate currentColumnDate = timerangeProvider.getStartDate().plus(days, ChronoUnit.DAYS); String displayDate = FormattingUtil.formatDate(currentColumnDate); // worklog column taskTableView.getColumns().add(new WorklogTreeTableColumn(displayDate, currentColumnDate)); } // also add another summary per task column taskTableView.getColumns().add(new TaskWorklogSummaryTreeTableColumn()); lastUsedTimerangeProvider = Optional.of(timerangeProvider); lastCollapseState = Optional.of(settings.getCollapseState()); lastHighlightState = Optional.of(settings.getHighlightState()); } // refresh data LOGGER.debug("[{}] Refreshing items in TableView", getText()); TreeItem<DisplayRow> root = taskTableView.getRoot(); root.getChildren().clear(); DisplayData displayData = getDisplayData(timereportContext, resultToDisplayChangedSinceLastRender); root.getChildren().addAll(displayData.getTreeRows()); resultToDisplayChangedSinceLastRender = false; }