diff --git a/OutlawEditor/pom.xml b/OutlawEditor/pom.xml index 794cde50..1f5e7734 100644 --- a/OutlawEditor/pom.xml +++ b/OutlawEditor/pom.xml @@ -24,7 +24,7 @@ com.gluonhq gluonfx-maven-plugin - 1.0.19 + 1.0.24 ${mainClass} @@ -56,12 +56,12 @@ 17 17 - 3.11.0 + 3.13.0 org.codehaus.mojo jaxb2-maven-plugin - 3.1.0 + 3.2.0 xjc @@ -78,7 +78,7 @@ org.apache.maven.plugins maven-dependency-plugin - 3.6.0 + 3.8.1 copy-dependencies @@ -109,17 +109,17 @@ jakarta.xml.bind jakarta.xml.bind-api - 4.0.1 + 4.0.2 org.glassfish.jaxb jaxb-runtime - 4.0.3 + 4.0.5 org.controlsfx controlsfx - 11.2.0 + 11.2.1 org.openjfx diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/impl/SheetEditorControllerImpl.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/impl/SheetEditorControllerImpl.java index 2995ade1..670aa729 100644 --- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/impl/SheetEditorControllerImpl.java +++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/impl/SheetEditorControllerImpl.java @@ -39,7 +39,7 @@ import org.badvision.outlaweditor.ui.SheetEditorController; import org.badvision.outlaweditor.ui.UIAction; import org.controlsfx.control.spreadsheet.GridBase; import org.controlsfx.control.spreadsheet.SpreadsheetCell; -import org.controlsfx.control.spreadsheet.SpreadsheetCellBase; +import org.controlsfx.control.spreadsheet.SpreadsheetCellType; import jakarta.xml.bind.JAXBException; import javafx.beans.value.ObservableValue; @@ -70,6 +70,7 @@ public class SheetEditorControllerImpl extends SheetEditorController { super.initialize(); tableData = table.getGrid().getRows(); table.setEditable(true); + table.getContextMenu().getItems().addAll( createMenuItem("Insert Row", () -> insertRow(new Row(), getSelectedRow())), createMenuItem("Clone Row", () -> cloneRow(editor.getSheet().getRows().getRow().get(getSelectedRow()))), @@ -153,11 +154,16 @@ public class SheetEditorControllerImpl extends SheetEditorController { public void addColumnAction(ActionEvent event) { String newColName = UIAction.getText("Enter new column name", "new"); if (newColName != null && !newColName.isEmpty()) { + // If the column exists with that name, show an error instead UserType col = new UserType(); col.setName(newColName); if (editor.getSheet().getColumns() == null) { editor.getSheet().setColumns(new Columns()); + } else if (editor.getSheet().getColumns().getColumn().stream().anyMatch(c -> c.getName().equals(newColName))) { + UIAction.alert("A column with that name already exists. Please choose a different name."); + return; } + insertColumn(col); rebuildGridUI(); } @@ -276,8 +282,7 @@ public class SheetEditorControllerImpl extends SheetEditorController { tableData.add(rowUi); for (UserType col : editor.getSheet().getColumns().getColumn()) { String value = getValue(row.getOtherAttributes(), col.getName()); - SpreadsheetCellBase cell = new SpreadsheetCellBase(rowNum, colNum, 1, 1); - cell.setItem(value); + SpreadsheetCell cell = SpreadsheetCellType.STRING.createCell(rowNum, colNum, 1, 1, value); cell.itemProperty().addListener((ObservableValue val, Object oldVal, Object newVal) -> { setValue(row.getOtherAttributes(), col.getName(), String.valueOf(newVal)); });