SEBSERV-138 fixed navigation and filter. Added more input field types
This commit is contained in:
parent
c3b999fc4c
commit
2dea3e2285
22 changed files with 263 additions and 117 deletions
|
@ -15,8 +15,8 @@ import org.eclipse.swt.SWT;
|
|||
import org.eclipse.swt.custom.SashForm;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
@ -96,12 +96,12 @@ public class MainPage implements TemplateComposer {
|
|||
},
|
||||
false);
|
||||
|
||||
final Label toggleView = this.widgetFactory.imageButton(
|
||||
final Button toggleView = this.widgetFactory.imageButton(
|
||||
ImageIcon.MAXIMIZE,
|
||||
content,
|
||||
new LocTextKey("sebserver.mainpage.maximize.tooltip"),
|
||||
event -> {
|
||||
final Label ib = (Label) event.widget;
|
||||
final Button ib = (Button) event.widget;
|
||||
if ((Boolean) ib.getData("fullScreen")) {
|
||||
mainSash.setWeights(DEFAULT_SASH_WEIGHTS);
|
||||
ib.setData("fullScreen", false);
|
||||
|
|
|
@ -16,6 +16,8 @@ import org.eclipse.swt.widgets.Event;
|
|||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -44,6 +46,8 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.CustomVariant;
|
|||
@Component
|
||||
public class ActivitiesPane implements TemplateComposer {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ActivitiesPane.class);
|
||||
|
||||
private static final String SKIP_EXPAND = "SKIP_EXPAND";
|
||||
|
||||
private static final String ATTR_ACTIVITY_SELECTION = "ACTIVITY_SELECTION";
|
||||
|
@ -361,7 +365,12 @@ public class ActivitiesPane implements TemplateComposer {
|
|||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// register page listener and initialize navigation data
|
||||
navigation.addListener(SWT.Selection, event -> handleSelection(pageContext, event));
|
||||
navigation.addListener(SWT.MouseUp, event -> handleSelection(pageContext, event));
|
||||
navigation.addListener(SWT.KeyDown, event -> {
|
||||
if (event.keyCode == 13 || event.keyCode == 32) {
|
||||
handleSelection(pageContext, event);
|
||||
}
|
||||
});
|
||||
navigation.addListener(SWT.Expand, event -> {
|
||||
final TreeItem item = (TreeItem) event.item;
|
||||
selectCurrentItem(navigation, item);
|
||||
|
@ -406,69 +415,83 @@ public class ActivitiesPane implements TemplateComposer {
|
|||
}
|
||||
|
||||
private TreeItem getDefaultSelectionFor(final Tree navigation, final CurrentUser currentUser2) {
|
||||
if (this.currentUser.get().hasAnyRole(UserRole.SEB_SERVER_ADMIN, UserRole.INSTITUTIONAL_ADMIN)) {
|
||||
return navigation.getItem(0);
|
||||
} else if (this.currentUser.get().hasAnyRole(UserRole.EXAM_ADMIN)) {
|
||||
return findItemByActionDefinition(
|
||||
navigation.getItems(),
|
||||
ActivityDefinition.SEB_EXAM_CONFIG);
|
||||
} else if (this.currentUser.get().hasAnyRole(UserRole.EXAM_SUPPORTER)) {
|
||||
return findItemByActionDefinition(
|
||||
navigation.getItems(),
|
||||
ActivityDefinition.MONITORING_EXAMS);
|
||||
} else {
|
||||
try {
|
||||
if (this.currentUser.get().hasAnyRole(UserRole.SEB_SERVER_ADMIN, UserRole.INSTITUTIONAL_ADMIN)) {
|
||||
return navigation.getItem(0);
|
||||
} else if (this.currentUser.get().hasAnyRole(UserRole.EXAM_ADMIN)) {
|
||||
return findItemByActionDefinition(
|
||||
navigation.getItems(),
|
||||
ActivityDefinition.SEB_EXAM_CONFIG);
|
||||
} else if (this.currentUser.get().hasAnyRole(UserRole.EXAM_SUPPORTER)) {
|
||||
return findItemByActionDefinition(
|
||||
navigation.getItems(),
|
||||
ActivityDefinition.MONITORING_EXAMS);
|
||||
} else {
|
||||
return navigation.getItem(0);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
return navigation.getItem(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void selectCurrentItem(final Tree navigation, final TreeItem item) {
|
||||
final PageState currentState = this.pageService.getCurrentState();
|
||||
if (currentState == null) {
|
||||
return;
|
||||
}
|
||||
final TreeItem currentItem = findItemByActionDefinition(
|
||||
item.getItems(),
|
||||
currentState.definition.activityAnchor());
|
||||
if (currentItem != null) {
|
||||
navigation.select(currentItem);
|
||||
try {
|
||||
final PageState currentState = this.pageService.getCurrentState();
|
||||
if (currentState == null) {
|
||||
return;
|
||||
}
|
||||
final TreeItem currentItem = findItemByActionDefinition(
|
||||
item.getItems(),
|
||||
currentState.definition.activityAnchor());
|
||||
if (currentItem != null) {
|
||||
navigation.select(currentItem);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
log.warn("Failed to select current navigation item: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSelection(final PageContext composerCtx, final Event event) {
|
||||
final Tree tree = (Tree) event.widget;
|
||||
final TreeItem treeItem = (TreeItem) event.item;
|
||||
try {
|
||||
final Tree tree = (Tree) event.widget;
|
||||
TreeItem treeItem = (event.item == null && tree.getSelectionCount() == 1)
|
||||
? treeItem = tree.getSelection()[0]
|
||||
: (TreeItem) event.item;
|
||||
|
||||
if (treeItem.getItemCount() > 0 && !treeItem.getExpanded()) {
|
||||
return;
|
||||
}
|
||||
if (treeItem.getItemCount() > 0 && !treeItem.getExpanded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final PageAction action = getActivitySelection(treeItem);
|
||||
// if there is no form action associated with the treeItem and the treeItem has sub items, toggle the item state
|
||||
if (action == null) {
|
||||
handleParentSelection(tree, treeItem);
|
||||
return;
|
||||
}
|
||||
final PageAction action = getActivitySelection(treeItem);
|
||||
// if there is no form action associated with the treeItem and the treeItem has sub items, toggle the item state
|
||||
if (action == null) {
|
||||
handleParentSelection(tree, treeItem);
|
||||
return;
|
||||
}
|
||||
|
||||
final PageState currentState = this.pageService.getCurrentState();
|
||||
if (currentState != null && currentState.definition == action.definition.targetState) {
|
||||
return;
|
||||
}
|
||||
final PageState currentState = this.pageService.getCurrentState();
|
||||
if (currentState != null && currentState.definition == action.definition.targetState) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pageService.executePageAction(
|
||||
action,
|
||||
resultAction -> {
|
||||
if (resultAction.hasError()) {
|
||||
tree.deselect(treeItem);
|
||||
if (currentState != null) {
|
||||
final TreeItem item = findItemByActionDefinition(
|
||||
tree.getItems(),
|
||||
currentState.activityAnchor());
|
||||
if (item != null) {
|
||||
tree.select(item);
|
||||
this.pageService.executePageAction(
|
||||
action,
|
||||
resultAction -> {
|
||||
if (resultAction.hasError()) {
|
||||
tree.deselect(treeItem);
|
||||
if (currentState != null) {
|
||||
final TreeItem item = findItemByActionDefinition(
|
||||
tree.getItems(),
|
||||
currentState.activityAnchor());
|
||||
if (item != null) {
|
||||
tree.select(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
} catch (final Exception e) {
|
||||
log.warn("Failed to select navigation bar: {} cause: {}", event, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleParentSelection(final Tree tree, final TreeItem treeItem) {
|
||||
|
|
|
@ -44,14 +44,18 @@ public class CheckboxFieldBuilder extends FieldBuilder<String> {
|
|||
checkbox = builder.widgetFactory.buttonLocalized(
|
||||
fieldGrid,
|
||||
SWT.CHECK,
|
||||
this.label, this.tooltip);
|
||||
this.label,
|
||||
this.tooltip,
|
||||
getARIALabel(builder));
|
||||
} else {
|
||||
titleLabel = createTitleLabel(builder.formParent, builder, this);
|
||||
fieldGrid = createFieldGrid(builder.formParent, this.spanInput);
|
||||
checkbox = builder.widgetFactory.buttonLocalized(
|
||||
fieldGrid,
|
||||
SWT.CHECK,
|
||||
null, null);
|
||||
null,
|
||||
null,
|
||||
getARIALabel(builder));
|
||||
}
|
||||
|
||||
final GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, true);
|
||||
|
|
|
@ -20,7 +20,6 @@ import org.eclipse.swt.widgets.Control;
|
|||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
||||
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
|
||||
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.CustomVariant;
|
||||
|
||||
|
@ -110,6 +109,14 @@ public abstract class FieldBuilder<T> {
|
|||
|
||||
abstract void build(FormBuilder builder);
|
||||
|
||||
protected LocTextKey getARIALabel(final FormBuilder builder) {
|
||||
LocTextKey label = this.label;
|
||||
if (this.isMandatory) {
|
||||
label = new LocTextKey("sebserver.form.mandatory.label", builder.i18nSupport.getText(this.label));
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
protected static Control createTitleLabel(
|
||||
final Composite parent,
|
||||
final FormBuilder builder,
|
||||
|
@ -142,16 +149,8 @@ public abstract class FieldBuilder<T> {
|
|||
1,
|
||||
fieldBuilder.titleValign);
|
||||
|
||||
if (hasTooltip && builder.pageService.getFormTooltipMode() == PageService.FormTooltipMode.LEFT) {
|
||||
final Label info = builder.widgetFactory.imageButton(
|
||||
WidgetFactory.ImageIcon.HELP,
|
||||
infoGrid,
|
||||
fieldBuilder.tooltip);
|
||||
info.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
|
||||
}
|
||||
|
||||
if (fieldBuilder.isMandatory) {
|
||||
final Label mandatory = builder.widgetFactory.imageButton(
|
||||
final Label mandatory = builder.widgetFactory.mandatoryLabel(
|
||||
WidgetFactory.ImageIcon.MANDATORY,
|
||||
infoGrid,
|
||||
MANDATORY_TEXT_KEY);
|
||||
|
|
|
@ -10,7 +10,6 @@ package ch.ethz.seb.sebserver.gui.form;
|
|||
|
||||
import java.util.Collection;
|
||||
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
@ -18,6 +17,7 @@ import org.eclipse.swt.widgets.Control;
|
|||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
||||
import ch.ethz.seb.sebserver.gui.widget.FileUploadSelection;
|
||||
|
||||
public class FileUploadFieldBuilder extends FieldBuilder<String> {
|
||||
|
@ -41,7 +41,8 @@ public class FileUploadFieldBuilder extends FieldBuilder<String> {
|
|||
final FileUploadSelection fileUpload = builder.widgetFactory.fileUploadSelection(
|
||||
fieldGrid,
|
||||
builder.readonly || this.readonly,
|
||||
this.supportedFiles);
|
||||
this.supportedFiles,
|
||||
getARIALabel(builder));
|
||||
final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
|
||||
fileUpload.setLayoutData(gridData);
|
||||
fileUpload.setFileName(this.value);
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
package ch.ethz.seb.sebserver.gui.form;
|
||||
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
@ -16,6 +15,7 @@ import org.eclipse.swt.widgets.Control;
|
|||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
||||
import ch.ethz.seb.sebserver.gui.widget.ImageUploadSelection;
|
||||
|
||||
public final class ImageUploadFieldBuilder extends FieldBuilder<String> {
|
||||
|
@ -46,7 +46,8 @@ public final class ImageUploadFieldBuilder extends FieldBuilder<String> {
|
|||
new LocTextKey("sebserver.overall.upload"),
|
||||
builder.readonly || this.readonly,
|
||||
this.maxWidth,
|
||||
this.maxHeight);
|
||||
this.maxHeight,
|
||||
getARIALabel(builder));
|
||||
final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
|
||||
imageUpload.setLayoutData(gridData);
|
||||
imageUpload.setImageBase64(this.value);
|
||||
|
|
|
@ -33,7 +33,11 @@ public class PasswordFieldBuilder extends FieldBuilder<CharSequence> {
|
|||
final Control titleLabel = createTitleLabel(builder.formParent, builder, this);
|
||||
final Composite fieldGrid = createFieldGrid(builder.formParent, this.spanInput);
|
||||
|
||||
final PasswordInput input = new PasswordInput(fieldGrid, builder.widgetFactory);
|
||||
final PasswordInput input = new PasswordInput(
|
||||
fieldGrid,
|
||||
builder.widgetFactory,
|
||||
getARIALabel(builder));
|
||||
|
||||
input.setEditable(!readonly);
|
||||
input.setValue((StringUtils.isNotBlank(this.value))
|
||||
? builder.cryptor.decrypt(this.value)
|
||||
|
|
|
@ -76,7 +76,7 @@ public final class SelectionFieldBuilder extends FieldBuilder<String> {
|
|||
(builder.pageService.getFormTooltipMode() == PageService.FormTooltipMode.INPUT) ? this.tooltip : null,
|
||||
null,
|
||||
actionKey,
|
||||
this.label);
|
||||
getARIALabel(builder));
|
||||
|
||||
final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
|
||||
((Control) selection).setLayoutData(gridData);
|
||||
|
|
|
@ -118,11 +118,12 @@ public final class TextFieldBuilder extends FieldBuilder<String> {
|
|||
return;
|
||||
}
|
||||
|
||||
final LocTextKey label = getARIALabel(builder);
|
||||
final Text textInput = (this.isNumber)
|
||||
? builder.widgetFactory.numberInput(fieldGrid, this.numberCheck, readonly, this.label)
|
||||
? builder.widgetFactory.numberInput(fieldGrid, this.numberCheck, readonly, label)
|
||||
: (this.isArea)
|
||||
? builder.widgetFactory.textAreaInput(fieldGrid, readonly, this.label)
|
||||
: builder.widgetFactory.textInput(fieldGrid, this.isPassword, readonly, this.label);
|
||||
? builder.widgetFactory.textAreaInput(fieldGrid, readonly, label)
|
||||
: builder.widgetFactory.textInput(fieldGrid, this.isPassword, readonly, label);
|
||||
|
||||
if (builder.pageService.getFormTooltipMode() == PageService.FormTooltipMode.INPUT) {
|
||||
builder.pageService.getPolyglotPageService().injectI18nTooltip(
|
||||
|
|
|
@ -74,7 +74,8 @@ public class CheckBoxBuilder implements InputFieldBuilder {
|
|||
(orientation.title == TitleOrientation.NONE)
|
||||
? ExamConfigurationService.attributeNameLocKey(attribute)
|
||||
: null,
|
||||
ExamConfigurationService.getToolTipKey(attribute, i18nSupport));
|
||||
ExamConfigurationService.getToolTipKey(attribute, i18nSupport),
|
||||
ExamConfigurationService.attributeNameLocKey(attribute));
|
||||
|
||||
final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
|
||||
gridData.verticalIndent = 0;
|
||||
|
|
|
@ -24,6 +24,7 @@ import ch.ethz.seb.sebserver.gbl.model.sebconfig.Orientation;
|
|||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||
import ch.ethz.seb.sebserver.gbl.util.Cryptor;
|
||||
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.LocTextKey;
|
||||
|
@ -73,11 +74,22 @@ public class PasswordFieldBuilder implements InputFieldBuilder {
|
|||
final Composite innerGrid = InputFieldBuilder
|
||||
.createInnerGrid(parent, attribute, orientation);
|
||||
|
||||
final PasswordInput passwordInput = new PasswordInput(innerGrid, this.widgetFactory);
|
||||
final LocTextKey attributeNameLocKey = ExamConfigurationService.attributeNameLocKey(attribute);
|
||||
final PasswordInput passwordInput = new PasswordInput(
|
||||
innerGrid,
|
||||
this.widgetFactory,
|
||||
attributeNameLocKey);
|
||||
final GridData passwordInputLD = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
passwordInput.setLayoutData(passwordInputLD);
|
||||
|
||||
final PasswordInput confirmInput = new PasswordInput(innerGrid, this.widgetFactory);
|
||||
final LocTextKey confirmNameLocKey =
|
||||
new LocTextKey(
|
||||
"sebserver.form.confirm.label",
|
||||
viewContext.i18nSupport.getText(attributeNameLocKey));
|
||||
final PasswordInput confirmInput = new PasswordInput(
|
||||
innerGrid,
|
||||
this.widgetFactory,
|
||||
confirmNameLocKey);
|
||||
final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
gridData.verticalIndent = 14;
|
||||
confirmInput.setLayoutData(gridData);
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.swt.layout.GridData;
|
|||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.layout.RowData;
|
||||
import org.eclipse.swt.layout.RowLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.DateTime;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
|
@ -199,13 +200,13 @@ public class TableFilter<ROW> {
|
|||
|
||||
final GridData gridData = new GridData(SWT.FILL, SWT.BOTTOM, true, true);
|
||||
gridData.heightHint = 20;
|
||||
final Label imageButton = this.entityTable.widgetFactory.imageButton(
|
||||
final Button imageButton = this.entityTable.widgetFactory.imageButton(
|
||||
ImageIcon.SEARCH,
|
||||
inner,
|
||||
new LocTextKey("sebserver.overall.action.filter"),
|
||||
event -> this.entityTable.applyFilter());
|
||||
imageButton.setLayoutData(gridData);
|
||||
final Label imageButton2 = this.entityTable.widgetFactory.imageButton(
|
||||
final Button imageButton2 = this.entityTable.widgetFactory.imageButton(
|
||||
ImageIcon.CANCEL,
|
||||
inner,
|
||||
new LocTextKey("sebserver.overall.action.filter.clear"),
|
||||
|
@ -267,6 +268,10 @@ public class TableFilter<ROW> {
|
|||
inner.setLayoutData(this.rowData);
|
||||
return inner;
|
||||
}
|
||||
|
||||
protected LocTextKey getAriaLabel() {
|
||||
return new LocTextKey("sebserver.form.tablefilter.label", this.attribute.columnName);
|
||||
}
|
||||
}
|
||||
|
||||
private static class NullFilter extends FilterComponent {
|
||||
|
@ -323,7 +328,8 @@ public class TableFilter<ROW> {
|
|||
|
||||
this.textInput = TableFilter.this.entityTable.widgetFactory.textInput(
|
||||
innerComposite,
|
||||
super.attribute.columnName);
|
||||
getAriaLabel());
|
||||
|
||||
this.textInput.setLayoutData(gridData);
|
||||
return this;
|
||||
}
|
||||
|
@ -376,7 +382,7 @@ public class TableFilter<ROW> {
|
|||
ch.ethz.seb.sebserver.gui.widget.Selection.Type.SINGLE,
|
||||
innerComposite,
|
||||
resourceSupplier,
|
||||
this.attribute.columnName);
|
||||
getAriaLabel());
|
||||
|
||||
this.selector
|
||||
.adaptToControl()
|
||||
|
@ -430,7 +436,9 @@ public class TableFilter<ROW> {
|
|||
@Override
|
||||
FilterComponent build(final Composite parent) {
|
||||
final Composite innerComposite = createInnerComposite(parent);
|
||||
this.selector = TableFilter.this.entityTable.widgetFactory.dateSelector(innerComposite);
|
||||
this.selector = TableFilter.this.entityTable.widgetFactory.dateSelector(
|
||||
innerComposite,
|
||||
getAriaLabel());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -523,15 +531,15 @@ public class TableFilter<ROW> {
|
|||
|
||||
final WidgetFactory wf = TableFilter.this.entityTable.widgetFactory;
|
||||
wf.labelLocalized(this.innerComposite, DATE_FROM_TEXT);
|
||||
this.fromDateSelector = wf.dateSelector(this.innerComposite);
|
||||
this.fromDateSelector = wf.dateSelector(this.innerComposite, getAriaLabel());
|
||||
if (this.withTime) {
|
||||
this.fromTimeSelector = wf.timeSelector(this.innerComposite);
|
||||
this.fromTimeSelector = wf.timeSelector(this.innerComposite, getAriaLabel());
|
||||
}
|
||||
|
||||
wf.labelLocalized(this.innerComposite, DATE_TO_TEXT);
|
||||
this.toDateSelector = wf.dateSelector(this.innerComposite);
|
||||
this.toDateSelector = wf.dateSelector(this.innerComposite, getAriaLabel());
|
||||
if (this.withTime) {
|
||||
this.toTimeSelector = wf.timeSelector(this.innerComposite);
|
||||
this.toTimeSelector = wf.timeSelector(this.innerComposite, getAriaLabel());
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.swt.graphics.Color;
|
|||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.ColorDialog;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
|
@ -83,7 +84,7 @@ public final class ColorSelection extends Composite implements Selection {
|
|||
this.colorLabel.setLayoutData(gridData);
|
||||
this.colorLabel.setData(RWT.CUSTOM_VARIANT, CustomVariant.LIGHT_COLOR_LABEL.key);
|
||||
|
||||
final Label imageButton = widgetFactory.imageButton(
|
||||
final Button imageButton = widgetFactory.imageButton(
|
||||
ImageIcon.COLOR,
|
||||
this,
|
||||
(StringUtils.isNotBlank(tooltipKeyPrefix)
|
||||
|
|
|
@ -36,6 +36,7 @@ import ch.ethz.seb.sebserver.gbl.Constants;
|
|||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||
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.WidgetFactory.AriaRole;
|
||||
|
||||
public class FileUploadSelection extends Composite {
|
||||
|
||||
|
@ -63,7 +64,8 @@ public class FileUploadSelection extends Composite {
|
|||
final Composite parent,
|
||||
final I18nSupport i18nSupport,
|
||||
final Collection<String> supportedFiles,
|
||||
final boolean readonly) {
|
||||
final boolean readonly,
|
||||
final LocTextKey ariaLabel) {
|
||||
|
||||
super(parent, SWT.NONE);
|
||||
final GridLayout gridLayout = new GridLayout(2, false);
|
||||
|
@ -80,6 +82,9 @@ public class FileUploadSelection extends Composite {
|
|||
this.fileName = new Label(this, SWT.NONE);
|
||||
this.fileName.setText(i18nSupport.getText(PLEASE_SELECT_TEXT));
|
||||
this.fileName.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true));
|
||||
if (ariaLabel != null) {
|
||||
WidgetFactory.setARIALabel(this.fileName, i18nSupport.getText(ariaLabel));
|
||||
}
|
||||
this.fileUpload = null;
|
||||
this.uploadHandler = null;
|
||||
this.inputReceiver = null;
|
||||
|
@ -88,6 +93,11 @@ public class FileUploadSelection extends Composite {
|
|||
this.fileUpload.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true));
|
||||
this.fileUpload.setImage(WidgetFactory.ImageIcon.IMPORT.getImage(parent.getDisplay()));
|
||||
|
||||
if (ariaLabel != null) {
|
||||
WidgetFactory.setARIALabel(this.fileUpload, i18nSupport.getText(ariaLabel));
|
||||
}
|
||||
WidgetFactory.setARIARole(this.fileUpload, AriaRole.button);
|
||||
|
||||
this.fileUpload.setToolTipText(Utils.formatLineBreaks(this.i18nSupport.getText(PLEASE_SELECT_TEXT)));
|
||||
this.inputReceiver = new InputReceiver();
|
||||
this.uploadHandler = new FileUploadHandler(this.inputReceiver);
|
||||
|
|
|
@ -51,7 +51,7 @@ public class GridTable extends Composite {
|
|||
|
||||
private final WidgetFactory widgetFactory;
|
||||
private final List<Column> columns;
|
||||
private final Label addAction;
|
||||
private final Button addAction;
|
||||
private final List<Row> rows;
|
||||
private final String locTextKeyPrefix;
|
||||
private Listener listener;
|
||||
|
@ -222,7 +222,7 @@ public class GridTable extends Composite {
|
|||
|
||||
final class Row {
|
||||
final List<ControlAdapter> cells;
|
||||
final Label removeAction;
|
||||
final Button removeAction;
|
||||
|
||||
protected Row(final List<ControlAdapter> cells) {
|
||||
this.cells = cells;
|
||||
|
|
|
@ -40,8 +40,10 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.I18nSupport;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
import ch.ethz.seb.sebserver.gui.service.push.ServerPushContext;
|
||||
import ch.ethz.seb.sebserver.gui.service.push.ServerPushService;
|
||||
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.AriaRole;
|
||||
|
||||
public final class ImageUploadSelection extends Composite {
|
||||
|
||||
|
@ -71,7 +73,8 @@ public final class ImageUploadSelection extends Composite {
|
|||
final I18nSupport i18nSupport,
|
||||
final boolean readonly,
|
||||
final int maxWidth,
|
||||
final int maxHeight) {
|
||||
final int maxHeight,
|
||||
final LocTextKey ariaLabel) {
|
||||
|
||||
super(parent, SWT.NONE);
|
||||
final GridLayout gridLayout = new GridLayout(1, false);
|
||||
|
@ -93,6 +96,11 @@ public final class ImageUploadSelection extends Composite {
|
|||
gridData.horizontalIndent = 0;
|
||||
this.fileUpload.setLayoutData(gridData);
|
||||
|
||||
if (ariaLabel != null) {
|
||||
WidgetFactory.setARIALabel(this.fileUpload, i18nSupport.getText(ariaLabel));
|
||||
}
|
||||
WidgetFactory.setARIARole(this.fileUpload, AriaRole.button);
|
||||
|
||||
final FileUploadHandler uploadHandler = new FileUploadHandler(new ImageReceiver());
|
||||
this.fileUpload.addListener(SWT.Selection, event -> {
|
||||
final String fileName = ImageUploadSelection.this.fileUpload.getFileName();
|
||||
|
|
|
@ -13,9 +13,9 @@ 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.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.Constants;
|
||||
|
@ -30,15 +30,21 @@ public class PasswordInput extends Composite {
|
|||
new LocTextKey("sebserver.overall.action.showPassword.tooltip");
|
||||
|
||||
private final Composite inputAnchor;
|
||||
private final Label visibilityButton;
|
||||
private final Button visibilityButton;
|
||||
|
||||
private Text passwordInputField = null;
|
||||
private boolean isPlainText = true;
|
||||
private boolean isEditable = true;
|
||||
private String label = null;
|
||||
|
||||
public PasswordInput(
|
||||
final Composite parent,
|
||||
final WidgetFactory widgetFactory,
|
||||
final LocTextKey label) {
|
||||
|
||||
public PasswordInput(final Composite parent, final WidgetFactory widgetFactory) {
|
||||
super(parent, SWT.NONE);
|
||||
|
||||
this.label = widgetFactory.getI18nSupport().getText(label);
|
||||
GridLayout gridLayout = new GridLayout(2, false);
|
||||
gridLayout.horizontalSpacing = 0;
|
||||
gridLayout.verticalSpacing = 0;
|
||||
|
@ -107,6 +113,10 @@ public class PasswordInput extends Composite {
|
|||
this.visibilityButton.setImage(WidgetFactory.ImageIcon.VISIBILITY_OFF.getImage(getDisplay()));
|
||||
}
|
||||
|
||||
if (this.label != null) {
|
||||
WidgetFactory.setARIALabel(passwordInput, this.label);
|
||||
}
|
||||
|
||||
this.passwordInputField = passwordInput;
|
||||
this.isPlainText = !this.isPlainText;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
|
@ -102,7 +103,7 @@ public final class ThresholdList extends Composite {
|
|||
this.colorCell = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||
colorTitle.setLayoutData(this.colorCell);
|
||||
|
||||
final Label imageButton = widgetFactory.imageButton(
|
||||
final Button imageButton = widgetFactory.imageButton(
|
||||
ImageIcon.ADD_BOX,
|
||||
this,
|
||||
ADD_TEXT_KEY,
|
||||
|
@ -165,7 +166,7 @@ public final class ThresholdList extends Composite {
|
|||
selectorCell.horizontalIndent = 2;
|
||||
selector.adaptToControl().setLayoutData(selectorCell);
|
||||
|
||||
final Label imageButton = this.widgetFactory.imageButton(
|
||||
final Button imageButton = this.widgetFactory.imageButton(
|
||||
ImageIcon.REMOVE_BOX,
|
||||
this,
|
||||
REMOVE_TEXT_KEY,
|
||||
|
@ -216,9 +217,9 @@ public final class ThresholdList extends Composite {
|
|||
private final class Entry {
|
||||
final Text valueInput;
|
||||
final Selection colorSelector;
|
||||
final Label removeButton;
|
||||
final Button removeButton;
|
||||
|
||||
Entry(final Text valueInput, final Selection colorSelector, final Label removeButton) {
|
||||
Entry(final Text valueInput, final Selection colorSelector, final Button removeButton) {
|
||||
super();
|
||||
this.valueInput = valueInput;
|
||||
this.colorSelector = colorSelector;
|
||||
|
|
|
@ -14,7 +14,6 @@ import java.io.InputStream;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -80,7 +79,8 @@ public class WidgetFactory {
|
|||
row,
|
||||
rowgroup,
|
||||
columnheader,
|
||||
gridcell
|
||||
gridcell,
|
||||
dialog
|
||||
}
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(WidgetFactory.class);
|
||||
|
@ -400,10 +400,14 @@ public class WidgetFactory {
|
|||
final Composite parent,
|
||||
final int type,
|
||||
final LocTextKey locTextKey,
|
||||
final LocTextKey toolTipKey) {
|
||||
final LocTextKey toolTipKey,
|
||||
final LocTextKey ariaLabel) {
|
||||
|
||||
final Button button = new Button(parent, type);
|
||||
setARIARole(button, AriaRole.button);
|
||||
if (ariaLabel != null) {
|
||||
setARIALabel(button, this.i18nSupport.getText(ariaLabel));
|
||||
}
|
||||
this.polyglotPageService.injectI18n(button, locTextKey, toolTipKey);
|
||||
return button;
|
||||
}
|
||||
|
@ -742,27 +746,35 @@ public class WidgetFactory {
|
|||
return label;
|
||||
}
|
||||
|
||||
public Label imageButton(
|
||||
public Label mandatoryLabel(
|
||||
final ImageIcon type,
|
||||
final Composite parent,
|
||||
final LocTextKey toolTip) {
|
||||
|
||||
return this.imageButton(type, parent, toolTip, null);
|
||||
final Label imageButton = labelLocalized(parent, (LocTextKey) null, toolTip);
|
||||
imageButton.setImage(type.getImage(parent.getDisplay()));
|
||||
return imageButton;
|
||||
}
|
||||
|
||||
public Label imageButton(
|
||||
public Button imageButton(
|
||||
final ImageIcon type,
|
||||
final Composite parent,
|
||||
final LocTextKey toolTip,
|
||||
final Listener listener) {
|
||||
|
||||
final Label imageButton = labelLocalized(parent, (LocTextKey) null, toolTip);
|
||||
imageButton.setData(RWT.CUSTOM_VARIANT, CustomVariant.IMAGE_BUTTON.name());
|
||||
imageButton.setImage(type.getImage(parent.getDisplay()));
|
||||
final Button imageButton = new Button(parent, SWT.NONE);
|
||||
this.polyglotPageService.injectI18n(imageButton, null, toolTip);
|
||||
imageButton.setData(RWT.CUSTOM_VARIANT, CustomVariant.IMAGE_BUTTON.key);
|
||||
final Image image = type.getImage(parent.getDisplay());
|
||||
imageButton.setImage(image);
|
||||
if (listener != null) {
|
||||
imageButton.addListener(SWT.MouseDown, listener);
|
||||
imageButton.addListener(SWT.Selection, listener);
|
||||
}
|
||||
setARIARole(imageButton, AriaRole.button);
|
||||
if (toolTip != null) {
|
||||
setARIALabel(imageButton, this.i18nSupport.getText(toolTip));
|
||||
}
|
||||
return imageButton;
|
||||
}
|
||||
|
||||
|
@ -899,30 +911,40 @@ public class WidgetFactory {
|
|||
return selection;
|
||||
}
|
||||
|
||||
public DateTime dateSelector(final Composite parent) {
|
||||
RWT.setLocale(Locale.GERMANY);
|
||||
public DateTime dateSelector(final Composite parent, final LocTextKey label) {
|
||||
RWT.setLocale(this.i18nSupport.getUsersFormatLocale());
|
||||
final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
final DateTime dateTime = new DateTime(parent, SWT.DATE | SWT.BORDER | SWT.DROP_DOWN);
|
||||
dateTime.setLayoutData(gridData);
|
||||
if (label != null) {
|
||||
setARIALabel(dateTime, this.i18nSupport.getText(label));
|
||||
}
|
||||
return dateTime;
|
||||
}
|
||||
|
||||
public DateTime timeSelector(final Composite parent) {
|
||||
public DateTime timeSelector(final Composite parent, final LocTextKey label) {
|
||||
final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
final DateTime dateTime = new DateTime(parent, SWT.TIME | SWT.BORDER | SWT.SHORT);
|
||||
dateTime.setLayoutData(gridData);
|
||||
if (label != null) {
|
||||
setARIALabel(dateTime, this.i18nSupport.getText(label));
|
||||
}
|
||||
return dateTime;
|
||||
}
|
||||
|
||||
public DateTime timeSelectorWithSeconds(final Composite parent) {
|
||||
public DateTime timeSelectorWithSeconds(final Composite parent, final LocTextKey label) {
|
||||
final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
final DateTime dateTime = new DateTime(parent, SWT.TIME | SWT.BORDER | SWT.MEDIUM);
|
||||
dateTime.setLayoutData(gridData);
|
||||
if (label != null) {
|
||||
setARIALabel(dateTime, this.i18nSupport.getText(label));
|
||||
}
|
||||
return dateTime;
|
||||
}
|
||||
|
||||
public ColorDialog getColorDialog(final Composite parent) {
|
||||
return new ColorDialog(parent.getShell(), SWT.NONE);
|
||||
final ColorDialog colorDialog = new ColorDialog(parent.getShell(), SWT.NONE);
|
||||
return colorDialog;
|
||||
}
|
||||
|
||||
public ThresholdList thresholdList(
|
||||
|
@ -945,14 +967,16 @@ public class WidgetFactory {
|
|||
public ImageUploadSelection logoImageUploadLocalized(
|
||||
final Composite parent,
|
||||
final LocTextKey locTextKey,
|
||||
final boolean readonly) {
|
||||
final boolean readonly,
|
||||
final LocTextKey label) {
|
||||
|
||||
return imageUploadLocalized(
|
||||
parent,
|
||||
locTextKey,
|
||||
readonly,
|
||||
DefaultPageLayout.LOGO_IMAGE_MAX_WIDTH,
|
||||
DefaultPageLayout.LOGO_IMAGE_MAX_HEIGHT);
|
||||
DefaultPageLayout.LOGO_IMAGE_MAX_HEIGHT,
|
||||
label);
|
||||
}
|
||||
|
||||
public ImageUploadSelection imageUploadLocalized(
|
||||
|
@ -960,7 +984,8 @@ public class WidgetFactory {
|
|||
final LocTextKey locTextKey,
|
||||
final boolean readonly,
|
||||
final int maxWidth,
|
||||
final int maxHeight) {
|
||||
final int maxHeight,
|
||||
final LocTextKey label) {
|
||||
|
||||
final ImageUploadSelection imageUpload = new ImageUploadSelection(
|
||||
parent,
|
||||
|
@ -968,7 +993,8 @@ public class WidgetFactory {
|
|||
this.i18nSupport,
|
||||
readonly,
|
||||
maxWidth,
|
||||
maxHeight);
|
||||
maxHeight,
|
||||
label);
|
||||
|
||||
this.polyglotPageService.injectI18n(imageUpload, locTextKey);
|
||||
return imageUpload;
|
||||
|
@ -977,13 +1003,15 @@ public class WidgetFactory {
|
|||
public FileUploadSelection fileUploadSelection(
|
||||
final Composite parent,
|
||||
final boolean readonly,
|
||||
final Collection<String> supportedFiles) {
|
||||
final Collection<String> supportedFiles,
|
||||
final LocTextKey label) {
|
||||
|
||||
final FileUploadSelection fileUploadSelection = new FileUploadSelection(
|
||||
parent,
|
||||
this.i18nSupport,
|
||||
supportedFiles,
|
||||
readonly);
|
||||
readonly,
|
||||
label);
|
||||
|
||||
if (supportedFiles != null) {
|
||||
supportedFiles.forEach(fileUploadSelection::withSupportFor);
|
||||
|
|
|
@ -96,6 +96,9 @@ sebserver.error.unexpected=Unexpected Error
|
|||
sebserver.page.message=Information
|
||||
sebserver.dialog.confirm.title=Confirmation
|
||||
sebserver.form.mandatory=This field is mandatory.
|
||||
sebserver.form.mandatory.label={0} mandatory
|
||||
sebserver.form.confirm.label=confirm {0}
|
||||
sebserver.form.tablefilter.label={0} table-column filter
|
||||
sebserver.table.column.sort.default.tooltip=Click on the column header to sort the table within this column
|
||||
|
||||
sebserver.dialog.confirm.deactivation=Note that there are {0} other entities that belong to this entity.<br/>Those will also be deactivated by deactivating this entity.<br/><br/>Are You sure to deactivate this entity?
|
||||
|
|
|
@ -517,6 +517,30 @@ Button {
|
|||
padding: 5px 6px 5px 6px;
|
||||
}
|
||||
|
||||
Button.imageButton,
|
||||
Button:hover.imageButton,
|
||||
Button:hover.imageButton,
|
||||
Button:default.imageButton,
|
||||
Button:pressed.imageButton {
|
||||
font: 12px Arial, Helvetica, sans-serif;
|
||||
background-color: transparent;
|
||||
background-gradient-color: transparent;
|
||||
background-image: gradient( linear, left top, left bottom, from( transparent ), to( transparent ) );
|
||||
padding: 0px 0px 0px 0px;
|
||||
}
|
||||
|
||||
Button[PUSH].imageButton,
|
||||
Button[PUSH]:hover.imageButton,
|
||||
Button[PUSH]:hover.imageButton,
|
||||
Button[PUSH]:default.imageButton,
|
||||
Button[PUSH]:pressed.imageButton {
|
||||
font: 12px Arial, Helvetica, sans-serif;
|
||||
background-color: transparent;
|
||||
background-gradient-color: transparent;
|
||||
background-image: gradient( linear, left top, left bottom, from( transparent ), to( transparent ) );
|
||||
padding: 0px 0px 0px 0px;
|
||||
}
|
||||
|
||||
/* Push Buttons */
|
||||
Button[PUSH],
|
||||
Button[PUSH]:default {
|
||||
|
|
|
@ -395,6 +395,13 @@ Button {
|
|||
padding: 5px 6px 5px 6px;
|
||||
}
|
||||
|
||||
Button[PUSH]:hover.imageButton {
|
||||
font: 12px Arial, Helvetica, sans-serif;
|
||||
padding: 5px 6px 5px 6px;
|
||||
background-color: transparent;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
/* Push Buttons */
|
||||
Button[PUSH],
|
||||
Button[PUSH]:default {
|
||||
|
|
Loading…
Add table
Reference in a new issue