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

Revision 93, 3.2 KB checked in by bmcguffin, 9 years ago (diff)

Moved classes which represent elements of the main event editor frame to their own package, for clarity' sake.

Line 
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 event.editor.frame.PropertyPanels;
18import event.editor.frame.PropertyPanel;
19import event.editor.frame.Properties;
20import java.awt.event.ActionEvent;
21import java.awt.event.ActionListener;
22import java.util.EnumMap;
23import java.util.Observable;
24import java.util.Observer;
25import javax.swing.JPanel;
26import scriptbuilder.structures.events.I_ScriptEvent;
27
28/**
29 *
30 * @author Bryan McGuffin
31 */
32public class PropertyModel extends Observable implements Observer
33{
34
35    PropertyPanels properties = new PropertyPanels();
36
37    private EnumMap<Properties, Class> classMap
38            = new EnumMap<Properties, Class>(Properties.class);
39
40    public PropertyModel()
41    {
42        classMap.put(Properties.ATMS, GenericEvaluationPanel.class);
43        classMap.put(Properties.ActivityLog, GenericEvaluationPanel.class);
44        classMap.put(Properties.CAD, GenericEvaluationPanel.class);
45        classMap.put(Properties.Facilitator, GenericEvaluationPanel.class);
46        classMap.put(Properties.Radio, GenericEvaluationPanel.class);
47
48        classMap.put(Properties.MaintenanceRadio, MaintenanceRadioPanel.class);
49        classMap.put(Properties.TMTRadio, TMTRadioPanel.class);
50        classMap.put(Properties.CHPRadio, CHPRadioPanel.class);
51        classMap.put(Properties.Telephone, TelephonePanel.class);
52
53        classMap.put(Properties.Audio, AudioPanel.class);
54        classMap.put(Properties.CADLog, CADLogPanel.class);
55        classMap.put(Properties.CCTV, CCTVPanel.class);
56        classMap.put(Properties.CMS, CMSEvaluationPanel.class);
57        classMap.put(Properties.Paramics, ParamicsPanel.class);
58        classMap.put(Properties.Tow, TowPanel.class);
59        classMap.put(Properties.Unit, UnitPanel.class);
60        classMap.put(Properties.Witness, WitnessPanel.class);
61
62        properties.addObserver(this);
63    }
64
65    public void addProperty(Properties property, I_ScriptEvent se)
66    {
67        try
68        {
69            JPanel panel = (JPanel) classMap.get(property).newInstance();
70
71            final PropertyPanel propertyPanel = properties.addPropertyPanel(property, panel);
72            if (panel instanceof I_ScriptEventEditorPanel)
73            {
74                ((I_ScriptEventEditorPanel) panel).getEventObject(se);
75            }
76        }
77        catch (Exception e)
78        {
79            System.err.println("Could not create panel of type \"" + property + "\"");
80        }
81    }
82
83    public void removeProperty(Properties property)
84    {
85        properties.removeProperty(property);
86    }
87
88    public void update(Observable o, Object arg)
89    {
90        setChanged();
91        notifyObservers(arg);
92    }
93
94    /*
95     public Vector<PropertyPanel> getPropertyPanels()
96     {
97     return properties.getProperties();
98     }
99     */
100}
Note: See TracBrowser for help on using the repository browser.