Merge branch 'messagescripttest' of ssh://kielweek.web4sap.com:22/home/trac/git into messagescripttest

This commit is contained in:
Fabian Schwarz-Fritz committed 2011-11-15 19:26:54 +01:00
commit 910667d061
5 files changed
+1261

No files matched your search

@@ -0,0 +1,186 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* CommandChoice.java
*
* Created on 15.11.2011, 15:10:16
*/
package com.sap.sailing.domain.swisstimingadapter.test.ui;
/**
*
* @author D056866
*/
public class CommandChoice extends javax.swing.JDialog {
public static final int CANCEL = 0;
public static final int RAC = 1;
public static final int ABS = 2;
public static final int RPD = 3;
private int userChoice = 0;
/** Creates new form CommandChoice */
public CommandChoice(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jButton1.setText("RAC");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("Cancel");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setText("ABS");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton4.setText("RPD");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton2)
.addContainerGap(325, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 88, Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 88, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 88, Short.MAX_VALUE))
.addGap(302, 302, 302))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton4)
.addGap(50, 50, 50)
.addComponent(jButton2)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
userChoice = RAC;
dispose();
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
userChoice = CANCEL;
dispose();
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// TODO add your handling code here:
userChoice = ABS;
dispose();
}//GEN-LAST:event_jButton3ActionPerformed
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
// TODO add your handling code here:
userChoice = RPD;
dispose();
}//GEN-LAST:event_jButton4ActionPerformed
public int getUserChoice(){
return userChoice;
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(CommandChoice.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(CommandChoice.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(CommandChoice.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(CommandChoice.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
CommandChoice dialog = new CommandChoice(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
// End of variables declaration//GEN-END:variables
}
@@ -0,0 +1,154 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* EditABS.java
*
* Created on 15.11.2011, 16:30:05
*/
package com.sap.sailing.domain.swisstimingadapter.test.ui;
import com.sap.sailing.domain.swisstimingadapter.classes.messages.ABSMessage;
/**
*
* @author D056866
*/
public class EditABS extends javax.swing.JDialog {
private ABSMessage abs;
/** Creates new form EditABS */
public EditABS(java.awt.Frame parent, boolean modal, ABSMessage pAbs) {
super(parent, modal);
initComponents();
if (pAbs != null)
this.abs = pAbs;
else
this.abs = new ABSMessage();
jRacedID.setText(abs.getRaceId());
jLeg.setText(abs.getLeg());
jSailNumber.setText(abs.getSailNumber());
jSpeed.setText(""+abs.getSpeed());
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jRacedID = new javax.swing.JTextField();
jLeg = new javax.swing.JTextField();
jSailNumber = new javax.swing.JTextField();
jSpeed = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jOk = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jLabel1.setText("Race-ID:");
jRacedID.setText("jTextField1");
jLeg.setText("jTextField2");
jSailNumber.setText("jTextField3");
jSpeed.setText("jTextField4");
jLabel2.setText("Leg:");
jLabel3.setText("Sail Number:");
jLabel4.setText("Speed:");
jOk.setText("Ok");
jOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jOkActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jOk, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jSpeed)
.addComponent(jSailNumber)
.addComponent(jLeg)
.addComponent(jRacedID, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE))))
.addContainerGap(258, 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(jLabel1)
.addComponent(jRacedID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLeg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jSailNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jSpeed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jOk)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jOkActionPerformed
// TODO add your handling code here:
abs.setLeg(jLeg.getText());
abs.setRaceId(jRacedID.getText());
abs.setSailNumber(jSailNumber.getText());
abs.setSpeed(Double.parseDouble(jSpeed.getText()));
dispose();
}//GEN-LAST:event_jOkActionPerformed
public ABSMessage getMessage(){
return abs;
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JTextField jLeg;
private javax.swing.JButton jOk;
private javax.swing.JTextField jRacedID;
private javax.swing.JTextField jSailNumber;
private javax.swing.JTextField jSpeed;
// End of variables declaration//GEN-END:variables
}
@@ -0,0 +1,192 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* EditRAC.java
*
* Created on 15.11.2011, 14:48:09
*/
package com.sap.sailing.domain.swisstimingadapter.test.ui;
import com.sap.sailing.domain.swisstimingadapter.Race;
import com.sap.sailing.domain.swisstimingadapter.classes.messages.RACMessage;
import com.sap.sailing.domain.swisstimingadapter.impl.RaceImpl;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author D056866
*/
public class EditRAC extends javax.swing.JDialog {
private List<Race> races;
private RACMessage rac;
/** Creates new form EditRAC */
public EditRAC(java.awt.Frame parent, boolean modal, RACMessage rac) {
super(parent, modal);
initComponents();
if (rac != null){
this.rac = rac;
races = rac.getRaceList();
}
else{
this.races = new ArrayList<Race>();
this.rac = new RACMessage(races);
}
jRaceList.setListData(races.toArray());
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jButton1 = new javax.swing.JButton();
jRaceID = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jRaceDesc = new javax.swing.JTextField();
jAdd = new javax.swing.JButton();
jRemove = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jRaceList = new javax.swing.JList();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jButton1.setText("Ok");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jRaceID.setText("jTextField1");
jLabel1.setText("Race-ID:");
jLabel2.setText("Race-Description:");
jRaceDesc.setText("jTextField2");
jAdd.setText("Add");
jAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jAddActionPerformed(evt);
}
});
jRemove.setText("Remove");
jRemove.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRemoveActionPerformed(evt);
}
});
jScrollPane1.setViewportView(jRaceList);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jRaceDesc, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jRaceID, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jRemove, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jAdd, javax.swing.GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE)))
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jAdd)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jRemove))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jRaceID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jRaceDesc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 84, Short.MAX_VALUE)
.addComponent(jButton1)))
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jAddActionPerformed
// TODO add your handling code here:
races.add(new DescriptionRace(jRaceID.getText(), jRaceDesc.getText()));
jRaceList.setListData(races.toArray());
}//GEN-LAST:event_jAddActionPerformed
private void jRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRemoveActionPerformed
// TODO add your handling code here:
for (Object o : jRaceList.getSelectedValues()){
if (o instanceof Race)
races.remove((Race) o);
}
jRaceList.setListData(races.toArray());
}//GEN-LAST:event_jRemoveActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
this.dispose();
}//GEN-LAST:event_jButton1ActionPerformed
public RACMessage getRACMessage(){
return rac;
}
private class DescriptionRace extends RaceImpl {
public DescriptionRace(String raceId, String desc){
super(raceId, desc);
}
@Override
public String toString(){
return "" + getRaceID() + ": " + getDescription();
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jAdd;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JTextField jRaceDesc;
private javax.swing.JTextField jRaceID;
private javax.swing.JList jRaceList;
private javax.swing.JButton jRemove;
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration//GEN-END:variables
}
@@ -0,0 +1,502 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* EditRPD.java
*
* Created on 15.11.2011, 17:11:44
*/
package com.sap.sailing.domain.swisstimingadapter.test.ui;
import com.sap.sailing.domain.swisstimingadapter.classes.messages.RPDMessage;
import com.sap.sailing.domain.swisstimingadapter.classes.messages.RacePositionDataElement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
/**
*
* @author D056866
*/
public class EditRPD extends javax.swing.JDialog {
private RPDMessage rpd;
private List<RacePositionDataElement> rpdData;
private DateFormat dateFormat;
/** Creates new form EditRPD */
public EditRPD(java.awt.Frame parent, boolean modal, RPDMessage pRpd) {
super(parent, modal);
initComponents();
dateFormat = new SimpleDateFormat("HH:MM:SS");
if (pRpd != null){
this.rpd = pRpd;
}
else{
rpd = new RPDMessage();
try {
rpd.setStartTime(dateFormat.parse("00:00:00"));
rpd.setRaceTime(dateFormat.parse("00:00:00"));
rpd.setDataTime(dateFormat.parse("00:00:00"));
}
catch (Exception e){
}
}
rpdData = rpd.getRacePositionElements();
jRPDData.setListData(rpdData.toArray());
setValuesInUI();
}
private void setValuesInUI(){
jRaceID.setText(rpd.getRaceId());
jStatus.setText(""+rpd.getStatus());
jDateTime.setText(""+rpd.getDataTime());
jStartTime.setText(""+rpd.getStartTime());
jRaceTime.setText(""+rpd.getRaceTime());
jNextMarkLeader.setText(""+rpd.getNextMarkLeader());
jDistanceToNextMarkLeader.setText(""+rpd.getDistanceToNextMarkLeader());
}
private void getValuesFromUI(){
rpd.setRaceId(jRaceID.getText());
rpd.setStatus(Integer.parseInt(jStatus.getText()));
try {
rpd.setDataTime(dateFormat.parse(jDateTime.getText()));
rpd.setStartTime(dateFormat.parse(jStartTime.getText()));
rpd.setRaceTime(dateFormat.parse(jRaceTime.getText()));
}
catch (Exception e){
}
rpd.setNextMarkLeader(Integer.parseInt(jNextMarkLeader.getText()));
rpd.setDistanceToNextMarkLeader(Double.parseDouble(jDistanceToNextMarkLeader.getText()));
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jRaceID = new javax.swing.JTextField();
jStatus = new javax.swing.JTextField();
jDateTime = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jStartTime = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
jRaceTime = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
jNextMarkLeader = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
jDistanceToNextMarkLeader = new javax.swing.JTextField();
jSeparator1 = new javax.swing.JSeparator();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
jLabel17 = new javax.swing.JLabel();
jLabel18 = new javax.swing.JLabel();
jDistanceToNextMark = new javax.swing.JTextField();
jDistanceToLeader = new javax.swing.JTextField();
jRank = new javax.swing.JTextField();
jCOG = new javax.swing.JTextField();
jVMG = new javax.swing.JTextField();
jSOG = new javax.swing.JTextField();
jLongitude = new javax.swing.JTextField();
jLatitude = new javax.swing.JTextField();
jAgeOfData = new javax.swing.JTextField();
jBoatType = new javax.swing.JTextField();
jSailNumber = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jRPDData = new javax.swing.JList();
jButton3 = new javax.swing.JButton();
jLabel19 = new javax.swing.JLabel();
jALS = new javax.swing.JTextField();
jLabel20 = new javax.swing.JLabel();
jNextMark = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jLabel1.setText("Race-ID:");
jLabel2.setText("Status:");
jLabel3.setText("Data Time:");
jRaceID.setText("jTextField1");
jStatus.setText("jTextField2");
jDateTime.setText("jTextField3");
jLabel4.setText("Starttime:");
jStartTime.setText("jTextField4");
jLabel5.setText("Racetime:");
jRaceTime.setText("jTextField5");
jLabel6.setText("Next Mark Leader:");
jNextMarkLeader.setText("jTextField6");
jLabel7.setText("Distance to next mark leader:");
jDistanceToNextMarkLeader.setText("jTextField7");
jLabel8.setText("Sail number:");
jLabel9.setText("Boat type:");
jLabel10.setText("Age of data:");
jLabel11.setText("Latitude:");
jLabel12.setText("Longitude");
jLabel13.setText("SOG:");
jLabel14.setText("VMG:");
jLabel15.setText("COG:");
jLabel16.setText("Rank:");
jLabel17.setText("Distance to leader:");
jLabel18.setText("Distance to next mark:");
jDistanceToNextMark.setText("450.0");
jDistanceToLeader.setText("23.30");
jRank.setText("2");
jCOG.setText("330.5");
jVMG.setText("2.3");
jSOG.setText("3.4");
jLongitude.setText("45.234");
jLatitude.setText("45.2343");
jAgeOfData.setText("0");
jBoatType.setText("1");
jSailNumber.setText("s123");
jButton1.setText("Add");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("Remove");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jScrollPane1.setViewportView(jRPDData);
jButton3.setText("Ok");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jLabel19.setText("ALS");
jALS.setText("3.3");
jLabel20.setText("Next mark:");
jNextMark.setText("1");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 619, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel2)
.addComponent(jLabel1)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jStartTime)
.addComponent(jRaceID)
.addComponent(jStatus)
.addComponent(jDateTime, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE))
.addGap(4, 4, 4)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6)
.addComponent(jLabel5)
.addComponent(jLabel7))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jNextMarkLeader, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE)
.addComponent(jRaceTime, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE)
.addComponent(jDistanceToNextMarkLeader, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel14)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel18)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jDistanceToNextMark))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel13)
.addComponent(jLabel12)
.addComponent(jLabel11)
.addComponent(jLabel10)
.addComponent(jLabel9)
.addComponent(jLabel8)
.addComponent(jLabel15)
.addComponent(jLabel19)
.addComponent(jLabel20))
.addGap(52, 52, 52)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jNextMark)
.addComponent(jCOG)
.addComponent(jALS)
.addComponent(jBoatType)
.addComponent(jAgeOfData)
.addComponent(jLatitude)
.addComponent(jLongitude)
.addComponent(jSOG)
.addComponent(jVMG)
.addComponent(jSailNumber, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel16)
.addComponent(jLabel17))
.addGap(22, 22, 22)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jDistanceToLeader, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)
.addComponent(jRank, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jRaceID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jRaceTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)
.addComponent(jNextMarkLeader, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jDateTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jDistanceToNextMarkLeader, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(jStartTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(jSailNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(jBoatType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel10)
.addComponent(jAgeOfData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11)
.addComponent(jLatitude, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(jLongitude, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel13)
.addComponent(jSOG, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel14)
.addComponent(jVMG, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel19)
.addComponent(jALS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(9, 9, 9)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jCOG, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel15))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel20)
.addComponent(jNextMark, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel16)
.addComponent(jRank, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel17)
.addComponent(jDistanceToLeader, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel18)
.addComponent(jDistanceToNextMark, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton3))
.addComponent(jScrollPane1))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
try {
rpdData.add(new RacePositionDataElement(
jSailNumber.getText(),
Integer.parseInt(jBoatType.getText()),
Long.parseLong(jAgeOfData.getText()),
Double.parseDouble(jLatitude.getText()),
Double.parseDouble(jLongitude.getText()),
Double.parseDouble(jSOG.getText()),
Double.parseDouble(jVMG.getText()),
Double.parseDouble(jALS.getText()),
Double.parseDouble(jCOG.getText()),
jNextMark.getText(),
Integer.parseInt(jRank.getText()),
Double.parseDouble(jDistanceToLeader.getText()),
Double.parseDouble(jDistanceToNextMark.getText())));
}
catch(Exception e){
JOptionPane.showMessageDialog(this, "Invalid input paramters!", "Invalid input", JOptionPane.ERROR_MESSAGE);
}
jRPDData.setListData(rpdData.toArray());
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
for (Object o : jRPDData.getSelectedValues())
rpdData.remove(o);
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// TODO add your handling code here:
getValuesFromUI();
dispose();
}//GEN-LAST:event_jButton3ActionPerformed
public RPDMessage getMessage(){
return rpd;
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField jALS;
private javax.swing.JTextField jAgeOfData;
private javax.swing.JTextField jBoatType;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JTextField jCOG;
private javax.swing.JTextField jDateTime;
private javax.swing.JTextField jDistanceToLeader;
private javax.swing.JTextField jDistanceToNextMark;
private javax.swing.JTextField jDistanceToNextMarkLeader;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JTextField jLatitude;
private javax.swing.JTextField jLongitude;
private javax.swing.JTextField jNextMark;
private javax.swing.JTextField jNextMarkLeader;
private javax.swing.JList jRPDData;
private javax.swing.JTextField jRaceID;
private javax.swing.JTextField jRaceTime;
private javax.swing.JTextField jRank;
private javax.swing.JTextField jSOG;
private javax.swing.JTextField jSailNumber;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JTextField jStartTime;
private javax.swing.JTextField jStatus;
private javax.swing.JTextField jVMG;
// End of variables declaration//GEN-END:variables
}
@@ -0,0 +1,227 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* RaceEditor.java
*
* Created on 15.11.2011, 14:14:41
*/
package com.sap.sailing.domain.swisstimingadapter.test.ui;
import com.sap.sailing.domain.swisstimingadapter.classes.messages.ABSMessage;
import com.sap.sailing.domain.swisstimingadapter.classes.messages.RACMessage;
import com.sap.sailing.domain.swisstimingadapter.classes.messages.RPDMessage;
import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractListModel;
/**
*
* @author D056866
*/
public class SwissTimingRaceEditor extends javax.swing.JFrame {
private List<Object> commands;
/** Creates new form RaceEditor */
public SwissTimingRaceEditor() {
initComponents();
jCommandList.setModel(new AbstractListModel() {
private ArrayList<Object> commands = new ArrayList<Object>();
@Override
public int getSize() {
return commands.size();
}
@Override
public Object getElementAt(int index) {
return commands.get(index);
}
});
commands = new ArrayList<Object>();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jCommandList = new javax.swing.JList();
jAdd = new javax.swing.JButton();
jRemove = new javax.swing.JButton();
jEdit = new javax.swing.JButton();
jMoveUp = new javax.swing.JButton();
jMoveDown = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jCommandList.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane1.setViewportView(jCommandList);
jAdd.setText("Add");
jAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jAddActionPerformed(evt);
}
});
jRemove.setText("Remove");
jEdit.setText("Edit");
jEdit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jEditActionPerformed(evt);
}
});
jMoveUp.setText("Up");
jMoveDown.setText("Down");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jMoveDown, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jMoveUp, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jEdit, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jRemove, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jAdd, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(jAdd)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jRemove)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jEdit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jMoveUp)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jMoveDown)))
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jAddActionPerformed
// TODO Create Dialog
CommandChoice cc = new CommandChoice(this, true);
cc.setVisible(true);
switch(cc.getUserChoice()){
case CommandChoice.RAC:
EditRAC jRac = new EditRAC(this, true, null);
jRac.setVisible(true);
commands.add(jRac.getRACMessage());
break;
case CommandChoice.ABS:
EditABS jAbs = new EditABS(this, true, null);
jAbs.setVisible(true);
commands.add(jAbs.getMessage());
break;
case CommandChoice.RPD:
EditRPD jRpd = new EditRPD(this, true, null);
jRpd.setVisible(true);
commands.add(jRpd.getMessage());
break;
}
jCommandList.setListData(getArrayOfList(commands));
}//GEN-LAST:event_jAddActionPerformed
private void jEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jEditActionPerformed
// TODO add your handling code here:
Object o = jCommandList.getSelectedValue();
if (o != null){
o = commands.get(commands.indexOf(o));
if (o instanceof RACMessage){
EditRAC jRac = new EditRAC(this, true, (RACMessage) o);
jRac.setVisible(true);
}
else if (o instanceof ABSMessage){
EditABS jAbs = new EditABS(this, true, (ABSMessage) o);
jAbs.setVisible(true);
}
else if (o instanceof RPDMessage){
EditRPD jRpd = new EditRPD(this, true, (RPDMessage) o);
jRpd.setVisible(true);
}
jCommandList.setListData(getArrayOfList(commands));
}
}//GEN-LAST:event_jEditActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(SwissTimingRaceEditor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(SwissTimingRaceEditor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(SwissTimingRaceEditor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(SwissTimingRaceEditor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new SwissTimingRaceEditor().setVisible(true);
}
});
}
private Object[] getArrayOfList(List<Object> al){
Object[] obj = new Object[al.size()];
for (int i = 0; i < obj.length; i++)
obj[i] = al.get(i);
return obj;
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jAdd;
private javax.swing.JList jCommandList;
private javax.swing.JButton jEdit;
private javax.swing.JButton jMoveDown;
private javax.swing.JButton jMoveUp;
private javax.swing.JButton jRemove;
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration//GEN-END:variables
}