Index: trunk/src/event/editor/UnitPanel.java
===================================================================
--- trunk/src/event/editor/UnitPanel.java	(revision 140)
+++ trunk/src/event/editor/UnitPanel.java	(revision 145)
@@ -3,5 +3,10 @@
 import java.awt.event.*;
 import java.util.Observable;
+import java.util.List;
+import java.util.ArrayList;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.ComboBoxModel;
 import scriptbuilder.structures.events.I_ScriptEvent;
+import scriptbuilder.structures.units.Unit;
 import scriptbuilder.structures.events.UnitEvent;
 
@@ -9,4 +14,6 @@
  *
  * @author nathaniellehrer
+ * 
+ * 
  */
 public class UnitPanel extends javax.swing.JPanel implements I_ScriptEventEditorPanel
@@ -15,5 +22,7 @@
     private ActionListener removeListener;
     private UnitEvent event;
-
+    private List<Unit> units;
+    
+    List<String> names = new ArrayList<String>();
     /**
      * Creates new form UnitPanel
@@ -22,26 +31,20 @@
     {
         initComponents();
-
-        txtUnitNumber.addFocusListener(new FocusListener()
-        {
-
-            public void focusGained(FocusEvent e)
-            {
-                help.setText("Unit number is formatted as #-#\t\tExample: 5-5");
-            }
-
-            public void focusLost(FocusEvent e)
-            {
-                help.setText("");
-            }
-
-        });
-    }
-
+        
+        //units = event.slice.getIncident().script.units;
+        
+    }
+
+    /**
+     * Loads the event information into the event editor window.
+     * @param sei  Scriptevent that is being loaded in
+     */
     @Override
     public void getEventObject(I_ScriptEvent sei)
     {
+        
         event = (UnitEvent) sei;
-        txtUnitNumber.setText(event.unitNum);
+        //loads the current unit list into the combobox on re-opening of unit event
+        loadSelector();
         for (int i = 0; i < ActiveDropdown.getItemCount(); i++)
         {
@@ -49,4 +52,17 @@
             {
                 ActiveDropdown.setSelectedIndex(i);
+            }
+        }
+        
+        //for each name in the names list
+        for (int i = 0; i < names.size(); i++)
+        {
+            //which event equals which index in the names list?
+            if (event.unitNum.equalsIgnoreCase((String) names.get(i)))
+            {
+                
+                //set the unit selector to the data model value
+                unitSelector.setSelectedIndex(i);
+                
             }
         }
@@ -80,4 +96,5 @@
     public void update(Observable o, Object arg)
     {
+        //todo: make supported
         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
     }
@@ -90,14 +107,74 @@
         return true;
     }
+    
+    
+    private void loadSelector(){
+        //checks if the event is exist
+        if(event != null)
+        {
+            //loads the names list from the top data model
+            loadNames();
+            //asks if the unitselector already has some units added into it
+            
+            if(unitSelector.getModel().equals(new DefaultComboBoxModel(names.toArray())) || (unitSelector.getModel().getSize() == 0))
+            {
+                //if combobox empty, load combobox
+                unitSelector.setModel(new DefaultComboBoxModel(names.toArray()));
+            }
+            
+            
+            
+        }
+        
+    }
+    
+    /**
+     * Loads the unit names from the unit list in SimulationScript
+     */
+    private void loadNames(){
+        //checks if the event is exist
+        if(event!=null)
+        {
+            //this sucks! try to change it sometime
+            //grabs the unit list from the top of the SimulationScript and 
+            //appends them to the names list
+            units = event.slice.getIncident().script.units;
+            
+            for(Unit u : units)
+            {
+                names.add(u.UnitNum);
+            }
+        }
+    }
 
     @Override
