2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
5 package org.ufcspa.simdecs.diagram.mb;
7 import java.util.HashMap;
9 import javax.faces.component.html.HtmlSelectOneMenu;
10 import org.primefaces.component.commandbutton.CommandButton;
11 import org.ufcspa.simdecs.diagram.elements.Doctor;
12 import org.ufcspa.simdecs.diagram.elements.Patient;
13 import org.ufcspa.simdecs.diagram.elements.SwimLane;
19 public class EditActor extends DefaultManagedBean {
24 private Map<String, String> actorTypes;
29 private EditDiagram editDiagram;
31 public void addActor() {
32 if (type.equals("doctor")) {
33 Doctor doctor = new Doctor(getMessageBundle(), getLocale());
35 doctor.setHeight(height);
38 doctor.setWeight(weight);
39 editDiagram.getDiagramManager().addSwimLane(doctor);
40 } else if (type.equals("patient")) {
41 Patient patient = new Patient(getMessageBundle(), getLocale());
43 patient.setHeight(height);
44 patient.setName(name);
46 patient.setWeight(weight);
47 editDiagram.getDiagramManager().addSwimLane(patient);
50 addInfoMessage("defaultInfoMessageTitle", "SucessAddActorMessage");
53 public void editActor() {
54 SwimLane actorToEdit = editDiagram.getDiagramManager().getSwimLane(id);
55 actorToEdit.setAge(age);
56 actorToEdit.setHeight(height);
57 actorToEdit.setName(name);
58 actorToEdit.setSex(sex);
59 actorToEdit.setWeight(weight);
61 addInfoMessage("defaultInfoMessageTitle", "SucessEditActorMessage");
64 public void removeActor() {
65 editDiagram.getDiagramManager().removeSwimLane(id);
66 addInfoMessage("defaultInfoMessageTitle", "SucessRemoveActorMessage");
69 public void prepareWindowAddActor() {
70 id = name = type = sex = null;
72 weight = height = null;
74 CommandButton buttonAdd = (CommandButton) getComponentById("fEditActor:buttonAddActor");
75 CommandButton buttonEdit = (CommandButton) getComponentById("fEditActor:buttonEditActor");
76 CommandButton buttonRemove = (CommandButton) getComponentById("fEditActor:buttonRemoveActor");
77 HtmlSelectOneMenu selectType = (HtmlSelectOneMenu) getComponentById("fEditActor:editActorType");
78 buttonAdd.setRendered(true);
79 buttonEdit.setRendered(false);
80 buttonRemove.setRendered(false);
81 selectType.setDisabled(false);
84 public void prepareWindowEditActor() {
85 id=getTextParameter("pActorID");
86 SwimLane actorToEdit = editDiagram.getDiagramManager().getSwimLane(id);
87 age = actorToEdit.getAge();
88 height = actorToEdit.getHeight();
89 weight = actorToEdit.getWeight();
90 name = actorToEdit.getName();
91 sex = actorToEdit.getSex();
92 type = actorToEdit.getType();
94 CommandButton buttonAdd = (CommandButton) getComponentById("fEditActor:buttonAddActor");
95 CommandButton buttonEdit = (CommandButton) getComponentById("fEditActor:buttonEditActor");
96 CommandButton buttonRemove = (CommandButton) getComponentById("fEditActor:buttonRemoveActor");
97 HtmlSelectOneMenu selectType = (HtmlSelectOneMenu) getComponentById("fEditActor:editActorType");
98 buttonAdd.setRendered(false);
99 buttonRemove.setRendered(true);
100 buttonEdit.setRendered(true);
101 selectType.setDisabled(true);
105 actorTypes = new HashMap<String, String>();
106 actorTypes.put(getResourceMessage("DoctorActorType"), "doctor");
107 actorTypes.put(getResourceMessage("PatientActorType"), "patient");
110 public Map<String, String> getActorTypes() {
114 public void setActorTypes(Map<String, String> actorTypes) {
115 this.actorTypes = actorTypes;
118 public String getType() {
122 public void setType(String type) {
126 public Integer getAge() {
130 public void setAge(Integer age) {
134 public Float getHeight() {
138 public void setHeight(Float height) {
139 this.height = height;
142 public String getName() {
146 public void setName(String name) {
151 public String getSex() {
155 public void setSex(String sex) {
159 public Float getWeight() {
163 public void setWeight(Float weight) {
164 this.weight = weight;
167 public EditDiagram getEditDiagram() {
171 public void setEditDiagram(EditDiagram editDiagram) {
172 this.editDiagram = editDiagram;
175 public String getId() {
179 public void setId(String id) {