/* * Copyright (c) 2014-2017 Paul Scherrer Institute. All rights reserved. */ import ch.psi.pshell.ui.Panel; import ch.psi.utils.State; import ch.psi.utils.swing.SwingUtils; /** * */ public class Recovery extends Panel { public Recovery() { 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) { } //Callback to perform update - in event thread @Override protected void doUpdate() { } @Override public boolean isActive() { return true; } void execute(String statement){ execute(statement, false); } void execute(String statement, boolean background){ execute(statement, background, false); } void execute(String statement, boolean background, boolean showReturn){ try { evalAsync(statement, background).handle((ret, ex) -> { if (ex != null){ showException((Exception)ex); } else if (showReturn){ SwingUtils.showMessage(getTopLevel(), "Return", String.valueOf(ret)); } return ret; }); } catch (Exception ex) { showException(ex); } } void execute(String script, Object args){ try { runAsync(script, args).handle((ret, ex) -> { if (ex != null){ showException((Exception)ex); } return ret; }); } catch (Exception ex) { showException(ex); } } @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { ledLidControlActive = new ch.psi.pshell.swing.Led(); jLabel6 = new javax.swing.JLabel(); ledLidInitialized = new ch.psi.pshell.swing.Led(); jLabel7 = new javax.swing.JLabel(); buttonInitHexiposi = new javax.swing.JButton(); jLabel6.setText("Known position"); jLabel7.setText("Valid segment"); buttonInitHexiposi.setText("Recover"); buttonInitHexiposi.setEnabled(false); buttonInitHexiposi.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonInitHexiposiActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(ledLidControlActive, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel6)) .addGroup(layout.createSequentialGroup() .addComponent(ledLidInitialized, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel7)))) .addGroup(layout.createSequentialGroup() .addContainerGap(96, Short.MAX_VALUE) .addComponent(buttonInitHexiposi))) .addContainerGap(116, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(ledLidControlActive, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel6)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(ledLidInitialized, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel7)) .addGap(18, 18, 18) .addComponent(buttonInitHexiposi) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); }// //GEN-END:initComponents private void buttonInitHexiposiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonInitHexiposiActionPerformed try{ this.showDevicePanel("hexiposi"); } catch (Exception ex) { showException(ex); } }//GEN-LAST:event_buttonInitHexiposiActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton buttonInitHexiposi; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private ch.psi.pshell.swing.Led ledLidControlActive; private ch.psi.pshell.swing.Led ledLidInitialized; // End of variables declaration//GEN-END:variables }