01: package org.romaframework.module.admin.view.domain.environment;
02:
03: import org.romaframework.aspect.core.annotation.AnnotationConstants;
04: import org.romaframework.aspect.core.annotation.CoreClass;
05: import org.romaframework.aspect.view.ViewConstants;
06: import org.romaframework.aspect.view.annotation.ViewClass;
07: import org.romaframework.aspect.view.annotation.ViewField;
08: import org.romaframework.aspect.view.feature.ViewFieldFeatures;
09: import org.romaframework.core.flow.ObjectContext;
10: import org.romaframework.module.admin.domain.EnvironmentItem;
11: import org.romaframework.module.crud.CRUDEntity;
12:
13: @CoreClass(orderFields="entity types")
14: @ViewClass(entity=EnvironmentItem.class,render=ViewConstants.RENDER_POPUP,layout=ViewConstants.LAYOUT_POPUP)
15: public class EnvironmentItemInstance extends
16: CRUDEntity<EnvironmentItem> {
17: @ViewField(visible=AnnotationConstants.FALSE)
18: protected String prefix;
19: protected static String[] TYPES = new String[] { "String",
20: "Integer", "Float", "Boolean" };
21:
22: public EnvironmentItemInstance() {
23: super (null);
24: }
25:
26: public EnvironmentItemInstance(EnvironmentItem item) {
27: super (item);
28: setPrefix(entity.getKey());
29: }
30:
31: @Override
32: public void setEntity(EnvironmentItem iEntity) {
33: super .setEntity(iEntity);
34: setPrefix(entity.getKey());
35: }
36:
37: @ViewField(render=ViewConstants.RENDER_SELECT,selectionField="entity.type",selectionMode=ViewFieldFeatures.SELECTION_MODE_INDEX)
38: public String[] getTypes() {
39: return TYPES;
40: }
41:
42: public void save() {
43: bindValue();
44: ObjectContext.getInstance().close(this );
45: }
46:
47: @Override
48: public String toString() {
49: return entity.toString();
50: }
51:
52: public String getKey() {
53: int pos = entity.getKey().indexOf(
54: EnvironmentInstance.SHEET_SEPARATOR);
55: if (pos > -1)
56: return entity.getKey().substring(pos + 1);
57: return entity.getKey();
58: }
59:
60: @ViewField(visible=AnnotationConstants.FALSE)
61: public String getFullKey() {
62: return entity.getKey();
63: }
64:
65: public void setKey(String key) {
66: String p = prefix.length() > 0 ? prefix
67: + EnvironmentInstance.SHEET_SEPARATOR : "";
68: entity.setKey(p + key);
69: }
70:
71: protected void setPrefix(String iFullKey) {
72: int pos = iFullKey.indexOf(EnvironmentInstance.SHEET_SEPARATOR);
73: prefix = pos > -1 ? iFullKey.substring(0, pos) : "";
74: }
75: }
|