fix user account edit privileges and page state
This commit is contained in:
parent
cacd780f50
commit
c2b2dea65f
21 changed files with 209 additions and 154 deletions
|
@ -53,6 +53,7 @@ import ch.ethz.seb.sebserver.gui.service.page.PageService.PageActionBuilder;
|
|||
import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.event.ActionEvent;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.impl.PageState;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.download.DownloadService;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.download.SebExamConfigDownload;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
|
||||
|
@ -574,8 +575,8 @@ public class ExamForm implements TemplateComposer {
|
|||
return activityHomeAction;
|
||||
}
|
||||
|
||||
this.pageService.onEmptyEntityKeyGoTo(action, ActionDefinition.EXAM_VIEW_LIST);
|
||||
return action;
|
||||
final PageState lastState = this.pageService.getCurrentState();
|
||||
return lastState.gotoAction;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -174,9 +174,7 @@ public class ExamSebConfigMapForm implements TemplateComposer {
|
|||
|
||||
.newAction(ActionDefinition.EXAM_CONFIGURATION_CANCEL_MODIFY)
|
||||
.withEntityKey(parentEntityKey)
|
||||
.withExec(action -> this.pageService.onEmptyEntityKeyGoTo(
|
||||
action,
|
||||
ActionDefinition.EXAM_VIEW_LIST))
|
||||
.withExec(this.pageService.backToCurrentFunction())
|
||||
.publishIf(() -> !isReadonly);
|
||||
}
|
||||
|
||||
|
|
|
@ -160,9 +160,7 @@ public class IndicatorForm implements TemplateComposer {
|
|||
|
||||
.newAction(ActionDefinition.EXAM_INDICATOR_CANCEL_MODIFY)
|
||||
.withEntityKey(parentEntityKey)
|
||||
.withExec(action -> this.pageService.onEmptyEntityKeyGoTo(
|
||||
action,
|
||||
ActionDefinition.EXAM_VIEW_LIST))
|
||||
.withExec(this.pageService.backToCurrentFunction())
|
||||
.publishIf(() -> !isReadonly);
|
||||
|
||||
}
|
||||
|
|
|
@ -170,9 +170,7 @@ public class InstitutionForm implements TemplateComposer {
|
|||
|
||||
.newAction(ActionDefinition.INSTITUTION_CANCEL_MODIFY)
|
||||
.withEntityKey(entityKey)
|
||||
.withExec(action -> this.pageService.onEmptyEntityKeyGoTo(
|
||||
action,
|
||||
ActionDefinition.INSTITUTION_VIEW_LIST))
|
||||
.withExec(this.pageService.backToCurrentFunction())
|
||||
.publishIf(() -> !isReadonly);
|
||||
}
|
||||
|
||||
|
|
|
@ -231,9 +231,7 @@ public class LmsSetupForm implements TemplateComposer {
|
|||
|
||||
.newAction(ActionDefinition.LMS_SETUP_CANCEL_MODIFY)
|
||||
.withEntityKey(entityKey)
|
||||
.withExec(action -> this.pageService.onEmptyEntityKeyGoTo(
|
||||
action,
|
||||
ActionDefinition.LMS_SETUP_VIEW_LIST))
|
||||
.withExec(this.pageService.backToCurrentFunction())
|
||||
.publishIf(() -> !readonly);
|
||||
}
|
||||
|
||||
|
|
|
@ -208,9 +208,7 @@ public class SebClientConfigForm implements TemplateComposer {
|
|||
|
||||
.newAction(ActionDefinition.SEB_CLIENT_CONFIG_CANCEL_MODIFY)
|
||||
.withEntityKey(entityKey)
|
||||
.withExec(action -> this.pageService.onEmptyEntityKeyGoTo(
|
||||
action,
|
||||
ActionDefinition.SEB_CLIENT_CONFIG_LIST))
|
||||
.withExec(this.pageService.backToCurrentFunction())
|
||||
.publishIf(() -> !isReadonly);
|
||||
}
|
||||
|
||||
|
|
|
@ -209,9 +209,7 @@ public class SebExamConfigPropForm implements TemplateComposer {
|
|||
|
||||
.newAction(ActionDefinition.SEB_EXAM_CONFIG_CANCEL_MODIFY)
|
||||
.withEntityKey(entityKey)
|
||||
.withExec(action -> this.pageService.onEmptyEntityKeyGoTo(
|
||||
action,
|
||||
ActionDefinition.SEB_EXAM_CONFIG_LIST))
|
||||
.withExec(this.pageService.backToCurrentFunction())
|
||||
.publishIf(() -> !isReadonly);
|
||||
|
||||
}
|
||||
|
|
|
@ -133,9 +133,7 @@ public class UserAccountChangePasswordForm implements TemplateComposer {
|
|||
.publish()
|
||||
|
||||
.newAction(ActionDefinition.USER_ACCOUNT_CANCEL_MODIFY)
|
||||
.withExec(action -> this.pageService.onEmptyEntityKeyGoTo(
|
||||
action,
|
||||
ActionDefinition.USER_ACCOUNT_VIEW_LIST))
|
||||
.withExec(this.pageService.backToCurrentFunction())
|
||||
.publish();
|
||||
}
|
||||
|
||||
|
|
|
@ -120,12 +120,12 @@ public class UserAccountForm implements TemplateComposer {
|
|||
return;
|
||||
}
|
||||
|
||||
final boolean roleBasedEditGrant = Privilege.hasRoleBasedUserAccountEditGrant(userAccount, currentUser.get());
|
||||
// new PageContext with actual EntityKey
|
||||
final PageContext formContext = pageContext.withEntityKey(userAccount.getEntityKey());
|
||||
|
||||
final boolean ownAccount = user.uuid.equals(userAccount.getModelId());
|
||||
final EntityGrantCheck userGrantCheck = currentUser.entityGrantCheck(userAccount);
|
||||
final boolean roleBasedEditGrant = Privilege.hasRoleBasedUserAccountEditGrant(userAccount, currentUser.get());
|
||||
|
||||
final boolean writeGrant = roleBasedEditGrant && userGrantCheck.w();
|
||||
final boolean modifyGrant = roleBasedEditGrant && userGrantCheck.m();
|
||||
final boolean institutionalWriteGrant = currentUser.hasInstitutionalPrivilege(
|
||||
|
@ -262,10 +262,7 @@ public class UserAccountForm implements TemplateComposer {
|
|||
.publishIf(() -> !readonly)
|
||||
|
||||
.newAction(ActionDefinition.USER_ACCOUNT_CANCEL_MODIFY)
|
||||
.withEntityKey(entityKey)
|
||||
.withExec(action -> this.pageService.onEmptyEntityKeyGoTo(
|
||||
action,
|
||||
ActionDefinition.USER_ACCOUNT_VIEW_LIST))
|
||||
.withExec(this.pageService.backToCurrentFunction())
|
||||
.publishIf(() -> !readonly);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,9 @@ import org.springframework.context.annotation.Lazy;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.Constants;
|
||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||
import ch.ethz.seb.sebserver.gbl.api.authorization.Privilege;
|
||||
import ch.ethz.seb.sebserver.gbl.model.Domain;
|
||||
import ch.ethz.seb.sebserver.gbl.model.Entity;
|
||||
import ch.ethz.seb.sebserver.gbl.model.user.UserInfo;
|
||||
|
@ -27,11 +29,13 @@ import ch.ethz.seb.sebserver.gui.content.action.ActionDefinition;
|
|||
import ch.ethz.seb.sebserver.gui.service.ResourceService;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageContext;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageMessageException;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageService.PageActionBuilder;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.GetUserAccount;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.GetUserAccountPage;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser.GrantCheck;
|
||||
|
@ -65,6 +69,8 @@ public class UserAccountList implements TemplateComposer {
|
|||
new LocTextKey("sebserver.useraccount.list.column.name");
|
||||
private static final LocTextKey TITLE_TEXT_KEY =
|
||||
new LocTextKey("sebserver.useraccount.list.title");
|
||||
private static final LocTextKey NO_EDIT_RIGHT_MESSAGE =
|
||||
new LocTextKey("sebserver.useraccount.info.notEditable");
|
||||
|
||||
// filter attribute models
|
||||
private final TableFilterAttribute institutionFilter;
|
||||
|
@ -193,10 +199,24 @@ public class UserAccountList implements TemplateComposer {
|
|||
.publishIf(() -> table.hasAnyContent())
|
||||
|
||||
.newAction(ActionDefinition.USER_ACCOUNT_MODIFY_FROM_LIST)
|
||||
.withSelect(table::getSelection, PageAction::applySingleSelection, EMPTY_SELECTION_TEXT_KEY)
|
||||
.withSelect(table::getSelection, this::editAction, EMPTY_SELECTION_TEXT_KEY)
|
||||
.publishIf(() -> userGrant.im() && table.hasAnyContent());
|
||||
}
|
||||
|
||||
private PageAction editAction(final PageAction pageAction) {
|
||||
if (!this.resourceService.getRestService()
|
||||
.getBuilder(GetUserAccount.class)
|
||||
.withURIVariable(API.PARAM_MODEL_ID, pageAction.getSingleSelection().modelId)
|
||||
.call()
|
||||
.map(user -> Privilege.hasRoleBasedUserAccountEditGrant(user,
|
||||
this.resourceService.getCurrentUser().get()))
|
||||
.getOr(false)) {
|
||||
throw new PageMessageException(NO_EDIT_RIGHT_MESSAGE);
|
||||
}
|
||||
|
||||
return PageAction.applySingleSelection(pageAction);
|
||||
}
|
||||
|
||||
private String getLocaleDisplayText(final UserInfo userInfo) {
|
||||
return (userInfo.language != null)
|
||||
? userInfo.language.getDisplayLanguage(this.pageService.getI18nSupport().getCurrentLocale())
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
package ch.ethz.seb.sebserver.gui.content.action;
|
||||
|
||||
import ch.ethz.seb.sebserver.gui.content.activity.PageStateDefinition;
|
||||
import ch.ethz.seb.sebserver.gui.content.activity.PageStateDefinitionImpl;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageState;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageStateDefinition;
|
||||
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.ImageIcon;
|
||||
|
||||
/** Enumeration of static action data for each action within the SEB Server GUI */
|
||||
|
@ -18,162 +18,162 @@ public enum ActionDefinition {
|
|||
|
||||
INSTITUTION_VIEW_LIST(
|
||||
new LocTextKey("sebserver.institution.action.list"),
|
||||
PageStateDefinition.INSTITUTION_LIST),
|
||||
PageStateDefinitionImpl.INSTITUTION_LIST),
|
||||
INSTITUTION_VIEW_FORM(
|
||||
new LocTextKey("sebserver.institution.action.form"),
|
||||
PageStateDefinition.INSTITUTION_VIEW),
|
||||
PageStateDefinitionImpl.INSTITUTION_VIEW),
|
||||
INSTITUTION_NEW(
|
||||
new LocTextKey("sebserver.institution.action.new"),
|
||||
ImageIcon.NEW,
|
||||
PageStateDefinition.INSTITUTION_EDIT),
|
||||
PageStateDefinitionImpl.INSTITUTION_EDIT),
|
||||
INSTITUTION_VIEW_FROM_LIST(
|
||||
new LocTextKey("sebserver.institution.action.list.view"),
|
||||
ImageIcon.SHOW,
|
||||
PageStateDefinition.INSTITUTION_VIEW,
|
||||
PageStateDefinitionImpl.INSTITUTION_VIEW,
|
||||
ActionCategory.INSTITUTION_LIST),
|
||||
INSTITUTION_MODIFY_FROM_LIST(
|
||||
new LocTextKey("sebserver.institution.action.list.modify"),
|
||||
ImageIcon.EDIT,
|
||||
PageStateDefinition.INSTITUTION_EDIT,
|
||||
PageStateDefinitionImpl.INSTITUTION_EDIT,
|
||||
ActionCategory.INSTITUTION_LIST),
|
||||
INSTITUTION_MODIFY(
|
||||
new LocTextKey("sebserver.institution.action.modify"),
|
||||
ImageIcon.EDIT,
|
||||
PageStateDefinition.INSTITUTION_EDIT,
|
||||
PageStateDefinitionImpl.INSTITUTION_EDIT,
|
||||
ActionCategory.FORM),
|
||||
INSTITUTION_CANCEL_MODIFY(
|
||||
new LocTextKey("sebserver.overall.action.modify.cancel"),
|
||||
ImageIcon.CANCEL,
|
||||
PageStateDefinition.INSTITUTION_VIEW,
|
||||
PageStateDefinitionImpl.INSTITUTION_VIEW,
|
||||
ActionCategory.FORM),
|
||||
INSTITUTION_SAVE(
|
||||
new LocTextKey("sebserver.institution.action.save"),
|
||||
ImageIcon.SAVE,
|
||||
PageStateDefinition.INSTITUTION_VIEW,
|
||||
PageStateDefinitionImpl.INSTITUTION_VIEW,
|
||||
ActionCategory.FORM),
|
||||
INSTITUTION_ACTIVATE(
|
||||
new LocTextKey("sebserver.institution.action.activate"),
|
||||
ImageIcon.TOGGLE_OFF,
|
||||
PageStateDefinition.INSTITUTION_VIEW,
|
||||
PageStateDefinitionImpl.INSTITUTION_VIEW,
|
||||
ActionCategory.FORM),
|
||||
INSTITUTION_DEACTIVATE(
|
||||
new LocTextKey("sebserver.institution.action.deactivate"),
|
||||
ImageIcon.TOGGLE_ON,
|
||||
PageStateDefinition.INSTITUTION_VIEW,
|
||||
PageStateDefinitionImpl.INSTITUTION_VIEW,
|
||||
ActionCategory.FORM),
|
||||
|
||||
USER_ACCOUNT_VIEW_LIST(
|
||||
new LocTextKey("sebserver.useraccount.action.list"),
|
||||
PageStateDefinition.USER_ACCOUNT_LIST),
|
||||
PageStateDefinitionImpl.USER_ACCOUNT_LIST),
|
||||
USER_ACCOUNT_VIEW_FORM(
|
||||
new LocTextKey("sebserver.useraccount.action.form"),
|
||||
PageStateDefinition.USER_ACCOUNT_VIEW),
|
||||
PageStateDefinitionImpl.USER_ACCOUNT_VIEW),
|
||||
USER_ACCOUNT_NEW(
|
||||
new LocTextKey("sebserver.useraccount.action.new"),
|
||||
ImageIcon.NEW,
|
||||
PageStateDefinition.USER_ACCOUNT_EDIT),
|
||||
PageStateDefinitionImpl.USER_ACCOUNT_EDIT),
|
||||
USER_ACCOUNT_VIEW_FROM_LIST(
|
||||
new LocTextKey("sebserver.useraccount.action.view"),
|
||||
ImageIcon.SHOW,
|
||||
PageStateDefinition.USER_ACCOUNT_VIEW,
|
||||
PageStateDefinitionImpl.USER_ACCOUNT_VIEW,
|
||||
ActionCategory.USER_ACCOUNT_LIST),
|
||||
USER_ACCOUNT_MODIFY_FROM_LIST(
|
||||
new LocTextKey("sebserver.useraccount.action.list.modify"),
|
||||
ImageIcon.EDIT,
|
||||
PageStateDefinition.USER_ACCOUNT_EDIT,
|
||||
PageStateDefinitionImpl.USER_ACCOUNT_EDIT,
|
||||
ActionCategory.USER_ACCOUNT_LIST),
|
||||
USER_ACCOUNT_MODIFY(
|
||||
new LocTextKey("sebserver.useraccount.action.modify"),
|
||||
ImageIcon.EDIT,
|
||||
PageStateDefinition.USER_ACCOUNT_EDIT,
|
||||
PageStateDefinitionImpl.USER_ACCOUNT_EDIT,
|
||||
ActionCategory.FORM),
|
||||
USER_ACCOUNT_CANCEL_MODIFY(
|
||||
new LocTextKey("sebserver.overall.action.modify.cancel"),
|
||||
ImageIcon.CANCEL,
|
||||
PageStateDefinition.USER_ACCOUNT_VIEW,
|
||||
PageStateDefinitionImpl.USER_ACCOUNT_VIEW,
|
||||
ActionCategory.FORM),
|
||||
USER_ACCOUNT_SAVE(
|
||||
new LocTextKey("sebserver.useraccount.action.save"),
|
||||
ImageIcon.SAVE,
|
||||
PageStateDefinition.USER_ACCOUNT_VIEW,
|
||||
PageStateDefinitionImpl.USER_ACCOUNT_VIEW,
|
||||
ActionCategory.FORM),
|
||||
USER_ACCOUNT_ACTIVATE(
|
||||
new LocTextKey("sebserver.useraccount.action.activate"),
|
||||
ImageIcon.TOGGLE_OFF,
|
||||
PageStateDefinition.USER_ACCOUNT_VIEW,
|
||||
PageStateDefinitionImpl.USER_ACCOUNT_VIEW,
|
||||
ActionCategory.FORM),
|
||||
USER_ACCOUNT_DEACTIVATE(
|
||||
new LocTextKey("sebserver.useraccount.action.deactivate"),
|
||||
ImageIcon.TOGGLE_ON,
|
||||
PageStateDefinition.USER_ACCOUNT_VIEW,
|
||||
PageStateDefinitionImpl.USER_ACCOUNT_VIEW,
|
||||
ActionCategory.FORM),
|
||||
USER_ACCOUNT_CHANGE_PASSOWRD(
|
||||
new LocTextKey("sebserver.useraccount.action.change.password"),
|
||||
ImageIcon.SECURE,
|
||||
PageStateDefinition.USER_ACCOUNT_PASSWORD_CHANGE,
|
||||
PageStateDefinitionImpl.USER_ACCOUNT_PASSWORD_CHANGE,
|
||||
ActionCategory.FORM),
|
||||
USER_ACCOUNT_CHANGE_PASSOWRD_SAVE(
|
||||
new LocTextKey("sebserver.useraccount.action.change.password.save"),
|
||||
ImageIcon.SAVE,
|
||||
PageStateDefinition.USER_ACCOUNT_VIEW,
|
||||
PageStateDefinitionImpl.USER_ACCOUNT_VIEW,
|
||||
ActionCategory.FORM),
|
||||
|
||||
LMS_SETUP_VIEW_LIST(
|
||||
new LocTextKey("sebserver.lmssetup.action.list"),
|
||||
PageStateDefinition.LMS_SETUP_LIST),
|
||||
PageStateDefinitionImpl.LMS_SETUP_LIST),
|
||||
LMS_SETUP_NEW(
|
||||
new LocTextKey("sebserver.lmssetup.action.new"),
|
||||
ImageIcon.NEW,
|
||||
PageStateDefinition.LMS_SETUP_EDIT),
|
||||
PageStateDefinitionImpl.LMS_SETUP_EDIT),
|
||||
LMS_SETUP_VIEW_FROM_LIST(
|
||||
new LocTextKey("sebserver.lmssetup.action.list.view"),
|
||||
ImageIcon.SHOW,
|
||||
PageStateDefinition.LMS_SETUP_VIEW,
|
||||
PageStateDefinitionImpl.LMS_SETUP_VIEW,
|
||||
ActionCategory.LMS_SETUP_LIST),
|
||||
LMS_SETUP_MODIFY_FROM_LIST(
|
||||
new LocTextKey("sebserver.lmssetup.action.list.modify"),
|
||||
ImageIcon.EDIT,
|
||||
PageStateDefinition.LMS_SETUP_EDIT,
|
||||
PageStateDefinitionImpl.LMS_SETUP_EDIT,
|
||||
ActionCategory.LMS_SETUP_LIST),
|
||||
LMS_SETUP_MODIFY(
|
||||
new LocTextKey("sebserver.lmssetup.action.modify"),
|
||||
ImageIcon.EDIT,
|
||||
PageStateDefinition.LMS_SETUP_EDIT,
|
||||
PageStateDefinitionImpl.LMS_SETUP_EDIT,
|
||||
ActionCategory.FORM),
|
||||
LMS_SETUP_SAVE_AND_TEST(
|
||||
new LocTextKey("sebserver.lmssetup.action.savetest"),
|
||||
ImageIcon.TEST,
|
||||
PageStateDefinition.LMS_SETUP_VIEW,
|
||||
PageStateDefinitionImpl.LMS_SETUP_VIEW,
|
||||
ActionCategory.FORM),
|
||||
LMS_SETUP_TEST_AND_SAVE(
|
||||
new LocTextKey("sebserver.lmssetup.action.testsave"),
|
||||
ImageIcon.TEST,
|
||||
PageStateDefinition.LMS_SETUP_VIEW,
|
||||
PageStateDefinitionImpl.LMS_SETUP_VIEW,
|
||||
ActionCategory.FORM),
|
||||
LMS_SETUP_CANCEL_MODIFY(
|
||||
new LocTextKey("sebserver.overall.action.modify.cancel"),
|
||||
ImageIcon.CANCEL,
|
||||
PageStateDefinition.LMS_SETUP_VIEW,
|
||||
PageStateDefinitionImpl.LMS_SETUP_VIEW,
|
||||
ActionCategory.FORM),
|
||||
LMS_SETUP_SAVE(
|
||||
new LocTextKey("sebserver.lmssetup.action.save"),
|
||||
ImageIcon.SAVE,
|
||||
PageStateDefinition.LMS_SETUP_VIEW,
|
||||
PageStateDefinitionImpl.LMS_SETUP_VIEW,
|
||||
ActionCategory.FORM),
|
||||
LMS_SETUP_ACTIVATE(
|
||||
new LocTextKey("sebserver.lmssetup.action.activate"),
|
||||
ImageIcon.TOGGLE_OFF,
|
||||
PageStateDefinition.LMS_SETUP_VIEW,
|
||||
PageStateDefinitionImpl.LMS_SETUP_VIEW,
|
||||
ActionCategory.FORM),
|
||||
LMS_SETUP_DEACTIVATE(
|
||||
new LocTextKey("sebserver.lmssetup.action.deactivate"),
|
||||
ImageIcon.TOGGLE_ON,
|
||||
PageStateDefinition.LMS_SETUP_VIEW,
|
||||
PageStateDefinitionImpl.LMS_SETUP_VIEW,
|
||||
ActionCategory.FORM),
|
||||
|
||||
QUIZ_DISCOVERY_VIEW_LIST(
|
||||
new LocTextKey("sebserver.quizdiscovery.action.list"),
|
||||
PageStateDefinition.QUIZ_LIST),
|
||||
PageStateDefinitionImpl.QUIZ_LIST),
|
||||
QUIZ_DISCOVERY_SHOW_DETAILS(
|
||||
new LocTextKey("sebserver.quizdiscovery.action.details"),
|
||||
ImageIcon.SHOW,
|
||||
|
@ -181,76 +181,76 @@ public enum ActionDefinition {
|
|||
QUIZ_DISCOVERY_EXAM_IMPORT(
|
||||
new LocTextKey("sebserver.quizdiscovery.action.import"),
|
||||
ImageIcon.IMPORT,
|
||||
PageStateDefinition.EXAM_EDIT,
|
||||
PageStateDefinitionImpl.EXAM_EDIT,
|
||||
ActionCategory.QUIZ_LIST),
|
||||
|
||||
EXAM_VIEW_LIST(
|
||||
new LocTextKey("sebserver.exam.action.list"),
|
||||
PageStateDefinition.EXAM_LIST),
|
||||
PageStateDefinitionImpl.EXAM_LIST),
|
||||
EXAM_IMPORT(
|
||||
new LocTextKey("sebserver.exam.action.import"),
|
||||
ImageIcon.IMPORT,
|
||||
PageStateDefinition.QUIZ_LIST),
|
||||
PageStateDefinitionImpl.QUIZ_LIST),
|
||||
EXAM_VIEW_FROM_LIST(
|
||||
new LocTextKey("sebserver.exam.action.list.view"),
|
||||
ImageIcon.SHOW,
|
||||
PageStateDefinition.EXAM_VIEW,
|
||||
PageStateDefinitionImpl.EXAM_VIEW,
|
||||
ActionCategory.EXAM_LIST),
|
||||
EXAM_MODIFY_FROM_LIST(
|
||||
new LocTextKey("sebserver.exam.action.list.modify"),
|
||||
ImageIcon.EDIT,
|
||||
PageStateDefinition.EXAM_EDIT,
|
||||
PageStateDefinitionImpl.EXAM_EDIT,
|
||||
ActionCategory.EXAM_LIST),
|
||||
EXAM_MODIFY(
|
||||
new LocTextKey("sebserver.exam.action.modify"),
|
||||
ImageIcon.EDIT,
|
||||
PageStateDefinition.EXAM_EDIT,
|
||||
PageStateDefinitionImpl.EXAM_EDIT,
|
||||
ActionCategory.FORM),
|
||||
EXAM_CANCEL_MODIFY(
|
||||
new LocTextKey("sebserver.overall.action.modify.cancel"),
|
||||
ImageIcon.CANCEL,
|
||||
PageStateDefinition.EXAM_VIEW,
|
||||
PageStateDefinitionImpl.EXAM_VIEW,
|
||||
ActionCategory.FORM),
|
||||
EXAM_SAVE(
|
||||
new LocTextKey("sebserver.exam.action.save"),
|
||||
ImageIcon.SAVE,
|
||||
PageStateDefinition.EXAM_VIEW,
|
||||
PageStateDefinitionImpl.EXAM_VIEW,
|
||||
ActionCategory.FORM),
|
||||
EXAM_ACTIVATE(
|
||||
new LocTextKey("sebserver.exam.action.activate"),
|
||||
ImageIcon.TOGGLE_OFF,
|
||||
PageStateDefinition.EXAM_VIEW,
|
||||
PageStateDefinitionImpl.EXAM_VIEW,
|
||||
ActionCategory.FORM),
|
||||
EXAM_DEACTIVATE(
|
||||
new LocTextKey("sebserver.exam.action.deactivate"),
|
||||
ImageIcon.TOGGLE_ON,
|
||||
PageStateDefinition.EXAM_VIEW,
|
||||
PageStateDefinitionImpl.EXAM_VIEW,
|
||||
ActionCategory.FORM),
|
||||
|
||||
EXAM_CONFIGURATION_NEW(
|
||||
new LocTextKey("sebserver.exam.configuration.action.list.new"),
|
||||
ImageIcon.NEW,
|
||||
PageStateDefinition.EXAM_CONFIG_MAP_EDIT,
|
||||
PageStateDefinitionImpl.EXAM_CONFIG_MAP_EDIT,
|
||||
ActionCategory.EXAM_CONFIG_MAPPING_LIST),
|
||||
EXAM_CONFIGURATION_MODIFY_FROM_LIST(
|
||||
new LocTextKey("sebserver.exam.configuration.action.list.modify"),
|
||||
ImageIcon.EDIT,
|
||||
PageStateDefinition.EXAM_CONFIG_MAP_EDIT,
|
||||
PageStateDefinitionImpl.EXAM_CONFIG_MAP_EDIT,
|
||||
ActionCategory.EXAM_CONFIG_MAPPING_LIST),
|
||||
EXAM_CONFIGURATION_EXAM_CONFIG_VIEW_PROP(
|
||||
new LocTextKey("sebserver.examconfig.action.view"),
|
||||
ImageIcon.SHOW,
|
||||
PageStateDefinition.SEB_EXAM_CONFIG_VIEW,
|
||||
PageStateDefinitionImpl.SEB_EXAM_CONFIG_VIEW,
|
||||
ActionCategory.EXAM_CONFIG_MAPPING_LIST),
|
||||
EXAM_CONFIGURATION_DELETE_FROM_LIST(
|
||||
new LocTextKey("sebserver.exam.configuration.action.list.delete"),
|
||||
ImageIcon.DELETE,
|
||||
PageStateDefinition.EXAM_VIEW,
|
||||
PageStateDefinitionImpl.EXAM_VIEW,
|
||||
ActionCategory.EXAM_CONFIG_MAPPING_LIST),
|
||||
EXAM_CONFIGURATION_EXPORT(
|
||||
new LocTextKey("sebserver.exam.configuration.action.export-config"),
|
||||
ImageIcon.EXPORT,
|
||||
PageStateDefinition.EXAM_VIEW,
|
||||
PageStateDefinitionImpl.EXAM_VIEW,
|
||||
ActionCategory.EXAM_CONFIG_MAPPING_LIST),
|
||||
EXAM_CONFIGURATION_GET_CONFIG_KEY(
|
||||
new LocTextKey("sebserver.exam.configuration.action.get-config-key"),
|
||||
|
@ -259,135 +259,135 @@ public enum ActionDefinition {
|
|||
EXAM_CONFIGURATION_SAVE(
|
||||
new LocTextKey("sebserver.exam.configuration.action.save"),
|
||||
ImageIcon.SAVE,
|
||||
PageStateDefinition.EXAM_VIEW,
|
||||
PageStateDefinitionImpl.EXAM_VIEW,
|
||||
ActionCategory.FORM),
|
||||
EXAM_CONFIGURATION_CANCEL_MODIFY(
|
||||
new LocTextKey("sebserver.overall.action.modify.cancel"),
|
||||
ImageIcon.CANCEL,
|
||||
PageStateDefinition.EXAM_VIEW,
|
||||
PageStateDefinitionImpl.EXAM_VIEW,
|
||||
ActionCategory.FORM),
|
||||
|
||||
EXAM_INDICATOR_NEW(
|
||||
new LocTextKey("sebserver.exam.indicator.action.list.new"),
|
||||
ImageIcon.NEW,
|
||||
PageStateDefinition.INDICATOR_EDIT,
|
||||
PageStateDefinitionImpl.INDICATOR_EDIT,
|
||||
ActionCategory.INDICATOR_LIST),
|
||||
EXAM_INDICATOR_MODIFY_FROM_LIST(
|
||||
new LocTextKey("sebserver.exam.indicator.action.list.modify"),
|
||||
ImageIcon.EDIT,
|
||||
PageStateDefinition.INDICATOR_EDIT,
|
||||
PageStateDefinitionImpl.INDICATOR_EDIT,
|
||||
ActionCategory.INDICATOR_LIST),
|
||||
EXAM_INDICATOR_DELETE_FROM_LIST(
|
||||
new LocTextKey("sebserver.exam.indicator.action.list.delete"),
|
||||
ImageIcon.DELETE,
|
||||
PageStateDefinition.EXAM_VIEW,
|
||||
PageStateDefinitionImpl.EXAM_VIEW,
|
||||
ActionCategory.INDICATOR_LIST),
|
||||
EXAM_INDICATOR_SAVE(
|
||||
new LocTextKey("sebserver.exam.indicator.action.save"),
|
||||
ImageIcon.SAVE,
|
||||
PageStateDefinition.EXAM_VIEW,
|
||||
PageStateDefinitionImpl.EXAM_VIEW,
|
||||
ActionCategory.FORM),
|
||||
EXAM_INDICATOR_CANCEL_MODIFY(
|
||||
new LocTextKey("sebserver.overall.action.modify.cancel"),
|
||||
ImageIcon.CANCEL,
|
||||
PageStateDefinition.EXAM_VIEW,
|
||||
PageStateDefinitionImpl.EXAM_VIEW,
|
||||
ActionCategory.FORM),
|
||||
|
||||
SEB_CLIENT_CONFIG_LIST(
|
||||
new LocTextKey("sebserver.clientconfig.action.list"),
|
||||
PageStateDefinition.SEB_CLIENT_CONFIG_LIST),
|
||||
PageStateDefinitionImpl.SEB_CLIENT_CONFIG_LIST),
|
||||
SEB_CLIENT_CONFIG_NEW(
|
||||
new LocTextKey("sebserver.clientconfig.action.list.new"),
|
||||
ImageIcon.NEW,
|
||||
PageStateDefinition.SEB_CLIENT_CONFIG_EDIT),
|
||||
PageStateDefinitionImpl.SEB_CLIENT_CONFIG_EDIT),
|
||||
SEB_CLIENT_CONFIG_VIEW_FROM_LIST(
|
||||
new LocTextKey("sebserver.clientconfig.action.list.view"),
|
||||
ImageIcon.SHOW,
|
||||
PageStateDefinition.SEB_CLIENT_CONFIG_VIEW,
|
||||
PageStateDefinitionImpl.SEB_CLIENT_CONFIG_VIEW,
|
||||
ActionCategory.SEB_CLIENT_CONFIG_LIST),
|
||||
SEB_CLIENT_CONFIG_MODIFY_FROM_LIST(
|
||||
new LocTextKey("sebserver.clientconfig.action.list.modify"),
|
||||
ImageIcon.EDIT,
|
||||
PageStateDefinition.SEB_CLIENT_CONFIG_EDIT,
|
||||
PageStateDefinitionImpl.SEB_CLIENT_CONFIG_EDIT,
|
||||
ActionCategory.SEB_CLIENT_CONFIG_LIST),
|
||||
SEB_CLIENT_CONFIG_MODIFY(
|
||||
new LocTextKey("sebserver.clientconfig.action.modify"),
|
||||
ImageIcon.EDIT,
|
||||
PageStateDefinition.SEB_CLIENT_CONFIG_EDIT,
|
||||
PageStateDefinitionImpl.SEB_CLIENT_CONFIG_EDIT,
|
||||
ActionCategory.FORM),
|
||||
SEB_CLIENT_CONFIG_CANCEL_MODIFY(
|
||||
new LocTextKey("sebserver.overall.action.modify.cancel"),
|
||||
ImageIcon.CANCEL,
|
||||
PageStateDefinition.SEB_CLIENT_CONFIG_VIEW,
|
||||
PageStateDefinitionImpl.SEB_CLIENT_CONFIG_VIEW,
|
||||
ActionCategory.FORM),
|
||||
SEB_CLIENT_CONFIG_SAVE(
|
||||
new LocTextKey("sebserver.clientconfig.action.save"),
|
||||
ImageIcon.SAVE,
|
||||
PageStateDefinition.SEB_CLIENT_CONFIG_VIEW,
|
||||
PageStateDefinitionImpl.SEB_CLIENT_CONFIG_VIEW,
|
||||
ActionCategory.FORM),
|
||||
SEB_CLIENT_CONFIG_ACTIVATE(
|
||||
new LocTextKey("sebserver.clientconfig.action.activate"),
|
||||
ImageIcon.TOGGLE_OFF,
|
||||
PageStateDefinition.SEB_CLIENT_CONFIG_VIEW,
|
||||
PageStateDefinitionImpl.SEB_CLIENT_CONFIG_VIEW,
|
||||
ActionCategory.FORM),
|
||||
SEB_CLIENT_CONFIG_DEACTIVATE(
|
||||
new LocTextKey("sebserver.clientconfig.action.deactivate"),
|
||||
ImageIcon.TOGGLE_ON,
|
||||
PageStateDefinition.SEB_CLIENT_CONFIG_VIEW,
|
||||
PageStateDefinitionImpl.SEB_CLIENT_CONFIG_VIEW,
|
||||
ActionCategory.FORM),
|
||||
SEB_CLIENT_CONFIG_EXPORT(
|
||||
new LocTextKey("sebserver.clientconfig.action.export"),
|
||||
ImageIcon.EXPORT,
|
||||
PageStateDefinition.SEB_CLIENT_CONFIG_VIEW,
|
||||
PageStateDefinitionImpl.SEB_CLIENT_CONFIG_VIEW,
|
||||
ActionCategory.FORM),
|
||||
|
||||
SEB_EXAM_CONFIG_LIST(
|
||||
new LocTextKey("sebserver.examconfig.action.list"),
|
||||
PageStateDefinition.SEB_EXAM_CONFIG_LIST),
|
||||
PageStateDefinitionImpl.SEB_EXAM_CONFIG_LIST),
|
||||
SEB_EXAM_CONFIG_NEW(
|
||||
new LocTextKey("sebserver.examconfig.action.list.new"),
|
||||
ImageIcon.NEW,
|
||||
PageStateDefinition.SEB_EXAM_CONFIG_PROP_EDIT),
|
||||
PageStateDefinitionImpl.SEB_EXAM_CONFIG_PROP_EDIT),
|
||||
SEB_EXAM_CONFIG_VIEW_PROP_FROM_LIST(
|
||||
new LocTextKey("sebserver.examconfig.action.list.view"),
|
||||
ImageIcon.SHOW,
|
||||
PageStateDefinition.SEB_EXAM_CONFIG_VIEW,
|
||||
PageStateDefinitionImpl.SEB_EXAM_CONFIG_VIEW,
|
||||
ActionCategory.SEB_EXAM_CONFIG_LIST),
|
||||
SEB_EXAM_CONFIG_VIEW_PROP(
|
||||
new LocTextKey("sebserver.examconfig.action.view"),
|
||||
ImageIcon.SHOW,
|
||||
PageStateDefinition.SEB_EXAM_CONFIG_VIEW,
|
||||
PageStateDefinitionImpl.SEB_EXAM_CONFIG_VIEW,
|
||||
ActionCategory.FORM),
|
||||
|
||||
SEB_EXAM_CONFIG_MODIFY_PROP_FROM_LIST(
|
||||
new LocTextKey("sebserver.examconfig.action.list.modify.properties"),
|
||||
ImageIcon.EDIT,
|
||||
PageStateDefinition.SEB_EXAM_CONFIG_PROP_EDIT,
|
||||
PageStateDefinitionImpl.SEB_EXAM_CONFIG_PROP_EDIT,
|
||||
ActionCategory.SEB_EXAM_CONFIG_LIST),
|
||||
SEB_EXAM_CONFIG_PROP_MODIFY(
|
||||
new LocTextKey("sebserver.examconfig.action.modify.properties"),
|
||||
ImageIcon.EDIT,
|
||||
PageStateDefinition.SEB_EXAM_CONFIG_PROP_EDIT,
|
||||
PageStateDefinitionImpl.SEB_EXAM_CONFIG_PROP_EDIT,
|
||||
ActionCategory.FORM),
|
||||
SEB_EXAM_CONFIG_MODIFY(
|
||||
new LocTextKey("sebserver.examconfig.action.modify"),
|
||||
ImageIcon.EDIT_SETTINGS,
|
||||
PageStateDefinition.SEB_EXAM_CONFIG_EDIT,
|
||||
PageStateDefinitionImpl.SEB_EXAM_CONFIG_EDIT,
|
||||
ActionCategory.FORM),
|
||||
SEB_EXAM_CONFIG_CANCEL_MODIFY(
|
||||
new LocTextKey("sebserver.overall.action.modify.cancel"),
|
||||
ImageIcon.CANCEL,
|
||||
PageStateDefinition.SEB_EXAM_CONFIG_VIEW,
|
||||
PageStateDefinitionImpl.SEB_EXAM_CONFIG_VIEW,
|
||||
ActionCategory.FORM),
|
||||
SEB_EXAM_CONFIG_SAVE(
|
||||
new LocTextKey("sebserver.examconfig.action.save"),
|
||||
ImageIcon.SAVE,
|
||||
PageStateDefinition.SEB_EXAM_CONFIG_VIEW,
|
||||
PageStateDefinitionImpl.SEB_EXAM_CONFIG_VIEW,
|
||||
ActionCategory.FORM),
|
||||
SEB_EXAM_CONFIG_EXPORT_PLAIN_XML(
|
||||
new LocTextKey("sebserver.examconfig.action.export.plainxml"),
|
||||
ImageIcon.EXPORT,
|
||||
PageStateDefinition.SEB_EXAM_CONFIG_VIEW,
|
||||
PageStateDefinitionImpl.SEB_EXAM_CONFIG_VIEW,
|
||||
ActionCategory.FORM),
|
||||
SEB_EXAM_CONFIG_GET_CONFIG_KEY(
|
||||
new LocTextKey("sebserver.examconfig.action.get-config-key"),
|
||||
|
@ -397,42 +397,42 @@ public enum ActionDefinition {
|
|||
SEB_EXAM_CONFIG_MODIFY_FROM_LIST(
|
||||
new LocTextKey("sebserver.examconfig.action.list.modify"),
|
||||
ImageIcon.EDIT_SETTINGS,
|
||||
PageStateDefinition.SEB_EXAM_CONFIG_EDIT,
|
||||
PageStateDefinitionImpl.SEB_EXAM_CONFIG_EDIT,
|
||||
ActionCategory.SEB_EXAM_CONFIG_LIST),
|
||||
|
||||
SEB_EXAM_CONFIG_SAVE_TO_HISTORY(
|
||||
new LocTextKey("sebserver.examconfig.action.saveToHistory"),
|
||||
ImageIcon.SAVE,
|
||||
PageStateDefinition.SEB_EXAM_CONFIG_EDIT,
|
||||
PageStateDefinitionImpl.SEB_EXAM_CONFIG_EDIT,
|
||||
ActionCategory.FORM),
|
||||
SEB_EXAM_CONFIG_UNDO(
|
||||
new LocTextKey("sebserver.examconfig.action.undo"),
|
||||
ImageIcon.UNDO,
|
||||
PageStateDefinition.SEB_EXAM_CONFIG_EDIT,
|
||||
PageStateDefinitionImpl.SEB_EXAM_CONFIG_EDIT,
|
||||
ActionCategory.FORM),
|
||||
|
||||
RUNNING_EXAM_VIEW_LIST(
|
||||
new LocTextKey("sebserver.monitoring.action.list"),
|
||||
PageStateDefinition.MONITORING_RUNNING_EXAM_LIST),
|
||||
PageStateDefinitionImpl.MONITORING_RUNNING_EXAM_LIST),
|
||||
MONITOR_EXAM_FROM_LIST(
|
||||
new LocTextKey("sebserver.monitoring.exam.action.list.view"),
|
||||
ImageIcon.SHOW,
|
||||
PageStateDefinition.MONITORING_RUNNING_EXAM,
|
||||
PageStateDefinitionImpl.MONITORING_RUNNING_EXAM,
|
||||
ActionCategory.RUNNING_EXAM_LIST),
|
||||
MONITOR_CLIENT_CONNECTION(
|
||||
new LocTextKey("sebserver.monitoring.exam.connection.action.view"),
|
||||
ImageIcon.SHOW,
|
||||
PageStateDefinition.MONITORING_CLIENT_CONNECTION,
|
||||
PageStateDefinitionImpl.MONITORING_CLIENT_CONNECTION,
|
||||
ActionCategory.CLIENT_EVENT_LIST),
|
||||
MONITOR_EXAM_FROM_DETAILS(
|
||||
new LocTextKey("sebserver.monitoring.exam.action.detail.view"),
|
||||
ImageIcon.SHOW,
|
||||
PageStateDefinition.MONITORING_RUNNING_EXAM,
|
||||
PageStateDefinitionImpl.MONITORING_RUNNING_EXAM,
|
||||
ActionCategory.VARIA),
|
||||
|
||||
LOGS_USER_ACTIVITY_LIST(
|
||||
new LocTextKey("sebserver.logs.activity.userlogs"),
|
||||
PageStateDefinition.USER_ACTIVITY_LOGS),
|
||||
PageStateDefinitionImpl.USER_ACTIVITY_LOGS),
|
||||
LOGS_USER_ACTIVITY_SHOW_DETAILS(
|
||||
new LocTextKey("sebserver.logs.activity.userlogs.details"),
|
||||
ImageIcon.SHOW,
|
||||
|
@ -440,7 +440,7 @@ public enum ActionDefinition {
|
|||
|
||||
LOGS_SEB_CLIENT(
|
||||
new LocTextKey("sebserver.logs.activity.seblogs"),
|
||||
PageStateDefinition.SEB_CLIENT_LOGS),
|
||||
PageStateDefinitionImpl.SEB_CLIENT_LOGS),
|
||||
LOGS_SEB_CLIENT_SHOW_DETAILS(
|
||||
new LocTextKey("sebserver.logs.activity.seblogs.details"),
|
||||
ImageIcon.SHOW,
|
||||
|
@ -450,14 +450,14 @@ public enum ActionDefinition {
|
|||
|
||||
public final LocTextKey title;
|
||||
public final ImageIcon icon;
|
||||
public final PageState targetState;
|
||||
public final PageStateDefinition targetState;
|
||||
public final ActionCategory category;
|
||||
|
||||
private ActionDefinition(final LocTextKey title, final PageState targetState) {
|
||||
private ActionDefinition(final LocTextKey title, final PageStateDefinition targetState) {
|
||||
this(title, null, targetState, ActionCategory.VARIA);
|
||||
}
|
||||
|
||||
private ActionDefinition(final LocTextKey title, final ImageIcon icon, final PageState targetState) {
|
||||
private ActionDefinition(final LocTextKey title, final ImageIcon icon, final PageStateDefinition targetState) {
|
||||
this(title, icon, targetState, ActionCategory.VARIA);
|
||||
}
|
||||
|
||||
|
@ -472,7 +472,7 @@ public enum ActionDefinition {
|
|||
private ActionDefinition(
|
||||
final LocTextKey title,
|
||||
final ImageIcon icon,
|
||||
final PageState targetState,
|
||||
final PageStateDefinition targetState,
|
||||
final ActionCategory category) {
|
||||
|
||||
this.title = title;
|
||||
|
|
|
@ -119,10 +119,6 @@ public class ActionPane implements TemplateComposer {
|
|||
}
|
||||
}
|
||||
|
||||
// final Label labelSeparator = this.widgetFactory.labelSeparator(composite);
|
||||
// final GridData separatorLayout = new GridData(SWT.FILL, SWT.TOP, true, false);
|
||||
// labelSeparator.setLayoutData(separatorLayout);
|
||||
|
||||
// title
|
||||
if (category.title != null) {
|
||||
final Label actionsTitle = this.widgetFactory.labelLocalized(
|
||||
|
|
|
@ -30,12 +30,12 @@ import ch.ethz.seb.sebserver.gui.service.page.PageContext;
|
|||
import ch.ethz.seb.sebserver.gui.service.page.PageContext.AttributeKeys;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageService.PageActionBuilder;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageState;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.event.ActionEvent;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.event.ActionEventListener;
|
||||
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.service.page.impl.PageState;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser;
|
||||
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
|
||||
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.CustomVariant;
|
||||
|
@ -351,7 +351,7 @@ public class ActivitiesPane implements TemplateComposer {
|
|||
} else {
|
||||
final TreeItem item = findItemByActionDefinition(
|
||||
navigation.getItems(),
|
||||
state.activityAnchor());
|
||||
state.definition.activityAnchor());
|
||||
if (item != null) {
|
||||
final PageAction action = getActivitySelection(item);
|
||||
this.pageService.executePageAction(action, result -> {
|
||||
|
@ -379,9 +379,12 @@ public class ActivitiesPane implements TemplateComposer {
|
|||
|
||||
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.activityAnchor());
|
||||
currentState.definition.activityAnchor());
|
||||
if (currentItem != null) {
|
||||
navigation.select(currentItem);
|
||||
}
|
||||
|
@ -403,7 +406,7 @@ public class ActivitiesPane implements TemplateComposer {
|
|||
}
|
||||
|
||||
final PageState currentState = this.pageService.getCurrentState();
|
||||
if (currentState == action.definition.targetState) {
|
||||
if (currentState != null && currentState.definition == action.definition.targetState) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,10 +32,10 @@ import ch.ethz.seb.sebserver.gui.content.UserAccountList;
|
|||
import ch.ethz.seb.sebserver.gui.content.UserActivityLogs;
|
||||
import ch.ethz.seb.sebserver.gui.content.action.ActionPane;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.Activity;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageState;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageStateDefinition;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer;
|
||||
|
||||
public enum PageStateDefinition implements PageState {
|
||||
public enum PageStateDefinitionImpl implements PageStateDefinition {
|
||||
|
||||
INSTITUTION_LIST(Type.LIST_VIEW, InstitutionList.class, ActivityDefinition.INSTITUTION),
|
||||
INSTITUTION_VIEW(Type.FORM_VIEW, InstitutionForm.class, ActivityDefinition.INSTITUTION),
|
||||
|
@ -81,7 +81,7 @@ public enum PageStateDefinition implements PageState {
|
|||
public final Class<? extends TemplateComposer> actionPaneComposer;
|
||||
public final Activity activityAnchor;
|
||||
|
||||
private PageStateDefinition(
|
||||
private PageStateDefinitionImpl(
|
||||
final Type type,
|
||||
final Class<? extends TemplateComposer> contentPaneComposer,
|
||||
final Activity activityAnchor) {
|
||||
|
@ -89,7 +89,7 @@ public enum PageStateDefinition implements PageState {
|
|||
this(type, contentPaneComposer, ActionPane.class, activityAnchor);
|
||||
}
|
||||
|
||||
private PageStateDefinition(
|
||||
private PageStateDefinitionImpl(
|
||||
final Type type,
|
||||
final Class<? extends TemplateComposer> contentPaneComposer,
|
||||
final Class<? extends TemplateComposer> actionPaneComposer,
|
|
@ -38,6 +38,7 @@ import ch.ethz.seb.sebserver.gui.service.i18n.PolyglotPageService;
|
|||
import ch.ethz.seb.sebserver.gui.service.page.PageContext.AttributeKeys;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.event.PageEvent;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.impl.PageState;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.AuthorizationContextHolder;
|
||||
|
@ -85,6 +86,14 @@ public interface PageService {
|
|||
* @return PageState of the current user. */
|
||||
PageState getCurrentState();
|
||||
|
||||
/** Get a PageAction function to go back to the current state.
|
||||
*
|
||||
* @return a PageAction function to go back to the current state. */
|
||||
default Function<PageAction, PageAction> backToCurrentFunction() {
|
||||
final PageState currentState = this.getCurrentState();
|
||||
return action -> (currentState != null) ? currentState.gotoAction : action;
|
||||
}
|
||||
|
||||
/** Publishes a given PageEvent to the current page tree
|
||||
* This goes through the page-tree and collects all listeners the are listen to
|
||||
* the specified page event type.
|
||||
|
@ -151,17 +160,6 @@ public interface PageService {
|
|||
/** Clears the PageState of the current users page */
|
||||
void clearState();
|
||||
|
||||
default PageAction onEmptyEntityKeyGoTo(final PageAction action, final ActionDefinition gotoActionDef) {
|
||||
if (action.getEntityKey() == null) {
|
||||
final PageContext pageContext = action.pageContext();
|
||||
return pageActionBuilder(pageContext)
|
||||
.newAction(gotoActionDef)
|
||||
.create();
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
/** Key to store the ScrolledComposite update function within Control data map */
|
||||
static String SCROLLED_COMPOSITE_UPDATE = "SCROLLED_COMPOSITE_UPDATE";
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
package ch.ethz.seb.sebserver.gui.service.page;
|
||||
|
||||
public interface PageState {
|
||||
public interface PageStateDefinition {
|
||||
|
||||
enum Type {
|
||||
UNDEFINED,
|
|
@ -120,6 +120,9 @@ public class ComposerServiceImpl implements ComposerService {
|
|||
try {
|
||||
composer.compose(pageContext);
|
||||
PageService.updateScrolledComposite(pageContext.getParent());
|
||||
} catch (final RuntimeException e) {
|
||||
log.warn("Failed to compose: {}, pageContext: {}", name, pageContext, e);
|
||||
throw e;
|
||||
} catch (final Exception e) {
|
||||
log.error("Failed to compose: {}, pageContext: {}", name, pageContext, e);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
|||
import ch.ethz.seb.sebserver.gui.service.page.PageContext;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageContext.AttributeKeys;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageMessageException;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageState.Type;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageStateDefinition.Type;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCallError;
|
||||
|
||||
public final class PageAction {
|
||||
|
|
|
@ -35,8 +35,7 @@ import ch.ethz.seb.sebserver.gui.service.i18n.PolyglotPageService;
|
|||
import ch.ethz.seb.sebserver.gui.service.page.ComposerService;
|
||||
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.PageState;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageState.Type;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageStateDefinition.Type;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.event.ActionEvent;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.event.ActionPublishEvent;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.event.PageEvent;
|
||||
|
@ -178,28 +177,26 @@ public class PageServiceImpl implements PageService {
|
|||
private void exec(final PageAction pageAction, final Consumer<Result<PageAction>> callback) {
|
||||
pageAction.applyAction(result -> {
|
||||
if (!result.hasError()) {
|
||||
|
||||
final PageAction action = result.get();
|
||||
if (pageAction.fireActionEvent) {
|
||||
firePageEvent(new ActionEvent(action), action.pageContext());
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
final HttpSession httpSession = RWT
|
||||
.getUISession()
|
||||
.getHttpSession();
|
||||
|
||||
log.debug("Set session PageState: {} : {}", pageAction.definition.targetState, httpSession.getId());
|
||||
httpSession.setAttribute(ATTR_PAGE_STATE, pageAction.definition.targetState);
|
||||
|
||||
final PageState pageState = new PageState(action.definition.targetState, action);
|
||||
log.debug("Set session PageState: {} : {}", pageState, httpSession.getId());
|
||||
httpSession.setAttribute(ATTR_PAGE_STATE, pageState);
|
||||
} catch (final Exception e) {
|
||||
log.error("Failed to set current PageState: ", e);
|
||||
}
|
||||
|
||||
}
|
||||
callback.accept(result);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ch.ethz.seb.sebserver.gui.service.page.impl;
|
||||
|
||||
import ch.ethz.seb.sebserver.gui.service.page.Activity;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageStateDefinition;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageStateDefinition.Type;
|
||||
|
||||
public final class PageState {
|
||||
|
||||
public final PageStateDefinition definition;
|
||||
public final PageAction gotoAction;
|
||||
|
||||
PageState(final PageStateDefinition definition, final PageAction goToAction) {
|
||||
super();
|
||||
this.definition = definition;
|
||||
this.gotoAction = goToAction;
|
||||
}
|
||||
|
||||
public PageStateDefinition getDefinition() {
|
||||
return this.definition;
|
||||
}
|
||||
|
||||
public PageAction getGotoAction() {
|
||||
return this.gotoAction;
|
||||
}
|
||||
|
||||
public Type type() {
|
||||
return this.definition.type();
|
||||
}
|
||||
|
||||
public Activity activityAnchor() {
|
||||
return this.definition.activityAnchor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append("PageState [definition=");
|
||||
builder.append(this.definition);
|
||||
builder.append(", gotoAction=");
|
||||
builder.append(this.gotoAction);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -170,6 +170,7 @@ sebserver.useraccount.action.change.password=Change Password
|
|||
sebserver.useraccount.action.change.password.save=Save New Password
|
||||
|
||||
sebserver.useraccount.info.pleaseSelect=Please Select a User Account first.
|
||||
sebserver.useraccount.info.notEditable=You have no edit rights for this User Account.
|
||||
|
||||
sebserver.useraccount.form.title=User Account
|
||||
sebserver.useraccount.form.title.new=New User Account
|
||||
|
|
Loading…
Reference in a new issue