| 1 | package event.editor.frame; |
|---|
| 2 | |
|---|
| 3 | import event.editor.AudioPanel; |
|---|
| 4 | import event.editor.CADLogPanel; |
|---|
| 5 | import event.editor.CCTVPanel; |
|---|
| 6 | import event.editor.CHPRadioPanel; |
|---|
| 7 | import event.editor.CMSEvaluationPanel; |
|---|
| 8 | import event.editor.GenericEvaluationPanel; |
|---|
| 9 | import event.editor.I_ScriptEventEditorPanel; |
|---|
| 10 | import event.editor.MaintenanceRadioPanel; |
|---|
| 11 | import event.editor.ParamicsPanel; |
|---|
| 12 | import event.editor.TMTRadioPanel; |
|---|
| 13 | import event.editor.TelephonePanel; |
|---|
| 14 | import event.editor.TowPanel; |
|---|
| 15 | import event.editor.UnitPanel; |
|---|
| 16 | import event.editor.WitnessPanel; |
|---|
| 17 | import java.awt.event.ActionEvent; |
|---|
| 18 | import java.awt.event.ActionListener; |
|---|
| 19 | import java.util.EnumMap; |
|---|
| 20 | import java.util.Observable; |
|---|
| 21 | import java.util.Observer; |
|---|
| 22 | import javax.swing.JPanel; |
|---|
| 23 | import scriptbuilder.structures.events.I_ScriptEvent; |
|---|
| 24 | |
|---|
| 25 | /** |
|---|
| 26 | * |
|---|
| 27 | * @author Bryan McGuffin |
|---|
| 28 | */ |
|---|
| 29 | public 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 | } |
|---|