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