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