Skip to content

Commit

Permalink
work on how description is shown
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Nov 22, 2024
1 parent bc8d63c commit 787dd36
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public void error(String text) {
}

};
private Boolean installed = false;
private boolean onlyBiggest = false;
/**
* Name of the model
Expand Down Expand Up @@ -108,7 +107,7 @@ public String getName() {
* {@inheritDoc}
*/
public String getDescription() {
return HTML_DESCRIPTION + (!this.installed ? SAMModel.HTML_NOT_INSTALLED : CAUTION_STRING);
return HTML_DESCRIPTION + (!this.isInstalled() ? SAMModel.HTML_NOT_INSTALLED : CAUTION_STRING);
}

@Override
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/ai/nets/samj/gui/components/ModelDrawerPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class ModelDrawerPanel extends JPanel implements ActionListener {
private JLabel drawerTitle = new JLabel();
private JButton install = new JButton("Install");
private JButton uninstall = new JButton("Uninstall");
HTMLPane html = new HTMLPane("Arial", "#000", "#CCCCCC", 200, 200);

private SAMModel model;
private ModelDrawerPanelListener listener;
Expand All @@ -54,7 +55,6 @@ private void createDrawerPanel() {
drawerTitle.setText(String.format(MODEL_TITLE, " "));
this.add(drawerTitle, BorderLayout.NORTH);
this.add(createInstallModelComponent(), BorderLayout.SOUTH);
HTMLPane html = new HTMLPane("Arial", "#000", "#CCCCCC", 200, 200);
html.append("Model description");
html.append("Model description");
html.append("Model description");
Expand Down Expand Up @@ -93,14 +93,24 @@ public void setSelectedModel(SAMModel model) {
this.model = model;
setTitle(model.getName());
setInfo();
install.setEnabled(false);
uninstall.setEnabled(false);
new Thread(() -> {
boolean installed = model.isInstalled();
SwingUtilities.invokeLater(() -> {
if (installed) this.uninstall.setEnabled(true);
else this.install.setEnabled(true);
});
}).start();;
}

private void setTitle(String title) {
drawerTitle.setText(String.format(MODEL_TITLE, title));
}

private void setInfo() {
// TODO
html.clear();
html.append("p", model.getDescription());
}

@Override
Expand Down

0 comments on commit 787dd36

Please sign in to comment.