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

Revision 94, 3.1 KB checked in by bmcguffin, 9 years ago (diff)

Minor cosmetic changes.

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