SEBSERV-414 lock screen color selector
This commit is contained in:
parent
5f6c32ac54
commit
6d47e8f803
7 changed files with 143 additions and 5 deletions
|
@ -43,6 +43,8 @@ public enum AttributeType {
|
|||
/** Multiple selection with checkbox type */
|
||||
MULTI_CHECKBOX_SELECTION(LIST),
|
||||
|
||||
COLOR_SELECTOR(TEXT),
|
||||
|
||||
FILE_UPLOAD(BASE64_BINARY),
|
||||
|
||||
/** Table type is a list of a composite of single types */
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
package ch.ethz.seb.sebserver.gui.service.examconfig.impl;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.Constants;
|
||||
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.gbl.profile.GuiProfile;
|
||||
import ch.ethz.seb.sebserver.gui.form.FieldBuilder;
|
||||
import ch.ethz.seb.sebserver.gui.service.examconfig.ExamConfigurationService;
|
||||
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.i18n.I18nSupport;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
import ch.ethz.seb.sebserver.gui.widget.ColorSelection;
|
||||
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
|
||||
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.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Lazy
|
||||
@Component
|
||||
@GuiProfile
|
||||
public class ColorSelectorFieldBuilder implements InputFieldBuilder {
|
||||
|
||||
private final WidgetFactory widgetFactory;
|
||||
|
||||
public ColorSelectorFieldBuilder(final WidgetFactory widgetFactory) {
|
||||
this.widgetFactory = widgetFactory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init(final InputFieldBuilderSupplier inputFieldBuilderSupplier) {
|
||||
InputFieldBuilder.super.init(inputFieldBuilderSupplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean builderFor(final ConfigurationAttribute attribute, final Orientation orientation) {
|
||||
if (attribute == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return attribute.type == AttributeType.COLOR_SELECTOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputField createInputField(
|
||||
final Composite parent,
|
||||
final ConfigurationAttribute attribute,
|
||||
final ViewContext viewContext) {
|
||||
|
||||
final I18nSupport i18nSupport = viewContext.getI18nSupport();
|
||||
final Orientation orientation = viewContext
|
||||
.getOrientation(attribute.id);
|
||||
final Composite innerGrid = InputFieldBuilder
|
||||
.createInnerGrid(parent, attribute, orientation);
|
||||
|
||||
final LocTextKey toolTipKey = ExamConfigurationService.getToolTipKey(
|
||||
attribute,
|
||||
i18nSupport);
|
||||
final ColorSelection colorSelector = new ColorSelection(
|
||||
innerGrid,
|
||||
widgetFactory,
|
||||
toolTipKey != null ? toolTipKey.name: null);
|
||||
|
||||
colorSelector.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||
final ColorSelectionInputField singleSelectionInputField = new ColorSelectionInputField(
|
||||
attribute,
|
||||
orientation,
|
||||
colorSelector,
|
||||
FieldBuilder.createErrorLabel(innerGrid));
|
||||
|
||||
if (viewContext.readonly) {
|
||||
colorSelector.setEnabled(false);
|
||||
} else {
|
||||
colorSelector.setSelectionListener(event -> {
|
||||
singleSelectionInputField.clearError();
|
||||
viewContext.getValueChangeListener().valueChanged(
|
||||
viewContext,
|
||||
attribute,
|
||||
singleSelectionInputField.getValue(),
|
||||
singleSelectionInputField.listIndex);
|
||||
});
|
||||
}
|
||||
|
||||
return singleSelectionInputField;
|
||||
}
|
||||
|
||||
static final class ColorSelectionInputField extends AbstractInputField<ColorSelection> {
|
||||
|
||||
protected ColorSelectionInputField(
|
||||
final ConfigurationAttribute attribute,
|
||||
final Orientation orientation,
|
||||
final ColorSelection control,
|
||||
final Label errorLabel) {
|
||||
|
||||
super(attribute, orientation, control, errorLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
final String selection = this.control.getSelectionValue();
|
||||
if (selection == null) {
|
||||
return null;
|
||||
}
|
||||
return Constants.HASH_TAG + selection;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setValueToControl(final String value) {
|
||||
if (value != null && value.startsWith(Constants.HASH_TAG.toString())) {
|
||||
this.control.select(value.substring(1));
|
||||
} else {
|
||||
this.control.select(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -53,7 +53,8 @@ public class TextFieldBuilder implements InputFieldBuilder {
|
|||
return attribute.type == AttributeType.TEXT_FIELD ||
|
||||
attribute.type == AttributeType.TEXT_AREA ||
|
||||
attribute.type == AttributeType.INTEGER ||
|
||||
attribute.type == AttributeType.DECIMAL;
|
||||
attribute.type == AttributeType.DECIMAL ||
|
||||
attribute.type == AttributeType.COLOR_SELECTOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -51,7 +51,7 @@ public final class ColorSelection extends Composite implements Selection {
|
|||
|
||||
private Listener listener = null;
|
||||
|
||||
ColorSelection(
|
||||
public ColorSelection(
|
||||
final Composite parent,
|
||||
final WidgetFactory widgetFactory,
|
||||
final String tooltipKeyPrefix) {
|
||||
|
|
|
@ -42,7 +42,8 @@ public class StringConverter implements AttributeValueConverter {
|
|||
AttributeType.TEXT_AREA,
|
||||
AttributeType.PASSWORD_FIELD,
|
||||
AttributeType.DECIMAL,
|
||||
AttributeType.COMBO_SELECTION)));
|
||||
AttributeType.COMBO_SELECTION,
|
||||
AttributeType.COLOR_SELECTOR)));
|
||||
|
||||
private static final String XML_TEMPLATE = "<key>%s</key><string>%s</string>";
|
||||
private static final String XML_TEMPLATE_EMPTY = "<key>%s</key><string />";
|
||||
|
|
|
@ -175,3 +175,16 @@ INSERT IGNORE INTO orientation (config_attribute_id, template_id, view_id, group
|
|||
(1563, 0, 3, 'mediaPlaybackCapture', 9, 19, 3, 1, 'NONE')
|
||||
;
|
||||
|
||||
-- ----------------------------------------------------------------
|
||||
-- Add Lock screen color (SEBSERV-414)
|
||||
-- ----------------------------------------------------------------
|
||||
|
||||
INSERT IGNORE INTO configuration_attribute VALUES
|
||||
(1595, 'lockScreenBackgroundColor', 'COLOR_SELECTOR', null, null, null, null, '#FF0000')
|
||||
;
|
||||
|
||||
INSERT IGNORE INTO orientation (config_attribute_id, template_id, view_id, group_id, x_position, y_position, width, height, title) VALUES
|
||||
(1595, 0, 2, null, 7, 9, 5, 2, 'TOP')
|
||||
;
|
||||
|
||||
UPDATE orientation SET height=1 WHERE config_attribute_id=8 AND template_id=0;
|
|
@ -1293,7 +1293,8 @@ sebserver.examconfig.props.label.allowSpellCheckDictionary.fr-FR=French (France)
|
|||
sebserver.examconfig.props.label.allowSpellCheckDictionary.pt-PT=Portuguese (Portugal) (pt-PT)
|
||||
sebserver.examconfig.props.label.allowSpellCheckDictionary.sv-SE=Swedish (Sweden)
|
||||
sebserver.examconfig.props.label.allowSpellCheckDictionary.sv-FI=Swedish (Finland)
|
||||
|
||||
sebserver.examconfig.props.label.lockScreenBackgroundColor=Lock screen background color
|
||||
sebserver.examconfig.props.label.lockScreenBackgroundColor.tooltip=
|
||||
sebserver.examconfig.props.group.newBrowserWindow=Links requesting to be opened in a new browser window (Mac)
|
||||
sebserver.examconfig.props.label.newBrowserWindowByLinkPolicy.0=get generally blocked
|
||||
sebserver.examconfig.props.label.newBrowserWindowByLinkPolicy.1=open in same window
|
||||
|
@ -1633,7 +1634,6 @@ sebserver.examconfig.props.label.allowSiri=Allow to use Siri
|
|||
sebserver.examconfig.props.label.allowSiri.tooltip=If enabled, Siri can be used by tapping the menu bar icon, Touch Bar icon or shortcut set in System Preferences/Siri (default: hold command space). The Siri window won't be displayed though
|
||||
sebserver.examconfig.props.label.detectStoppedProcess=Detect when SEB process was stopped
|
||||
sebserver.examconfig.props.label.detectStoppedProcess.tooltip=SEB displays a lock screen (requiring to enter the quit/unlock password) if it detects its process was stopped, which can indicate manipulation
|
||||
sebserver.examconfig.props.label.detectStoppedProcess.tooltip=SEB displays a lock screen (requiring to enter the quit/unlock password) if it detects its process was stopped, which can indicate manipulation
|
||||
sebserver.examconfig.props.label.allowDisplayMirroring=Allow display mirroring (affects also AirPlay Display)
|
||||
sebserver.examconfig.props.label.allowDisplayMirroring.tooltip=If not selected, SEB prevents to mirror the main display to another
|
||||
sebserver.examconfig.props.label.allowedDisplaysMaxNumber=Maximum allowed number of connected displays
|
||||
|
|
Loading…
Reference in a new issue