XPS
This commit is contained in:
@@ -31,6 +31,7 @@ public class EnergyScan extends ScriptProcessor {
|
||||
public EnergyScan() {
|
||||
initComponents();
|
||||
model = (DefaultTableModel) table.getModel();
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,6 +81,7 @@ public class EnergyScan extends ScriptProcessor {
|
||||
buttonAbort.setEnabled((state == State.Busy) && isRunning());
|
||||
buttonScienta.setEnabled(state.isInitialized());
|
||||
buttonAddToQueue.setEnabled(buttonStart.isEnabled());
|
||||
updateButtons();
|
||||
updateSeq();
|
||||
}
|
||||
|
||||
@@ -134,6 +136,7 @@ public class EnergyScan extends ScriptProcessor {
|
||||
data.add(spinnerPasses.getValue());
|
||||
String json = EncoderJson.encode(data, true);
|
||||
Files.write(currentFile.toPath(), json.getBytes());
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -152,6 +155,7 @@ public class EnergyScan extends ScriptProcessor {
|
||||
model.setDataVector(vector[1], SwingUtils.getTableColumnNames(table));
|
||||
spinnerPasses.setValue((vector.length>2) ? (Integer)vector[2][0][0] : 1);
|
||||
}
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
String lastOutput;
|
||||
@@ -201,6 +205,18 @@ public class EnergyScan extends ScriptProcessor {
|
||||
return args;
|
||||
}
|
||||
|
||||
protected void updateButtons() {
|
||||
boolean editing = !isExecuting();
|
||||
int rows = model.getRowCount();
|
||||
int cur = table.getSelectedRow();
|
||||
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() {
|
||||
@@ -216,7 +232,7 @@ public class EnergyScan extends ScriptProcessor {
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
table = new javax.swing.JTable();
|
||||
buttonAdd = new javax.swing.JButton();
|
||||
buttonInsert = new javax.swing.JButton();
|
||||
buttonDelete = new javax.swing.JButton();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
buttonOpen = new javax.swing.JButton();
|
||||
@@ -274,12 +290,22 @@ public class EnergyScan extends ScriptProcessor {
|
||||
return types [columnIndex];
|
||||
}
|
||||
});
|
||||
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);
|
||||
|
||||
buttonAdd.setText("Add");
|
||||
buttonAdd.addActionListener(new java.awt.event.ActionListener() {
|
||||
buttonInsert.setText("Insert");
|
||||
buttonInsert.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonAddActionPerformed(evt);
|
||||
buttonInsertActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -297,16 +323,16 @@ public class EnergyScan extends ScriptProcessor {
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(buttonAdd)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(buttonInsert)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonDelete)
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addComponent(buttonDelete)))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonAdd, buttonDelete});
|
||||
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonDelete, buttonInsert});
|
||||
|
||||
jPanel1Layout.setVerticalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@@ -315,7 +341,7 @@ public class EnergyScan extends ScriptProcessor {
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(buttonAdd)
|
||||
.addComponent(buttonInsert)
|
||||
.addComponent(buttonDelete))
|
||||
.addContainerGap())
|
||||
);
|
||||
@@ -361,27 +387,24 @@ public class EnergyScan extends ScriptProcessor {
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(textName)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonClear)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonOpen)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonSave)))
|
||||
.addContainerGap())
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(textName, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonClear)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonOpen)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonSave))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
|
||||
.addComponent(jLabel3)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(spinnerPasses, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonAddToQueue)
|
||||
.addGap(26, 26, 26))))
|
||||
.addComponent(buttonAddToQueue)))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonClear, buttonOpen, buttonSave});
|
||||
@@ -490,19 +513,21 @@ public class EnergyScan extends ScriptProcessor {
|
||||
}
|
||||
}//GEN-LAST:event_buttonAbortActionPerformed
|
||||
|
||||
private void buttonAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAddActionPerformed
|
||||
private void buttonInsertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonInsertActionPerformed
|
||||
try {
|
||||
//model.addRow(new Object[]{energy.getMinValue(), energy.getMaxValue(), 10.0});
|
||||
model.addRow(new Object[]{500.0, 1000.0, 100.0});
|
||||
updateButtons();
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonAddActionPerformed
|
||||
}//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);
|
||||
@@ -578,12 +603,20 @@ public class EnergyScan extends ScriptProcessor {
|
||||
}
|
||||
}//GEN-LAST:event_buttonClearActionPerformed
|
||||
|
||||
private void tableMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableMouseReleased
|
||||
updateButtons();
|
||||
}//GEN-LAST:event_tableMouseReleased
|
||||
|
||||
private void tableKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tableKeyReleased
|
||||
updateButtons();
|
||||
}//GEN-LAST:event_tableKeyReleased
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton buttonAbort;
|
||||
private javax.swing.JButton buttonAdd;
|
||||
private javax.swing.JButton buttonAddToQueue;
|
||||
private javax.swing.JButton buttonClear;
|
||||
private javax.swing.JButton buttonDelete;
|
||||
private javax.swing.JButton buttonInsert;
|
||||
private javax.swing.JButton buttonOpen;
|
||||
private javax.swing.JButton buttonResetId;
|
||||
private javax.swing.JButton buttonSave;
|
||||
|
||||
Reference in New Issue
Block a user