Warning: Can't use blame annotator:
svn blame failed on trunk/src/event/editor/frame/PropertyModel.java: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator-scriptbuilder/trunk/src/event/editor/frame/PropertyModel.java @ 134

Revision 134, 4.4 KB checked in by bmcguffin, 9 years ago (diff)

The event-add dropdown menus in the event editor window now function correctly. Clicking on an event in the dropdown list adds it to that timeslice.

RevLine 
1package event.editor.frame;
2
3import event.editor.AudioPanel;
4import event.editor.CADLogPanel;
5import event.editor.CCTVPanel;
6import event.editor.CHPRadioPanel;
7import event.editor.CMSEvaluationPanel;
8import event.editor.GenericEvaluationPanel;
9import event.editor.I_ScriptEventEditorPanel;
10import event.editor.MaintenanceRadioPanel;
11import event.editor.ParamicsPanel;
12import event.editor.TMTRadioPanel;
13import event.editor.TelephonePanel;
14import event.editor.TowPanel;
15import event.editor.UnitPanel;
16import event.editor.WitnessPanel;
17import java.awt.event.ActionEvent;
18import java.awt.event.ActionListener;
19import java.util.EnumMap;
20import java.util.HashMap;
21import java.util.Observable;
22import java.util.Observer;
23import java.util.TreeMap;
24import javax.swing.JPanel;
25import scriptbuilder.structures.ScriptIncident;
26import scriptbuilder.structures.TimeSlice;
27import scriptbuilder.structures.events.I_ScriptEvent;
28
29/**
30 *
31 * @author Bryan McGuffin
32 */
33public class PropertyModel extends Observable implements Observer
34{
35
36    PropertyPanels properties = new PropertyPanels();
37
38    private EnumMap<Properties, Class> classMap
39            = new EnumMap<Properties, Class>(Properties.class);
40   
41    public HashMap<JPanel, I_ScriptEvent> eventMap = new HashMap<JPanel, I_ScriptEvent>();
42
43    public PropertyModel()
44    {
45        classMap.put(Properties.ATMS, GenericEvaluationPanel.class);
46        classMap.put(Properties.ActivityLog, GenericEvaluationPanel.class);
47        classMap.put(Properties.CAD, GenericEvaluationPanel.class);
48        classMap.put(Properties.Facilitator, GenericEvaluationPanel.class);
49        classMap.put(Properties.Radio, GenericEvaluationPanel.class);
50
51        classMap.put(Properties.MaintenanceRadio, MaintenanceRadioPanel.class);
52        classMap.put(Properties.TMTRadio, TMTRadioPanel.class);
53        classMap.put(Properties.CHPRadio, CHPRadioPanel.class);
54        classMap.put(Properties.Telephone, TelephonePanel.class);
55
56        classMap.put(Properties.Audio, AudioPanel.class);
57        classMap.put(Properties.CADLog, CADLogPanel.class);
58        classMap.put(Properties.CCTV, CCTVPanel.class);
59        classMap.put(Properties.CMS, CMSEvaluationPanel.class);
60        classMap.put(Properties.Paramics, ParamicsPanel.class);
61        classMap.put(Properties.Tow, TowPanel.class);
62        classMap.put(Properties.Unit, UnitPanel.class);
63        classMap.put(Properties.Witness, WitnessPanel.class);
64
65        properties.addObserver(this);
66    }
67
68    public void addEventPanel(Properties property, I_ScriptEvent se)
69    {
70        try
71        {
72            JPanel panel = (JPanel) classMap.get(property).newInstance();
73
74            final PropertyPanel propertyPanel = properties.addPropertyPanel(property, panel);
75            if (panel instanceof I_ScriptEventEditorPanel)
76            {
77                eventMap.put(panel, se);
78                ((I_ScriptEventEditorPanel) panel).getEventObject(se);
79            }
80        }
81        catch (Exception e)
82        {
83            System.err.println("Could not create panel of type \"" + property + "\"");
84        }
85    }
86   
87    public void addEventFromDropdown(Properties property, ScriptIncident inc, TimeSlice ts)
88    {
89        try
90        {
91            I_ScriptEvent se = property.getEvent();
92           
93            inc.addNewEvent(se, ts.getTime());
94           
95            JPanel panel = (JPanel) classMap.get(property).newInstance();
96
97            final PropertyPanel propertyPanel = properties.addPropertyPanel(property, panel);
98            if (panel instanceof I_ScriptEventEditorPanel)
99            {
100                eventMap.put(panel, se);
101                ((I_ScriptEventEditorPanel) panel).getEventObject(se);
102            }
103        }
104        catch (Exception e)
105        {
106            System.err.println("Could not create panel of type \"" + property + "\"");
107        }
108    }
109
110    public void removeProperty(Properties property)
111    {
112        properties.removeProperty(property);
113    }
114
115    public void update(Observable o, Object arg)
116    {
117        setChanged();
118        notifyObservers(arg);
119    }
120   
121    /**
122     * Propagate the window closure.
123     */
124    public void closePanels()
125    {
126        for(JPanel panel : eventMap.keySet())
127        {
128            if(panel instanceof I_ScriptEventEditorPanel)
129            {
130                ((I_ScriptEventEditorPanel) panel).uponClose();
131            }
132        }
133    }
134
135    /*
136     public Vector<PropertyPanel> getPropertyPanels()
137     {
138     return properties.getProperties();
139     }
140     */
141}
Note: See TracBrowser for help on using the repository browser.