use of de.unijena.cheminf.mortar.gui.views.FragmentsDataTableView in project MORTAR by FelixBaensch.
the class MainViewController method addFragmentationResultTabs.
//
/**
* Adds a tab for fragments and a tab for items (results of fragmentation)
*
* @param aFragmentationName
*/
private void addFragmentationResultTabs(String aFragmentationName) {
// fragments tab
FragmentsDataTableView tmpFragmentsDataTableView = new FragmentsDataTableView();
GridTabForTableView tmpFragmentsTab = new GridTabForTableView(Message.get("MainTabPane.fragmentsTab.title") + " - " + aFragmentationName, TabNames.Fragments.name(), tmpFragmentsDataTableView);
this.mainTabPane.getTabs().add(tmpFragmentsTab);
ObservableList<MoleculeDataModel> tmpList = FXCollections.observableArrayList(this.mapOfFragmentDataModelLists.get(aFragmentationName));
tmpFragmentsDataTableView.setItemsList(tmpList);
int tmpRowsPerPage = this.settingsContainer.getRowsPerPageSetting();
int tmpPageCount = tmpList.size() / tmpRowsPerPage;
if (tmpList.size() % tmpRowsPerPage > 0) {
tmpPageCount++;
}
Pagination tmpPagination = new Pagination(tmpPageCount, 0);
tmpPagination.setPageFactory((pageIndex) -> tmpFragmentsDataTableView.createFragmentsTableViewPage(pageIndex, this.settingsContainer));
VBox.setVgrow(tmpPagination, Priority.ALWAYS);
HBox.setHgrow(tmpPagination, Priority.ALWAYS);
tmpFragmentsTab.addPaginationToGridPane(tmpPagination, 0, 0, 2, 2);
Button tmpExportCsvButton = new Button(Message.get("MainTabPane.fragments.buttonCSV.txt"));
tmpExportCsvButton.setTooltip(new Tooltip(Message.get("MainTabPane.fragments.buttonCSV.tooltip")));
Button tmpExportPdfButton = new Button(Message.get("MainTabPane.fragments.buttonPDF.txt"));
tmpExportPdfButton.setTooltip(new Tooltip(Message.get("MainTabPane.fragments.buttonPDF.tooltip")));
Button tmpCancelExportButton = new Button(Message.get("MainTabPane.fragments.buttonCancelExport.txt"));
tmpCancelExportButton.setTooltip(new Tooltip(Message.get("MainTabPane.fragments.buttonCancelExport.tooltip")));
tmpCancelExportButton.visibleProperty().bind(this.isExportRunningProperty);
ButtonBar tmpButtonBarFragments = new ButtonBar();
tmpButtonBarFragments.setPadding(new Insets(0, 0, 0, 0));
tmpExportCsvButton.setPrefWidth(GuiDefinitions.GUI_BUTTON_WIDTH_VALUE);
tmpExportCsvButton.setPrefHeight(GuiDefinitions.GUI_BUTTON_HEIGHT_VALUE);
tmpExportPdfButton.setPrefWidth(GuiDefinitions.GUI_BUTTON_WIDTH_VALUE);
tmpExportPdfButton.setPrefHeight(GuiDefinitions.GUI_BUTTON_HEIGHT_VALUE);
tmpCancelExportButton.setPrefWidth(GuiDefinitions.GUI_BUTTON_WIDTH_VALUE);
tmpCancelExportButton.setPrefHeight(GuiDefinitions.GUI_BUTTON_HEIGHT_VALUE);
tmpButtonBarFragments.getButtons().addAll(tmpExportCsvButton, tmpExportPdfButton, tmpCancelExportButton);
tmpFragmentsTab.addNodeToGridPane(tmpButtonBarFragments, 0, 1, 1, 1);
tmpExportPdfButton.setOnAction(event -> this.exportFile(Exporter.ExportTypes.FRAGMENT_PDF_FILE));
tmpExportCsvButton.setOnAction(event -> this.exportFile(Exporter.ExportTypes.FRAGMENT_CSV_FILE));
tmpCancelExportButton.setOnAction(event -> this.interruptExport());
tmpFragmentsDataTableView.setOnSort((EventHandler<SortEvent<TableView>>) event -> {
GuiUtil.sortTableViewGlobally(event, tmpPagination, tmpRowsPerPage);
});
tmpFragmentsDataTableView.addTableViewHeightListener(this.settingsContainer);
tmpFragmentsDataTableView.getCopyMenuItem().setOnAction(event -> GuiUtil.copySelectedTableViewCellsToClipboard(tmpFragmentsDataTableView));
tmpFragmentsDataTableView.setOnKeyPressed(event -> {
if (GuiDefinitions.KEY_CODE_COPY.match(event)) {
GuiUtil.copySelectedTableViewCellsToClipboard(tmpFragmentsDataTableView);
}
});
// itemization tab
// tmpAmount is the number of fragments appearing in the molecule with the highest number of fragments
int tmpAmount = 0;
for (int i = 0; i < this.moleculeDataModelList.size(); i++) {
if (!this.moleculeDataModelList.get(i).hasMoleculeUndergoneSpecificFragmentation(aFragmentationName)) {
continue;
}
HashMap<String, Integer> tmpCurrentFragmentsMap = this.moleculeDataModelList.get(i).getFragmentFrequencyOfSpecificAlgorithm(aFragmentationName);
if (tmpCurrentFragmentsMap == null) {
// redundant, see if clause above
continue;
}
int tmpNrOfFragmentsOfCurrentMolecule = tmpCurrentFragmentsMap.size();
tmpAmount = Math.max(tmpAmount, tmpNrOfFragmentsOfCurrentMolecule);
}
ItemizationDataTableView tmpItemizationDataTableView = new ItemizationDataTableView(tmpAmount, aFragmentationName);
tmpItemizationDataTableView.setItemsList(this.moleculeDataModelList);
GridTabForTableView tmpItemizationTab = new GridTabForTableView(Message.get("MainTabPane.itemizationTab.title") + " - " + aFragmentationName, TabNames.Itemization.name(), tmpItemizationDataTableView);
this.mainTabPane.getTabs().add(tmpItemizationTab);
tmpPageCount = this.moleculeDataModelList.size() / tmpRowsPerPage;
if (this.moleculeDataModelList.size() % tmpRowsPerPage > 0) {
tmpPageCount++;
}
Pagination tmpPaginationItems = new Pagination(tmpPageCount, 0);
tmpPaginationItems.setPageFactory((pageIndex) -> tmpItemizationDataTableView.createItemizationTableViewPage(pageIndex, this.settingsContainer));
VBox.setVgrow(tmpPaginationItems, Priority.ALWAYS);
HBox.setHgrow(tmpPaginationItems, Priority.ALWAYS);
tmpItemizationTab.addPaginationToGridPane(tmpPaginationItems, 0, 0, 2, 2);
Button tmpItemizationTabExportPDfButton = new Button(Message.get("MainTabPane.itemizationTab.pdfButton.txt"));
tmpItemizationTabExportPDfButton.setTooltip(new Tooltip(Message.get("MainTabPane.itemizationTab.pdfButton.tooltip")));
Button tmpItemizationExportCsvButton = new Button(Message.get("MainTabPane.itemizationTab.csvButton.txt"));
tmpItemizationExportCsvButton.setTooltip(new Tooltip(Message.get("MainTabPane.itemizationTab.csvButton.tooltip")));
ButtonBar tmpButtonBarItemization = new ButtonBar();
tmpButtonBarItemization.setPadding(new Insets(0, 0, 0, 0));
tmpItemizationExportCsvButton.setPrefWidth(GuiDefinitions.GUI_BUTTON_WIDTH_VALUE);
tmpItemizationExportCsvButton.setPrefHeight(GuiDefinitions.GUI_BUTTON_HEIGHT_VALUE);
tmpItemizationTabExportPDfButton.setPrefWidth(GuiDefinitions.GUI_BUTTON_WIDTH_VALUE);
tmpItemizationTabExportPDfButton.setPrefHeight(GuiDefinitions.GUI_BUTTON_HEIGHT_VALUE);
tmpButtonBarItemization.getButtons().addAll(tmpItemizationExportCsvButton, tmpItemizationTabExportPDfButton, tmpCancelExportButton);
tmpItemizationTab.addNodeToGridPane(tmpButtonBarItemization, 0, 1, 1, 1);
tmpItemizationExportCsvButton.setOnAction(event -> this.exportFile(Exporter.ExportTypes.ITEM_CSV_FILE));
tmpItemizationTabExportPDfButton.setOnAction(event -> this.exportFile(Exporter.ExportTypes.ITEM_PDF_FILE));
tmpItemizationDataTableView.setOnSort((EventHandler<SortEvent<TableView>>) event -> {
GuiUtil.sortTableViewGlobally(event, tmpPaginationItems, tmpRowsPerPage);
});
tmpItemizationDataTableView.addTableViewHeightListener(this.settingsContainer);
tmpItemizationDataTableView.getCopyMenuItem().setOnAction(event -> GuiUtil.copySelectedTableViewCellsToClipboard(tmpItemizationDataTableView));
tmpItemizationDataTableView.setOnKeyPressed(event -> {
if (GuiDefinitions.KEY_CODE_COPY.match(event)) {
GuiUtil.copySelectedTableViewCellsToClipboard(tmpItemizationDataTableView);
}
});
//
this.mainTabPane.getSelectionModel().select(tmpFragmentsTab);
}
Aggregations