Search in sources :

Example 1 with MoleculesDataTableView

use of de.unijena.cheminf.mortar.gui.views.MoleculesDataTableView 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);
    });
}
Also used : EventHandler(javafx.event.EventHandler) Button(javafx.scene.control.Button) MainView(de.unijena.cheminf.mortar.gui.views.MainView) SettingsContainer(de.unijena.cheminf.mortar.model.settings.SettingsContainer) VBox(javafx.scene.layout.VBox) FragmentsDataTableView(de.unijena.cheminf.mortar.gui.views.FragmentsDataTableView) Task(javafx.concurrent.Task) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) TabPane(javafx.scene.control.TabPane) BasicDefinitions(de.unijena.cheminf.mortar.model.util.BasicDefinitions) WindowEvent(javafx.stage.WindowEvent) Message(de.unijena.cheminf.mortar.message.Message) TableView(javafx.scene.control.TableView) Alert(javafx.scene.control.Alert) HBox(javafx.scene.layout.HBox) ButtonBar(javafx.scene.control.ButtonBar) Set(java.util.Set) KeyEvent(javafx.scene.input.KeyEvent) Observable(javafx.beans.Observable) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) Importer(de.unijena.cheminf.mortar.model.io.Importer) MoleculesDataTableView(de.unijena.cheminf.mortar.gui.views.MoleculesDataTableView) Platform(javafx.application.Platform) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) Objects(java.util.Objects) Priority(javafx.scene.layout.Priority) BooleanProperty(javafx.beans.property.BooleanProperty) List(java.util.List) FragmentationService(de.unijena.cheminf.mortar.model.fragmentation.FragmentationService) ObservableList(javafx.collections.ObservableList) FileUtil(de.unijena.cheminf.mortar.model.util.FileUtil) Pagination(javafx.scene.control.Pagination) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Scene(javafx.scene.Scene) MoleculeDataModel(de.unijena.cheminf.mortar.model.data.MoleculeDataModel) RadioMenuItem(javafx.scene.control.RadioMenuItem) FragmentDataModel(de.unijena.cheminf.mortar.model.data.FragmentDataModel) ItemizationDataTableView(de.unijena.cheminf.mortar.gui.views.ItemizationDataTableView) ButtonType(javafx.scene.control.ButtonType) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) IDataTableView(de.unijena.cheminf.mortar.gui.views.IDataTableView) Level(java.util.logging.Level) GridTabForTableView(de.unijena.cheminf.mortar.gui.panes.GridTabForTableView) Insets(javafx.geometry.Insets) ChemFileTypes(de.unijena.cheminf.mortar.model.io.ChemFileTypes) Tooltip(javafx.scene.control.Tooltip) ChemUtil(de.unijena.cheminf.mortar.model.util.ChemUtil) KeyCode(javafx.scene.input.KeyCode) GuiUtil(de.unijena.cheminf.mortar.gui.util.GuiUtil) Label(javafx.scene.control.Label) GuiDefinitions(de.unijena.cheminf.mortar.gui.util.GuiDefinitions) LogUtil(de.unijena.cheminf.mortar.model.util.LogUtil) File(java.io.File) EventType(javafx.event.EventType) ExecutionException(java.util.concurrent.ExecutionException) ToggleGroup(javafx.scene.control.ToggleGroup) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) SortEvent(javafx.scene.control.SortEvent) Stage(javafx.stage.Stage) Tab(javafx.scene.control.Tab) IMoleculeFragmenter(de.unijena.cheminf.mortar.model.fragmentation.algorithm.IMoleculeFragmenter) Image(javafx.scene.image.Image) Exporter(de.unijena.cheminf.mortar.model.io.Exporter) InputStream(java.io.InputStream) Pagination(javafx.scene.control.Pagination) SortEvent(javafx.scene.control.SortEvent) ButtonBar(javafx.scene.control.ButtonBar) Insets(javafx.geometry.Insets) GridTabForTableView(de.unijena.cheminf.mortar.gui.panes.GridTabForTableView) Button(javafx.scene.control.Button) Tooltip(javafx.scene.control.Tooltip) Label(javafx.scene.control.Label) MoleculesDataTableView(de.unijena.cheminf.mortar.gui.views.MoleculesDataTableView)

Aggregations

GridTabForTableView (de.unijena.cheminf.mortar.gui.panes.GridTabForTableView)1 GuiDefinitions (de.unijena.cheminf.mortar.gui.util.GuiDefinitions)1 GuiUtil (de.unijena.cheminf.mortar.gui.util.GuiUtil)1 FragmentsDataTableView (de.unijena.cheminf.mortar.gui.views.FragmentsDataTableView)1 IDataTableView (de.unijena.cheminf.mortar.gui.views.IDataTableView)1 ItemizationDataTableView (de.unijena.cheminf.mortar.gui.views.ItemizationDataTableView)1 MainView (de.unijena.cheminf.mortar.gui.views.MainView)1 MoleculesDataTableView (de.unijena.cheminf.mortar.gui.views.MoleculesDataTableView)1 Message (de.unijena.cheminf.mortar.message.Message)1 FragmentDataModel (de.unijena.cheminf.mortar.model.data.FragmentDataModel)1 MoleculeDataModel (de.unijena.cheminf.mortar.model.data.MoleculeDataModel)1 FragmentationService (de.unijena.cheminf.mortar.model.fragmentation.FragmentationService)1 IMoleculeFragmenter (de.unijena.cheminf.mortar.model.fragmentation.algorithm.IMoleculeFragmenter)1 ChemFileTypes (de.unijena.cheminf.mortar.model.io.ChemFileTypes)1 Exporter (de.unijena.cheminf.mortar.model.io.Exporter)1 Importer (de.unijena.cheminf.mortar.model.io.Importer)1 SettingsContainer (de.unijena.cheminf.mortar.model.settings.SettingsContainer)1 BasicDefinitions (de.unijena.cheminf.mortar.model.util.BasicDefinitions)1 ChemUtil (de.unijena.cheminf.mortar.model.util.ChemUtil)1 FileUtil (de.unijena.cheminf.mortar.model.util.FileUtil)1