use of javafx.scene.control.SortEvent in project MORTAR by FelixBaensch.
the class MainViewController method openMoleculesTab.
//
/**
* Opens molecules tab
*/
private void openMoleculesTab() {
this.moleculesDataTableView = new MoleculesDataTableView();
this.moleculesDataTableView.setItemsList(this.moleculeDataModelList);
GridTabForTableView tmpMoleculesTab = new GridTabForTableView(Message.get("MainTabPane.moleculesTab.title"), TabNames.Molecules.name(), this.moleculesDataTableView);
this.mainTabPane.getTabs().add(tmpMoleculesTab);
int tmpRowsPerPage = this.settingsContainer.getRowsPerPageSetting();
int tmpPageCount = this.moleculeDataModelList.size() / tmpRowsPerPage;
if (this.moleculeDataModelList.size() % tmpRowsPerPage > 0) {
tmpPageCount++;
}
Pagination tmpPagination = new Pagination(tmpPageCount, 0);
tmpPagination.setPageFactory((pageIndex) -> this.moleculesDataTableView.createMoleculeTableViewPage(pageIndex, this.settingsContainer));
VBox.setVgrow(tmpPagination, Priority.ALWAYS);
HBox.setHgrow(tmpPagination, Priority.ALWAYS);
tmpMoleculesTab.addPaginationToGridPane(tmpPagination, 0, 0, 2, 2);
this.fragmentationButton = new Button(Message.get("MainTabPane.moleculesTab.fragmentButton.text"));
ButtonBar tmpButtonBar = new ButtonBar();
tmpButtonBar.setPadding(new Insets(0, 0, 0, 0));
this.fragmentationButton.setPrefWidth(GuiDefinitions.GUI_BUTTON_WIDTH_VALUE);
this.fragmentationButton.setMinWidth(GuiDefinitions.GUI_BUTTON_WIDTH_VALUE);
this.fragmentationButton.setMaxWidth(GuiDefinitions.GUI_BUTTON_WIDTH_VALUE);
this.fragmentationButton.setPrefHeight(GuiDefinitions.GUI_BUTTON_HEIGHT_VALUE);
tmpButtonBar.getButtons().add(this.fragmentationButton);
tmpButtonBar.setButtonMinWidth(GuiDefinitions.GUI_BUTTON_WIDTH_VALUE);
Label tmpLabel = new Label();
tmpLabel.textProperty().bind(this.fragmentationService.selectedFragmenterNamePropertyProperty());
Tooltip tmpTooltip = new Tooltip();
tmpTooltip.textProperty().bind(this.fragmentationService.selectedFragmenterNamePropertyProperty());
tmpLabel.setTooltip(tmpTooltip);
HBox.setHgrow(tmpLabel, Priority.ALWAYS);
tmpButtonBar.getButtons().add(tmpLabel);
this.cancelFragmentationButton = new Button(Message.get("MainTabPane.moleculesTab.cancelFragmentationButton.text"));
this.cancelFragmentationButton.setTooltip(new Tooltip(Message.get("MainTabPane.moleculesTab.cancelFragmentationButton.tooltip")));
this.cancelFragmentationButton.setPrefWidth(GuiDefinitions.GUI_BUTTON_WIDTH_VALUE);
this.cancelFragmentationButton.setMinWidth(GuiDefinitions.GUI_BUTTON_WIDTH_VALUE);
this.cancelFragmentationButton.setMaxWidth(GuiDefinitions.GUI_BUTTON_WIDTH_VALUE);
this.cancelFragmentationButton.setPrefHeight(GuiDefinitions.GUI_BUTTON_HEIGHT_VALUE);
this.cancelFragmentationButton.setVisible(false);
tmpButtonBar.getButtons().add(this.cancelFragmentationButton);
tmpMoleculesTab.addNodeToGridPane(tmpButtonBar, 0, 1, 1, 1);
this.fragmentationButton.setOnAction(event -> {
this.startFragmentation();
});
this.cancelFragmentationButton.setOnAction(event -> {
this.interruptFragmentation();
});
this.moleculesDataTableView.addTableViewHeightListener(this.settingsContainer);
this.moleculesDataTableView.getCopyMenuItem().setOnAction(event -> GuiUtil.copySelectedTableViewCellsToClipboard(this.moleculesDataTableView));
this.moleculesDataTableView.setOnKeyPressed(event -> {
if (GuiDefinitions.KEY_CODE_COPY.match(event)) {
GuiUtil.copySelectedTableViewCellsToClipboard(this.moleculesDataTableView);
}
});
this.moleculesDataTableView.setOnSort((EventHandler<SortEvent<TableView>>) event -> {
GuiUtil.sortTableViewGlobally(event, tmpPagination, tmpRowsPerPage);
});
}
use of javafx.scene.control.SortEvent 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