From 9f488a465d0df910b967bab18753128d05f9926c Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Mon, 2 Nov 2020 10:43:00 +0000 Subject: [PATCH] require collection name --- .../com/muwire/gui/CollectionWizardController.groovy | 5 +++++ gui/griffon-app/i18n/messages.properties | 2 ++ .../views/com/muwire/gui/CollectionWizardView.groovy | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/gui/griffon-app/controllers/com/muwire/gui/CollectionWizardController.groovy b/gui/griffon-app/controllers/com/muwire/gui/CollectionWizardController.groovy index 2fefe2bb..f043fc1d 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/CollectionWizardController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/CollectionWizardController.groovy @@ -36,6 +36,11 @@ class CollectionWizardController { void review() { model.timestamp = System.currentTimeMillis() model.root = view.nameTextField.text + if (model.root == null || model.root.trim().length() == 0) { + view.warnMissingName() + return + } + model.root = model.root.trim() model.comment = view.commentTextArea.text if (model.comment == null) model.comment = "" diff --git a/gui/griffon-app/i18n/messages.properties b/gui/griffon-app/i18n/messages.properties index d400f059..93654cfc 100644 --- a/gui/griffon-app/i18n/messages.properties +++ b/gui/griffon-app/i18n/messages.properties @@ -535,6 +535,8 @@ COLLECTION_DESCRIPTION=Enter description for this collection COLLECTION_TOTAL_FILES=Number of files COLLECTION_TOTAL_SIZE=Total size COLLECTION_REVIEW_TITLE=This is what the collection will look like +COLLECTION_NAME_WARNING=The collection name cannot be blank. Please select a name for this collection. +COLLECTION_NAME_WARNING_TITLE=Missing collection name ## Collections tool COLLECTION_TOOL_TITLE=Collections in your repository diff --git a/gui/griffon-app/views/com/muwire/gui/CollectionWizardView.groovy b/gui/griffon-app/views/com/muwire/gui/CollectionWizardView.groovy index 7e824e26..5d3c29f8 100644 --- a/gui/griffon-app/views/com/muwire/gui/CollectionWizardView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/CollectionWizardView.groovy @@ -12,6 +12,7 @@ import griffon.metadata.ArtifactProviderFor import net.i2p.data.DataHelper import javax.swing.JDialog +import javax.swing.JOptionPane import javax.swing.JTree import javax.swing.SwingConstants import javax.swing.border.TitledBorder @@ -108,6 +109,11 @@ class CollectionWizardView { mainPanel.getLayout().show(mainPanel, "configuration") } + void warnMissingName() { + JOptionPane.showMessageDialog(dialog, trans("COLLECTION_NAME_WARNING"), + trans("COLLECTION_NAME_WARNING_TITLE"), JOptionPane.WARNING_MESSAGE) + } + void mvcGroupInit(Map args) { filesTable.setDefaultRenderer(Long.class, new SizeRenderer())