1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.common.ui.client.mvc.dto;
17
18 import java.util.HashMap;
19 import java.util.Map;
20
21 import org.kuali.student.common.ui.client.configurable.mvc.HasReferenceId;
22 import org.kuali.student.common.ui.client.mvc.Model;
23 import org.kuali.student.common.ui.client.mvc.ModelChangeEvent;
24 import org.kuali.student.common.ui.client.mvc.ModelChangeHandler;
25 import org.kuali.student.common.ui.client.mvc.ModelChangeEvent.Action;
26
27 import com.google.gwt.event.shared.HandlerManager;
28 import com.google.gwt.event.shared.HandlerRegistration;
29
30
31
32
33
34
35
36 public class ReferenceModel implements HasReferenceId, Model {
37 String referenceId;
38 String referenceTypeKey;
39 String referenceType;
40 String referenceState;
41 Map<String, String> referenceAttributes;
42 private HandlerManager handlers = new HandlerManager(this);
43
44 @Override
45 public HandlerRegistration addModelChangeHandler(
46 ModelChangeHandler handler) {
47 return handlers.addHandler(ModelChangeEvent.TYPE, handler);
48 }
49
50
51
52
53 @Override
54 public void setReferenceId(String id) {
55 this.referenceId = id;
56 handlers.fireEvent(new ModelChangeEvent(Action.RELOAD, this));
57 }
58
59
60
61
62 @Override
63 public String getReferenceId() {
64 return referenceId;
65 }
66
67 @Override
68 public String getReferenceTypeKey() {
69 return referenceTypeKey;
70 }
71
72 @Override
73 public void setReferenceTypeKey(String referenceTypeKey) {
74 this.referenceTypeKey = referenceTypeKey;
75 handlers.fireEvent(new ModelChangeEvent(Action.RELOAD, this));
76 }
77
78 @Override
79 public String getReferenceType() {
80 return referenceType;
81 }
82
83 @Override
84 public void setReferenceType(String referenceType) {
85 this.referenceType = referenceType;
86 handlers.fireEvent(new ModelChangeEvent(Action.RELOAD, this));
87 }
88
89 @Override
90 public String getReferenceState() {
91 return referenceState;
92 }
93
94 @Override
95 public void setReferenceState(String referenceState) {
96 this.referenceState = referenceState;
97 handlers.fireEvent(new ModelChangeEvent(Action.RELOAD, this));
98 }
99
100 public Map<String, String> getReferenceAttributes(){
101 if(referenceAttributes!=null){
102 return referenceAttributes;
103 }
104 else{
105 return new HashMap<String,String>();
106 }
107 }
108 public void setReferenceAttributes(Map<String, String> referenceAttributes){
109 this.referenceAttributes = referenceAttributes;
110 handlers.fireEvent(new ModelChangeEvent(Action.RELOAD, this));
111 }
112 }