Skip to content

Commit

Permalink
keep improving user expereince
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Nov 22, 2024
1 parent 846cef2 commit dd8387b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/main/java/ai/nets/samj/gui/ImageSelection.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
try {
ComboBoxItem item = (ComboBoxItem) this.cmbBox.getSelectedItem();
if (selected != item) {
if (selected == null || selected.getId().equals(item.getId())) {
listener.modelActionsOnImageChanged();
listener.imageActionsOnImageChanged();
selected = item;
}
} catch (Exception ex) {
ex.printStackTrace();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/ai/nets/samj/gui/MainGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ private void loadModel() {

private void close() {
cmbModels.unLoadModel();
this.drawerPanel.interruptThreads();
}

// Method to create the title panel
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/ai/nets/samj/gui/components/ComboBoxItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
package ai.nets.samj.gui.components;


import java.util.UUID;

import net.imglib2.RandomAccessibleInterval;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;
Expand All @@ -31,7 +33,7 @@
* @author CArlos Garcia
*/
public abstract class ComboBoxItem {
final private int id;
final private String id;
final private Object value;
private static final String SELECT_IMAGE_STR = "Select image";

Expand All @@ -43,9 +45,8 @@ public abstract class ComboBoxItem {
* @param seq
* the object
*/
public ComboBoxItem(int uniqueID, Object seq) {
if (uniqueID == -1) throw new IllegalArgumentException("The unique identifier cannot be -1.");
this.id = uniqueID;
public ComboBoxItem(Object seq) {
this.id = UUID.randomUUID().toString();
this.value = seq;
}

Expand All @@ -54,15 +55,15 @@ public ComboBoxItem(int uniqueID, Object seq) {
* In this case it is empty, the unique identifier will by -1.
*/
public ComboBoxItem() {
this.id = -1;
this.id = "-1";
this.value = null;
}

/**
*
* @return the unique identifier of the instance
*/
public int getId() {
public String getId() {
return id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public void actionPerformed(ActionEvent e) {

private void installModel() {
SwingUtilities.invokeLater(() -> listener.setGUIEnabled(false));
SwingUtilities.invokeLater(() -> install.setEnabled(false));
modelInstallThread = new Thread(() ->{
try {
this.html.clear();
Expand Down Expand Up @@ -292,6 +293,7 @@ private static String formatHTML(String html) {

private void uninstallModel() {
SwingUtilities.invokeLater(() -> listener.setGUIEnabled(false));
SwingUtilities.invokeLater(() -> uninstall.setEnabled(false));
startLoadingAnimation("Uninstalling model");
modelInstallThread = new Thread(() ->{
this.model.getInstallationManger().uninstall();
Expand Down Expand Up @@ -339,7 +341,7 @@ private void stopLoadingAnimation() {
}


private void interruptThreads() {
public void interruptThreads() {
if (infoThread != null)
this.infoThread.interrupt();
if (installedThread != null)
Expand Down

0 comments on commit dd8387b

Please sign in to comment.