From 144fd10b34a885a8038cc38266cd0e188b6a4490 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Fri, 26 Sep 2014 20:47:53 +0200 Subject: Disallow deleting the last dataset/model as this is not supported --- inst/GUI/gmkin.R | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'inst') diff --git a/inst/GUI/gmkin.R b/inst/GUI/gmkin.R index c85d660..5932f37 100644 --- a/inst/GUI/gmkin.R +++ b/inst/GUI/gmkin.R @@ -311,12 +311,16 @@ copy_dataset_handler <- function(h, ...) { } delete_dataset_handler <- function(h, ...) { - ds[[ds.cur]] <<- NULL - names(ds) <<- as.character(1:length(ds)) - ds.cur <<- names(ds)[[1]] - update_ds.df() - ds.gtable[,] <- ds.df - update_ds_editor() + if (length(ds) > 1) { + ds[[ds.cur]] <<- NULL + names(ds) <<- as.character(1:length(ds)) + ds.cur <<- names(ds)[[1]] + update_ds.df() + ds.gtable[,] <- ds.df + update_ds_editor() + } else { + galert("Deleting the last dataset is not supported", parent = w) + } } new_dataset_handler <- function(h, ...) { @@ -540,12 +544,16 @@ copy_model_handler <- function(h, ...) { } delete_model_handler <- function(h, ...) { - m[[m.cur]] <<- NULL - names(m) <<- as.character(1:length(m)) - m.cur <<- "1" - update_m.df() - m.gtable[,] <- m.df - update_m_editor() + if (length(m) > 1) { + m[[m.cur]] <<- NULL + names(m) <<- as.character(1:length(m)) + m.cur <<- "1" + update_m.df() + m.gtable[,] <- m.df + update_m_editor() + } else { + galert("Deleting the last model is not supported", parent = w) + } } add_observed_handler <- function(h, ...) { -- cgit v1.2.1