diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java index 6aa41c8c81ed21c7b937443ed48e8e7359081b7e..1df6d3e6c0a84ae205f46c0ee941bc800b17cf9a 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java @@ -1351,10 +1351,22 @@ public abstract class AbstractBrowserGrid<T/* Entity */, M extends BaseEntityMod if (data.isEmpty() == false) { IBrowserGridActionInvoker invoker = asActionInvoker(); - createDialog(data, invoker).show(); + if (validateSelectedData(data)) + { + createDialog(data, invoker).show(); + } } } + /** + * If specified data is valid returns true, otherwise returns false. Dialog will be shown + * only if this method returns true. Default implementation always returns true. + */ + protected boolean validateSelectedData(List<T> data) + { + return true; + } + protected abstract Dialog createDialog(List<T> data, IBrowserGridActionInvoker invoker); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/vocabulary/VocabularyGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/vocabulary/VocabularyGrid.java index 732e03b4a913da7de14b424aa8300a3079f7fc39..56679e76d312c67a74f33c81e0f5260616ac3585 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/vocabulary/VocabularyGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/vocabulary/VocabularyGrid.java @@ -107,8 +107,8 @@ public class VocabularyGrid extends AbstractSimpleBrowserGrid<Vocabulary> Vocabulary vocabulary = selectedItem.getBaseObject(); if (vocabulary.isManagedInternally()) { - MessageBox.alert("Error", - "Internally managed vocabulary cannot be edited.", null); + String errorMsg = "Internally managed vocabulary cannot be edited."; + MessageBox.alert("Error", errorMsg, null); } else { createEditEntityDialog(vocabulary).show(); @@ -116,10 +116,11 @@ public class VocabularyGrid extends AbstractSimpleBrowserGrid<Vocabulary> } })); - + addButton(createSelectedItemsButton(viewContext.getMessage(Dict.BUTTON_DELETE), new AbstractCreateDialogListener() { + @Override protected Dialog createDialog(List<Vocabulary> vocabularies, IBrowserGridActionInvoker invoker) @@ -127,6 +128,21 @@ public class VocabularyGrid extends AbstractSimpleBrowserGrid<Vocabulary> return new VocabularyListDeletionConfirmationDialog(viewContext, vocabularies, createDeletionCallback(invoker)); } + + @Override + protected boolean validateSelectedData(List<Vocabulary> data) + { + String errorMsg = "Internally managed vocabulary cannot be deleted."; + for (Vocabulary vocabulary : data) + { + if (vocabulary.isManagedInternally()) + { + MessageBox.alert("Error", errorMsg, null); + return false; + } + } + return true; + } })); allowMultipleSelection(); // we allow deletion of multiple attachments