From 4c344f50fe007aa67af7171c37bad6ee416bd7dc Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 4 Dec 2024 14:32:59 +0100 Subject: [PATCH] correct small UX errors --- .../java/ai/nets/samj/communication/model/SAMModel.java | 8 ++++++++ src/main/java/ai/nets/samj/gui/MainGUI.java | 3 ++- .../ai/nets/samj/gui/components/ModelDrawerPanel.java | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/ai/nets/samj/communication/model/SAMModel.java b/src/main/java/ai/nets/samj/communication/model/SAMModel.java index 89fb3c6..dabef2a 100644 --- a/src/main/java/ai/nets/samj/communication/model/SAMModel.java +++ b/src/main/java/ai/nets/samj/communication/model/SAMModel.java @@ -313,6 +313,14 @@ public void closeProcess() { samj.close(); samj = null; } + + /** + * Check whether the model is loaded or not + * @return whether the model is loaded or not + */ + public boolean isLoaded() { + return samj != null; + } public String persistEncoding() throws IOException, InterruptedException { try { diff --git a/src/main/java/ai/nets/samj/gui/MainGUI.java b/src/main/java/ai/nets/samj/gui/MainGUI.java index 404d4bb..3ac4849 100644 --- a/src/main/java/ai/nets/samj/gui/MainGUI.java +++ b/src/main/java/ai/nets/samj/gui/MainGUI.java @@ -642,7 +642,8 @@ public void validPromptChosen(boolean isValid) { CardLayout lyt = (CardLayout) cardPanel1_2.getLayout(); lyt.show(cardPanel1_2, INVISIBLE_STR); isValidPrompt = true; - MainGUI.this.chkInstant.setEnabled(true); + if (cmbModels.getSelectedModel().isLoaded()) + MainGUI.this.chkInstant.setEnabled(true); } else if (!isValid && isValidPrompt) { CardLayout lyt = (CardLayout) cardPanel1_2.getLayout(); lyt.show(cardPanel1_2, VISIBLE_STR); diff --git a/src/main/java/ai/nets/samj/gui/components/ModelDrawerPanel.java b/src/main/java/ai/nets/samj/gui/components/ModelDrawerPanel.java index 8461f8d..c527151 100644 --- a/src/main/java/ai/nets/samj/gui/components/ModelDrawerPanel.java +++ b/src/main/java/ai/nets/samj/gui/components/ModelDrawerPanel.java @@ -337,6 +337,9 @@ private void stopLoadingAnimation() { isLoading = false; if (loadingAnimationThread != null && loadingAnimationThread.isAlive()) { loadingAnimationThread.interrupt(); + try { + loadingAnimationThread.join(); + } catch (InterruptedException e) {} } }