Link samples table to GUI events
This commit is contained in:
@@ -7,6 +7,7 @@ import ch.psi.mxsc.Puck.PuckType;
|
||||
import ch.psi.pshell.core.Context;
|
||||
import ch.psi.pshell.core.DevicePool;
|
||||
import ch.psi.pshell.core.DevicePoolListener;
|
||||
import ch.psi.pshell.core.JsonSerializer;
|
||||
import ch.psi.pshell.device.Device;
|
||||
import ch.psi.pshell.device.DeviceAdapter;
|
||||
import ch.psi.pshell.device.DeviceListener;
|
||||
@@ -23,6 +24,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.script.ScriptException;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -189,6 +191,9 @@ public class Controller {
|
||||
}
|
||||
});
|
||||
updateDevices();
|
||||
updatePuckTypes();
|
||||
clearSamplesTable();
|
||||
refreshSamplesTable();
|
||||
|
||||
}
|
||||
|
||||
@@ -196,6 +201,8 @@ public class Controller {
|
||||
public void onStateChange(State state, State former) {
|
||||
if (state == State.Initializing){
|
||||
getMainFrame().removeDevice(basePlate);
|
||||
} else if (state==State.Ready){
|
||||
refreshSamplesTable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,6 +212,7 @@ public class Controller {
|
||||
} catch (Exception ex) {
|
||||
setPuckLoading(false);
|
||||
}
|
||||
refreshSamplesTable();
|
||||
}
|
||||
|
||||
final DeviceListener hexiposiListener = new DeviceAdapter() {
|
||||
@@ -498,7 +506,39 @@ public class Controller {
|
||||
getMainFrame().execute(statement, background, showReturn);
|
||||
}
|
||||
|
||||
////////////////////// Sample Info /////////////////////////////////
|
||||
|
||||
String samplesTableJson;
|
||||
final Object samplesTableLock = new Object();
|
||||
void refreshSamplesTable() {
|
||||
synchronized(samplesTableLock){
|
||||
try {
|
||||
String json = (String) Context.getInstance().evalLineBackground("get_samples_info()");
|
||||
if (!json.equals(samplesTableJson)) {
|
||||
samplesTableJson = json;
|
||||
|
||||
//SamplesInfo sampleInfo = (SamplesInfo) JsonSerializer.decode(json, SampleInfo.class);
|
||||
SampleInfo[] samples = (SampleInfo[]) JsonSerializer.decode(json, SampleInfo[].class);
|
||||
|
||||
Object[][] sampleData = new Object[samples.length][];
|
||||
for (int i = 0; i < samples.length; i++) {
|
||||
sampleData[i] = samples[i].getData();
|
||||
}
|
||||
getMainFrame().setSamplesTable(sampleData);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
clearSamplesTable();
|
||||
Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void clearSamplesTable() {
|
||||
samplesTableJson = null;
|
||||
getMainFrame().setSamplesTable(new Object[][]{});
|
||||
}
|
||||
|
||||
|
||||
////////////////////// Puck Loading /////////////////////////////////
|
||||
Boolean puckLoading;
|
||||
Puck.Detection[] currentDetection;
|
||||
|
||||
Reference in New Issue
Block a user