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