Hooked up rename and delete column features to the UI

This commit is contained in:
Brendan Robert 2021-04-02 17:01:23 -05:00
parent b727537457
commit 2e779e05f4

View File

@ -72,6 +72,8 @@ public class SheetEditorControllerImpl extends SheetEditorController {
createMenuItem("Insert Row", () -> insertRow(new Row(), getSelectedRow())), createMenuItem("Insert Row", () -> insertRow(new Row(), getSelectedRow())),
createMenuItem("Clone Row", () -> cloneRow(editor.getSheet().getRows().getRow().get(getSelectedRow()))), createMenuItem("Clone Row", () -> cloneRow(editor.getSheet().getRows().getRow().get(getSelectedRow()))),
createMenuItem("Delete Row", () -> deleteRowWithConfirmation(editor.getSheet().getRows().getRow().get(getSelectedRow()))), createMenuItem("Delete Row", () -> deleteRowWithConfirmation(editor.getSheet().getRows().getRow().get(getSelectedRow()))),
createMenuItem("Delete Column", () -> deleteColumnWithConfirmation(editor.getSheet().getColumns().getColumn().get(getSelectedColumn()))),
createMenuItem("Rename Column", () -> renameColumn(editor.getSheet().getColumns().getColumn().get(getSelectedColumn()))),
createMenuItem("Sort ascending", () -> { createMenuItem("Sort ascending", () -> {
int sortCol = table.getSelectionModel().getFocusedCell().getColumn(); int sortCol = table.getSelectionModel().getFocusedCell().getColumn();
table.setComparator((a,b)->compare(getCellFromRow(a, sortCol), getCellFromRow(b, sortCol))); table.setComparator((a,b)->compare(getCellFromRow(a, sortCol), getCellFromRow(b, sortCol)));
@ -99,6 +101,10 @@ public class SheetEditorControllerImpl extends SheetEditorController {
return table.getSelectionModel().getFocusedCell().getRow(); return table.getSelectionModel().getFocusedCell().getRow();
} }
private int getSelectedColumn() {
return table.getSelectionModel().getFocusedCell().getColumn();
}
@Override @Override
public void doImport(ActionEvent event) { public void doImport(ActionEvent event) {
FileChooser openFileDialog = new FileChooser(); FileChooser openFileDialog = new FileChooser();