Changeset 87 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/gui


Ignore:
Timestamp:
08/28/2017 09:42:09 AM (9 years ago)
Author:
bmcguffin
Message:

Fixed a bug in which editing an incident in the incident details screen, and then clicking the "OK" button, caused the incident's events to be deleted.

Fixed a bug in which attempting to select a new color for the incident, and then clicking the "OK" button on the color selection palette, caused the incident details screen and the color selection palette to both close without applying changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scriptbuilder/gui/ScriptBuilderFrame.java

    r85 r87  
    14611461     */ 
    14621462    private void incidentOkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_incidentOkButtonActionPerformed 
    1463         if (!editingIncident) 
     1463        if (!editingIncident)//adding new incident 
    14641464        { 
    14651465            boolean found = false; 
     
    15071507            script.numberOfIncidents++; 
    15081508        } 
    1509         else 
    1510         { 
    1511             ScriptIncident backup = script.incidents.get(oldIncidentIndex); 
    1512             script.incidents.remove(oldIncidentIndex); 
    1513             script.incidents.add(oldIncidentIndex, null); 
    1514  
    1515             for (ScriptIncident i : script.incidents) 
    1516             { 
    1517                 if (i != null && i.number == (Integer) addIncidentNumber.getValue()) 
    1518                 { 
    1519                     script.incidents.remove(oldIncidentIndex); 
    1520                     script.incidents.add(oldIncidentIndex, backup); 
    1521                     JOptionPane.showMessageDialog(this, "Incident number already in use.", 
    1522                             "Unable to Create Incident", JOptionPane.ERROR_MESSAGE); 
    1523                     incidentFrame.setVisible(true); 
    1524                     return; 
    1525                 } 
    1526             } 
    1527  
    1528             script.incidents.remove(oldIncidentIndex); 
    1529             SimulationScript.incidentColors[oldIncidentIndex] = selectedColor; 
    1530             script.incidents.add(oldIncidentIndex, 
    1531                     new ScriptIncident(SimulationScript.incidentColors[oldIncidentIndex], 
    1532                             (Integer) addIncidentNumber.getValue(), addIncidentName.getText(), addIncidentDescription.getText(), 
    1533                             script)); 
    1534             script.incidents.get(oldIncidentIndex).length = (Integer) addIncidentLength.getValue() * 60; 
    1535             script.incidents.get(oldIncidentIndex).slices = backup.slices; 
    1536             script.incidents.get(oldIncidentIndex).offset = backup.offset; 
    1537             script.incidents.get(oldIncidentIndex).setOffset((Integer) addIncidentStart.getValue() * 60); 
    1538             script.numberOfIncidents++; 
     1509        else//editing existing incident 
     1510        { 
     1511//            //what the hell? 
     1512//            ScriptIncident backup = script.incidents.get(oldIncidentIndex); 
     1513//            script.incidents.remove(oldIncidentIndex); 
     1514//            script.incidents.add(oldIncidentIndex, null); 
     1515// 
     1516//            for (ScriptIncident i : script.incidents) 
     1517//            { 
     1518//                if (i != null && i.number == (Integer) addIncidentNumber.getValue()) 
     1519//                { 
     1520//                    script.incidents.remove(oldIncidentIndex); 
     1521//                    script.incidents.add(oldIncidentIndex, backup); 
     1522//                    JOptionPane.showMessageDialog(this, "Incident number already in use.", 
     1523//                            "Unable to Create Incident", JOptionPane.ERROR_MESSAGE); 
     1524//                    incidentFrame.setVisible(true); 
     1525//                    return; 
     1526//                } 
     1527//            } 
     1528// 
     1529//            //ugh why do it like this 
     1530//            script.incidents.remove(oldIncidentIndex); 
     1531//            SimulationScript.incidentColors[oldIncidentIndex] = selectedColor; 
     1532//            script.incidents.add(oldIncidentIndex, 
     1533//                    new ScriptIncident(SimulationScript.incidentColors[oldIncidentIndex], 
     1534//                            (Integer) addIncidentNumber.getValue(), addIncidentName.getText(), addIncidentDescription.getText(), 
     1535//                            script)); 
     1536//            script.incidents.get(oldIncidentIndex).length = (Integer) addIncidentLength.getValue() * 60; 
     1537//            script.incidents.get(oldIncidentIndex).slices = backup.slices; 
     1538//            script.incidents.get(oldIncidentIndex).offset = backup.offset; 
     1539//            script.incidents.get(oldIncidentIndex).setOffset((Integer) addIncidentStart.getValue() * 60); 
     1540 
     1541            script.incidents.get(oldIncidentIndex).color = selectedColor; 
     1542            script.incidents.get(oldIncidentIndex).name = addIncidentName.getText(); 
     1543            script.incidents.get(oldIncidentIndex).description = addIncidentDescription.getText(); 
     1544            script.incidents.get(oldIncidentIndex).setOffset(((int) addIncidentStart.getValue()) * 60); 
     1545            if (!scriptContainsLogNum(script, (int) addIncidentNumber.getValue())) 
     1546            { 
     1547                script.incidents.get(oldIncidentIndex).number = (int) addIncidentNumber.getValue(); 
     1548            } 
     1549            else 
     1550            { 
     1551                JOptionPane.showMessageDialog(this, "Incident number already in use.", 
     1552                        "Unable To Alter Incident Detail", JOptionPane.ERROR_MESSAGE); 
     1553            } 
    15391554        } 
    15401555 
     
    15431558        repaint(); 
    15441559    }//GEN-LAST:event_incidentOkButtonActionPerformed 
     1560 
     1561    private boolean scriptContainsLogNum(SimulationScript script, int num) 
     1562    { 
     1563        for (ScriptIncident incident : script.incidents) 
     1564        { 
     1565            if (incident != null && incident.number == num) 
     1566            { 
     1567                return true; 
     1568            } 
     1569        } 
     1570        return false; 
     1571    } 
    15451572 
    15461573    /** 
     
    18651892        if (newColor != null) 
    18661893        { 
     1894            System.out.println("New color is " + newColor.toString()); 
    18671895            selectedColor = newColor; 
    18681896            incidentColorField.setBackground(newColor); 
    18691897        } 
     1898        incidentFrame.setVisible(true); 
    18701899    }//GEN-LAST:event_jButton3ActionPerformed 
    18711900 
Note: See TracChangeset for help on using the changeset viewer.