SEBSERV-78 SEBSERV-77 fixed

This commit is contained in:
anhefti 2019-08-07 15:47:46 +02:00
parent 0b1ed4c46c
commit 24c3d31e58
8 changed files with 58 additions and 24 deletions

View file

@ -94,7 +94,7 @@ public class ActivitiesPane implements TemplateComposer {
.newAction(ActionDefinition.INSTITUTION_VIEW_LIST)
.create());
} else {
} else if (userInfo.hasRole(UserRole.INSTITUTIONAL_ADMIN)) {
// otherwise show the form of the institution for current user
final TreeItem institutions = this.widgetFactory.treeItemLocalized(
navigation,

View file

@ -109,7 +109,7 @@ public final class SelectionFieldBuilder extends FieldBuilder<String> {
composite.setLayout(gridLayout);
if (StringUtils.isBlank(this.value)) {
final Label label = new Label(composite, SWT.NONE);
final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
final GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, true);
label.setLayoutData(gridData);
label.setText(this.value);
} else {
@ -131,7 +131,7 @@ public final class SelectionFieldBuilder extends FieldBuilder<String> {
private Text buildReadonlyLabel(final Composite composite, final String valueKey, final int hspan) {
final Text label = new Text(composite, SWT.READ_ONLY);
final GridData gridData = new GridData(SWT.LEFT, SWT.TOP, true, false, hspan, 1);
final GridData gridData = new GridData(SWT.LEFT, SWT.TOP, true, true, hspan, 1);
gridData.verticalIndent = 0;
gridData.horizontalIndent = 0;
label.setLayoutData(gridData);
@ -141,7 +141,7 @@ public final class SelectionFieldBuilder extends FieldBuilder<String> {
.findFirst()
.map(tuple -> tuple._2)
.orElse(Constants.EMPTY_NOTE);
final Consumer<Label> updateFunction = l -> l.setText(valueSupplier.get());
final Consumer<Text> updateFunction = t -> t.setText(valueSupplier.get());
label.setText(valueSupplier.get());
label.setData(PolyglotPageService.POLYGLOT_WIDGET_FUNCTION_KEY, updateFunction);

View file

@ -58,12 +58,12 @@ public final class TextFieldBuilder extends FieldBuilder<String> {
final Composite fieldGrid = Form.createFieldGrid(builder.formParent, this.spanInput);
final Text textInput = (this.isNumber)
? builder.widgetFactory.numberInput(fieldGrid, null)
? builder.widgetFactory.numberInput(fieldGrid, null, readonly)
: (this.isArea)
? builder.widgetFactory.textAreaInput(fieldGrid)
: builder.widgetFactory.textInput(fieldGrid, this.isPassword);
? builder.widgetFactory.textAreaInput(fieldGrid, readonly)
: builder.widgetFactory.textInput(fieldGrid, this.isPassword, readonly);
final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
final GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, true);
if (this.isArea) {
gridData.minimumHeight = 35;
}

View file

@ -240,7 +240,7 @@ public class TableFilter<ROW extends Entity> {
@Override
boolean adaptWidth(final int width) {
return super.adaptWidth(width - CELL_WIDTH_ADJUSTMENT);
return super.adaptWidth(width - 2 * CELL_WIDTH_ADJUSTMENT);
}
@Override
@ -252,6 +252,7 @@ public class TableFilter<ROW extends Entity> {
String getValue() {
return null;
}
}
private class TextFilter extends FilterComponent {

View file

@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory;
import ch.ethz.seb.sebserver.gbl.Constants;
import ch.ethz.seb.sebserver.gbl.util.Tuple;
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.ImageIcon;
public final class MultiSelectionCombo extends Composite implements Selection {
@ -55,13 +56,15 @@ public final class MultiSelectionCombo extends Composite implements Selection {
private final GridData comboCell;
private final GridData actionCell;
private final Composite updateAnchor;
private Listener listener = null;
MultiSelectionCombo(
final Composite parent,
final WidgetFactory widgetFactory,
final String locTextPrefix) {
final String locTextPrefix,
final Composite updateAnchor) {
super(parent, SWT.NONE);
this.widgetFactory = widgetFactory;
@ -94,6 +97,7 @@ public final class MultiSelectionCombo extends Composite implements Selection {
this.actionCell = new GridData(SWT.LEFT, SWT.CENTER, true, false);
this.actionCell.widthHint = ACTION_COLUMN_WIDTH;
imageButton.setLayoutData(this.actionCell);
this.updateAnchor = updateAnchor;
}
@Override
@ -202,7 +206,8 @@ public final class MultiSelectionCombo extends Composite implements Selection {
this.selectionControls.add(new Tuple<>(label, imageButton));
this.combo.remove(itemName);
this.getParent().layout();
this.updateAnchor.layout();
PageService.updateScrolledComposite(this);
}
private void removeComboSelection(final Event event) {
@ -228,7 +233,8 @@ public final class MultiSelectionCombo extends Composite implements Selection {
final Tuple<String> value = this.selectedValues.remove(indexOf);
this.combo.add(value._2, this.combo.getItemCount());
this.getParent().layout();
this.updateAnchor.layout();
PageService.updateScrolledComposite(this);
if (this.listener != null) {
this.listener.handleEvent(event);
}

View file

@ -308,25 +308,40 @@ public class WidgetFactory {
}
public Text textInput(final Composite content) {
return textInput(content, false);
return textInput(content, false, false);
}
public Text textLabel(final Composite content) {
return textInput(content, false, true);
}
public Text passwordInput(final Composite content) {
return textInput(content, true);
return textInput(content, true, false);
}
public Text textAreaInput(final Composite content) {
final Text textArea = new Text(content, SWT.LEFT | SWT.BORDER | SWT.MULTI);
return textArea;
public Text textAreaInput(final Composite content, final boolean readonly) {
return readonly
? new Text(content, SWT.LEFT | SWT.MULTI)
: new Text(content, SWT.LEFT | SWT.BORDER | SWT.MULTI);
}
public Text textInput(final Composite content, final boolean password) {
return new Text(content, (password)
? SWT.LEFT | SWT.BORDER | SWT.PASSWORD
: SWT.LEFT | SWT.BORDER);
public Text textInput(final Composite content, final boolean password, final boolean readonly) {
return readonly
? new Text(content, SWT.LEFT | SWT.BORDER)
: new Text(content, (password)
? SWT.LEFT | SWT.BORDER | SWT.PASSWORD
: SWT.LEFT | SWT.BORDER);
}
public Text numberInput(final Composite content, final Consumer<String> numberCheck) {
return numberInput(content, numberCheck, false);
}
public Text numberInput(final Composite content, final Consumer<String> numberCheck, final boolean readonly) {
if (readonly) {
return new Text(content, SWT.RIGHT | SWT.READ_ONLY);
}
final Text numberInput = new Text(content, SWT.RIGHT | SWT.BORDER);
if (numberCheck != null) {
numberInput.addListener(SWT.Verify, event -> {
@ -520,7 +535,11 @@ public class WidgetFactory {
selection = new MultiSelection(parent);
break;
case MULTI_COMBO:
selection = new MultiSelectionCombo(parent, this, actionLocTextPrefix);
selection = new MultiSelectionCombo(
parent,
this,
actionLocTextPrefix,
parent);
break;
case MULTI_CHECKBOX:
selection = new MultiSelectionCheckbox(parent);

View file

@ -298,7 +298,8 @@ sebserver.exam.form.endtime=End Time
sebserver.exam.form.status=Status
sebserver.exam.form.type=Exam Type
sebserver.exam.form.supporter=Exam Supporter
sebserver.exam.form.supporter.add=Add as supporter for this exam
sebserver.exam.form.supporter.action.add=Add as supporter for this exam
sebserver.exam.form.supporter.action.remove=Remove supporter
sebserver.exam.type.UNDEFINED=Not Defined
sebserver.exam.type.MANAGED=Managed

View file

@ -247,7 +247,14 @@ Text[BORDER]:focused, Text[MULTI][BORDER]:focused {
box-shadow: none;
}
Text:disabled, Text:read-only, Text[BORDER]:disabled, Text[MULTI]:disabled, Text[MULTI][BORDER]:disabled, Text[BORDER]:read-only, Text[MULTI]:read-only, Text[MULTI][BORDER]:read-only {
Text:disabled,
Text:read-only,
Text[BORDER]:disabled,
Text[BORDER]:read-only,
Text[MULTI]:disabled,
Text[MULTI]:read-only,
Text[MULTI][BORDER]:disabled,
Text[MULTI][BORDER]:read-only {
box-shadow: none;
background-color: #ffffff;
border: none;