-
Notifications
You must be signed in to change notification settings - Fork 188
/
ItemPanelContext.java
129 lines (93 loc) · 2.99 KB
/
ItemPanelContext.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package com.evolveum.midpoint.gui.impl.factory;
import java.io.Serializable;
import org.apache.commons.lang.ClassUtils;
import org.apache.wicket.Component;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.IModel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.prism.ItemWrapper;
import com.evolveum.midpoint.gui.impl.prism.PrismValueWrapper;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismReferenceValue;
import com.evolveum.midpoint.prism.PrismValue;
import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.web.component.message.FeedbackAlerts;
public abstract class ItemPanelContext<T, IW extends ItemWrapper> implements Serializable {
private String componentId;
private Component parentComponent;
private IModel<IW> itemWrapper;
private ItemRealValueModel<T> realValueModel;
private FeedbackAlerts feedbackPanel;
private Form<?> form;
public ItemPanelContext(IModel<IW> itemWrapper) {
this.itemWrapper = itemWrapper;
}
public IW unwrapWrapperModel() {
return itemWrapper.getObject();
}
public PageBase getPageBase() {
return (PageBase) parentComponent.getPage();
}
public String getComponentId() {
return componentId;
}
public PrismReferenceValue getValueEnumerationRef() {
return unwrapWrapperModel().getValueEnumerationRef();
}
public IModel<IW> getItemWrapperModel() {
return itemWrapper;
}
public PrismContext getPrismContext() {
return unwrapWrapperModel().getPrismContext();
}
public boolean isPropertyReadOnly() {
return unwrapWrapperModel().isReadOnly();
}
public ItemName getDefinitionName() {
return unwrapWrapperModel().getItemName();
}
public Component getParentComponent() {
return parentComponent;
}
public Class<T> getTypeClass() {
Class<T> clazz = unwrapWrapperModel().getTypeClass();
if (clazz == null) {
clazz = getPrismContext().getSchemaRegistry().determineClassForType(unwrapWrapperModel().getTypeName());
}
if (clazz != null && clazz.isPrimitive()) {
clazz = ClassUtils.primitiveToWrapper(clazz);
}
return clazz;
}
public ItemRealValueModel<T> getRealValueModel() {
return realValueModel;
}
public FeedbackAlerts getFeedbackPanel() {
return feedbackPanel;
}
public <V extends PrismValue> void setRealValueModel(IModel<? extends PrismValueWrapper<T, V>> valueWrapper) {
this.realValueModel = new ItemRealValueModel<T>(valueWrapper);
}
public void setComponentId(String componentId) {
this.componentId = componentId;
}
public void setParentComponent(Component parentComponent) {
this.parentComponent = parentComponent;
}
public void setFeedbackPanel(FeedbackAlerts feedbackPanel) {
this.feedbackPanel = feedbackPanel;
}
/**
* @return the form
*/
public Form<?> getForm() {
return form;
}
/**
* @param form the form to set
*/
public void setForm(Form<?> form) {
this.form = form;
}
}