+    /**
+     * when window is closed, these values are set.
+     */
     public void uponClose()
     {
-        if (event != null)
-        {
-            event.unitNum = txtUnitNumber.getText();
+        
+        if (event != null && unitSelector.getItemCount() != 0)
+        {
+            event.unitNum = unitSelector.getSelectedItem().toString();
             event.unitActive = ActiveDropdown.getSelectedItem().toString();
             event.unitPrimary = PrimaryDropdown.getSelectedItem().toString();
             event.unitStatus = StatusDropdown.getSelectedItem().toString();
+                
+            //old logic for creating dummy unit
+            /*if(event.slice.getIncident().script.hasUnit(txtUnitNumber.getText())){
+                //checks to see if there is already a unit selected there
+                //event.unitNum = (txtUnitNumber.getText());
+                
+            }else{
+                //Creates a dummy unit here
+                event.slice.getIncident().script.addDummyUnit(txtUnitNumber.getText());
+                //event.unitNum = (txtUnitNumber.getText());
+                event.unitActive = ActiveDropdown.getSelectedItem().toString();
+                event.unitPrimary = PrimaryDropdown.getSelectedItem().toString();
+                event.unitStatus = StatusDropdown.getSelectedItem().toString();
+                //System.out.println("invalid unit number");
+            }*/
+            
         }
     }
@@ -110,9 +187,6 @@
     @SuppressWarnings("unchecked")
     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
-    private void initComponents()
-    {
-
-        jLabel1 = new javax.swing.JLabel();
-        txtUnitNumber = new javax.swing.JFormattedTextField();
+    private void initComponents() {
+
         jLabel2 = new javax.swing.JLabel();
         StatusDropdown = new javax.swing.JComboBox();
@@ -122,9 +196,6 @@
         ActiveDropdown = new javax.swing.JComboBox();
         help = new javax.swing.JLabel();
-
-        jLabel1.setText("Unit Number");
-
-        txtUnitNumber.setText("  -  ");
-        txtUnitNumber.setToolTipText("");
+        jLabel5 = new javax.swing.JLabel();
+        unitSelector = new javax.swing.JComboBox<>();
 
         jLabel2.setText("Status");
@@ -139,4 +210,26 @@
 
         ActiveDropdown.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "True", "False" }));
+
+        jLabel5.setText("Unit");
+
+        unitSelector.addAncestorListener(new javax.swing.event.AncestorListener() {
+            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
+            }
+            public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
+                unitSelectorAncestorAdded(evt);
+            }
+            public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
+            }
+        });
+        unitSelector.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                unitSelectorMouseEntered(evt);
+            }
+        });
+        unitSelector.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                unitSelectorActionPerformed(evt);
+            }
+        });
 
         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
@@ -150,12 +243,4 @@
                     .add(layout.createSequentialGroup()
                         .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-                            .add(jLabel1)
-                            .add(jLabel2))
-                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-                            .add(StatusDropdown, 0, 475, Short.MAX_VALUE)
-                            .add(txtUnitNumber, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 475, Short.MAX_VALUE)))
-                    .add(layout.createSequentialGroup()
-                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                             .add(jLabel3)
                             .add(jLabel4))
@@ -163,5 +248,17 @@
                         .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                             .add(ActiveDropdown, 0, 475, Short.MAX_VALUE)
-                            .add(PrimaryDropdown, 0, 475, Short.MAX_VALUE))))
+                            .add(PrimaryDropdown, 0, 475, Short.MAX_VALUE)))
+                    .add(layout.createSequentialGroup()
+                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                            .add(jLabel2)
+                            .add(jLabel5))
+                        .add(54, 54, 54)
+                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                            .add(layout.createSequentialGroup()
+                                .add(StatusDropdown, 0, 419, Short.MAX_VALUE)
+                                .add(57, 57, 57))
+                            .add(layout.createSequentialGroup()
+                                .add(unitSelector, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                                .add(0, 0, Short.MAX_VALUE)))))
                 .addContainerGap())
         );
@@ -169,9 +266,9 @@
             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
             .add(layout.createSequentialGroup()
-                .add(47, 47, 47)
+                .add(82, 82, 82)
                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-                    .add(jLabel1)
-                    .add(txtUnitNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
-                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                    .add(jLabel5)
+                    .add(unitSelector, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                     .add(jLabel2)
@@ -185,9 +282,22 @@
                     .add(jLabel4)
                     .add(ActiveDropdown, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
-                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 128, Short.MAX_VALUE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 100, Short.MAX_VALUE)
                 .add(help, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                 .addContainerGap())
         );
     }// </editor-fold>//GEN-END:initComponents
+
+    private void unitSelectorAncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_unitSelectorAncestorAdded
+        //loads the unitSelector on the initialization of the window
+        loadSelector();
+    }//GEN-LAST:event_unitSelectorAncestorAdded
+
+    private void unitSelectorMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_unitSelectorMouseEntered
+        
+    }//GEN-LAST:event_unitSelectorMouseEntered
+
+    private void unitSelectorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_unitSelectorActionPerformed
+        // TODO add your handling code here:
+    }//GEN-LAST:event_unitSelectorActionPerformed
 
 
@@ -197,9 +307,9 @@
     private javax.swing.JComboBox StatusDropdown;
     private javax.swing.JLabel help;
-    private javax.swing.JLabel jLabel1;
     private javax.swing.JLabel jLabel2;
     private javax.swing.JLabel jLabel3;
     private javax.swing.JLabel jLabel4;
-    private javax.swing.JFormattedTextField txtUnitNumber;
+    private javax.swing.JLabel jLabel5;
+    private javax.swing.JComboBox<String> unitSelector;
     // End of variables declaration//GEN-END:variables
 
