Changeset 54 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/gui/panels/ScriptBuilderTimelinePanel.java


Ignore:
Timestamp:
08/09/2017 04:12:39 PM (9 years ago)
Author:
bmcguffin
Message:

Duplicated main ScriptBuilder? window. The new window will become the Incident Editor window (see Storyboard 2a-B). The main ScriptBuilder? window will become the Incident Combiner window (see storyboard 1a-B).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scriptbuilder/gui/panels/ScriptBuilderTimelinePanel.java

    r53 r54  
    1111import javax.swing.JPanel; 
    1212import javax.swing.event.MouseInputAdapter; 
     13import scriptbuilder.gui.IncidentEditorFrame; 
    1314import scriptbuilder.gui.ScriptBuilderFrame; 
    1415import scriptbuilder.gui.ScriptBuilderGuiConstants; 
     
    100101        { 
    101102            Editor ed = new Editor(); 
    102             ScriptBuilderFrame f = (ScriptBuilderFrame) getTopLevelAncestor(); 
     103            ScriptBuilderFrame f = null; 
     104            IncidentEditorFrame g = null; 
     105            if (getTopLevelAncestor() instanceof ScriptBuilderFrame) 
     106            { 
     107                f = (ScriptBuilderFrame) getTopLevelAncestor(); 
     108            } 
     109            else if (getTopLevelAncestor() instanceof IncidentEditorFrame) 
     110            { 
     111                g = (IncidentEditorFrame) getTopLevelAncestor(); 
     112            } 
    103113 
    104114            x = cursorTime = e.getX(); 
     
    142152            if (e.getButton() == MouseEvent.BUTTON1) 
    143153            { 
    144                 if (f.currentEventType != null) 
    145                 { 
    146                     I_ScriptEvent s = ScriptEvent.factoryByType(f.currentEventType); 
    147                     ed.addProperty(eventTypeToPropertyMap.get(f.currentEventType), s); 
    148                     if (incident.slices.get(newSlice) == null) 
     154                if (getTopLevelAncestor() instanceof ScriptBuilderFrame) 
     155                { 
     156                    if (f.currentEventType != null) 
    149157                    { 
    150                         incident.addNewEvent(s, newSlice); 
     158                        I_ScriptEvent s = ScriptEvent.factoryByType(f.currentEventType); 
     159                        ed.addProperty(eventTypeToPropertyMap.get(f.currentEventType), s); 
     160                        if (incident.slices.get(newSlice) == null) 
     161                        { 
     162                            incident.addNewEvent(s, newSlice); 
     163                        } 
     164                        else 
     165                        { 
     166                            incident.slices.get(newSlice).addEvent(s); 
     167                        } 
     168                        f.update(f.getScript(), f.getScript()); 
    151169                    } 
    152                     else 
     170                } 
     171                if (getTopLevelAncestor() instanceof IncidentEditorFrame) 
     172                { 
     173                    if (g.currentEventType != null) 
    153174                    { 
    154                         incident.slices.get(newSlice).addEvent(s); 
     175                        I_ScriptEvent s = ScriptEvent.factoryByType(g.currentEventType); 
     176                        ed.addProperty(eventTypeToPropertyMap.get(g.currentEventType), s); 
     177                        if (incident.slices.get(newSlice) == null) 
     178                        { 
     179                            incident.addNewEvent(s, newSlice); 
     180                        } 
     181                        else 
     182                        { 
     183                            incident.slices.get(newSlice).addEvent(s); 
     184                        } 
     185                        g.update(null, g.getIncident()); 
    155186                    } 
    156                     f.update(f.getScript(), f.getScript()); 
    157187                } 
    158188            } 
     
    294324 
    295325        Graphics2D g2d = (Graphics2D) g; 
    296         IncidentTimelineDrawer.DrawScriptBuilderTimeline(g2d, incident); 
     326        if (getTopLevelAncestor() instanceof ScriptBuilderFrame) 
     327        { 
     328            IncidentTimelineDrawer.DrawScriptBuilderTimeline(g2d, incident); 
     329        } 
     330        if (getTopLevelAncestor() instanceof IncidentEditorFrame) 
     331        { 
     332            IncidentTimelineDrawer.DrawIncidentTimeline(g2d, incident, false); 
     333        } 
    297334 
    298335        if (focused) 
    299336        { 
    300337            CursorDrawer.DrawCursor(g2d, cursorTime, false); 
    301             if (((ScriptBuilderFrame) this.getTopLevelAncestor()).currentEventType != null) 
    302             { 
    303                 EventIconDrawer.DrawEventIcon(g2d, 
    304                         ((ScriptBuilderFrame) this.getTopLevelAncestor()).currentEventType, 
    305                         x + 5, y + 10); 
     338            if (this.getTopLevelAncestor() instanceof ScriptBuilderFrame) 
     339            { 
     340                if (((ScriptBuilderFrame) this.getTopLevelAncestor()).currentEventType != null) 
     341                { 
     342                    EventIconDrawer.DrawEventIcon(g2d, 
     343                            ((ScriptBuilderFrame) this.getTopLevelAncestor()).currentEventType, 
     344                            x + 5, y + 10); 
     345                } 
     346            } 
     347            if (this.getTopLevelAncestor() instanceof IncidentEditorFrame) 
     348            { 
     349                if (((IncidentEditorFrame) this.getTopLevelAncestor()).currentEventType != null) 
     350                { 
     351                    EventIconDrawer.DrawEventIcon(g2d, 
     352                            ((IncidentEditorFrame) this.getTopLevelAncestor()).currentEventType, 
     353                            x + 5, y + 10); 
     354                } 
    306355            } 
    307356        } 
Note: See TracChangeset for help on using the changeset viewer.