password input field and fixed compile error
This commit is contained in:
parent
f4af098a6f
commit
7bf8edaa54
19 changed files with 304 additions and 121 deletions
|
@ -10,8 +10,6 @@ package ch.ethz.seb.sebserver.gui.service.examconfig;
|
|||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute;
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue;
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.Orientation;
|
||||
|
@ -24,8 +22,6 @@ public interface InputField {
|
|||
|
||||
void initValue(Collection<ConfigurationValue> values);
|
||||
|
||||
Control getControl();
|
||||
|
||||
void showError(String errorMessage);
|
||||
|
||||
void clearError();
|
||||
|
|
|
@ -8,12 +8,17 @@
|
|||
|
||||
package ch.ethz.seb.sebserver.gui.service.examconfig;
|
||||
|
||||
import org.eclipse.rap.rwt.RWT;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute;
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.Orientation;
|
||||
import ch.ethz.seb.sebserver.gui.service.examconfig.impl.ViewContext;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.CustomVariant;
|
||||
|
||||
public interface InputFieldBuilder {
|
||||
|
||||
|
@ -28,8 +33,31 @@ public interface InputFieldBuilder {
|
|||
final ConfigurationAttribute attribute,
|
||||
final ViewContext viewContext);
|
||||
|
||||
static LocTextKey createResourceBundleKey(final String paramName, final String value) {
|
||||
return new LocTextKey(RES_BUNDLE_KEY_PREFIX + paramName + "." + value);
|
||||
static Composite createInnerGrid(
|
||||
final Composite parent,
|
||||
final Orientation orientation) {
|
||||
|
||||
final Composite comp = new Composite(parent, SWT.NONE);
|
||||
final GridLayout gridLayout = new GridLayout();
|
||||
gridLayout.verticalSpacing = 0;
|
||||
gridLayout.marginHeight = 1;
|
||||
comp.setLayout(gridLayout);
|
||||
|
||||
final GridData gridData = new GridData(
|
||||
SWT.FILL, SWT.FILL,
|
||||
true, false,
|
||||
(orientation != null) ? orientation.width() : 1,
|
||||
(orientation != null) ? orientation.height() : 1);
|
||||
comp.setLayoutData(gridData);
|
||||
return comp;
|
||||
}
|
||||
|
||||
static Label createErrorLabel(final Composite innerGrid) {
|
||||
final Label errorLabel = new Label(innerGrid, SWT.NONE);
|
||||
errorLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||
errorLabel.setVisible(false);
|
||||
errorLabel.setData(RWT.CUSTOM_VARIANT, CustomVariant.ERROR.key);
|
||||
return errorLabel;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,14 +18,17 @@ import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue;
|
|||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.Orientation;
|
||||
import ch.ethz.seb.sebserver.gui.service.examconfig.InputField;
|
||||
|
||||
public abstract class ControlFieldAdapter<T extends Control> implements InputField {
|
||||
public abstract class AbstractInputField<T extends Control> implements InputField {
|
||||
|
||||
protected final ConfigurationAttribute attribute;
|
||||
protected final Orientation orientation;
|
||||
protected final T control;
|
||||
protected final Label errorLabel;
|
||||
|
||||
ControlFieldAdapter(
|
||||
protected String initValue = "";
|
||||
protected int listIndex = 0;
|
||||
|
||||
AbstractInputField(
|
||||
final ConfigurationAttribute attribute,
|
||||
final Orientation orientation,
|
||||
final T control,
|
||||
|
@ -42,11 +45,6 @@ public abstract class ControlFieldAdapter<T extends Control> implements InputFie
|
|||
return this.attribute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Control getControl() {
|
||||
return this.control;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
if (this.control.isEnabled()) {
|
||||
|
@ -89,7 +87,15 @@ public abstract class ControlFieldAdapter<T extends Control> implements InputFie
|
|||
|
||||
@Override
|
||||
public void initValue(final Collection<ConfigurationValue> values) {
|
||||
// Does Nothing for default
|
||||
values.stream()
|
||||
.filter(a -> this.attribute.id.equals(a.attributeId))
|
||||
.findFirst()
|
||||
.map(v -> {
|
||||
this.initValue = v.value;
|
||||
this.listIndex = (v.listIndex != null) ? v.listIndex : 0;
|
||||
setDefaultValue();
|
||||
return this.initValue;
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract void setDefaultValue();
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
package ch.ethz.seb.sebserver.gui.service.examconfig.impl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -19,7 +18,6 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.AttributeType;
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute;
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue;
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.Orientation;
|
||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||
import ch.ethz.seb.sebserver.gui.service.examconfig.InputField;
|
||||
|
@ -72,9 +70,7 @@ public class CheckBoxBuilder implements InputFieldBuilder {
|
|||
checkbox);
|
||||
}
|
||||
|
||||
static final class CheckboxField extends ControlFieldAdapter<Button> {
|
||||
|
||||
private boolean initValue = false;
|
||||
static final class CheckboxField extends AbstractInputField<Button> {
|
||||
|
||||
CheckboxField(
|
||||
final ConfigurationAttribute attribute,
|
||||
|
@ -84,21 +80,9 @@ public class CheckBoxBuilder implements InputFieldBuilder {
|
|||
super(attribute, orientation, control, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initValue(final Collection<ConfigurationValue> values) {
|
||||
values.stream()
|
||||
.filter(v -> this.attribute.id.equals(v.attributeId))
|
||||
.findFirst()
|
||||
.map(v -> {
|
||||
this.initValue = Boolean.valueOf(v.value);
|
||||
this.control.setSelection(this.initValue);
|
||||
return this.initValue;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setDefaultValue() {
|
||||
this.control.setSelection(this.initValue);
|
||||
this.control.setSelection(Boolean.valueOf(this.initValue));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import ch.ethz.seb.sebserver.gbl.Constants;
|
||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||
import ch.ethz.seb.sebserver.gbl.api.APIMessage;
|
||||
import ch.ethz.seb.sebserver.gbl.api.APIMessage.ErrorMessage;
|
||||
import ch.ethz.seb.sebserver.gbl.api.JSONMapper;
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.Configuration;
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute;
|
||||
|
@ -39,7 +41,10 @@ import ch.ethz.seb.sebserver.gui.service.examconfig.ExamConfigurationService;
|
|||
import ch.ethz.seb.sebserver.gui.service.examconfig.InputFieldBuilder;
|
||||
import ch.ethz.seb.sebserver.gui.service.examconfig.ValueChangeListener;
|
||||
import ch.ethz.seb.sebserver.gui.service.examconfig.ValueChangeRule;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.FieldValidationError;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageContext;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCallError;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetConfigAttributes;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetConfigurationValues;
|
||||
|
@ -162,9 +167,7 @@ public class ExamConfigurationServiceImpl implements ExamConfigurationService {
|
|||
public Composite createViewGrid(final Composite parent, final ViewContext viewContext) {
|
||||
final Composite composite = new Composite(parent, SWT.NONE);
|
||||
final GridLayout gridLayout = new GridLayout(viewContext.columns, true);
|
||||
gridLayout.marginTop = 10;
|
||||
gridLayout.verticalSpacing = 5;
|
||||
gridLayout.horizontalSpacing = 10;
|
||||
gridLayout.verticalSpacing = 0;
|
||||
composite.setLayout(gridLayout);
|
||||
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||
|
||||
|
@ -208,6 +211,8 @@ public class ExamConfigurationServiceImpl implements ExamConfigurationService {
|
|||
|
||||
private static final class ValueChangeListenerImpl implements ValueChangeListener {
|
||||
|
||||
public static final String VALIDATION_ERROR_KEY_PREFIX = "sebserver.examconfig.props.validation.";
|
||||
|
||||
private final PageContext pageContext;
|
||||
private final RestService restService;
|
||||
private final JSONMapper jsonMapper;
|
||||
|
@ -267,8 +272,25 @@ public class ExamConfigurationServiceImpl implements ExamConfigurationService {
|
|||
}
|
||||
|
||||
private String verifyErrorMessage(final Throwable error) {
|
||||
// TODO Auto-generated method stub
|
||||
return "TODO";
|
||||
if (error instanceof RestCallError) {
|
||||
final List<APIMessage> errorMessages = ((RestCallError) error).getErrorMessages();
|
||||
if (errorMessages.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
final APIMessage apiMessage = errorMessages.get(0);
|
||||
if (!ErrorMessage.FIELD_VALIDATION.isOf(apiMessage)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
final FieldValidationError fieldValidationError = new FieldValidationError(apiMessage);
|
||||
return this.pageContext.getI18nSupport().getText(new LocTextKey(
|
||||
VALIDATION_ERROR_KEY_PREFIX + fieldValidationError.errorType,
|
||||
(Object[]) fieldValidationError.getAttributes()));
|
||||
}
|
||||
|
||||
log.warn("Unexpected error happened while trying to set SEB configuration value: ", error);
|
||||
return VALIDATION_ERROR_KEY_PREFIX + "unexpected";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ public class LabelBuilder implements InputFieldBuilder {
|
|||
label);
|
||||
}
|
||||
|
||||
static final class LabelField extends ControlFieldAdapter<Label> {
|
||||
static final class LabelField extends AbstractInputField<Label> {
|
||||
|
||||
LabelField(
|
||||
final ConfigurationAttribute attribute,
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ch.ethz.seb.sebserver.gui.service.examconfig.impl;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.AttributeType;
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute;
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.Orientation;
|
||||
import ch.ethz.seb.sebserver.gui.service.examconfig.InputField;
|
||||
import ch.ethz.seb.sebserver.gui.service.examconfig.InputFieldBuilder;
|
||||
|
||||
public class PassworFieldBuilder implements InputFieldBuilder {
|
||||
|
||||
@Override
|
||||
public boolean builderFor(
|
||||
final ConfigurationAttribute attribute,
|
||||
final Orientation orientation) {
|
||||
|
||||
if (attribute == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return AttributeType.PASSWORD_FIELD == attribute.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputField createInputField(
|
||||
final Composite parent,
|
||||
final ConfigurationAttribute attribute,
|
||||
final ViewContext viewContext) {
|
||||
|
||||
final Orientation orientation = viewContext.attributeMapping
|
||||
.getOrientation(attribute.id);
|
||||
final Composite innerGrid = InputFieldBuilder
|
||||
.createInnerGrid(parent, orientation);
|
||||
|
||||
final Text passwordInput = new Text(innerGrid, SWT.LEFT | SWT.BORDER | SWT.PASSWORD);
|
||||
passwordInput.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||
final Text confirmInput = new Text(innerGrid, SWT.LEFT | SWT.BORDER | SWT.PASSWORD);
|
||||
confirmInput.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||
|
||||
final PasswordInputField passwordInputField = new PasswordInputField(
|
||||
attribute,
|
||||
orientation,
|
||||
passwordInput,
|
||||
confirmInput,
|
||||
InputFieldBuilder.createErrorLabel(innerGrid));
|
||||
|
||||
final Listener valueChangeEventListener = event -> {
|
||||
|
||||
final String pwd = passwordInput.getText();
|
||||
final String confirm = confirmInput.getText();
|
||||
|
||||
if (StringUtils.isBlank(pwd) && StringUtils.isBlank(confirm)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pwd.equals(confirm)) {
|
||||
passwordInputField.showError("TODO confirm password message");
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO hash password
|
||||
|
||||
passwordInputField.clearError();
|
||||
viewContext.getValueChangeListener().valueChanged(
|
||||
viewContext,
|
||||
attribute,
|
||||
pwd,
|
||||
passwordInputField.listIndex);
|
||||
};
|
||||
|
||||
passwordInput.addListener(SWT.FocusOut, valueChangeEventListener);
|
||||
passwordInput.addListener(SWT.Traverse, valueChangeEventListener);
|
||||
confirmInput.addListener(SWT.FocusOut, valueChangeEventListener);
|
||||
confirmInput.addListener(SWT.Traverse, valueChangeEventListener);
|
||||
return passwordInputField;
|
||||
}
|
||||
|
||||
static final class PasswordInputField extends AbstractInputField<Text> {
|
||||
|
||||
private final Text confirm;
|
||||
|
||||
PasswordInputField(
|
||||
final ConfigurationAttribute attribute,
|
||||
final Orientation orientation,
|
||||
final Text control,
|
||||
final Text confirm,
|
||||
final Label errorLabel) {
|
||||
|
||||
super(attribute, orientation, control, errorLabel);
|
||||
this.confirm = confirm;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setDefaultValue() {
|
||||
// TODO clarify setting some "fake" input when a password is set (like in config tool)
|
||||
this.control.setText(this.initValue);
|
||||
this.confirm.setText(this.initValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -8,26 +8,21 @@
|
|||
|
||||
package ch.ethz.seb.sebserver.gui.service.examconfig.impl;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.eclipse.rap.rwt.RWT;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.AttributeType;
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute;
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue;
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.Orientation;
|
||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||
import ch.ethz.seb.sebserver.gui.service.examconfig.InputField;
|
||||
import ch.ethz.seb.sebserver.gui.service.examconfig.InputFieldBuilder;
|
||||
import ch.ethz.seb.sebserver.gui.service.examconfig.ValueChangeListener;
|
||||
|
||||
@Lazy
|
||||
@Component
|
||||
|
@ -57,53 +52,40 @@ public class TextFieldBuilder implements InputFieldBuilder {
|
|||
|
||||
final Orientation orientation = viewContext.attributeMapping
|
||||
.getOrientation(attribute.id);
|
||||
|
||||
final Composite comp = new Composite(parent, SWT.NONE);
|
||||
final GridLayout gridLayout = new GridLayout();
|
||||
gridLayout.verticalSpacing = 0;
|
||||
comp.setLayout(gridLayout);
|
||||
final GridData gridData = new GridData(
|
||||
SWT.FILL, SWT.FILL,
|
||||
true, false,
|
||||
(orientation != null) ? orientation.width() : 1,
|
||||
(orientation != null) ? orientation.height() : 1);
|
||||
comp.setLayoutData(gridData);
|
||||
final Composite innerGrid = InputFieldBuilder
|
||||
.createInnerGrid(parent, orientation);
|
||||
|
||||
final Text text;
|
||||
if (attribute.type == AttributeType.INTEGER ||
|
||||
attribute.type == AttributeType.DECIMAL) {
|
||||
|
||||
text = new Text(comp, SWT.RIGHT | SWT.BORDER);
|
||||
text = new Text(innerGrid, SWT.RIGHT | SWT.BORDER);
|
||||
} else {
|
||||
text = new Text(comp, SWT.LEFT | SWT.BORDER);
|
||||
text = new Text(innerGrid, SWT.LEFT | SWT.BORDER);
|
||||
}
|
||||
text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||
|
||||
final Label errorLabel = new Label(comp, SWT.NONE);
|
||||
errorLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||
errorLabel.setVisible(false);
|
||||
errorLabel.setData(RWT.CUSTOM_VARIANT, "error");
|
||||
final TextInputField textInputField = new TextInputField(
|
||||
attribute,
|
||||
orientation,
|
||||
text,
|
||||
InputFieldBuilder.createErrorLabel(innerGrid));
|
||||
|
||||
final TextInputField textInputField = new TextInputField(attribute, orientation, text, errorLabel);
|
||||
final ValueChangeListener valueListener = viewContext.getValueChangeListener();
|
||||
text.addListener(
|
||||
SWT.FocusOut,
|
||||
event -> {
|
||||
textInputField.clearError();
|
||||
valueListener.valueChanged(
|
||||
viewContext,
|
||||
attribute,
|
||||
String.valueOf(text.getText()),
|
||||
textInputField.listIndex);
|
||||
});
|
||||
final Listener valueChangeEventListener = event -> {
|
||||
textInputField.clearError();
|
||||
viewContext.getValueChangeListener().valueChanged(
|
||||
viewContext,
|
||||
attribute,
|
||||
String.valueOf(text.getText()),
|
||||
textInputField.listIndex);
|
||||
};
|
||||
|
||||
text.addListener(SWT.FocusOut, valueChangeEventListener);
|
||||
text.addListener(SWT.Traverse, valueChangeEventListener);
|
||||
return textInputField;
|
||||
}
|
||||
|
||||
static final class TextInputField extends ControlFieldAdapter<Text> {
|
||||
|
||||
private String initValue = "";
|
||||
private int listIndex = 0;
|
||||
static final class TextInputField extends AbstractInputField<Text> {
|
||||
|
||||
TextInputField(
|
||||
final ConfigurationAttribute attribute,
|
||||
|
@ -114,19 +96,6 @@ public class TextFieldBuilder implements InputFieldBuilder {
|
|||
super(attribute, orientation, control, errorLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initValue(final Collection<ConfigurationValue> values) {
|
||||
values.stream()
|
||||
.filter(a -> this.attribute.id.equals(a.attributeId))
|
||||
.findFirst()
|
||||
.map(v -> {
|
||||
this.initValue = v.value;
|
||||
this.listIndex = (v.listIndex != null) ? v.listIndex : 0;
|
||||
setDefaultValue();
|
||||
return this.initValue;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setDefaultValue() {
|
||||
this.control.setText(this.initValue);
|
||||
|
|
|
@ -46,8 +46,6 @@ public class ViewGridBuilder {
|
|||
this.viewContext = viewContext;
|
||||
this.grid = new CellFieldBuilderAdapter[viewContext.rows][viewContext.columns];
|
||||
this.registeredGroups = new HashSet<>();
|
||||
|
||||
fillDummy(0, 0, viewContext.columns, viewContext.rows);
|
||||
}
|
||||
|
||||
ViewGridBuilder add(final ConfigurationAttribute attribute) {
|
||||
|
@ -78,6 +76,10 @@ public class ViewGridBuilder {
|
|||
final int xpos = orientation.xpos();
|
||||
final int ypos = orientation.ypos();
|
||||
|
||||
if (orientation.width > 1 || orientation.height > 1) {
|
||||
fillDummy(xpos, ypos, orientation.width, orientation.height);
|
||||
}
|
||||
|
||||
final InputFieldBuilder inputFieldBuilder = this.examConfigurationService.getInputFieldBuilder(
|
||||
attribute,
|
||||
orientation);
|
||||
|
@ -114,7 +116,8 @@ public class ViewGridBuilder {
|
|||
for (int x = 0; x < this.grid[y].length; x++) {
|
||||
if (this.grid[y][x] == null) {
|
||||
final Label empty = new Label(this.parent, SWT.LEFT);
|
||||
empty.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||
final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
|
||||
empty.setLayoutData(gridData);
|
||||
empty.setText("");
|
||||
} else {
|
||||
this.grid[y][x].createCell(this);
|
||||
|
@ -149,10 +152,6 @@ public class ViewGridBuilder {
|
|||
attribute,
|
||||
ViewGridBuilder.this.viewContext);
|
||||
|
||||
// final Orientation orientation =
|
||||
// ViewGridBuilder.this.viewContext.attributeMapping.getOrientation(attribute.id);
|
||||
//
|
||||
// //inputField.setSpan(orientation.width, orientation.height);
|
||||
ViewGridBuilder.this.viewContext.registerInputField(inputField);
|
||||
}
|
||||
};
|
||||
|
@ -257,13 +256,6 @@ public class ViewGridBuilder {
|
|||
attr,
|
||||
this.builder.viewContext);
|
||||
|
||||
final GridData gridData = new GridData(
|
||||
SWT.FILL, SWT.FILL,
|
||||
true, false,
|
||||
orientation.width(), orientation.height());
|
||||
|
||||
inputField.getControl().setLayoutData(gridData);
|
||||
inputField.getControl().setToolTipText(attr.name);
|
||||
this.builder.viewContext.registerInputField(inputField);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.I18nSupport;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
|
||||
/** Holds a page-context and defines some convenient functionality for page handling */
|
||||
|
@ -39,6 +40,11 @@ public interface PageContext {
|
|||
|
||||
}
|
||||
|
||||
/** Get the I18nSupport service
|
||||
*
|
||||
* @return the I18nSupport service */
|
||||
I18nSupport getI18nSupport();
|
||||
|
||||
/** Use this to get the ComposerService used by this PageContext
|
||||
*
|
||||
* @return the ComposerService used by this PageContext */
|
||||
|
|
|
@ -59,6 +59,11 @@ public class PageContextImpl implements PageContext {
|
|||
this.attributes = Utils.immutableMapOf(attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public I18nSupport getI18nSupport() {
|
||||
return this.i18nSupport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Shell getShell() {
|
||||
if (this.root == null) {
|
||||
|
@ -328,5 +333,4 @@ public class PageContextImpl implements PageContext {
|
|||
this.onOK.accept(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -117,7 +117,8 @@ public class WidgetFactory {
|
|||
FOOTER("footer"),
|
||||
TITLE_LABEL("head"),
|
||||
|
||||
MESSAGE("message")
|
||||
MESSAGE("message"),
|
||||
ERROR("error")
|
||||
|
||||
;
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@ import java.io.UnsupportedEncodingException;
|
|||
import java.security.SecureRandom;
|
||||
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.cryptonode.jncryptor.AES256JNCryptor;
|
||||
import org.cryptonode.jncryptor.JNCryptor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
@ -36,9 +34,6 @@ public class ClientCredentialServiceImpl implements ClientCredentialService {
|
|||
|
||||
private final Environment environment;
|
||||
|
||||
// TODO try to integrate with JNCryptor since this is also used by SEB
|
||||
private final JNCryptor cryptor = new AES256JNCryptor();
|
||||
|
||||
protected ClientCredentialServiceImpl(final Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,13 @@ public interface ConfigurationValueValidator {
|
|||
final ConfigurationValue value,
|
||||
final ConfigurationAttribute attribute) {
|
||||
|
||||
return "examConfigValue:" + attribute.name + ":" + name() + ":" + value.listIndex;
|
||||
return new StringBuffer("examConfigValue:")
|
||||
.append(attribute.name)
|
||||
.append(":")
|
||||
.append(name())
|
||||
.append(":")
|
||||
.append(value.listIndex)
|
||||
.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.AttributeType;
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute;
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue;
|
||||
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ConfigurationValueValidator;
|
||||
|
||||
@Lazy
|
||||
@Component
|
||||
@WebServiceProfile
|
||||
public class DecimalTypeValidator implements ConfigurationValueValidator {
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return AttributeType.DECIMAL.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate(
|
||||
final ConfigurationValue value,
|
||||
final ConfigurationAttribute attribute) {
|
||||
|
||||
// if value is not an integer type or another specific validation is defined --> skip
|
||||
if (attribute.type != AttributeType.DECIMAL ||
|
||||
StringUtils.isNoneBlank(attribute.validator)) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(value.value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
Double.parseDouble(value.value);
|
||||
return true;
|
||||
} catch (final NumberFormatException nfe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -21,7 +21,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ConfigurationValu
|
|||
@Lazy
|
||||
@Component
|
||||
@WebServiceProfile
|
||||
public class IntegerTypeValueValidator implements ConfigurationValueValidator {
|
||||
public class IntegerTypeValidator implements ConfigurationValueValidator {
|
||||
|
||||
@Override
|
||||
public String name() {
|
|
@ -154,7 +154,8 @@ public final class SebConfigEncryptionServiceImpl implements SebConfigEncryption
|
|||
input.get(b);
|
||||
return ByteBuffer.wrap(b).asReadOnlyBuffer();
|
||||
} else {
|
||||
return input.clear().asReadOnlyBuffer();
|
||||
input.clear();
|
||||
return input.asReadOnlyBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.PaginationService;
|
|||
import ch.ethz.seb.sebserver.webservice.servicelayer.authorization.AuthorizationService;
|
||||
import ch.ethz.seb.sebserver.webservice.servicelayer.bulkaction.BulkActionService;
|
||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ConfigurationDAO;
|
||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ConfigurationNodeDAO;
|
||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.UserActivityLogDAO;
|
||||
import ch.ethz.seb.sebserver.webservice.servicelayer.validation.BeanValidationService;
|
||||
|
||||
|
@ -41,7 +40,6 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.validation.BeanValidationSe
|
|||
public class ConfigurationController extends EntityController<Configuration, Configuration> {
|
||||
|
||||
private final ConfigurationDAO configurationDAO;
|
||||
private final ConfigurationNodeDAO configurationNodeDAO;
|
||||
|
||||
protected ConfigurationController(
|
||||
final AuthorizationService authorization,
|
||||
|
@ -49,8 +47,7 @@ public class ConfigurationController extends EntityController<Configuration, Con
|
|||
final ConfigurationDAO entityDAO,
|
||||
final UserActivityLogDAO userActivityLogDAO,
|
||||
final PaginationService paginationService,
|
||||
final BeanValidationService beanValidationService,
|
||||
final ConfigurationNodeDAO configurationNodeDAO) {
|
||||
final BeanValidationService beanValidationService) {
|
||||
|
||||
super(authorization,
|
||||
bulkActionService,
|
||||
|
@ -60,7 +57,6 @@ public class ConfigurationController extends EntityController<Configuration, Con
|
|||
beanValidationService);
|
||||
|
||||
this.configurationDAO = entityDAO;
|
||||
this.configurationNodeDAO = configurationNodeDAO;
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
|
|
|
@ -374,4 +374,9 @@ sebserver.examconfig.props.form.views.testView=Test View
|
|||
sebserver.examconfig.props.form.views.testView.tooltip=This is a test View
|
||||
sebserver.examconfig.props.action.list.modify=Edit Properties
|
||||
|
||||
sebserver.examconfig.props.label.testNumber=Test Number
|
||||
sebserver.examconfig.props.label.testNumber1=Test Number 1
|
||||
sebserver.examconfig.props.label.testNumber2=Test Number 2
|
||||
|
||||
sebserver.examconfig.props.validation.unexpected=Unexpected error happened. Value was not set correctly
|
||||
sebserver.examconfig.props.validation.INTEGER=Invalid number
|
||||
sebserver.examconfig.props.validation.DECIMAL=Invalid decimal number
|
||||
|
|
Loading…
Reference in a new issue