Link samples table to GUI events

This commit is contained in:
2018-09-11 16:53:50 +02:00
parent 0cf9904929
commit 5e7540620b
3 changed files with 51 additions and 16 deletions

View File

@@ -287,6 +287,10 @@ public class Controller {
public Puck getPuck(String name) {
return basePlate.getPuckByName(name);
}
public BasePlate getBasePlate() {
return basePlate;
}
EseraDetection detection;
@@ -588,7 +592,9 @@ public class Controller {
if (!datamatrix.isEmpty()){
getMainFrame().setPuckDatamatrix(null);
linkPuckDatamatrix(puck, datamatrix);
}
} else {
//TODO
}
} else if (detectedPuckRemoved){
linkPuckDatamatrix(puck, null);
}
@@ -602,14 +608,30 @@ public class Controller {
public void linkPuckDatamatrix(Puck puck, String datamatrix){
// if ( ((puck.getId()==null) && (datamatrix!=null)) ||
// (puck.getId()!=null) && (!puck.getId().equals(datamatrix))){
System.out.println("Setting to: " + puck.getName() + " datamatrix: " + datamatrix);
String puckName = (puck == null) ? "" : puck.getName();
if (datamatrix == null){
datamatrix = "";
}
datamatrix = datamatrix.trim();
boolean showMessage = (puck != null) && !datamatrix.isEmpty();
System.out.println("Setting datamatrix '" + datamatrix + "' to puck: " + puckName);
try {
Context.getInstance().evalLineBackground("set_puck_datamatrix('" + puck.getName() + "','" + datamatrix + "')");
puck.setId(datamatrix);
SwingUtils.showMessage(getMainFrame(), "Puck loading",
"Puck " + datamatrix + "set to position " + puck.getName(),
5000);
Context.getInstance().evalLineBackground("set_puck_datamatrix('" + puckName + "','" + datamatrix + "')");
if (puck != null){
puck.setId(datamatrix);
} else {
basePlate.clearId(datamatrix);
}
if (showMessage){
SwingUtils.showMessage(getMainFrame(), "Puck loading",
"Puck '" + datamatrix + "' set to position " + puckName,
5000);
}
} catch (Exception ex) {
Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex);
}