SEBSERV-163 fixed read-only fields and labels
This commit is contained in:
parent
43d8129006
commit
a6334bc436
4 changed files with 17 additions and 17 deletions
|
@ -123,12 +123,12 @@ public final class Form implements FormBinding {
|
|||
return this.formFields.containsKey(fieldName);
|
||||
}
|
||||
|
||||
Form putReadonlyField(final String name, final Control label, final Text field) {
|
||||
this.formFields.add(name, createReadonlyAccessor(label, field));
|
||||
Form putLabel(final String name, final Control label, final Label field) {
|
||||
this.formFields.add(name, createLabelAccessor(label, field));
|
||||
return this;
|
||||
}
|
||||
|
||||
Form putReadonlyField(final String name, final Control label, final Label field) {
|
||||
Form putReadonlyField(final String name, final Control label, final Text field) {
|
||||
this.formFields.add(name, createReadonlyAccessor(label, field));
|
||||
return this;
|
||||
}
|
||||
|
@ -313,13 +313,13 @@ public final class Form implements FormBinding {
|
|||
//@formatter:off
|
||||
private FormFieldAccessor createReadonlyAccessor(final Control label, final Text field) {
|
||||
return new FormFieldAccessor(label, field, null) {
|
||||
@Override public String getStringValue() { return field.getText(); }
|
||||
@Override public String getStringValue() { return null; } // ensures that read-only fields do not send diplay values to the back-end
|
||||
@Override public void setStringValue(final String value) { field.setText( (value == null) ? StringUtils.EMPTY : value); }
|
||||
};
|
||||
}
|
||||
private FormFieldAccessor createReadonlyAccessor(final Control label, final Label field) {
|
||||
private FormFieldAccessor createLabelAccessor(final Control label, final Label field) {
|
||||
return new FormFieldAccessor(label, field, null) {
|
||||
@Override public String getStringValue() { return field.getText(); }
|
||||
@Override public String getStringValue() { return field.getText(); } // read-only labels a are not API attributes.
|
||||
@Override public void setStringValue(final String value) { field.setText( (value == null) ? StringUtils.EMPTY : value); }
|
||||
};
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public final class TextFieldBuilder extends FieldBuilder<String> {
|
|||
int areaMinHeight = WidgetFactory.TEXT_AREA_INPUT_MIN_HEIGHT;
|
||||
boolean isColorBox = false;
|
||||
boolean isHTML = false;
|
||||
boolean isMarkup = false;
|
||||
boolean isMarkupLabel = false;
|
||||
|
||||
TextFieldBuilder(final String name, final LocTextKey label, final String value) {
|
||||
super(name, label, value);
|
||||
|
@ -77,11 +77,6 @@ public final class TextFieldBuilder extends FieldBuilder<String> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public TextFieldBuilder asMarkup() {
|
||||
this.isMarkup = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TextFieldBuilder asHTML(final int minHeight) {
|
||||
this.isHTML = true;
|
||||
this.areaMinHeight = minHeight;
|
||||
|
@ -93,6 +88,11 @@ public final class TextFieldBuilder extends FieldBuilder<String> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public TextFieldBuilder asMarkupLabel() {
|
||||
this.isMarkupLabel = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TextFieldBuilder asColorBox() {
|
||||
this.isColorBox = true;
|
||||
return this;
|
||||
|
@ -124,12 +124,12 @@ public final class TextFieldBuilder extends FieldBuilder<String> {
|
|||
return;
|
||||
}
|
||||
|
||||
if (readonly && this.isMarkup) {
|
||||
if (readonly && this.isMarkupLabel) {
|
||||
final Label label = new Label(fieldGrid, SWT.NONE);
|
||||
label.setData(RWT.MARKUP_ENABLED, Boolean.TRUE);
|
||||
label.setText(this.value);
|
||||
label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
|
||||
builder.form.putReadonlyField(this.name, titleLabel, label);
|
||||
builder.form.putLabel(this.name, titleLabel, label);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ public class ClientConnectionDetails {
|
|||
ClientConnectionData.ATTR_CLIENT_GROUPS,
|
||||
CONNECTION_GROUP_TEXT_KEY,
|
||||
Constants.EMPTY_NOTE)
|
||||
.asMarkup())
|
||||
.asMarkupLabel())
|
||||
.addField(FormBuilder.text(
|
||||
ClientConnection.ATTR_INFO,
|
||||
CONNECTION_INFO_TEXT_KEY,
|
||||
|
|
|
@ -86,8 +86,8 @@ public class MockCourseAccessAPI implements CourseAccessAPI {
|
|||
"http://lms.mockup.com/api/"));
|
||||
this.mockups.add(new QuizData(
|
||||
"quiz11", institutionId, lmsSetupId, lmsType, "Demo Quiz 11 (MOCKUP)",
|
||||
"Starts in a minute and ends never",
|
||||
DateTime.now(DateTimeZone.UTC).plus(Constants.MINUTE_IN_MILLIS)
|
||||
"Starts in five minutes and ends never",
|
||||
DateTime.now(DateTimeZone.UTC).plus(Constants.MINUTE_IN_MILLIS * 5)
|
||||
.toString(Constants.DEFAULT_DATE_TIME_FORMAT),
|
||||
null,
|
||||
"http://lms.mockup.com/api/"));
|
||||
|
|
Loading…
Reference in a new issue