Link samples table to GUI events
This commit is contained in:
@@ -158,6 +158,16 @@ public class BasePlate extends DeviceBase {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void clearId(String id) {
|
||||
for (Device d : getChildren()) {
|
||||
if (d instanceof Puck){
|
||||
if ((id==null) || id.equals(((Puck) d).getId())){
|
||||
((Puck) d).setId(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void loadSample(Sample sample) throws Exception{
|
||||
Sample loaded = getLoadedSample();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -87,15 +87,18 @@ public class MainPanel extends Panel {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
try {
|
||||
String add = String.valueOf(tableSamples.getModel().getValueAt(tableSamples.getSelectedRow(), 3));
|
||||
if (!add.trim().isEmpty()) {
|
||||
String cur = Controller.getInstance().getCurrentSelection();
|
||||
if (cur != null) {
|
||||
cur = cur.substring(0, 2);
|
||||
}
|
||||
if (!add.equals(cur)) {
|
||||
Puck puck = Controller.getInstance().getPuck(add);
|
||||
Controller.getInstance().selectPuck(puck);
|
||||
int selection = tableSamples.getSelectedRow();
|
||||
if (selection>=0){
|
||||
String add = String.valueOf(tableSamples.getModel().getValueAt(selection, 3));
|
||||
if (!add.trim().isEmpty()) {
|
||||
String cur = Controller.getInstance().getCurrentSelection();
|
||||
if (cur != null) {
|
||||
cur = cur.substring(0, 2);
|
||||
}
|
||||
if (!add.equals(cur)) {
|
||||
Puck puck = Controller.getInstance().getPuck(add);
|
||||
Controller.getInstance().selectPuck(puck);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
||||
Reference in New Issue
Block a user