XPS
This commit is contained in:
731
plugins/XPS.java
Normal file
731
plugins/XPS.java
Normal file
@@ -0,0 +1,731 @@
|
||||
|
||||
import ch.psi.pshell.scan.Scan;
|
||||
import ch.psi.pshell.ui.ScriptProcessor;
|
||||
import ch.psi.utils.EncoderJson;
|
||||
import ch.psi.utils.IO;
|
||||
import ch.psi.utils.State;
|
||||
import ch.psi.utils.swing.StandardDialog;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
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.Map;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class XPS extends ScriptProcessor {
|
||||
|
||||
File currentFile;
|
||||
final DefaultTableModel model;
|
||||
public static final String FILE_EXTENSION = "xps";
|
||||
|
||||
public XPS() {
|
||||
initComponents();
|
||||
model = (DefaultTableModel) table.getModel();
|
||||
|
||||
table.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
try {
|
||||
if ((e.getClickCount() == 2) && (!e.isPopupTrigger())) {
|
||||
if (table.isEnabled()){
|
||||
int row = table.getSelectedRow();
|
||||
if ((model.getRowCount()>0) && (row>=0)){
|
||||
row = table.convertRowIndexToModel(row);
|
||||
|
||||
String name = (String) model.getValueAt(row, 1);
|
||||
String json = (String) model.getValueAt(row, 2);
|
||||
Map pars = (Map) EncoderJson.decode(json, Map.class);
|
||||
pars.put("name", name);
|
||||
Map<String, Object> newPars = showScientaParametersDialog(pars);
|
||||
if (newPars!=null){
|
||||
name = (String) newPars.get("name");
|
||||
if (name!=null){
|
||||
newPars.remove("name");
|
||||
json = EncoderJson.encode(newPars, true);
|
||||
//showMessage(name, json);
|
||||
model.setValueAt(name, row, 1);
|
||||
model.setValueAt(json, row, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
table.getColumnModel().getColumn(0).setMaxWidth(60);
|
||||
table.getColumnModel().getColumn(0).setResizable(false);
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "XPS";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSave() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileName() {
|
||||
return (currentFile==null) ? null : currentFile.toString();
|
||||
}
|
||||
@Override
|
||||
public boolean createMenuNew() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createFilePanel() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "XPS scan definition file (*." + FILE_EXTENSION + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getExtensions() {
|
||||
return new String[]{FILE_EXTENSION};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHomePath() {
|
||||
return "{home}/parameters";
|
||||
}
|
||||
|
||||
//Overridable callbacks
|
||||
@Override
|
||||
public void onInitialize(int runCount) {
|
||||
this.startTimer(1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChange(State state, State former) {
|
||||
buttonStart.setEnabled(state == State.Ready);
|
||||
buttonAbort.setEnabled((state == State.Busy) && isRunning());
|
||||
buttonScienta.setEnabled(state.isInitialized());
|
||||
buttonAddToQueue.setEnabled(buttonStart.isEnabled());
|
||||
updateButtons();
|
||||
updateSeq();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimer() {
|
||||
if (isRunning()){
|
||||
try{
|
||||
textCurScan.setText(getGlobalVar("CURRENT_REGION").toString());
|
||||
} catch(Exception ex){
|
||||
getLogger().log(Level.WARNING, null, ex);
|
||||
textCurScan.setText("");
|
||||
}
|
||||
try{
|
||||
int index = (Integer)getGlobalVar("CURRENT_INDEX");
|
||||
for (int row=0; row<model.getRowCount(); row++){
|
||||
if (Boolean.TRUE.equals(model.getValueAt(row, 0))){
|
||||
if (index==0){
|
||||
row = table.convertRowIndexToView(row);
|
||||
table.setRowSelectionInterval(row, row);
|
||||
break;
|
||||
}
|
||||
index--;
|
||||
}
|
||||
}
|
||||
} catch(Exception ex){
|
||||
getLogger().log(Level.WARNING, null, ex);
|
||||
table.clearSelection();
|
||||
}
|
||||
} else {
|
||||
textCurScan.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
void updateSeq() {
|
||||
try {
|
||||
textFileId.setText(String.valueOf(getContext().getFileSequentialNumber()));
|
||||
} catch (Exception ex) {
|
||||
textFileId.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecutedFile(String fileName, Object result) {
|
||||
}
|
||||
|
||||
//Callback to perform update - in event thread
|
||||
@Override
|
||||
protected void doUpdate() {
|
||||
}
|
||||
|
||||
String getScanName() {
|
||||
String name = textName.getText().trim();
|
||||
return name.isEmpty() ? null : name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScript() {
|
||||
return "templates/XPS";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getArgs() {
|
||||
HashMap<String, Object> args = new HashMap<>();
|
||||
|
||||
ArrayList regions = new ArrayList();
|
||||
for (int i = 0; i < model.getRowCount(); i++) {
|
||||
if (Boolean.TRUE.equals(model.getValueAt(i, 0))){
|
||||
ArrayList region = new ArrayList();
|
||||
region.add(model.getValueAt(i, 1));
|
||||
region.add(model.getValueAt(i, 2));
|
||||
regions.add(region);
|
||||
}
|
||||
}
|
||||
|
||||
args.put("FILE", null);
|
||||
args.put("NAME", getScanName());
|
||||
args.put("REGIONS", regions);
|
||||
return args;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartingExecution(Map<String, Object> args){
|
||||
table.clearSelection();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishedExecution(Map<String, Object> args, Object ret, Throwable t){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAs(String fileName) throws IOException {
|
||||
currentFile = new File(fileName);
|
||||
ArrayList data = new ArrayList();
|
||||
data.add(new Object[][]{new Object[]{textName.getText()}});
|
||||
data.add(model.getDataVector());
|
||||
String json = EncoderJson.encode(data, true);
|
||||
Files.write(currentFile.toPath(), json.getBytes());
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(String fileName) throws IOException {
|
||||
if (fileName==null){
|
||||
currentFile = null;
|
||||
textName.setText("");
|
||||
model.setRowCount(0);
|
||||
} else {
|
||||
Path path = Paths.get(fileName);
|
||||
String json = new String(Files.readAllBytes(path));
|
||||
currentFile = path.toFile();
|
||||
Object[][][] vector = (Object[][][]) EncoderJson.decode(json, Object[][][].class);
|
||||
textName.setText(String.valueOf(vector[0][0][0]));
|
||||
model.setDataVector(vector[1], SwingUtils.getTableColumnNames(table));
|
||||
}
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
|
||||
Map<String, Object> showScientaParametersDialog(Map<String, Object> pars) throws Exception{
|
||||
Class cls = getContext().getClassByName("ScientaParametersDialog");
|
||||
Constructor constructor= cls.getConstructor(Window.class, boolean.class, Map.class);
|
||||
StandardDialog dlg = (StandardDialog) constructor.newInstance(getWindow(),true, pars);
|
||||
dlg.setVisible(true);
|
||||
if (dlg.getResult()){
|
||||
return (Map<String, Object>)cls.getMethod("getValues").invoke(dlg);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void updateButtons() {
|
||||
boolean editing = !isExecuting();
|
||||
int rows = model.getRowCount();
|
||||
int cur = table.getSelectedRow();
|
||||
buttonUp.setEnabled((rows > 0) && (cur > 0) && editing);
|
||||
buttonDown.setEnabled((rows > 0) && (cur >= 0) && (cur < (rows - 1)) && editing);
|
||||
buttonDelete.setEnabled((rows > 0) && (cur >= 0) && editing);
|
||||
buttonInsert.setEnabled(editing);
|
||||
buttonClear.setEnabled(editing);
|
||||
buttonOpen.setEnabled(editing);
|
||||
table.setEnabled(editing);
|
||||
textName.setEnabled(editing);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jScrollPane2 = new javax.swing.JScrollPane();
|
||||
jEditorPane1 = new javax.swing.JEditorPane();
|
||||
buttonStart = new javax.swing.JButton();
|
||||
buttonAbort = new javax.swing.JButton();
|
||||
buttonScienta = new javax.swing.JButton();
|
||||
jPanel2 = new javax.swing.JPanel();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
textName = new javax.swing.JTextField();
|
||||
buttonOpen = new javax.swing.JButton();
|
||||
buttonSave = new javax.swing.JButton();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
table = new javax.swing.JTable();
|
||||
buttonInsert = new javax.swing.JButton();
|
||||
buttonDelete = new javax.swing.JButton();
|
||||
buttonClear = new javax.swing.JButton();
|
||||
buttonUp = new javax.swing.JButton();
|
||||
buttonDown = new javax.swing.JButton();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
textFileId = new javax.swing.JTextField();
|
||||
buttonResetId = new javax.swing.JButton();
|
||||
jLabel4 = new javax.swing.JLabel();
|
||||
textCurScan = new javax.swing.JTextField();
|
||||
buttonAddToQueue = new javax.swing.JButton();
|
||||
|
||||
jScrollPane2.setViewportView(jEditorPane1);
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
buttonScienta.setText("Scienta Panel");
|
||||
buttonScienta.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonScientaActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Parameters"));
|
||||
|
||||
jLabel1.setText("Name:");
|
||||
|
||||
textName.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
textNameActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
table.setModel(new javax.swing.table.DefaultTableModel(
|
||||
new Object [][] {
|
||||
|
||||
},
|
||||
new String [] {
|
||||
"Enabled", "Region Name", "Arguments"
|
||||
}
|
||||
) {
|
||||
Class[] types = new Class [] {
|
||||
java.lang.Boolean.class, java.lang.Object.class, java.lang.String.class
|
||||
};
|
||||
boolean[] canEdit = new boolean [] {
|
||||
true, true, false
|
||||
};
|
||||
|
||||
public Class getColumnClass(int columnIndex) {
|
||||
return types [columnIndex];
|
||||
}
|
||||
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return canEdit [columnIndex];
|
||||
}
|
||||
});
|
||||
table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
||||
table.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseReleased(java.awt.event.MouseEvent evt) {
|
||||
tableMouseReleased(evt);
|
||||
}
|
||||
});
|
||||
table.addKeyListener(new java.awt.event.KeyAdapter() {
|
||||
public void keyReleased(java.awt.event.KeyEvent evt) {
|
||||
tableKeyReleased(evt);
|
||||
}
|
||||
});
|
||||
jScrollPane1.setViewportView(table);
|
||||
|
||||
buttonInsert.setText("Insert");
|
||||
buttonInsert.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonInsertActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonDelete.setText("Delete");
|
||||
buttonDelete.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonDeleteActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonClear.setText("Clear");
|
||||
buttonClear.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonClearActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonUp.setText("Move Up");
|
||||
buttonUp.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonUpActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonDown.setText("Move Down");
|
||||
buttonDown.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonDownActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
|
||||
jPanel2.setLayout(jPanel2Layout);
|
||||
jPanel2Layout.setHorizontalGroup(
|
||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(textName)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonClear)
|
||||
.addGap(5, 5, 5)
|
||||
.addComponent(buttonOpen)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonSave))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
|
||||
.addComponent(buttonUp)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonDown)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonInsert)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonDelete)))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonDelete, buttonDown, buttonInsert, buttonUp});
|
||||
|
||||
jPanel2Layout.setVerticalGroup(
|
||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(textName)
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(buttonOpen)
|
||||
.addComponent(buttonSave)
|
||||
.addComponent(buttonClear))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(buttonInsert)
|
||||
.addComponent(buttonDelete)
|
||||
.addComponent(buttonUp)
|
||||
.addComponent(buttonDown))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel4.setText("Current Region:");
|
||||
|
||||
textCurScan.setEditable(false);
|
||||
textCurScan.setHorizontalAlignment(javax.swing.JTextField.CENTER);
|
||||
|
||||
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(buttonStart, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(33, 33, 33)
|
||||
.addComponent(buttonAbort)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel4)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(textCurScan, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(buttonScienta, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGap(18, 18, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(buttonAddToQueue)
|
||||
.addGap(18, 18, Short.MAX_VALUE)
|
||||
.addComponent(jLabel2)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(textFileId, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(buttonResetId, javax.swing.GroupLayout.Alignment.TRAILING))
|
||||
.addContainerGap())))
|
||||
);
|
||||
|
||||
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonAbort, buttonStart});
|
||||
|
||||
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonResetId, textCurScan, textFileId});
|
||||
|
||||
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(7, 7, 7)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel2)
|
||||
.addComponent(textFileId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel4)
|
||||
.addComponent(textCurScan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(buttonAddToQueue))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(buttonResetId)
|
||||
.addComponent(buttonScienta))
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(buttonStart)
|
||||
.addComponent(buttonAbort))
|
||||
.addContainerGap())
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
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 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);
|
||||
updateSeq();
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonResetIdActionPerformed
|
||||
|
||||
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);
|
||||
} else if (getScanName() != null) {
|
||||
File file = Paths.get(chooser.getCurrentDirectory().getAbsolutePath(), getScanName()).toFile();
|
||||
chooser.setSelectedFile(file);
|
||||
}
|
||||
} 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 {
|
||||
//queue(getFileName()!=null); //If file is defined then queue file.
|
||||
queue(); //Queue editing parameters
|
||||
} catch (Exception ex) {
|
||||
showException( ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonAddToQueueActionPerformed
|
||||
|
||||
private void textNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textNameActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_textNameActionPerformed
|
||||
|
||||
private void buttonClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonClearActionPerformed
|
||||
try {
|
||||
open(null);
|
||||
} catch (Exception ex) {
|
||||
showException( ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonClearActionPerformed
|
||||
|
||||
private void buttonInsertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonInsertActionPerformed
|
||||
try {
|
||||
Map<String, Object> pars = showScientaParametersDialog(null);
|
||||
if (pars!=null){
|
||||
String name = (String) pars.get("name");
|
||||
if (name!=null){
|
||||
pars.remove("name");
|
||||
String json = EncoderJson.encode(pars, true);
|
||||
model.addRow(new Object[]{true, name, json});
|
||||
updateButtons();
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
showException( ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonInsertActionPerformed
|
||||
|
||||
private void buttonDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDeleteActionPerformed
|
||||
try {
|
||||
if ((model.getRowCount() > 0) && (table.getSelectedRow() >= 0)) {
|
||||
model.removeRow(table.getSelectedRow());
|
||||
updateButtons();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonDeleteActionPerformed
|
||||
|
||||
private void buttonUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUpActionPerformed
|
||||
try {
|
||||
int rows = model.getRowCount();
|
||||
int cur = table.getSelectedRow();
|
||||
model.moveRow(cur, cur, cur - 1);
|
||||
table.setRowSelectionInterval(cur - 1, cur - 1);
|
||||
updateButtons();
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonUpActionPerformed
|
||||
|
||||
private void buttonDownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDownActionPerformed
|
||||
try {
|
||||
int rows = model.getRowCount();
|
||||
int cur = table.getSelectedRow();
|
||||
model.moveRow(cur, cur, cur + 1);
|
||||
table.setRowSelectionInterval(cur + 1, cur + 1);
|
||||
updateButtons();
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonDownActionPerformed
|
||||
|
||||
private void tableKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tableKeyReleased
|
||||
updateButtons();
|
||||
}//GEN-LAST:event_tableKeyReleased
|
||||
|
||||
private void tableMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableMouseReleased
|
||||
updateButtons();
|
||||
}//GEN-LAST:event_tableMouseReleased
|
||||
|
||||
// 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 buttonDelete;
|
||||
private javax.swing.JButton buttonDown;
|
||||
private javax.swing.JButton buttonInsert;
|
||||
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.JButton buttonUp;
|
||||
private javax.swing.JEditorPane jEditorPane1;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JLabel jLabel4;
|
||||
private javax.swing.JPanel jPanel2;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JScrollPane jScrollPane2;
|
||||
private javax.swing.JTable table;
|
||||
private javax.swing.JTextField textCurScan;
|
||||
private javax.swing.JTextField textFileId;
|
||||
private javax.swing.JTextField textName;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user