package event.editor; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.EnumMap; import java.util.Observable; import java.util.Observer; import javax.swing.JPanel; import scriptbuilder.structures.events.I_ScriptEvent; /** * * @author Bryan McGuffin */ public class PropertyModel extends Observable implements Observer { PropertyPanels properties = new PropertyPanels(); private EnumMap classMap = new EnumMap(Properties.class); public PropertyModel() { classMap.put(Properties.ATMS, GenericEvaluationPanel.class); classMap.put(Properties.ActivityLog, GenericEvaluationPanel.class); classMap.put(Properties.CAD, GenericEvaluationPanel.class); classMap.put(Properties.Facilitator, GenericEvaluationPanel.class); classMap.put(Properties.Radio, GenericEvaluationPanel.class); classMap.put(Properties.MaintenanceRadio, MaintenanceRadioPanel.class); classMap.put(Properties.TMTRadio, TMTRadioPanel.class); classMap.put(Properties.CHPRadio, CHPRadioPanel.class); classMap.put(Properties.Telephone, TelephonePanel.class); classMap.put(Properties.Audio, AudioPanel.class); classMap.put(Properties.CADLog, CADLogPanel.class); classMap.put(Properties.CCTV, CCTVPanel.class); classMap.put(Properties.CMS, CMSEvaluationPanel.class); classMap.put(Properties.Paramics, ParamicsPanel.class); classMap.put(Properties.Tow, TowPanel.class); classMap.put(Properties.Unit, UnitPanel.class); classMap.put(Properties.Witness, WitnessPanel.class); properties.addObserver(this); } public void addProperty(Properties property, I_ScriptEvent se) { try { JPanel panel = (JPanel) classMap.get(property).newInstance(); final PropertyPanel propertyPanel = properties.addPropertyPanel(property, panel); if (panel instanceof I_ScriptEventEditorPanel) { ((I_ScriptEventEditorPanel) panel).getEventObject(se); } } catch (Exception e) { System.err.println("Could not create panel of type \"" + property + "\""); } } public void removeProperty(Properties property) { properties.removeProperty(property); } public void update(Observable o, Object arg) { setChanged(); notifyObservers(arg); } /* public Vector getPropertyPanels() { return properties.getProperties(); } */ }