mirror of
https://gitlab.com/kauron/jstudy
synced 2024-11-13 07:33:44 +01:00
Added context menu to tabs (duplication and merging)
This commit is contained in:
parent
3e41a528a5
commit
0d4be04d58
1 changed files with 23 additions and 1 deletions
|
@ -169,8 +169,30 @@ public class Controller implements Initializable {
|
|||
tabPane.getSelectionModel().selectNext();
|
||||
});
|
||||
|
||||
MenuItem merge = new MenuItem("Merge with other table");
|
||||
merge.setOnAction(event -> {
|
||||
Map<String, TableController> choices = new HashMap<>(tabMap.values().size() - 1);
|
||||
for (TableController tc : tabMap.values())
|
||||
if (tc != loader.getController())
|
||||
choices.put(tc.getName(), tc);
|
||||
|
||||
ChoiceDialog<String> dialog = new ChoiceDialog<>();
|
||||
dialog.setTitle("Merging tables...");
|
||||
dialog.setHeaderText("Please select another table to merge with this one");
|
||||
dialog.getItems().addAll(choices.keySet());
|
||||
Optional<String> result = dialog.showAndWait();
|
||||
|
||||
if (result.isPresent() && choices.get(result.get()) != null) {
|
||||
List<TestItem> newList = new ArrayList<>(list);
|
||||
newList.addAll(choices.get(result.get()).getData());
|
||||
Tab newTab = createTableTab("Merge", newList, null);
|
||||
tabPane.getTabs().add(tabPane.getTabs().indexOf(tab) + 1, newTab);
|
||||
tabPane.getSelectionModel().selectNext();
|
||||
}
|
||||
});
|
||||
|
||||
tab.setContent(tableRoot);
|
||||
tab.setContextMenu(new ContextMenu(duplicate));
|
||||
tab.setContextMenu(new ContextMenu(duplicate, merge));
|
||||
tab.setOnCloseRequest(event -> {
|
||||
if (!((TableController) loader.getController()).saved.get()) {
|
||||
Alert dialog = new Alert(Alert.AlertType.WARNING);
|
||||
|
|
Loading…
Reference in a new issue