Files
x11ma/plugins/BeamlineInit.java
gac-x11ma 1d75bc4535
2023-07-18 11:00:54 +02:00

200 lines
7.2 KiB
Java

import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import javax.swing.JButton;
/**
*
*/
public class BeamlineInit extends Panel {
public BeamlineInit() {
initComponents();
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
}
@Override
public void onStateChange(State state, State former) {
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
@Override
protected void onTimer() {
}
@Override
protected void onLoaded() {
}
@Override
protected void onUnloaded() {
}
//Invoked by 'update()' to update components in the event thread
@Override
protected void doUpdate() {
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
buttonAUinit = new javax.swing.JButton();
buttonFEinit = new javax.swing.JButton();
buttonExitSlitsInit = new javax.swing.JButton();
buttonCMUinit = new javax.swing.JButton();
statusAU = new javax.swing.JLabel();
buttonAUinit.setText("Init AU");
buttonAUinit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonAUinitActionPerformed(evt);
}
});
buttonFEinit.setText("init FE");
buttonFEinit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonFEinitActionPerformed(evt);
}
});
buttonExitSlitsInit.setText("init Exit Slits");
buttonExitSlitsInit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonExitSlitsInitActionPerformed(evt);
}
});
buttonCMUinit.setText("init CMU");
buttonCMUinit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonCMUinitActionPerformed(evt);
}
});
statusAU.setText("status AU");
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(83, 83, 83)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(buttonAUinit, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonFEinit, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonExitSlitsInit, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonCMUinit, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addComponent(statusAU)
.addContainerGap(184, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(24, 24, 24)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonAUinit)
.addComponent(statusAU))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(buttonFEinit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(buttonExitSlitsInit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(buttonCMUinit)
.addContainerGap(271, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void buttonAUinitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAUinitActionPerformed
statusAU.setText("Running");
try {
runAsync("beamline_init/init/InitAU").handle((ret, ex) -> {
if (ex != null) {
statusAU.setText(ex.getMessage());
showException((Exception) ex);
} else {
statusAU.setText((ret==null)? "" : ret.toString());
}
return ret;
});
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonAUinitActionPerformed
private void buttonFEinitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonFEinitActionPerformed
try {
boolean background = false;
runAsync("beamline_init/init/InitFE", background).handle((ret, ex) -> {
((JButton) evt.getSource()).setEnabled(true);
if (ex != null) {
showException((Exception) ex);
}
return ret;
});
((JButton) evt.getSource()).setEnabled(false);
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonFEinitActionPerformed
private void buttonExitSlitsInitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExitSlitsInitActionPerformed
try {
boolean background = false;
runAsync("beamline_init/init/InitExitSlit", background).handle((ret, ex) -> {
((JButton) evt.getSource()).setEnabled(true);
if (ex != null) {
showException((Exception) ex);
}
return ret;
});
((JButton) evt.getSource()).setEnabled(false);
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonExitSlitsInitActionPerformed
private void buttonCMUinitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCMUinitActionPerformed
try {
boolean background = false;
runAsync("beamline_init/init/InitCMU", background).handle((ret, ex) -> {
((JButton) evt.getSource()).setEnabled(true);
if (ex != null) {
showException((Exception) ex);
}
return ret;
});
((JButton) evt.getSource()).setEnabled(false);
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonCMUinitActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonAUinit;
private javax.swing.JButton buttonCMUinit;
private javax.swing.JButton buttonExitSlitsInit;
private javax.swing.JButton buttonFEinit;
private javax.swing.JLabel statusAU;
// End of variables declaration//GEN-END:variables
}