1 package org.kuali.student.common.ui.client.configurable.mvc;
2
3 import org.kuali.student.common.ui.client.widgets.KSLabel;
4 import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo;
5 import org.kuali.student.core.assembly.data.Metadata;
6
7 import com.google.gwt.user.client.ui.Widget;
8
9 public class FieldDescriptorReadOnly extends FieldDescriptor{
10
11 public FieldDescriptorReadOnly(String fieldKey, MessageKeyInfo messageKey,
12 Metadata metadata) {
13 super(fieldKey, messageKey, metadata);
14 }
15
16 public FieldDescriptorReadOnly(String fieldKey, MessageKeyInfo messageKey,
17 Metadata metadata, Widget widget) {
18 super(fieldKey, messageKey, metadata, widget);
19 }
20
21
22 @Override
23 protected Widget createFieldWidget() {
24 if (metadata == null) {
25 Widget result = new KSLabel();
26 addStyleToWidget(result);
27 return result;
28 } else {
29 Widget result = DefaultWidgetFactory.getInstance().getReadOnlyWidget(metadata);
30 addStyleToWidget(result);
31 return result;
32 }
33 }
34
35 @Override
36 protected void addStyleToWidget(Widget w) {
37 if(fieldKey != null && !fieldKey.isEmpty()){
38 String style = this.fieldKey.replaceAll("/", "-");
39 style = style + "readOnly";
40 w.addStyleName(style);
41 }
42 }
43
44 @Override
45 protected void setupField() {
46
47 }
48 }