159 lines
6.4 KiB
Java
159 lines
6.4 KiB
Java
/*
|
|
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
|
|
*/
|
|
|
|
import ch.psi.pshell.ui.Panel;
|
|
import ch.psi.utils.swing.SwingUtils;
|
|
import ch.psi.utils.State;
|
|
import java.awt.Component;
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public class Commands extends Panel {
|
|
|
|
public Commands() {
|
|
initComponents();
|
|
}
|
|
|
|
|
|
//Overridable callbacks
|
|
@Override
|
|
public void onInitialize(int runCount) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onStateChange(State state, State former) {
|
|
for (Component c : SwingUtils.getComponentsByType(this, Component.class)){
|
|
c.setEnabled(state == State.Ready);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onExecutedFile(String fileName, Object result) {
|
|
}
|
|
|
|
|
|
//Callback to perform update - in event thread
|
|
@Override
|
|
protected void doUpdate() {
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
|
private void initComponents() {
|
|
|
|
btRock = new javax.swing.JButton();
|
|
btFbm = new javax.swing.JButton();
|
|
btSete = new javax.swing.JButton();
|
|
spEnergy = new javax.swing.JSpinner();
|
|
jLabel1 = new javax.swing.JLabel();
|
|
deviceValuePanel1 = new ch.psi.pshell.swing.DeviceValuePanel();
|
|
|
|
btRock.setText("Rock");
|
|
btRock.addActionListener(new java.awt.event.ActionListener() {
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
btRockActionPerformed(evt);
|
|
}
|
|
});
|
|
|
|
btFbm.setText("FBM");
|
|
btFbm.addActionListener(new java.awt.event.ActionListener() {
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
btFbmActionPerformed(evt);
|
|
}
|
|
});
|
|
|
|
btSete.setText("Set Energy");
|
|
btSete.addActionListener(new java.awt.event.ActionListener() {
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
btSeteActionPerformed(evt);
|
|
}
|
|
});
|
|
|
|
spEnergy.setModel(new javax.swing.SpinnerNumberModel(6.0d, 4.7d, 17.5d, 0.1d));
|
|
|
|
jLabel1.setText("kev");
|
|
|
|
deviceValuePanel1.setDeviceName("energy");
|
|
|
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
|
this.setLayout(layout);
|
|
layout.setHorizontalGroup(
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGroup(layout.createSequentialGroup()
|
|
.addGap(96, 96, 96)
|
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
.addComponent(btFbm, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
.addComponent(btRock, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
.addComponent(btSete, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
.addGap(18, 18, 18)
|
|
.addComponent(spEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
|
.addComponent(deviceValuePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addComponent(jLabel1)
|
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
);
|
|
|
|
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btFbm, btRock, btSete});
|
|
|
|
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {deviceValuePanel1, spEnergy});
|
|
|
|
layout.setVerticalGroup(
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGroup(layout.createSequentialGroup()
|
|
.addGap(56, 56, 56)
|
|
.addComponent(btRock)
|
|
.addGap(18, 18, 18)
|
|
.addComponent(btFbm)
|
|
.addGap(18, 18, 18)
|
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
|
|
.addComponent(jLabel1)
|
|
.addComponent(deviceValuePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
.addComponent(spEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
.addComponent(btSete))
|
|
.addContainerGap(210, Short.MAX_VALUE))
|
|
);
|
|
|
|
layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {btFbm, btRock, btSete, deviceValuePanel1, jLabel1, spEnergy});
|
|
|
|
}// </editor-fold>//GEN-END:initComponents
|
|
|
|
private void btRockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btRockActionPerformed
|
|
try {
|
|
getContext().evalLineAsync("rock()");
|
|
} catch (Exception ex) {
|
|
showException(ex);
|
|
}
|
|
}//GEN-LAST:event_btRockActionPerformed
|
|
|
|
private void btFbmActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btFbmActionPerformed
|
|
try {
|
|
getContext().evalLineAsync("fbm()");
|
|
} catch (Exception ex) {
|
|
showException(ex);
|
|
}
|
|
}//GEN-LAST:event_btFbmActionPerformed
|
|
|
|
private void btSeteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSeteActionPerformed
|
|
try {
|
|
getContext().evalLineAsync("sete(" + String.valueOf(spEnergy.getValue()) + ")");
|
|
} catch (Exception ex) {
|
|
showException(ex);
|
|
}
|
|
|
|
|
|
}//GEN-LAST:event_btSeteActionPerformed
|
|
|
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
|
private javax.swing.JButton btFbm;
|
|
private javax.swing.JButton btRock;
|
|
private javax.swing.JButton btSete;
|
|
private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel1;
|
|
private javax.swing.JLabel jLabel1;
|
|
private javax.swing.JSpinner spEnergy;
|
|
// End of variables declaration//GEN-END:variables
|
|
}
|