code cleanup

This commit is contained in:
anhefti 2020-03-05 16:05:56 +01:00
parent df884bd8d2
commit 884f9c78e0
40 changed files with 4320 additions and 4290 deletions

View file

@ -101,15 +101,15 @@ public class ExamForm implements TemplateComposer {
new LocTextKey("sebserver.exam.form.status");
private static final LocTextKey FORM_TYPE_TEXT_KEY =
new LocTextKey("sebserver.exam.form.type");
private static final LocTextKey FORM_ENDTIME_TEXT_KEY =
private static final LocTextKey FORM_END_TIME_TEXT_KEY =
new LocTextKey("sebserver.exam.form.endtime");
private static final LocTextKey FORM_STARTTIME_TEXT_KEY =
private static final LocTextKey FORM_START_TIME_TEXT_KEY =
new LocTextKey("sebserver.exam.form.starttime");
private static final LocTextKey FORM_DESCRIPTION_TEXT_KEY =
new LocTextKey("sebserver.exam.form.description");
private static final LocTextKey FORM_NAME_TEXT_KEY =
new LocTextKey("sebserver.exam.form.name");
private static final LocTextKey FORM_QUIZID_TEXT_KEY =
private static final LocTextKey FORM_QUIZ_ID_TEXT_KEY =
new LocTextKey("sebserver.exam.form.quizid");
private static final LocTextKey FORM_QUIZ_URL_TEXT_KEY =
new LocTextKey("sebserver.exam.form.quizurl");
@ -285,14 +285,14 @@ public class ExamForm implements TemplateComposer {
.addField(FormBuilder.text(
QuizData.QUIZ_ATTR_START_TIME,
FORM_STARTTIME_TEXT_KEY,
FORM_START_TIME_TEXT_KEY,
i18nSupport.formatDisplayDateWithTimeZone(exam.startTime))
.readonly(true)
.withInputSpan(3)
.withEmptyCellSeparation(false))
.addField(FormBuilder.text(
QuizData.QUIZ_ATTR_END_TIME,
FORM_ENDTIME_TEXT_KEY,
FORM_END_TIME_TEXT_KEY,
i18nSupport.formatDisplayDateWithTimeZone(exam.endTime))
.readonly(true)
.withInputSpan(3)
@ -300,7 +300,7 @@ public class ExamForm implements TemplateComposer {
.addField(FormBuilder.text(
Domain.EXAM.ATTR_EXTERNAL_ID,
FORM_QUIZID_TEXT_KEY,
FORM_QUIZ_ID_TEXT_KEY,
exam.externalId)
.readonly(true)
.withEmptyCellSeparation(false))

View file

@ -62,11 +62,11 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.CustomVariant;
@GuiProfile
public class ExamList implements TemplateComposer {
static final String EXAM_LIST_COLUMN_STARTTIME =
static final String EXAM_LIST_COLUMN_START_TIME =
"sebserver.exam.list.column.starttime";
static final LocTextKey PAGE_TITLE_KEY =
new LocTextKey("sebserver.exam.list.title");
static final LocTextKey NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUION =
static final LocTextKey NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION =
new LocTextKey("sebserver.exam.list.action.no.modify.privilege");
final static LocTextKey EMPTY_SELECTION_TEXT_KEY =
new LocTextKey("sebserver.exam.info.pleaseSelect");
@ -175,7 +175,7 @@ public class ExamList implements TemplateComposer {
.withColumn(new ColumnDefinition<>(
QuizData.QUIZ_ATTR_START_TIME,
new LocTextKey(
EXAM_LIST_COLUMN_STARTTIME,
EXAM_LIST_COLUMN_START_TIME,
i18nSupport.getUsersTimeZoneTitleSuffix()),
Exam::getStartTime)
.withFilter(new TableFilterAttribute(
@ -213,7 +213,7 @@ public class ExamList implements TemplateComposer {
.newAction(ActionDefinition.EXAM_MODIFY_FROM_LIST)
.withSelect(
table.getGrantedSelection(currentUser, NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUION),
table.getGrantedSelection(currentUser, NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION),
action -> modifyExam(action, table),
EMPTY_SELECTION_TEXT_KEY)
.publishIf(() -> userGrant.im() && table.hasAnyContent(), false);

View file

@ -46,7 +46,7 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
@GuiProfile
public class LmsSetupList implements TemplateComposer {
private static final LocTextKey NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUION =
private static final LocTextKey NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION =
new LocTextKey("sebserver.lmssetup.list.action.no.modify.privilege");
private static final LocTextKey EMPTY_SELECTION_TEXT_KEY =
new LocTextKey("sebserver.lmssetup.info.pleaseSelect");
@ -173,7 +173,7 @@ public class LmsSetupList implements TemplateComposer {
.newAction(ActionDefinition.LMS_SETUP_MODIFY_FROM_LIST)
.withSelect(
table.getGrantedSelection(currentUser, NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUION),
table.getGrantedSelection(currentUser, NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION),
PageAction::applySingleSelectionAsEntityKey, EMPTY_SELECTION_TEXT_KEY)
.publishIf(() -> userGrant.im() && table.hasAnyContent(), false)

View file

@ -48,19 +48,19 @@ public class LoginPage implements TemplateComposer {
private final WidgetFactory widgetFactory;
private final I18nSupport i18nSupport;
private final DefaultRegisterPage defaultRegisterPage;
private final boolean registreringEnabled;
private final boolean registeringEnabled;
public LoginPage(
final PageService pageService,
final DefaultRegisterPage defaultRegisterPage,
@Value("${sebserver.gui.self-registering:false}") final Boolean registreringEnabled) {
@Value("${sebserver.gui.self-registering:false}") final Boolean registeringEnabled) {
this.pageService = pageService;
this.authorizationContextHolder = pageService.getAuthorizationContextHolder();
this.widgetFactory = pageService.getWidgetFactory();
this.i18nSupport = pageService.getI18nSupport();
this.defaultRegisterPage = defaultRegisterPage;
this.registreringEnabled = BooleanUtils.toBoolean(registreringEnabled);
this.registeringEnabled = BooleanUtils.toBoolean(registeringEnabled);
}
@Override
@ -100,13 +100,11 @@ public class LoginPage implements TemplateComposer {
gridData = new GridData(SWT.LEFT, SWT.TOP, false, false);
gridData.verticalIndent = 10;
loginButton.setLayoutData(gridData);
loginButton.addListener(SWT.Selection, event -> {
login(
loginButton.addListener(SWT.Selection, event -> login(
pageContext,
loginName.getText(),
loginPassword.getText(),
authorizationContext);
});
authorizationContext));
loginName.addListener(SWT.KeyDown, event -> {
if (event.character == '\n' || event.character == '\r') {
if (StringUtils.isNotBlank(loginPassword.getText())) {
@ -134,14 +132,12 @@ public class LoginPage implements TemplateComposer {
}
});
if (this.registreringEnabled) {
if (this.registeringEnabled) {
final Button registerButton = this.widgetFactory.buttonLocalized(buttons, "sebserver.login.register");
gridData = new GridData(SWT.LEFT, SWT.TOP, false, false);
gridData.verticalIndent = 10;
registerButton.setLayoutData(gridData);
registerButton.addListener(SWT.Selection, event -> {
pageContext.forwardToPage(this.defaultRegisterPage);
});
registerButton.addListener(SWT.Selection, event -> pageContext.forwardToPage(this.defaultRegisterPage));
}
}
@ -151,11 +147,10 @@ public class LoginPage implements TemplateComposer {
final CharSequence loginPassword,
final SEBServerAuthorizationContext authorizationContext) {
final String username = loginName;
try {
final boolean loggedIn = authorizationContext.login(
username,
loginName,
loginPassword);
if (loggedIn) {
@ -179,7 +174,7 @@ public class LoginPage implements TemplateComposer {
loginError(pageContext, "sebserver.login.failed.message");
}
} catch (final Exception e) {
log.error("Unexpected error while trying to login with user: {}", username, e);
log.error("Unexpected error while trying to login with user: {}", loginName, e);
loginError(pageContext, "Unexpected Error. Please call an Administrator");
}
}

View file

@ -88,10 +88,10 @@ public class MainPage implements TemplateComposer {
scrolledComposite -> {
final Composite result = new Composite(scrolledComposite, SWT.NONE);
result.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
final GridLayout contentOuterlayout = new GridLayout();
contentOuterlayout.marginHeight = 0;
contentOuterlayout.marginWidth = 0;
result.setLayout(contentOuterlayout);
final GridLayout contentOuterLayout = new GridLayout();
contentOuterLayout.marginHeight = 0;
contentOuterLayout.marginWidth = 0;
result.setLayout(contentOuterLayout);
return result;
},
false);
@ -126,10 +126,10 @@ public class MainPage implements TemplateComposer {
final Composite contentObjects = new Composite(content, SWT.NONE);
contentObjects.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
final GridLayout contentObjectslayout = new GridLayout();
contentObjectslayout.marginHeight = 0;
contentObjectslayout.marginWidth = 0;
contentObjects.setLayout(contentObjectslayout);
final GridLayout contentObjectsLayout = new GridLayout();
contentObjectsLayout.marginHeight = 0;
contentObjectsLayout.marginWidth = 0;
contentObjects.setLayout(contentObjectsLayout);
contentObjects.setData(
PageEventListener.LISTENER_ATTRIBUTE_KEY,
new ContentActionEventListener(event -> pageContext

View file

@ -240,8 +240,8 @@ public class QuizDiscoveryList implements TemplateComposer {
}
private static Function<QuizData, String> quizDataLmsSetupNameFunction(final ResourceService resourceService) {
return quizzData -> resourceService.getLmsSetupNameFunction()
.apply(String.valueOf(quizzData.lmsSetupId));
return quizData -> resourceService.getLmsSetupNameFunction()
.apply(String.valueOf(quizData.lmsSetupId));
}
private PageAction importQuizData(final PageAction action, final EntityTable<QuizData> table) {

View file

@ -247,9 +247,7 @@ public class RegisterPage implements TemplateComposer {
gridData = new GridData(SWT.LEFT, SWT.TOP, false, false);
gridData.verticalIndent = 10;
cancelButton.setLayoutData(gridData);
cancelButton.addListener(SWT.Selection, event -> {
pageContext.forwardToLoginPage();
});
cancelButton.addListener(SWT.Selection, event -> pageContext.forwardToLoginPage());
}

View file

@ -48,7 +48,7 @@ import ch.ethz.seb.sebserver.gui.table.TableFilter.CriteriaType;
@GuiProfile
public class SebClientConfigList implements TemplateComposer {
private static final LocTextKey NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUION =
private static final LocTextKey NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION =
new LocTextKey("sebserver.clientconfig.list.action.no.modify.privilege");
private static final LocTextKey EMPTY_LIST_TEXT_KEY =
new LocTextKey("sebserver.clientconfig.list.empty");
@ -176,7 +176,7 @@ public class SebClientConfigList implements TemplateComposer {
.newAction(ActionDefinition.SEB_CLIENT_CONFIG_MODIFY_FROM_LIST)
.withSelect(
table.getGrantedSelection(this.currentUser, NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUION),
table.getGrantedSelection(this.currentUser, NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION),
PageAction::applySingleSelectionAsEntityKey, EMPTY_SELECTION_TEXT_KEY)
.publishIf(() -> clientConfigGrant.im() && table.hasAnyContent(), false)

View file

@ -81,7 +81,7 @@ final class SebExamConfigImportPopup {
};
}
private static final boolean doImport(
private static boolean doImport(
final PageService pageService,
final FormHandle<ConfigurationNode> formHandle,
final boolean newConfig) {
@ -93,7 +93,7 @@ final class SebExamConfigImportPopup {
final PageContext context = formHandle.getContext();
// Ad-hoc field validation
formHandle.process(name -> true, field -> field.resetError());
formHandle.process(name -> true, Form.FormFieldAccessor::resetError);
final String fieldValue = form.getFieldValue(Domain.CONFIGURATION_NODE.ATTR_NAME);
if (StringUtils.isBlank(fieldValue)) {
form.setFieldError(
@ -116,7 +116,7 @@ final class SebExamConfigImportPopup {
return false;
}
if (fieldControl != null && fieldControl instanceof FileUploadSelection) {
if (fieldControl instanceof FileUploadSelection) {
final FileUploadSelection fileUpload = (FileUploadSelection) fieldControl;
final InputStream inputStream = fileUpload.getInputStream();
if (inputStream != null) {
@ -162,7 +162,6 @@ final class SebExamConfigImportPopup {
new ActionEvent(action),
action.pageContext());
}
return true;
} else {
final Exception error = configuration.getError();
if (error instanceof RestCallError) {
@ -188,12 +187,12 @@ final class SebExamConfigImportPopup {
SebExamConfigPropForm.FORM_TITLE,
configuration.getError());
return true;
}
return true;
} else {
formHandle.getContext().publishPageMessage(
new LocTextKey("sebserver.error.unexpected"),
new LocTextKey("Please selecte a valid SEB Exam Configuration File"));
new LocTextKey("Please select a valid SEB Exam Configuration File"));
}
}
@ -271,7 +270,7 @@ final class SebExamConfigImportPopup {
void cancelUpload() {
if (this.form != null) {
final Control fieldControl = this.form.getFieldInput(API.IMPORT_FILE_ATTR_NAME);
if (fieldControl != null && fieldControl instanceof FileUploadSelection) {
if (fieldControl instanceof FileUploadSelection) {
((FileUploadSelection) fieldControl).close();
}
}

View file

@ -43,7 +43,7 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
@GuiProfile
public class SebExamConfigList implements TemplateComposer {
private static final LocTextKey NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUION =
private static final LocTextKey NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION =
new LocTextKey("sebserver.examconfig.list.action.no.modify.privilege");
private static final LocTextKey EMPTY_CONFIG_LIST_TEXT_KEY =
new LocTextKey("sebserver.examconfig.list.empty");
@ -165,7 +165,7 @@ public class SebExamConfigList implements TemplateComposer {
.newAction(ActionDefinition.SEB_EXAM_CONFIG_MODIFY_PROP_FROM_LIST)
.withSelect(
configTable.getGrantedSelection(this.currentUser, NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUION),
configTable.getGrantedSelection(this.currentUser, NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION),
PageAction::applySingleSelectionAsEntityKey, EMPTY_SELECTION_TEXT_KEY)
.publishIf(() -> examConfigGrant.im() && configTable.hasAnyContent(), false)

View file

@ -265,7 +265,7 @@ public class SebExamConfigPropForm implements TemplateComposer {
.noEventPropagation()
.publishIf(() -> modifyGrant && isReadonly)
.newAction(ActionDefinition.SEB_EXAM_CONFIG_COPY_CONFIG_AS_TEMPALTE)
.newAction(ActionDefinition.SEA_EXAM_CONFIG_COPY_CONFIG_AS_TEMPLATE)
.withEntityKey(entityKey)
.withExec(SebExamConfigCreationPopup.configCreationFunction(
this.pageService,
@ -313,7 +313,7 @@ public class SebExamConfigPropForm implements TemplateComposer {
.withColumn(new ColumnDefinition<>(
QuizData.QUIZ_ATTR_START_TIME,
new LocTextKey(
ExamList.EXAM_LIST_COLUMN_STARTTIME,
ExamList.EXAM_LIST_COLUMN_START_TIME,
this.pageService.getI18nSupport().getUsersTimeZoneTitleSuffix()),
ExamConfigurationMap::getExamStartTime))

View file

@ -190,7 +190,7 @@ public class SebExamConfigSettingsForm implements TemplateComposer {
.ignoreMoveAwayFromEdit()
.publishIf(() -> examConfigGrant.iw() && !readonly)
.newAction(ActionDefinition.SEB_EXAM_CONFIG_COPY_CONFIG_AS_TEMPALTE)
.newAction(ActionDefinition.SEA_EXAM_CONFIG_COPY_CONFIG_AS_TEMPLATE)
.withEntityKey(entityKey)
.withExec(SebExamConfigCreationPopup.configCreationFunction(
this.pageService,

View file

@ -33,7 +33,7 @@ public enum ActionCategory {
public final LocTextKey title;
public final int slotPosition;
private ActionCategory(final LocTextKey title, final int slotPosition) {
ActionCategory(final LocTextKey title, final int slotPosition) {
this.title = title;
this.slotPosition = slotPosition;
}

View file

@ -467,7 +467,7 @@ public enum ActionDefinition {
new LocTextKey("sebserver.examconfig.action.copy"),
ImageIcon.COPY,
ActionCategory.FORM),
SEB_EXAM_CONFIG_COPY_CONFIG_AS_TEMPALTE(
SEA_EXAM_CONFIG_COPY_CONFIG_AS_TEMPLATE(
new LocTextKey("sebserver.examconfig.action.copy-as-template"),
ImageIcon.TEMPLATE,
ActionCategory.FORM),

View file

@ -8,10 +8,17 @@
package ch.ethz.seb.sebserver.gui.content.action;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
import ch.ethz.seb.sebserver.gui.service.i18n.PolyglotPageService;
import ch.ethz.seb.sebserver.gui.service.page.PageContext;
import ch.ethz.seb.sebserver.gui.service.page.PageService;
import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer;
import ch.ethz.seb.sebserver.gui.service.page.event.ActionActivationEventListener;
import ch.ethz.seb.sebserver.gui.service.page.event.ActionPublishEventListener;
import ch.ethz.seb.sebserver.gui.service.page.event.PageEventListener;
import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction;
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.CustomVariant;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.template.ImageCell;
@ -31,19 +38,9 @@ import org.eclipse.swt.widgets.TreeItem;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
import ch.ethz.seb.sebserver.gui.service.i18n.PolyglotPageService;
import ch.ethz.seb.sebserver.gui.service.page.PageContext;
import ch.ethz.seb.sebserver.gui.service.page.PageService;
import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer;
import ch.ethz.seb.sebserver.gui.service.page.event.ActionActivationEvent;
import ch.ethz.seb.sebserver.gui.service.page.event.ActionActivationEventListener;
import ch.ethz.seb.sebserver.gui.service.page.event.ActionPublishEvent;
import ch.ethz.seb.sebserver.gui.service.page.event.ActionPublishEventListener;
import ch.ethz.seb.sebserver.gui.service.page.event.PageEventListener;
import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction;
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.CustomVariant;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@Lazy
@Component

View file

@ -96,7 +96,7 @@ public class ActivitiesPane implements TemplateComposer {
.hasAnyRole(UserRole.SEB_SERVER_ADMIN, UserRole.INSTITUTIONAL_ADMIN);
// SEB Server Administration
final TreeItem sebadmin = this.widgetFactory.treeItemLocalized(
final TreeItem sebAdmin = this.widgetFactory.treeItemLocalized(
navigation,
ActivityDefinition.SEB_ADMINISTRATION.displayName);
@ -105,7 +105,7 @@ public class ActivitiesPane implements TemplateComposer {
if (userInfo.hasRole(UserRole.SEB_SERVER_ADMIN)) {
// institutions (list) as root
final TreeItem institutions = this.widgetFactory.treeItemLocalized(
sebadmin,
sebAdmin,
ActivityDefinition.INSTITUTION.displayName);
injectActivitySelection(
institutions,
@ -116,7 +116,7 @@ public class ActivitiesPane implements TemplateComposer {
} else if (userInfo.hasRole(UserRole.INSTITUTIONAL_ADMIN)) {
// otherwise show the form of the institution for current user
final TreeItem institutions = this.widgetFactory.treeItemLocalized(
sebadmin,
sebAdmin,
ActivityDefinition.INSTITUTION.displayName);
injectActivitySelection(
institutions,
@ -131,7 +131,7 @@ public class ActivitiesPane implements TemplateComposer {
if (isServerOrInstAdmin) {
final TreeItem userAccounts = this.widgetFactory.treeItemLocalized(
sebadmin,
sebAdmin,
ActivityDefinition.USER_ACCOUNT.displayName);
injectActivitySelection(
userAccounts,
@ -157,7 +157,7 @@ public class ActivitiesPane implements TemplateComposer {
EntityType.USER_ACTIVITY_LOG);
if (viewUserActivityLogs) {
final TreeItem activityLogs = this.widgetFactory.treeItemLocalized(
sebadmin,
sebAdmin,
ActivityDefinition.USER_ACTIVITY_LOGS.displayName);
injectActivitySelection(
activityLogs,
@ -166,12 +166,12 @@ public class ActivitiesPane implements TemplateComposer {
.create());
}
if (sebadmin.getItemCount() > 0) {
sebadmin.setExpanded(this.currentUser.get().hasAnyRole(
if (sebAdmin.getItemCount() > 0) {
sebAdmin.setExpanded(this.currentUser.get().hasAnyRole(
UserRole.SEB_SERVER_ADMIN,
UserRole.INSTITUTIONAL_ADMIN));
} else {
sebadmin.dispose();
sebAdmin.dispose();
}
// ---- SEB ADMIN ----------------------------------------------------------------------
@ -244,7 +244,7 @@ public class ActivitiesPane implements TemplateComposer {
final boolean examWrite = this.currentUser.hasInstitutionalPrivilege(PrivilegeType.WRITE, EntityType.EXAM);
// Exam Administration
final TreeItem examadmin = this.widgetFactory.treeItemLocalized(
final TreeItem examAdmin = this.widgetFactory.treeItemLocalized(
navigation,
ActivityDefinition.EXAM_ADMINISTRATION.displayName);
@ -252,7 +252,7 @@ public class ActivitiesPane implements TemplateComposer {
// LMS Setup
if (lmsRead && !isSupporterOnly) {
final TreeItem lmsSetup = this.widgetFactory.treeItemLocalized(
examadmin,
examAdmin,
ActivityDefinition.LMS_SETUP.displayName);
injectActivitySelection(
lmsSetup,
@ -266,7 +266,7 @@ public class ActivitiesPane implements TemplateComposer {
if (examWrite) {
// Quiz Discovery
final TreeItem quizDiscovery = this.widgetFactory.treeItemLocalized(
examadmin,
examAdmin,
ActivityDefinition.QUIZ_DISCOVERY.displayName);
injectActivitySelection(
quizDiscovery,
@ -277,7 +277,7 @@ public class ActivitiesPane implements TemplateComposer {
// Exam
final TreeItem exam = this.widgetFactory.treeItemLocalized(
examadmin,
examAdmin,
ActivityDefinition.EXAM.displayName);
injectActivitySelection(
exam,
@ -286,7 +286,7 @@ public class ActivitiesPane implements TemplateComposer {
.create());
}
examadmin.setExpanded(this.currentUser.get().hasAnyRole(UserRole.EXAM_ADMIN));
examAdmin.setExpanded(this.currentUser.get().hasAnyRole(UserRole.EXAM_ADMIN));
}
// ---- EXAM ADMINISTRATION ------------------------------------------------------------
@ -388,9 +388,7 @@ public class ActivitiesPane implements TemplateComposer {
state.activityAnchor());
if (item != null) {
final PageAction action = getActivitySelection(item);
this.pageService.executePageAction(action, result -> {
navigation.select(item);
});
this.pageService.executePageAction(action, result -> navigation.select(item));
}
}
}
@ -491,7 +489,7 @@ public class ActivitiesPane implements TemplateComposer {
});
}
private static final boolean isInSubTree(final TreeItem treeItem, final TreeItem currentSelection) {
private static boolean isInSubTree(final TreeItem treeItem, final TreeItem currentSelection) {
if (treeItem == null) {
return false;
}
@ -510,7 +508,7 @@ public class ActivitiesPane implements TemplateComposer {
return false;
}
private static final TreeItem findItemByActionDefinition(
private static TreeItem findItemByActionDefinition(
final TreeItem[] items,
final Activity activity) {
@ -544,7 +542,7 @@ public class ActivitiesPane implements TemplateComposer {
return null;
}
private static final TreeItem getActionItem(final TreeItem item) {
private static TreeItem getActionItem(final TreeItem item) {
final PageAction action = (PageAction) item.getData(ATTR_ACTIVITY_SELECTION);
if (action == null && item.getItemCount() > 0) {
final TreeItem firstChild = item.getItem(0);
@ -556,11 +554,11 @@ public class ActivitiesPane implements TemplateComposer {
return item;
}
private static final PageAction getActivitySelection(final TreeItem item) {
private static PageAction getActivitySelection(final TreeItem item) {
return (PageAction) item.getData(ATTR_ACTIVITY_SELECTION);
}
private final static void injectActivitySelection(final TreeItem item, final PageAction action) {
private static void injectActivitySelection(final TreeItem item, final PageAction action) {
item.setData(ATTR_ACTIVITY_SELECTION, action);
}

View file

@ -30,7 +30,7 @@ public enum ActivityDefinition implements Activity {
public final LocTextKey displayName;
private ActivityDefinition(final LocTextKey displayName) {
ActivityDefinition(final LocTextKey displayName) {
this.displayName = displayName;
}

View file

@ -94,7 +94,7 @@ public enum PageStateDefinitionImpl implements PageStateDefinition {
public final Class<? extends TemplateComposer> actionPaneComposer;
public final Activity activityAnchor;
private PageStateDefinitionImpl(
PageStateDefinitionImpl(
final Type type,
final Class<? extends TemplateComposer> contentPaneComposer,
final Activity activityAnchor) {
@ -102,7 +102,7 @@ public enum PageStateDefinitionImpl implements PageStateDefinition {
this(type, contentPaneComposer, ActionPane.class, activityAnchor);
}
private PageStateDefinitionImpl(
PageStateDefinitionImpl(
final Type type,
final Class<? extends TemplateComposer> contentPaneComposer,
final Class<? extends TemplateComposer> actionPaneComposer,

View file

@ -44,7 +44,6 @@ public class ThresholdListBuilder extends FieldBuilder<Collection<Threshold>> {
final Control titleLabel = createTitleLabel(builder.formParent, builder, this);
if (builder.readonly || this.readonly) {
// No read-only view needed for this so far?
return;
} else {
final Composite fieldGrid = createFieldGrid(builder.formParent, this.spanInput);

View file

@ -30,10 +30,10 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
public interface ExamConfigurationService {
public static final String ATTRIBUTE_LABEL_LOC_TEXT_PREFIX = "sebserver.examconfig.props.label.";
public static final String GROUP_LABEL_LOC_TEXT_PREFIX = "sebserver.examconfig.props.group.";
public static final String TOOL_TIP_SUFFIX = ".tooltip";
public static final String TABLE_ROW_TITLE_SUFFIX = ".row.title";
String ATTRIBUTE_LABEL_LOC_TEXT_PREFIX = "sebserver.examconfig.props.label.";
String GROUP_LABEL_LOC_TEXT_PREFIX = "sebserver.examconfig.props.group.";
String TOOL_TIP_SUFFIX = ".tooltip";
String TABLE_ROW_TITLE_SUFFIX = ".row.title";
WidgetFactory getWidgetFactory();

View file

@ -82,12 +82,11 @@ public abstract class AbstractTableFieldBuilder implements InputFieldBuilder {
}
protected TableContext createTableContext(final ConfigurationAttribute attribute, final ViewContext viewContext) {
final TableContext tableContext = new TableContext(
return new TableContext(
this.inputFieldBuilderSupplier,
this.widgetFactory,
attribute,
viewContext);
return tableContext;
}
protected void setSelectionListener(final Table table, final AbstractTableInputField tableField) {
@ -115,7 +114,7 @@ public abstract class AbstractTableFieldBuilder implements InputFieldBuilder {
final Integer div = orientations
.stream()
.map(o -> o.width)
.reduce(0, (acc, val) -> acc + val);
.reduce(0, Integer::sum);
final int widthUnit = currentTableWidth / div;
for (int i = 0; i < columns.length - ((readonly) ? 0 : 2); i++) {
columns[i].setWidth(widthUnit * orientations.get(i).width);
@ -263,9 +262,8 @@ public abstract class AbstractTableFieldBuilder implements InputFieldBuilder {
values.clear();
final List<Integer> rows = new ArrayList<>(indexMapping.keySet());
rows.sort((i1, i2) -> i1.compareTo(i2));
rows.sort(Integer::compareTo);
rows
.stream()
.forEach(i -> {
final Map<Long, TableValue> rowValues = indexMapping.get(i);
values.add(rowValues);

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
interface CellFieldBuilderAdapter {
static CellFieldBuilderAdapter DUMMY_BUILDER_ADAPTER = new CellFieldBuilderAdapter() {
CellFieldBuilderAdapter DUMMY_BUILDER_ADAPTER = new CellFieldBuilderAdapter() {
@Override
public void createCell(final ViewGridBuilder builder) {
}
@ -163,7 +163,7 @@ interface CellFieldBuilderAdapter {
};
}
static class GroupCellFieldBuilderAdapter implements CellFieldBuilderAdapter {
class GroupCellFieldBuilderAdapter implements CellFieldBuilderAdapter {
final Collection<Orientation> orientationsOfGroup;
@ -177,11 +177,11 @@ interface CellFieldBuilderAdapter {
for (final Orientation o : this.orientationsOfGroup) {
final int xpos = o.xPosition - ((o.title == TitleOrientation.LEFT) ? 1 : 0);
this.x = (xpos < this.x) ? xpos : this.x;
this.x = Math.min(xpos, this.x);
final int ypos = o.yPosition - ((o.title == TitleOrientation.TOP) ? 1 : 0);
this.y = (ypos < this.y) ? ypos : this.y;
this.width = (this.width < o.xpos() + o.width()) ? o.xpos() + o.width() : this.width;
this.height = (this.height < o.ypos() + o.height()) ? o.ypos() + o.height() : this.height;
this.y = Math.min(ypos, this.y);
this.width = Math.max(this.width, o.xpos() + o.width());
this.height = Math.max(this.height, o.ypos() + o.height());
}
this.width = this.width - this.x;
@ -191,7 +191,7 @@ interface CellFieldBuilderAdapter {
@Override
public void createCell(final ViewGridBuilder builder) {
final WidgetFactory widgetFactory = builder.examConfigurationService.getWidgetFactory();
final Orientation o = this.orientationsOfGroup.stream().findFirst().get();
final Orientation o = this.orientationsOfGroup.stream().findFirst().orElse(null);
final LocTextKey groupLabelKey = new LocTextKey(
ExamConfigurationService.GROUP_LABEL_LOC_TEXT_PREFIX +
o.groupId,

View file

@ -112,7 +112,7 @@ public class CheckBoxBuilder implements InputFieldBuilder {
@Override
protected void setValueToControl(final String value) {
this.control.setSelection(Boolean.valueOf(this.initValue));
this.control.setSelection(Boolean.parseBoolean(this.initValue));
}
@Override

View file

@ -214,9 +214,9 @@ public class CompositeTableFieldBuilder extends AbstractTableFieldBuilder {
} else {
dialog.open(
new LocTextKey(ExamConfigurationService.ATTRIBUTE_LABEL_LOC_TEXT_PREFIX + row),
(Consumer<Map<Long, TableValue>>) rowVals -> applyFormValues(
(Consumer<Map<Long, TableValue>>) _rowValues -> applyFormValues(
this.values,
rowVals,
_rowValues,
selectionIndex),
() -> this.tableContext.getValueChangeListener()
.tableChanged(extractTableValue(this.values)),

View file

@ -10,6 +10,7 @@ package ch.ethz.seb.sebserver.gui.service.examconfig.impl;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@ -106,12 +107,10 @@ public class ExamConfigurationServiceImpl implements ExamConfigurationService {
@Override
public Result<AttributeMapping> getAttributes(final Long templateId) {
return Result.tryCatch(() -> {
return new AttributeMapping(
return Result.tryCatch(() -> new AttributeMapping(
templateId,
getAttributes(),
getOrientations(templateId));
});
getOrientations(templateId)));
}
@Override
@ -124,12 +123,10 @@ public class ExamConfigurationServiceImpl implements ExamConfigurationService {
orientations.add(defaultOrientation);
}
return Result.tryCatch(() -> {
return new AttributeMapping(
return Result.tryCatch(() -> new AttributeMapping(
attribute.templateId,
getAttributes(),
orientations);
});
orientations));
}
private List<Orientation> getOrientations(final Long templateId) {
@ -168,7 +165,7 @@ public class ExamConfigurationServiceImpl implements ExamConfigurationService {
.call()
.getOrThrow()
.stream()
.sorted((v1, v2) -> v1.position.compareTo(v2.position))
.sorted(Comparator.comparing(v -> v.position))
.collect(Collectors.toList());
}
@ -251,12 +248,10 @@ public class ExamConfigurationServiceImpl implements ExamConfigurationService {
final EntityKey parentEntityKey = action.pageContext().getParentEntityKey();
final Set<EntityKey> selection = action.getMultiSelection();
if (selection != null && !selection.isEmpty()) {
selection.stream().forEach(entityKey -> {
callTemplateAction(
selection.forEach(entityKey -> callTemplateAction(
ResetTemplateValues.class,
parentEntityKey.modelId,
entityKey.modelId);
});
entityKey.modelId));
} else {
final EntityKey entityKey = action.getEntityKey();
callTemplateAction(
@ -273,12 +268,10 @@ public class ExamConfigurationServiceImpl implements ExamConfigurationService {
final EntityKey parentEntityKey = action.pageContext().getParentEntityKey();
final Set<EntityKey> selection = action.getMultiSelection();
if (selection != null && !selection.isEmpty()) {
selection.stream().forEach(entityKey -> {
callTemplateAction(
selection.forEach(entityKey -> callTemplateAction(
RemoveOrientation.class,
parentEntityKey.modelId,
entityKey.modelId);
});
entityKey.modelId));
} else {
final EntityKey entityKey = action.getEntityKey();
callTemplateAction(
@ -295,12 +288,10 @@ public class ExamConfigurationServiceImpl implements ExamConfigurationService {
final EntityKey parentEntityKey = action.pageContext().getParentEntityKey();
final Set<EntityKey> selection = action.getMultiSelection();
if (selection != null && !selection.isEmpty()) {
selection.stream().forEach(entityKey -> {
callTemplateAction(
selection.forEach(entityKey -> callTemplateAction(
AttachDefaultOrientation.class,
parentEntityKey.modelId,
entityKey.modelId);
});
entityKey.modelId));
} else {
final EntityKey entityKey = action.getEntityKey();
callTemplateAction(

View file

@ -63,10 +63,9 @@ public class InlineTableFieldBuilder implements InputFieldBuilder {
final Map<String, String> defaultValues = StringUtils.isBlank(attribute.defaultValue)
? Collections.emptyMap()
: Arrays.asList(StringUtils.split(
: Arrays.stream(StringUtils.split(
attribute.defaultValue,
Constants.EMBEDDED_LIST_SEPARATOR))
.stream()
.map(valueString -> StringUtils.split(
valueString,
Constants.FORM_URL_ENCODED_NAME_VALUE_SEPARATOR))
@ -74,10 +73,9 @@ public class InlineTableFieldBuilder implements InputFieldBuilder {
valueMap -> valueMap[0],
valueMap -> (valueMap.length > 1) ? valueMap[1] : StringUtils.EMPTY));
final List<ColumnDef> columns = Arrays.asList(StringUtils.split(
final List<ColumnDef> columns = Arrays.stream(StringUtils.split(
attribute.getResources(),
Constants.EMBEDDED_LIST_SEPARATOR))
.stream()
.map(columnString -> ColumnDef.fromString(columnString, defaultValues))
.collect(Collectors.toList());

View file

@ -29,7 +29,6 @@ public class InputFieldBuilderSupplier {
protected InputFieldBuilderSupplier(final Collection<InputFieldBuilder> inputFieldBuilder) {
this.inputFieldBuilder = inputFieldBuilder;
inputFieldBuilder
.stream()
.forEach(builder -> builder.init(this));
}

View file

@ -43,7 +43,7 @@ public class LabelBuilder implements InputFieldBuilder {
}
return attribute.type == AttributeType.LABEL;
};
}
@Override
public InputField createInputField(

View file

@ -104,7 +104,7 @@ public class PasswordFieldBuilder implements InputFieldBuilder {
final CharSequence pwd = passwordInput.getValue();
final CharSequence confirm = confirmInput.getValue();
if (passwordInputField.initValue != null && passwordInputField.initValue.equals(pwd)) {
if (passwordInputField.initValue != null && passwordInputField.initValue.contentEquals(pwd)) {
return;
}

View file

@ -54,10 +54,9 @@ public abstract class SelectionFieldBuilder {
attribute) + "."
: ExamConfigurationService.ATTRIBUTE_LABEL_LOC_TEXT_PREFIX + attribute.name + ".";
return Arrays.asList(StringUtils.split(
return Arrays.stream(StringUtils.split(
attribute.resources,
Constants.LIST_SEPARATOR))
.stream()
.map(value -> {
final String key = prefix + value + ((toolTipResources)
? ExamConfigurationService.TOOL_TIP_SUFFIX

View file

@ -102,9 +102,7 @@ public class TableFieldBuilder extends AbstractTableFieldBuilder {
column.setResizable(false);
column.setMoveable(false);
column.addListener(SWT.Selection, event -> {
tableField.addRow();
});
column.addListener(SWT.Selection, event -> tableField.addRow());
column = new TableColumn(table, SWT.NONE);
column.setImage(ImageIcon.REMOVE_BOX_WHITE.getImage(parent.getDisplay()));
@ -212,9 +210,9 @@ public class TableFieldBuilder extends AbstractTableFieldBuilder {
ExamConfigurationService.getTablePopupTitleKey(
this.attribute,
this.tableContext.getViewContext().i18nSupport),
(Consumer<Map<Long, TableValue>>) rowVals -> applyFormValues(
(Consumer<Map<Long, TableValue>>) _rowValues -> applyFormValues(
this.values,
rowVals,
_rowValues,
selectionIndex),
() -> this.tableContext.getValueChangeListener()
.tableChanged(extractTableValue(this.values)),

View file

@ -100,9 +100,7 @@ public class TableRowFormBuilder implements ModalInputDialogComposer<Map<Long, T
}
// when the pop-up gets closed we have to remove the input fields from the view context
grid.addDisposeListener(event -> {
this.tableContext.flushInputFields(this.rowValues.keySet());
});
grid.addDisposeListener(event -> this.tableContext.flushInputFields(this.rowValues.keySet()));
return () -> inputFields.stream()
.map(field -> (field.hasError())

View file

@ -226,7 +226,6 @@ public final class ViewContext {
void setValuesToInputFields(final Collection<ConfigurationValue> values) {
this.inputFieldMapping
.values()
.stream()
.forEach(field -> {
final ConfigurationValue initValue = field.initValue(values);
if (initValue != null) {
@ -243,8 +242,7 @@ public final class ViewContext {
return;
}
values.stream()
.forEach(attrId -> this.inputFieldMapping.remove(attrId));
values.forEach(this.inputFieldMapping::remove);
}
}

View file

@ -200,7 +200,7 @@ public class ViewGridBuilder {
}
private String gridToString() {
final StringBuffer sb = new StringBuffer();
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < this.grid.length; i++) {
if (sb.length() > 0) {
sb.append(",\n");

View file

@ -51,10 +51,6 @@ public class BrowserViewModeRule implements ValueChangeRule {
context.enableGroup(KEY_MAIN_WINDOW_GROUP);
switch (Integer.parseInt(value.value)) {
case 0: {
context.disable(KEY_TOUCH_EXIT);
break;
}
case 1: {
context.disable(KEY_TOUCH_EXIT);
context.disableGroup(KEY_MAIN_WINDOW_GROUP);

View file

@ -17,10 +17,10 @@ import ch.ethz.seb.sebserver.gbl.util.Utils;
public interface I18nSupport {
public static final String SUPPORTED_LANGUAGES_KEY = "sebserver.gui.supported.languages";
public static final String MULTILINGUAL_KEY = "sebserver.gui.multilingual";
public static final String FORMAL_LOCALE_KEY = "sebserver.gui.date.displayformat";
public static final String ATTR_CURRENT_SESSION_LOCALE = "CURRENT_SESSION_LOCALE";
String SUPPORTED_LANGUAGES_KEY = "sebserver.gui.supported.languages";
String MULTILINGUAL_KEY = "sebserver.gui.multilingual";
String FORMAL_LOCALE_KEY = "sebserver.gui.date.displayformat";
String ATTR_CURRENT_SESSION_LOCALE = "CURRENT_SESSION_LOCALE";
/** Get all supported languages as a collection of Locale
*
@ -40,7 +40,7 @@ public interface I18nSupport {
Locale getUsersFormatLocale();
/** Format a DateTime to a text format to display.
* This uses the date-format defined by either the attribute 'sebserver.gui.date.displayformat'
* This uses the date-format defined by either the attribute 'sebserver.gui.date.display format'
* or the Constants.DEFAULT_DISPLAY_DATE_FORMAT
*
* Adds time-zone offset information if the currents user time-zone is different form UTC
@ -50,7 +50,7 @@ public interface I18nSupport {
String formatDisplayDate(DateTime date);
/** Format a DateTime to a text format to display with additional time zone name at the end.
* This uses the date-format defined by either the attribute 'sebserver.gui.date.displayformat'
* This uses the date-format defined by either the attribute 'sebserver.gui.date.display format'
* or the Constants.DEFAULT_DISPLAY_DATE_FORMAT
*
* Adds time-zone offset information if the currents user time-zone is different form UTC
@ -62,19 +62,19 @@ public interface I18nSupport {
}
/** Format a time-stamp (milliseconds) to a text format to display.
* This uses the date-format defined by either the attribute 'sebserver.gui.date.displayformat'
* This uses the date-format defined by either the attribute 'sebserver.gui.date.display format'
* or the Constants.DEFAULT_DISPLAY_DATE_FORMAT
*
* Adds time-zone information if the currents user time-zone is different form UTC
*
* @param date the DateTime instance
* @param timestamp the unix-timestamp in milliseconds
* @return date formatted date String to display */
default String formatDisplayDate(final Long timestamp) {
return formatDisplayDate(Utils.toDateTimeUTC(timestamp));
}
/** Format a DateTime to a text format to display.
* This uses the date-format defined by either the attribute 'sebserver.gui.datetime.displayformat'
* This uses the date-format defined by either the attribute 'sebserver.gui.datetime.display format'
* or the Constants.DEFAULT_DISPLAY_DATE_TIME_FORMAT
*
* Adds time-zone information if the currents user time-zone is different form UTC
@ -84,19 +84,19 @@ public interface I18nSupport {
String formatDisplayDateTime(DateTime date);
/** Format a time-stamp (milliseconds) to a text format to display.
* This uses the date-format defined by either the attribute 'sebserver.gui.datetime.displayformat'
* This uses the date-format defined by either the attribute 'sebserver.gui.datetime.display format'
* or the Constants.DEFAULT_DISPLAY_DATE_TIME_FORMAT
*
* Adds time-zone information if the currents user time-zone is different form UTC
*
* @param date the DateTime instance
* @param timestamp the unix-timestamp in milliseconds
* @return date formatted date time String to display */
default String formatDisplayDateTime(final Long timestamp) {
return formatDisplayDateTime(Utils.toDateTimeUTC(timestamp));
}
/** Format a DateTime to a text format to display.
* This uses the date-format defined by either the attribute 'sebserver.gui.time.displayformat'
* This uses the date-format defined by either the attribute 'sebserver.gui.time.display format'
* or the Constants.DEFAULT_DISPLAY_TIME_FORMAT
*
* Adds time-zone information if the currents user time-zone is different form UTC
@ -106,12 +106,12 @@ public interface I18nSupport {
String formatDisplayTime(DateTime date);
/** Format a time-stamp (milliseconds) to a text format to display.
* This uses the date-format defined by either the attribute 'sebserver.gui.time.displayformat'
* This uses the date-format defined by either the attribute 'sebserver.gui.time.display format'
* or the Constants.DEFAULT_DISPLAY_TIME_FORMAT
*
* Adds time-zone information if the currents user time-zone is different form UTC
*
* @param date the DateTime instance
* @param timestamp the unix-timestamp in milliseconds
* @return date formatted time String to display */
default String formatDisplayTime(final Long timestamp) {
return formatDisplayTime(Utils.toDateTimeUTC(timestamp));

View file

@ -39,34 +39,116 @@ public interface PolyglotPageService {
* @param locale the Locale to set */
void setPageLocale(Composite root, Locale locale);
/** Used to inject a localised text within the given Control (Widget) that automatically gets changed on language
* change.
*
* @param imageUpload the Control instance
* @param locTextKey the localized text key to inject
*/
void injectI18n(ImageUploadSelection imageUpload, LocTextKey locTextKey);
/** Used to inject a localised text within the given Control (Widget) that automatically gets changed on language
* change.
*
* @param label the Control instance
* @param locTextKey the localized text key to inject
*/
void injectI18n(Label label, LocTextKey locTextKey);
/** Used to inject a localised text within the given Control (Widget) that automatically gets changed on language
* change.
*
* @param label the Control instance
* @param locTextKey the localized text key to inject
* @param locToolTipKey the localized text key for the tooltip to inject
*/
void injectI18n(Label label, LocTextKey locTextKey, LocTextKey locToolTipKey);
/** Used to inject a localised text within the given Control (Widget) that automatically gets changed on language
* change.
*
* @param group the Control instance
* @param locTextKey the localized text key to inject
* @param locTooltipKey the localized text key for the tooltip to inject
*/
void injectI18n(Group group, LocTextKey locTextKey, LocTextKey locTooltipKey);
/** Used to inject a localised text within the given Control (Widget) that automatically gets changed on language
* change.
*
* @param button the Control instance
* @param locTextKey the localized text key to inject
*/
void injectI18n(Button button, LocTextKey locTextKey);
/** Used to inject a localised text within the given Control (Widget) that automatically gets changed on language
* change.
*
* @param button the Control instance
* @param locTextKey the localized text key to inject
* @param locToolTipKey the localized text key for the tooltip to inject
*/
void injectI18n(Button button, LocTextKey locTextKey, LocTextKey locToolTipKey);
/** Used to inject a localised text within the given Control (Widget) that automatically gets changed on language
* change.
*
* @param tree the Control instance
*/
void injectI18n(Tree tree);
/** Used to inject a localised text within the given Control (Widget) that automatically gets changed on language
* change.
*
* @param treeItem the Control instance
* @param locTextKey the localized text key to inject
*/
void injectI18n(TreeItem treeItem, LocTextKey locTextKey);
/** Used to inject a localised text within the given Control (Widget) that automatically gets changed on language
* change.
*
* @param table the Control instance
*/
void injectI18n(Table table);
/** Used to inject a localised text within the given Control (Widget) that automatically gets changed on language
* change.
*
* @param tabFolder the Control instance
*/
void injectI18n(TabFolder tabFolder);
/** Used to inject a localised text within the given Control (Widget) that automatically gets changed on language
* change.
*
* @param tableColumn the Control instance
* @param locTextKey the localized text key to inject
* @param locTooltipKey the localized text key for the tooltip to inject
*/
void injectI18n(TableColumn tableColumn, LocTextKey locTextKey, LocTextKey locTooltipKey);
void injectI18n(TableItem tableItem, LocTextKey... locTextKey);
/** Used to inject a localised text within the given Control (Widget) that automatically gets changed on language
* change.
*
* @param tabItem the Control instance
* @param locTextKey the localized text key to inject
* @param locTooltipKey the localized text key for the tooltip to inject
*/
void injectI18n(TabItem tabItem, LocTextKey locTextKey, LocTextKey locTooltipKey);
/** Used to inject a localised tooltip text within the given Control (Widget) that automatically gets changed on
* language change.
*
* @param control the Control instance
* @param locTooltipKey the localized text key for the tooltip to inject
*/
void injectI18nTooltip(Control control, LocTextKey locTooltipKey);
/** Used to create the page language selector if needed
*
* @param composerCtx the PageContext
*/
void createLanguageSelector(PageContext composerCtx);
}

View file

@ -56,11 +56,11 @@ public class I18nSupportImpl implements I18nSupport {
this.currentUser = currentUser;
this.messageSource = messageSource;
final String defaultForamtLocaleString = environment.getProperty(
final String defaultFormatLocaleString = environment.getProperty(
FORMAL_LOCALE_KEY,
Constants.DEFAULT_LANG_CODE);
this.defaultFormatLocale = Locale.forLanguageTag(defaultForamtLocaleString);
this.defaultFormatLocale = Locale.forLanguageTag(defaultFormatLocaleString);
final boolean multilingual = BooleanUtils.toBoolean(environment.getProperty(
MULTILINGUAL_KEY,
@ -71,9 +71,8 @@ public class I18nSupportImpl implements I18nSupport {
Locale.ENGLISH.getLanguage());
this.supportedLanguages = Utils.immutableCollectionOf(
Arrays.asList(StringUtils.split(languagesString, Constants.LIST_SEPARATOR))
.stream()
.map(s -> Locale.forLanguageTag(s))
Arrays.stream(StringUtils.split(languagesString, Constants.LIST_SEPARATOR))
.map(Locale::forLanguageTag)
.collect(Collectors.toList()));
} else {

View file

@ -165,18 +165,6 @@ public final class PolyglotPageServiceImpl implements PolyglotPageService {
}
}
@Override
public void injectI18n(final TableItem tableItem, final LocTextKey... locTextKey) {
if (locTextKey == null) {
return;
}
tableItem.setData(POLYGLOT_ITEM_TEXT_DATA_KEY, locTextKey);
for (int i = 0; i < locTextKey.length; i++) {
tableItem.setText(i, this.i18nSupport.getText(locTextKey[i]));
}
}
@Override
public void injectI18n(final TabItem tabItem, final LocTextKey locTextKey, final LocTextKey locTooltipKey) {
tabItem.setData(POLYGLOT_ITEM_TEXT_DATA_KEY, locTextKey);

View file

@ -111,7 +111,7 @@ public class ComposerServiceImpl implements ComposerService {
}
if (!this.composer.containsKey(name)) {
log.error("No TemplateComposer with name: " + name + " found. Check Spring confiuration and beans");
log.error("No TemplateComposer with name: " + name + " found. Check Spring configuration and beans");
return;
}
@ -126,7 +126,7 @@ public class ComposerServiceImpl implements ComposerService {
PageService.updateScrolledComposite(pageContext.getParent());
} catch (final IllegalUserSessionStateException e) {
log.warn("Illegal user session state detected... ceanup user session and forward to login page.");
log.warn("Illegal user session state detected... cleanup user session and forward to login page.");
pageContext.forwardToLoginPage();
final MessageBox logoutSuccess = new Message(
pageContext.getShell(),