import ch.psi.pshell.core.JsonSerializer; import ch.psi.pshell.device.Positioner; import ch.psi.pshell.ui.Panel; import ch.psi.pshell.ui.PanelProcessor; import ch.psi.pshell.ui.QueueProcessor; import ch.psi.utils.Arr; import ch.psi.utils.IO; import ch.psi.utils.State; import ch.psi.utils.swing.SwingUtils; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.Transferable; import java.awt.dnd.DnDConstants; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.DropMode; import javax.swing.JComponent; import javax.swing.JFileChooser; import javax.swing.JTable; import javax.swing.TransferHandler; import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.table.DefaultTableModel; /** * */ public class SIStem extends PanelProcessor { File currentFile; final DefaultTableModel modelInactive; final DefaultTableModel modelFixed; final DefaultTableModel modelScanned; public static final String FILE_EXTENSION = "json"; public SIStem() { initComponents(); modelInactive = (DefaultTableModel) tableInactive.getModel(); modelFixed = (DefaultTableModel) tableFixed.getModel(); modelScanned = (DefaultTableModel) tableScanned.getModel(); clear(); Standard st = new Standard(); st.run(); abstract class PositinerTransferHandler extends TransferHandler{ @Override public int getSourceActions(JComponent c) { return DnDConstants.ACTION_COPY_OR_MOVE; } @Override public Transferable createTransferable(JComponent comp) { try{ JTable table = (JTable) comp; return new StringSelection((String) table.getModel().getValueAt(table.getSelectedRow(),0)); } catch(Exception ex){ return null; } } @Override public boolean canImport(TransferHandler.TransferSupport support) { return support.isDataFlavorSupported(DataFlavor.stringFlavor); } @Override public boolean importData(TransferHandler.TransferSupport support) { if (support.isDrop() && canImport(support)) { try { JTable.DropLocation dl = (JTable.DropLocation)support.getDropLocation(); String name = (String) support.getTransferable().getTransferData(DataFlavor.stringFlavor); Positioner pos = getContext().getDevicePool().getByName(name, Positioner.class); DefaultTableModel model = ((DefaultTableModel)((JTable)support.getComponent()).getModel()); addPositioner(pos, model, dl.getRow(), getRowData(pos)); } catch (Exception ex) { return false; } } return true; } abstract Object[] getRowData(Positioner pos); }; tableInactive.setDragEnabled(true); tableInactive.setDropMode(DropMode.INSERT_ROWS); tableInactive.setFillsViewportHeight(true); tableInactive.setTransferHandler(new PositinerTransferHandler() { @Override Object[] getRowData(Positioner pos) { return new Object[]{pos.getName()}; } }); tableFixed.setDragEnabled(true); tableFixed.setDropMode(DropMode.INSERT_ROWS); tableFixed.setFillsViewportHeight(true); tableFixed.setTransferHandler(new PositinerTransferHandler() { @Override Object[] getRowData(Positioner pos) { return new Object[]{pos.getName(), Double.NaN, pos.getUnit()}; } }); tableScanned.setDragEnabled(true); tableScanned.setDropMode(DropMode.INSERT_ROWS); tableScanned.setFillsViewportHeight(true); tableScanned.setTransferHandler(new PositinerTransferHandler() { @Override Object[] getRowData(Positioner pos) { return new Object[]{pos.getName(), Double.NaN, Double.NaN, 0, Double.NaN, pos.getUnit()}; } }); } void addPositioner(Positioner pos, DefaultTableModel model, int row, Object[] data){ if (row<0){ row = model.getRowCount(); } model.insertRow(row, data); removePositioner(pos, modelInactive, (model==modelInactive) ? row : -1); removePositioner(pos, modelFixed, (model==modelFixed) ? row : -1); removePositioner(pos, modelScanned, (model==modelScanned) ?row : -1); } void removePositioner(Positioner pos, DefaultTableModel model, int except){ for (int i=0; i< model.getRowCount(); i++){ if ((except<0) || (i!=except)){ if (model.getValueAt(i, 0).equals(pos.getName())){ model.removeRow(i); break; } } } } //Overridable callbacks @Override public void onInitialize(int runCount) { } @Override public void onStateChange(State state, State former) { updateControls(); } @Override public void onExecutedFile(String fileName, Object result) { } //Callback to perform update - in event thread @Override protected void doUpdate() { } @Override public String getFileName(){ return (currentFile==null) ? null : currentFile.toString(); } @Override public boolean isTabNameUpdated() { return false; } @Override public String getType() { return "SIStem"; } @Override public boolean createMenuNew() { return true; } @Override public boolean createFilePanel() { return true; } @Override public String getDescription() { return "SIStem Scan definition file (*." + FILE_EXTENSION + ")"; } @Override public String[] getExtensions() { return new String[]{FILE_EXTENSION}; } @Override public String getHomePath() { return "{home}/scans"; } @Override public void saveAs(String fileName) throws IOException { currentFile = new File(fileName); Map preActions = new HashMap(); for (int i=0; i< modelFixed.getRowCount(); i++){ preActions.put(modelFixed.getValueAt(i, 0), modelFixed.getValueAt(i, 1)); } String[] positioners = new String[modelScanned.getRowCount()]; Double[] start = new Double[modelScanned.getRowCount()]; Double[] stop = new Double[modelScanned.getRowCount()]; Integer[] steps = new Integer[modelScanned.getRowCount()]; for (int i=0; i< modelScanned.getRowCount(); i++){ positioners[i] = (String) modelScanned.getValueAt(i, 0); start[i] = (Double) modelScanned.getValueAt(i, 1); stop[i] = (Double) modelScanned.getValueAt(i, 2); steps[i] = (Integer) modelScanned.getValueAt(i, 3) -1; } Map config = new HashMap(); config.put("PRE_ACTIONS", preActions); config.put("POSITIONERS", positioners); config.put("START", start); config.put("STOP", stop); config.put("STEPS", steps); //TODO: config.put("SENSORS", Arr.toList(new String[]{"scienta.dataMatrix", "sin"})); config.put("SETTLING_TIME", spinnerLatency.getValue() ); config.put("PASSES", spinnerPasses.getValue()); config.put("ZIGZAG", checkZigzag.isSelected()); config.put("COMPRESSION", true); String json = JsonSerializer.encode(config, true); Files.write(currentFile.toPath(), json.getBytes()); updateControls(); } @Override public void open(String fileName) throws IOException { clear(); if (fileName!=null){ Path path = Paths.get(fileName); String json = new String(Files.readAllBytes(path)); currentFile = path.toFile(); Map config = (Map) JsonSerializer.decode(json, Map.class); Map preActions = (Map) config.get("PRE_ACTIONS"); List positioners = (List)config.get("POSITIONERS"); List start = (List)config.get("START"); List stop = (List)config.get("STOP"); List steps = (List) config.get("STEPS"); for (String name:preActions.keySet()){ Positioner pos = getContext().getDevicePool().getByName(name, Positioner.class); if (pos!=null){ addPositioner(pos, modelFixed, -1, new Object[]{name, preActions.get(name), pos.getUnit()}); } } for (int i=0; i< positioners.size(); i++){ String name = positioners.get(i); Positioner pos = getContext().getDevicePool().getByName(name, Positioner.class); if (pos!=null){ addPositioner(pos, modelScanned, -1, new Object[]{name, start.get(i), stop.get(i), steps.get(i), 0, pos.getUnit()}); } } spinnerLatency.setValue(config.get("SETTLING_TIME")); spinnerPasses.setValue(config.get("PASSES")); checkZigzag.setSelected((Boolean) config.get("ZIGZAG")); } updateControls(); } public void clear(){ currentFile = null; modelInactive.setRowCount(0); modelFixed.setRowCount(0); modelScanned.setRowCount(0); Positioner[] positioners = getContext().getDevicePool().getAllDevicesOrderedByName(Positioner.class); for (Positioner pos: positioners){ modelInactive.addRow(new Object[]{pos.getName()}); } updateControls(); } @Override public void execute() throws Exception { checkValues(); HashMap args = new HashMap(); if (currentFile == null) { throw new Exception("TODO"); } args.put("NAME", getScanName()); this.runAsync("SIStem", args).handle((ret, ex) -> { if (ex != null) { } try { } catch (Exception e) { Logger.getLogger(SIStem.class.getName()).log(Level.SEVERE, null, e); } return ret; }); } String getScanName() { if (currentFile != null) { return IO.getPrefix(currentFile); } return null; } void updateControls() { State state = getState(); try { textFileId.setText(String.valueOf(getContext().getFileSequentialNumber())); } catch (Exception ex) { textFileId.setText(""); } String fileName = getFileName(); if (fileName == null){ textFile.setText(""); } else { String home = getContext().getSetup().expandPath(getHomePath()); if (IO.isSubPath(fileName, home)) { fileName = IO.getRelativePath(fileName, home); } textFile.setText(fileName); } buttonStart.setEnabled((state == State.Ready) && (currentFile != null)); buttonAddToQueue.setEnabled((state == State.Ready) && (currentFile != null)); buttonAbort.setEnabled(state.isProcessing()); buttonScienta.setEnabled(state.isInitialized()); } void checkValues(){ for (int i=0; i< modelFixed.getRowCount(); i++){ if (Double.isNaN((Double)modelFixed.getValueAt(i, 1))){ throw new IllegalArgumentException("Invalid value for " + modelFixed.getValueAt(i, 0)); } } for (int i=0; i< modelScanned.getRowCount(); i++){ if (Double.isNaN((Double)modelScanned.getValueAt(i, 1))){ throw new IllegalArgumentException("Invalid start for " + modelFixed.getValueAt(i, 0)); } if (Double.isNaN((Double)modelScanned.getValueAt(i, 2))){ throw new IllegalArgumentException("Invalid stop for " + modelFixed.getValueAt(i, 0)); } if (((Integer)modelScanned.getValueAt(i, 3)) < 1){ throw new IllegalArgumentException("Invalid points for " + modelFixed.getValueAt(i, 0)); } } } @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { buttonScienta = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); textFileId = new javax.swing.JTextField(); buttonResetId = new javax.swing.JButton(); buttonStart = new javax.swing.JButton(); buttonAbort = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); buttonOpen = new javax.swing.JButton(); buttonSave = new javax.swing.JButton(); jLabel3 = new javax.swing.JLabel(); textFile = new javax.swing.JTextField(); buttonClear = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); tableInactive = new javax.swing.JTable(); jScrollPane2 = new javax.swing.JScrollPane(); tableFixed = new javax.swing.JTable(); jScrollPane3 = new javax.swing.JScrollPane(); tableScanned = new javax.swing.JTable(); jLabel1 = new javax.swing.JLabel(); spinnerPasses = new javax.swing.JSpinner(); checkZigzag = new javax.swing.JCheckBox(); jLabel4 = new javax.swing.JLabel(); spinnerLatency = new javax.swing.JSpinner(); buttonAddToQueue = new javax.swing.JButton(); buttonScienta.setText("Scienta Panel"); buttonScienta.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonScientaActionPerformed(evt); } }); jLabel2.setText("File ID:"); textFileId.setEditable(false); textFileId.setHorizontalAlignment(javax.swing.JTextField.CENTER); buttonResetId.setText("Reset"); buttonResetId.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonResetIdActionPerformed(evt); } }); buttonStart.setText("Start"); buttonStart.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonStartActionPerformed(evt); } }); buttonAbort.setText("Abort"); buttonAbort.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonAbortActionPerformed(evt); } }); jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Parameters")); buttonOpen.setText("Open"); buttonOpen.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonOpenActionPerformed(evt); } }); buttonSave.setText("Save"); buttonSave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonSaveActionPerformed(evt); } }); jLabel3.setText("File:"); textFile.setDisabledTextColor(javax.swing.UIManager.getDefaults().getColor("TextField.foreground")); textFile.setEnabled(false); buttonClear.setText("Clear"); buttonClear.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonClearActionPerformed(evt); } }); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Positioners")); jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder("Inactive")); tableInactive.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { }, new String [] { "Name" } ) { Class[] types = new Class [] { java.lang.String.class }; boolean[] canEdit = new boolean [] { false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); tableInactive.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); jScrollPane1.setViewportView(tableInactive); jScrollPane2.setBorder(javax.swing.BorderFactory.createTitledBorder("Fixed")); tableFixed.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { }, new String [] { "Name", "Value", "Units" } ) { Class[] types = new Class [] { java.lang.String.class, java.lang.Double.class, java.lang.String.class }; boolean[] canEdit = new boolean [] { false, true, false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); tableFixed.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); jScrollPane2.setViewportView(tableFixed); jScrollPane3.setBorder(javax.swing.BorderFactory.createTitledBorder("Scanned")); tableScanned.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { }, new String [] { "Name", "Start", "Stop", "Points", "Step", "Units" } ) { Class[] types = new Class [] { java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Integer.class, java.lang.Double.class, java.lang.String.class }; boolean[] canEdit = new boolean [] { false, true, true, true, false, false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); tableScanned.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); jScrollPane3.setViewportView(tableScanned); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE) .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE)) .addGap(12, 12, 12)) ); jLabel1.setText("Passes:"); spinnerPasses.setModel(new javax.swing.SpinnerNumberModel(1, 1, 1000, 1)); checkZigzag.setText("Zigzag"); jLabel4.setText("Settling Time:"); spinnerLatency.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, 1000.0d, 1.0d)); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(17, 17, 17) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(0, 98, Short.MAX_VALUE) .addComponent(checkZigzag) .addGap(18, 18, 18) .addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(spinnerLatency, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(spinnerPasses, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(textFile) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(buttonOpen) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(buttonSave) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(buttonClear))))) .addContainerGap()) ); jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonClear, buttonOpen, buttonSave}); jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerLatency, spinnerPasses}); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonOpen) .addComponent(buttonSave) .addComponent(jLabel3) .addComponent(textFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(buttonClear)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(spinnerLatency, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(checkZigzag)) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(spinnerPasses, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(2, 2, 2) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(56, Short.MAX_VALUE)) ); buttonAddToQueue.setText("Add to Queue"); buttonAddToQueue.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonAddToQueueActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(buttonAddToQueue) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(buttonStart) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(buttonAbort) .addContainerGap(137, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(buttonScienta) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(textFileId, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(buttonResetId) .addContainerGap()))) ); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonAbort, buttonAddToQueue, buttonStart}); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonScienta) .addComponent(buttonResetId) .addComponent(jLabel2) .addComponent(textFileId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonStart) .addComponent(buttonAbort) .addComponent(buttonAddToQueue)) .addContainerGap()) ); }// //GEN-END:initComponents private void buttonScientaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonScientaActionPerformed try { this.showDevicePanel("scienta"); } catch (Exception ex) { showException(ex); } }//GEN-LAST:event_buttonScientaActionPerformed private void buttonResetIdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonResetIdActionPerformed try { this.getContext().setFileSequentialNumber(0); updateControls(); } catch (Exception ex) { showException(ex); } }//GEN-LAST:event_buttonResetIdActionPerformed private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed try { execute(); } catch (Exception ex) { showException(ex); } }//GEN-LAST:event_buttonStartActionPerformed private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed try { abort(); } catch (Exception ex) { showException(ex); } }//GEN-LAST:event_buttonAbortActionPerformed private void buttonOpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonOpenActionPerformed try { open(); } catch (Exception ex) { showException(ex); } }//GEN-LAST:event_buttonOpenActionPerformed private void buttonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSaveActionPerformed try { JFileChooser chooser = new JFileChooser(getContext().getSetup().expandPath(getHomePath())); FileNameExtensionFilter filter = new FileNameExtensionFilter(getDescription(), getExtensions()); chooser.setFileFilter(filter); try { if (currentFile != null) { chooser.setSelectedFile(currentFile); } } catch (Exception ex) { this.showException(ex); } int rVal = chooser.showSaveDialog(this); if (rVal == JFileChooser.APPROVE_OPTION) { String fileName = chooser.getSelectedFile().getAbsolutePath(); if (IO.getExtension(chooser.getSelectedFile().getAbsolutePath()).isEmpty()) { fileName += "." + FILE_EXTENSION; } saveAs(fileName); } } catch (Exception ex) { showException(ex); } }//GEN-LAST:event_buttonSaveActionPerformed private void buttonAddToQueueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAddToQueueActionPerformed try { QueueProcessor tq = null; List queues = getView().getQueues(); if (queues.size()==0){ tq = getView().openProcessor(QueueProcessor.class, null); } else { tq = queues.get(0); } getView().getDocumentsTab().setSelectedComponent(tq); tq.addNewFile(currentFile.getPath()); } catch (Exception ex) { showException(ex); } }//GEN-LAST:event_buttonAddToQueueActionPerformed private void buttonClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonClearActionPerformed try { clear(); } catch (Exception ex) { showException(ex); } }//GEN-LAST:event_buttonClearActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton buttonAbort; private javax.swing.JButton buttonAddToQueue; private javax.swing.JButton buttonClear; private javax.swing.JButton buttonOpen; private javax.swing.JButton buttonResetId; private javax.swing.JButton buttonSave; private javax.swing.JButton buttonScienta; private javax.swing.JButton buttonStart; private javax.swing.JCheckBox checkZigzag; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JSpinner spinnerLatency; private javax.swing.JSpinner spinnerPasses; private javax.swing.JTable tableFixed; private javax.swing.JTable tableInactive; private javax.swing.JTable tableScanned; private javax.swing.JTextField textFile; private javax.swing.JTextField textFileId; // End of variables declaration//GEN-END:variables }