diff --git a/gui/src/main/java/pl/marcinchwedczuk/elfviewer/gui/mainwindow/MainWindow.fxml b/gui/src/main/java/pl/marcinchwedczuk/elfviewer/gui/mainwindow/MainWindow.fxml
index 2d7041d..5c7c703 100644
--- a/gui/src/main/java/pl/marcinchwedczuk/elfviewer/gui/mainwindow/MainWindow.fxml
+++ b/gui/src/main/java/pl/marcinchwedczuk/elfviewer/gui/mainwindow/MainWindow.fxml
@@ -36,7 +36,7 @@
-
+
diff --git a/gui/src/main/java/pl/marcinchwedczuk/elfviewer/gui/mainwindow/MainWindow.java b/gui/src/main/java/pl/marcinchwedczuk/elfviewer/gui/mainwindow/MainWindow.java
index 4c8b3af..46350e9 100644
--- a/gui/src/main/java/pl/marcinchwedczuk/elfviewer/gui/mainwindow/MainWindow.java
+++ b/gui/src/main/java/pl/marcinchwedczuk/elfviewer/gui/mainwindow/MainWindow.java
@@ -1,14 +1,15 @@
package pl.marcinchwedczuk.elfviewer.gui.mainwindow;
import javafx.application.Platform;
-import javafx.beans.value.ChangeListener;
-import javafx.beans.value.ObservableValue;
+import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.input.KeyCode;
+import javafx.scene.input.KeyCodeCombination;
+import javafx.scene.input.KeyCombination;
import javafx.scene.input.KeyEvent;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
@@ -103,6 +104,9 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
}
});
+ // Allow selecting cells
+ tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
+ tableView.getSelectionModel().setCellSelectionEnabled(true);
tableView.setPlaceholder(new Label("Select data to display"));
recentlyOpenFiles = new RecentlyOpenFiles(recentlyOpen, this::loadElfFile);
@@ -135,6 +139,29 @@ private void recreateTreeView() {
rootItem.setExpanded(true);
}
+ @FXML
+ private void tableViewKeyPressed(KeyEvent event) {
+ // Copy to clipboard
+ KeyCodeCombination copyShortcut = new KeyCodeCombination(KeyCode.C, KeyCombination.SHORTCUT_DOWN);
+ if (copyShortcut.match(event)) {
+ event.consume();
+
+ StringBuilder clipboardText = new StringBuilder();
+
+ // Cells are in by row order, here we depend on this JavaFX behaviour
+ ObservableList cells = tableView.getSelectionModel().getSelectedCells();
+ int lastRow = -1;
+ for (int i = 0; i < cells.size(); i++) {
+ TablePosition position = cells.get(i);
+
+ Object data = position.getTableColumn().getCellData(position.getRow());
+
+ System.out.println(String.format(
+ "row %d, col %d - %s", position.getRow(), position.getColumn(), data));
+ }
+ }
+ }
+
@FXML
private void guiOpen() {
File f = openFileChooser.showOpenDialog(window);