This commit is contained in:
@@ -10,7 +10,6 @@ import ch.psi.pshell.imaging.PointDouble;
|
||||
import ch.psi.pshell.imaging.Utils;
|
||||
import ch.psi.utils.swing.MainFrame;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
@@ -279,4 +278,20 @@ public class BasePlate extends DeviceBase {
|
||||
unloadSample (getLoadedSample());
|
||||
}
|
||||
|
||||
|
||||
void onSelectionChanged(){
|
||||
Sample sample = getSelectedSample();
|
||||
if (sample!=null){
|
||||
//setCache(sample.getName());
|
||||
setCache(new Object[]{sample.getPuck().segment, sample.getPuck().number, sample.index+1});
|
||||
} else {
|
||||
Puck puck = getSelectedPuck();
|
||||
if (puck!=null){
|
||||
//setCache(puck.getName());
|
||||
setCache(new Object[]{puck.segment, puck.number, null});
|
||||
}
|
||||
}
|
||||
setCache(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -301,6 +301,15 @@ public class BasePlatePanel extends DevicePanel {
|
||||
|
||||
}
|
||||
|
||||
void selectSample(Sample sample){
|
||||
if (getDevice().isSelectable()){
|
||||
sample.setSelected(true);
|
||||
repaint();
|
||||
}
|
||||
Controller.getInstance().onSamplePressed(sample);
|
||||
|
||||
}
|
||||
|
||||
void onSamplePressed(MouseEvent e, Sample sample){
|
||||
if (getDevice().isSelectable()){
|
||||
if (TOGGLE_SELECTION){
|
||||
@@ -332,6 +341,14 @@ public class BasePlatePanel extends DevicePanel {
|
||||
|
||||
}
|
||||
|
||||
void selectPuck(Puck puck){
|
||||
if (getDevice().isSelectable()){
|
||||
puck.setSelected(true);
|
||||
repaint();
|
||||
}
|
||||
Controller.getInstance().onPuckPressed(puck);
|
||||
}
|
||||
|
||||
void onPuckPressed(MouseEvent e, Puck puck){
|
||||
if (getDevice().isSelectable()){
|
||||
if (TOGGLE_SELECTION){
|
||||
|
||||
@@ -91,6 +91,43 @@ public class Controller {
|
||||
this.mainFrame = (MainPanel) mainFrame;
|
||||
instance = this;
|
||||
clearPuckStates();
|
||||
|
||||
basePlate.addListener(new DeviceAdapter() {
|
||||
@Override
|
||||
public void onValueChanged(Device device, Object value, Object former) {
|
||||
if (value!=null){
|
||||
String segment = ((Object[])value)[0].toString();
|
||||
Integer puck = (Integer) ((Object[])value)[1];
|
||||
Integer sample = (Integer) ((Object[])value)[2];
|
||||
Controller.this.mainFrame.onSelectionChanged(segment, puck, sample);
|
||||
} else {
|
||||
Controller.this.mainFrame.onSelectionChanged(null,null,null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String getCurrentSelection(){
|
||||
Object value = basePlate.take();
|
||||
if (value!=null){
|
||||
String segment = ((Object[])value)[0].toString();
|
||||
Integer puck = (Integer) ((Object[])value)[1];
|
||||
Integer sample = (Integer) ((Object[])value)[2];
|
||||
String ret = segment + String.valueOf(puck);
|
||||
if (sample!=null){
|
||||
ret = ret + String.valueOf(sample);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void selectPuck(Puck puck){
|
||||
getMainFrame().basePlatePanel.selectPuck(puck);
|
||||
}
|
||||
|
||||
public void selectSample(Sample sample){
|
||||
getMainFrame().basePlatePanel.selectSample(sample);
|
||||
}
|
||||
|
||||
//public Panel getMainFrame() {
|
||||
@@ -109,6 +146,7 @@ public class Controller {
|
||||
}
|
||||
getMainFrame().addDevice(basePlate);
|
||||
|
||||
|
||||
|
||||
if (puckSensorAccess == PuckSensorAccess.Esera) {
|
||||
getMainFrame().getContext().getDevicePool().addListener(new DevicePoolListener() {
|
||||
|
||||
@@ -79,6 +79,9 @@
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
@@ -805,18 +808,16 @@
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="filler1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="labeManualMode" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="labeManualMode" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="buttonRelease" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@@ -1144,10 +1145,7 @@
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="panelExpert" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="devicesPanel" pref="229" max="32767" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="devicesPanel" pref="229" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@@ -1166,7 +1164,6 @@
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="buttonExpertCommands" linkSize="28" max="32767" attributes="0"/>
|
||||
<Component id="buttonRecovery" linkSize="28" max="32767" attributes="0"/>
|
||||
|
||||
@@ -30,6 +30,8 @@ import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
/**
|
||||
@@ -56,7 +58,26 @@ public class MainPanel extends Panel {
|
||||
for (int puck=1; puck<=5; puck++){
|
||||
tablePucks.getModel().setValueAt(segment+puck, row++, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tablePucks.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
@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);
|
||||
}
|
||||
} catch (Exception ex){
|
||||
showException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,8 +94,10 @@ public class MainPanel extends Panel {
|
||||
public void onInitialize(int runCount) {
|
||||
stopTimer();
|
||||
Controller.getInstance().onInitialize(runCount);
|
||||
//basePlatePanel.setDevice((Device) getDevice("BasePlate"));
|
||||
//basePlatePanel.getDevice().setSelectable(true);
|
||||
if (basePlatePanel.getDevice() != (Device) getDevice("BasePlate")){
|
||||
basePlatePanel.setDevice((Device) getDevice("BasePlate"));
|
||||
basePlatePanel.getDevice().setSelectable(true);
|
||||
}
|
||||
try {
|
||||
devicesPanel.initialize();
|
||||
((Device) getDevice("dewar_level")).addListener(new DeviceAdapter() {
|
||||
@@ -167,6 +190,7 @@ public class MainPanel extends Panel {
|
||||
void refresh(){
|
||||
repaint();
|
||||
for (Puck p : Controller.getInstance().basePlate.getPucks()) {
|
||||
//int index = (p.getSegment() - new Character('A')) * 5 + p.getNumber();
|
||||
tablePucks.getModel().setValueAt(p.getStatus(), p.getIndex(), 1);
|
||||
tablePucks.getModel().setValueAt(p.getId(), p.getIndex(), 2);
|
||||
}
|
||||
@@ -430,6 +454,23 @@ public class MainPanel extends Panel {
|
||||
HEADER
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
void onSelectionChanged(String segment, Integer puck, Integer sample){
|
||||
if (segment != null){
|
||||
String add = segment + String.valueOf(puck);
|
||||
for (int i=0; i<tablePucks.getModel().getRowCount(); i++){
|
||||
if (tablePucks.getModel().getValueAt(i, 0).equals(add)){
|
||||
if (tablePucks.getSelectedRow()!=i){
|
||||
tablePucks.setRowSelectionInterval(i, i);
|
||||
SwingUtils.scrollToVisible(tablePucks, i, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
@@ -975,15 +1016,14 @@ public class MainPanel extends Panel {
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGroup(panelSystemStatusLayout.createSequentialGroup()
|
||||
.addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(panelSystemStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(labeManualMode, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(panelSystemStatusLayout.createSequentialGroup()
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(labeManualMode, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
.addGroup(panelSystemStatusLayout.createSequentialGroup()
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(buttonRelease)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
panelSystemStatusLayout.setVerticalGroup(
|
||||
panelSystemStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@@ -1193,7 +1233,6 @@ public class MainPanel extends Panel {
|
||||
panelExpertLayout.setHorizontalGroup(
|
||||
panelExpertLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelExpertLayout.createSequentialGroup()
|
||||
.addGap(0, 0, 0)
|
||||
.addGroup(panelExpertLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(buttonExpertCommands, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonRecovery, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
@@ -1243,9 +1282,7 @@ public class MainPanel extends Panel {
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(panelDevicesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(panelExpert, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(panelDevicesLayout.createSequentialGroup()
|
||||
.addComponent(devicesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 229, Short.MAX_VALUE)
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addComponent(devicesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 229, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
@@ -1557,7 +1594,7 @@ public class MainPanel extends Panel {
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private ch.psi.mxsc.BasePlatePanel basePlatePanel;
|
||||
ch.psi.mxsc.BasePlatePanel basePlatePanel;
|
||||
private javax.swing.JToggleButton btViewDewar;
|
||||
private javax.swing.JToggleButton btViewRT;
|
||||
private javax.swing.JButton buttonCalibrateCover;
|
||||
|
||||
@@ -303,6 +303,7 @@ public class Puck extends DeviceBase {
|
||||
sample.selected = false;
|
||||
}
|
||||
selected = value;
|
||||
getBasePlate().onSelectionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ public class Sample extends DeviceBase {
|
||||
}
|
||||
selected = value;
|
||||
}
|
||||
getPuck().getBasePlate().onSelectionChanged();
|
||||
}
|
||||
|
||||
boolean present;
|
||||
|
||||
Reference in New Issue
Block a user