fixed bug in minor actions
@@ -31,13 +31,9 @@ import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
-import javafx.scene.control.Alert;
-import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.application.Platform;
-import javafx.stage.FileChooser;
-
import javax.swing.*;
import java.awt.*;
@@ -105,8 +101,13 @@ public class ResultWindowController {
private void AddIdentityClick(ActionEvent ae){
// TODO: handle Button event
- int index = resultTable.getSelectionModel().getSelectedIndex();
- ResultFormula formula = resultTable.getItems().get(index);
+ ResultFormula formula = resultTable.getSelectionModel().getSelectedItem();
+
+ if(formula == null) {
+ MZmineCore.getDesktop().displayMessage(null,
+ "Select one result to add as compound identity");
+ return;
+ }
SimplePeakIdentity newIdentity = new SimplePeakIdentity(formula.getFormulaAsString());
peakListRow.addPeakIdentity(newIdentity, false);
@@ -159,8 +160,6 @@ public class ResultWindowController {
}
-
-
@FXML
private void viewIsotopeClick(ActionEvent ae){
// TODO: handle Button event
@@ -184,8 +183,13 @@ public class ResultWindowController {
@FXML
private void copyClick(ActionEvent ae){
// TODO: handle Button event
- int index = resultTable.getSelectionModel().getSelectedIndex();
- ResultFormula formula = resultTable.getItems().get(index);
+ ResultFormula formula = resultTable.getSelectionModel().getSelectedItem();
+ if(formula == null)
+ {
+ MZmineCore.getDesktop().displayMessage(null,
+ "Select one result to copy");
+ return;
+ }
String formulaString = formula.getFormulaAsString();
StringSelection stringSelection = new StringSelection(formulaString);
@@ -196,8 +200,12 @@ public class ResultWindowController {
@FXML
private void showsMSClick(ActionEvent ae){
// TODO: handle Button event
- int index = resultTable.getSelectionModel().getSelectedIndex();
- ResultFormula formula = resultTable.getItems().get(index);
+ ResultFormula formula = resultTable.getSelectionModel().getSelectedItem();
+ if(formula == null){
+ MZmineCore.getDesktop().displayMessage(null,
+ "Select one result to show MS score");
+ return;
+ }
Feature bestPeak = peakListRow.getBestPeak();
