1
2
3
4
5
6
7 package org.asyrinx.joey.gui.swing;
8
9 import java.awt.LayoutManager;
10 import java.io.Serializable;
11
12 import javax.swing.JPanel;
13
14 import org.asyrinx.joey.gui.EntityEditView;
15 import org.asyrinx.joey.gui.EntityViewManager;
16 import org.asyrinx.joey.om.Entity;
17 import org.asyrinx.joey.om.EntityService;
18
19 /***
20 * @author akima
21 */
22 public abstract class EntityEditViewPanel extends JPanel implements
23 EntityEditView {
24
25 /***
26 *
27 */
28 public EntityEditViewPanel() {
29 super();
30 }
31
32 /***
33 * @param isDoubleBuffered
34 */
35 public EntityEditViewPanel(boolean isDoubleBuffered) {
36 super(isDoubleBuffered);
37 }
38
39 /***
40 * @param layout
41 */
42 public EntityEditViewPanel(LayoutManager layout) {
43 super(layout);
44 }
45
46 /***
47 * @param layout
48 * @param isDoubleBuffered
49 */
50 public EntityEditViewPanel(LayoutManager layout, boolean isDoubleBuffered) {
51 super(layout, isDoubleBuffered);
52 }
53
54 private EntityViewManager entityViewManager = null;
55
56
57
58
59
60
61 public EntityViewManager getEntityViewManager() {
62 return entityViewManager;
63 }
64
65
66
67
68
69
70
71 public void setEntityViewManager(EntityViewManager entityViewManager) {
72 this.entityViewManager = entityViewManager;
73 }
74
75 private Object invoker = null;
76
77 /***
78 * @return
79 */
80 public Object getInvoker() {
81 return invoker;
82 }
83
84 /***
85 * @param object
86 */
87 public void setInvoker(Object object) {
88 invoker = object;
89 }
90
91 /***
92 * @return
93 */
94 public abstract Class getEntityClass();
95
96 private Entity entity = null;
97
98
99
100
101
102
103 public Entity getEntity() {
104 return entity;
105 }
106
107
108
109
110
111
112 public void setEntity(Entity entity) {
113 this.entity = entity;
114 }
115
116 private EntityService entityService = null;
117
118
119
120
121
122
123 public EntityService getService() {
124 if (entityService == null) {
125 entityService = getEntityViewManager().getEntityServiceManager()
126 .getEntityService(getEntityClass());
127 }
128 return entityService;
129 }
130
131
132
133
134
135
136 public void setService(EntityService service) {
137 this.entityService = service;
138 }
139
140
141
142
143
144
145 public void refresh() {
146 loadFrom(getEntity());
147 }
148
149
150
151
152
153
154 public void load(Serializable key) {
155 if (getService() != null) {
156 final Entity loadedEntity = getService().loadEntity(key);
157 setEntity(loadedEntity);
158 refresh();
159 }
160 }
161
162
163
164
165 public void beforeShow() {
166 }
167
168
169
170
171 public void afterShow() {
172 }
173
174
175
176
177 public void beforeHide() {
178 }
179
180
181
182
183 public void afterHide() {
184 }
185 }