Link samples table to GUI events
This commit is contained in:
@@ -158,6 +158,17 @@ public class BasePlate extends DeviceBase {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Sample getSampleByName(String name) {
|
||||
try{
|
||||
Puck p = getPuckByName(name.substring(0,2));
|
||||
if (p!=null){
|
||||
return p.getSamples()[Integer.valueOf(name.substring(2,3))-1];
|
||||
}
|
||||
} catch (Exception ex){
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void clearId(String id) {
|
||||
for (Device d : getChildren()) {
|
||||
if (d instanceof Puck){
|
||||
|
||||
@@ -365,8 +365,8 @@ public class BasePlatePanel extends DevicePanel {
|
||||
void selectSample(Sample sample){
|
||||
if (getSelectionMode()==SelectionMode.Samples){
|
||||
sample.setSelected(true);
|
||||
repaint();
|
||||
Controller.getInstance().onSamplePressed(sample);
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,7 +389,6 @@ public class BasePlatePanel extends DevicePanel {
|
||||
}
|
||||
|
||||
void onSamplePopupMenu(MouseEvent e,Sample sample){
|
||||
System.out.println(sample);
|
||||
menuLoadSample.setEnabled(sample.isPresent() && getDevice().getLoadedSample()==null);
|
||||
menuUnloadSample.setEnabled(!sample.isPresent() && getDevice().getLoadedSample()!=null);
|
||||
samplePopupMenu.show(e.getComponent(), e.getX(), e.getY());
|
||||
@@ -406,8 +405,8 @@ public class BasePlatePanel extends DevicePanel {
|
||||
void selectPuck(Puck puck){
|
||||
if (getSelectionMode()!=SelectionMode.None){
|
||||
puck.setSelected(true);
|
||||
repaint();
|
||||
Controller.getInstance().onPuckPressed(puck);
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,7 +439,6 @@ public class BasePlatePanel extends DevicePanel {
|
||||
|
||||
|
||||
void onPuckPopupMenu(MouseEvent e, Puck puck){
|
||||
System.out.println(puck);
|
||||
}
|
||||
|
||||
void onPuckDoubleClicked(MouseEvent e, Puck puck){
|
||||
|
||||
@@ -148,6 +148,10 @@ public class Controller {
|
||||
|
||||
public void selectSample(Sample sample) {
|
||||
getMainFrame().basePlatePanel.selectSample(sample);
|
||||
if ((puckPanel != null) && puckPanel.isShowing()){
|
||||
puckPanel.selectSample(sample);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//public Panel getMainFrame() {
|
||||
@@ -162,7 +166,6 @@ public class Controller {
|
||||
void onInitialize(int runCount) {
|
||||
getMainFrame().addDevice(basePlate);
|
||||
basePlate.addListener(basePlateListener);
|
||||
System.out.println(basePlate.getState());
|
||||
|
||||
if (puckSensorAccess == PuckSensorAccess.Esera) {
|
||||
getMainFrame().getContext().getDevicePool().addListener(new DevicePoolListener() {
|
||||
@@ -294,6 +297,10 @@ public class Controller {
|
||||
public Puck getPuck(String name) {
|
||||
return basePlate.getPuckByName(name);
|
||||
}
|
||||
|
||||
public Sample getSample(String name) {
|
||||
return basePlate.getSampleByName(name);
|
||||
}
|
||||
|
||||
public BasePlate getBasePlate() {
|
||||
return basePlate;
|
||||
|
||||
@@ -68,14 +68,16 @@ public class MainPanel extends Panel {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
try {
|
||||
String add = String.valueOf(tablePucks.getModel().getValueAt(tablePucks.getSelectedRow(), 0));
|
||||
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);
|
||||
if (e.getValueIsAdjusting() == false) {
|
||||
String add = String.valueOf(tablePucks.getModel().getValueAt(tablePucks.getSelectedRow(), 0));
|
||||
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) {
|
||||
showException(ex);
|
||||
@@ -87,18 +89,30 @@ public class MainPanel extends Panel {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
try {
|
||||
if (e.getValueIsAdjusting() == false) {
|
||||
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);
|
||||
}
|
||||
if (selection>=0){
|
||||
String add = String.valueOf(tableSamples.getModel().getValueAt(selection, 3));
|
||||
if (!add.trim().isEmpty()) {
|
||||
int pos = -1;
|
||||
try{
|
||||
pos = Integer.valueOf(String.valueOf(tableSamples.getModel().getValueAt(selection, 7)));
|
||||
} catch (Exception ex){
|
||||
}
|
||||
String curSelection = Controller.getInstance().getCurrentSelection();
|
||||
String curPuck = (curSelection == null) ? null : curSelection.substring(0, 2);
|
||||
if (!add.equals(curPuck)) {
|
||||
Puck puck = Controller.getInstance().getPuck(add);
|
||||
Controller.getInstance().selectPuck(puck);
|
||||
}
|
||||
if (pos>=0){
|
||||
add += pos;
|
||||
if (!add.equals(curSelection)) {
|
||||
Sample sample = Controller.getInstance().getSample(add);
|
||||
Controller.getInstance().selectSample(sample);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
@@ -482,6 +496,11 @@ public class MainPanel extends Panel {
|
||||
|
||||
for (int i = 0; i < tableSamples.getModel().getRowCount(); i++) {
|
||||
if (add.equals(tableSamples.getModel().getValueAt(i, 3))) {
|
||||
if (sample!=null){
|
||||
if (!sample.equals(tableSamples.getModel().getValueAt(i, 7))){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (tableSamples.getSelectedRow() != i) {
|
||||
tableSamples.setRowSelectionInterval(i, i);
|
||||
SwingUtils.scrollToVisible(tableSamples, i, 0);
|
||||
|
||||
Reference in New Issue
Block a user