SEBSERV-79 SEBSERV-66 implementation

This commit is contained in:
anhefti 2019-09-03 14:49:24 +02:00
parent c885ef85b9
commit 71783cf278
6 changed files with 285 additions and 207 deletions

View file

@ -211,9 +211,9 @@ public class ExamList implements TemplateComposer {
throw new PageMessageException(EMPTY_SELECTION_TEXT_KEY); throw new PageMessageException(EMPTY_SELECTION_TEXT_KEY);
} }
if (exam.startTime != null) { if (exam.endTime != null) {
final DateTime now = DateTime.now(DateTimeZone.UTC); final DateTime now = DateTime.now(DateTimeZone.UTC);
if (exam.startTime.isBefore(now)) { if (exam.endTime.isBefore(now)) {
throw new PageMessageException(NO_MODIFY_OF_OUT_DATED_EXAMS); throw new PageMessageException(NO_MODIFY_OF_OUT_DATED_EXAMS);
} }
} }

View file

@ -42,7 +42,7 @@ public class MainPage implements TemplateComposer {
static final Logger log = LoggerFactory.getLogger(MainPage.class); static final Logger log = LoggerFactory.getLogger(MainPage.class);
private static final int ACTIVITY_PANE_WEIGHT = 15; private static final int ACTIVITY_PANE_WEIGHT = 18;
private static final int CONTENT_PANE_WEIGHT = 65; private static final int CONTENT_PANE_WEIGHT = 65;
private static final int ACTION_PANE_WEIGHT = 20; private static final int ACTION_PANE_WEIGHT = 20;
private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { private static final int[] DEFAULT_SASH_WEIGHTS = new int[] {

View file

@ -8,7 +8,8 @@
package ch.ethz.seb.sebserver.gui.content.activity; package ch.ethz.seb.sebserver.gui.content.activity;
import org.eclipse.rap.rwt.RWT; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Event;
@ -20,7 +21,6 @@ import org.springframework.stereotype.Component;
import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.api.EntityType;
import ch.ethz.seb.sebserver.gbl.api.authorization.PrivilegeType; import ch.ethz.seb.sebserver.gbl.api.authorization.PrivilegeType;
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
import ch.ethz.seb.sebserver.gbl.model.user.UserInfo; import ch.ethz.seb.sebserver.gbl.model.user.UserInfo;
import ch.ethz.seb.sebserver.gbl.model.user.UserRole; import ch.ethz.seb.sebserver.gbl.model.user.UserRole;
import ch.ethz.seb.sebserver.gui.content.action.ActionDefinition; import ch.ethz.seb.sebserver.gui.content.action.ActionDefinition;
@ -44,6 +44,8 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.CustomVariant;
@Component @Component
public class ActivitiesPane implements TemplateComposer { public class ActivitiesPane implements TemplateComposer {
private static final String SKIP_EXPAND = "SKIP_EXPAND";
private static final String ATTR_ACTIVITY_SELECTION = "ACTIVITY_SELECTION"; private static final String ATTR_ACTIVITY_SELECTION = "ACTIVITY_SELECTION";
private final WidgetFactory widgetFactory; private final WidgetFactory widgetFactory;
@ -81,12 +83,20 @@ public class ActivitiesPane implements TemplateComposer {
final PageActionBuilder actionBuilder = this.pageService.pageActionBuilder(pageContext); final PageActionBuilder actionBuilder = this.pageService.pageActionBuilder(pageContext);
//--------------------------------------------------------------------------------------
// ---- SEB ADMIN ----------------------------------------------------------------------
// SEB Server Administration
final TreeItem sebadmin = this.widgetFactory.treeItemLocalized(
navigation,
ActivityDefinition.SEB_ADMINISTRATION.displayName);
// Institution // Institution
// If current user has SEB Server Admin role, show the Institution list // If current user has SEB Server Admin role, show the Institution list
if (userInfo.hasRole(UserRole.SEB_SERVER_ADMIN)) { if (userInfo.hasRole(UserRole.SEB_SERVER_ADMIN)) {
// institutions (list) as root // institutions (list) as root
final TreeItem institutions = this.widgetFactory.treeItemLocalized( final TreeItem institutions = this.widgetFactory.treeItemLocalized(
navigation, sebadmin,
ActivityDefinition.INSTITUTION.displayName); ActivityDefinition.INSTITUTION.displayName);
injectActivitySelection( injectActivitySelection(
institutions, institutions,
@ -97,7 +107,7 @@ public class ActivitiesPane implements TemplateComposer {
} else if (userInfo.hasRole(UserRole.INSTITUTIONAL_ADMIN)) { } else if (userInfo.hasRole(UserRole.INSTITUTIONAL_ADMIN)) {
// otherwise show the form of the institution for current user // otherwise show the form of the institution for current user
final TreeItem institutions = this.widgetFactory.treeItemLocalized( final TreeItem institutions = this.widgetFactory.treeItemLocalized(
navigation, sebadmin,
ActivityDefinition.INSTITUTION.displayName); ActivityDefinition.INSTITUTION.displayName);
injectActivitySelection( injectActivitySelection(
institutions, institutions,
@ -112,7 +122,7 @@ public class ActivitiesPane implements TemplateComposer {
if (this.currentUser.get().hasAnyRole(UserRole.SEB_SERVER_ADMIN, UserRole.INSTITUTIONAL_ADMIN)) { if (this.currentUser.get().hasAnyRole(UserRole.SEB_SERVER_ADMIN, UserRole.INSTITUTIONAL_ADMIN)) {
final TreeItem userAccounts = this.widgetFactory.treeItemLocalized( final TreeItem userAccounts = this.widgetFactory.treeItemLocalized(
navigation, sebadmin,
ActivityDefinition.USER_ACCOUNT.displayName); ActivityDefinition.USER_ACCOUNT.displayName);
injectActivitySelection( injectActivitySelection(
userAccounts, userAccounts,
@ -122,7 +132,7 @@ public class ActivitiesPane implements TemplateComposer {
} else { } else {
// otherwise show the user account form for current user // otherwise show the user account form for current user
final TreeItem userAccounts = this.widgetFactory.treeItemLocalized( final TreeItem userAccounts = this.widgetFactory.treeItemLocalized(
navigation, sebadmin,
ActivityDefinition.USER_ACCOUNT.displayName); ActivityDefinition.USER_ACCOUNT.displayName);
injectActivitySelection( injectActivitySelection(
userAccounts, userAccounts,
@ -132,42 +142,27 @@ public class ActivitiesPane implements TemplateComposer {
.create()); .create());
} }
// LMS Setup // User Activity Logs
if (this.currentUser.hasInstitutionalPrivilege(PrivilegeType.READ, EntityType.LMS_SETUP)) { final boolean viewUserActivityLogs = this.currentUser.hasInstitutionalPrivilege(
final TreeItem lmsSetup = this.widgetFactory.treeItemLocalized( PrivilegeType.READ,
navigation, EntityType.USER_ACTIVITY_LOG);
ActivityDefinition.LMS_SETUP.displayName); if (viewUserActivityLogs) {
final TreeItem activityLogs = this.widgetFactory.treeItemLocalized(
sebadmin,
ActivityDefinition.USER_ACTIVITY_LOGS.displayName);
injectActivitySelection( injectActivitySelection(
lmsSetup, activityLogs,
actionBuilder actionBuilder
.newAction(ActionDefinition.LMS_SETUP_VIEW_LIST) .newAction(ActionDefinition.LOGS_USER_ACTIVITY_LIST)
.create()); .create());
} }
// Exam (Quiz Discovery) sebadmin.setExpanded(true);
if (this.currentUser.get().hasAnyRole(UserRole.EXAM_SUPPORTER, UserRole.EXAM_ADMIN) || // ---- SEB ADMIN ----------------------------------------------------------------------
this.currentUser.hasInstitutionalPrivilege(PrivilegeType.READ, EntityType.EXAM)) { //--------------------------------------------------------------------------------------
// Quiz Discovery //--------------------------------------------------------------------------------------
final TreeItem quizDiscovery = this.widgetFactory.treeItemLocalized( // ---- SEB CONFIGURATION --------------------------------------------------------------
navigation,
ActivityDefinition.QUIZ_DISCOVERY.displayName);
injectActivitySelection(
quizDiscovery,
actionBuilder
.newAction(ActionDefinition.QUIZ_DISCOVERY_VIEW_LIST)
.create());
// Exam
final TreeItem exam = this.widgetFactory.treeItemLocalized(
navigation,
ActivityDefinition.EXAM.displayName);
injectActivitySelection(
exam,
actionBuilder
.newAction(ActionDefinition.EXAM_VIEW_LIST)
.create());
}
// SEB Configurations // SEB Configurations
final boolean clientConfigRead = this.currentUser.hasInstitutionalPrivilege( final boolean clientConfigRead = this.currentUser.hasInstitutionalPrivilege(
@ -177,120 +172,175 @@ public class ActivitiesPane implements TemplateComposer {
PrivilegeType.READ, PrivilegeType.READ,
EntityType.CONFIGURATION_NODE); EntityType.CONFIGURATION_NODE);
TreeItem sebConfigs = null; if (clientConfigRead || examConfigRead) {
if (clientConfigRead && examConfigRead) { final TreeItem sebConfigs = this.widgetFactory.treeItemLocalized(
sebConfigs = this.widgetFactory.treeItemLocalized(
navigation, navigation,
ActivityDefinition.SEB_CONFIGURATION.displayName); ActivityDefinition.SEB_CONFIGURATION.displayName);
sebConfigs.setData(RWT.CUSTOM_VARIANT, CustomVariant.ACTIVITY_TREE_SECTION.key); //sebConfigs.setData(RWT.CUSTOM_VARIANT, CustomVariant.ACTIVITY_TREE_SECTION.key);
// SEB Client Config
if (clientConfigRead) {
final TreeItem clientConfig = (sebConfigs != null)
? this.widgetFactory.treeItemLocalized(
sebConfigs,
ActivityDefinition.SEB_CLIENT_CONFIG.displayName)
: this.widgetFactory.treeItemLocalized(
navigation,
ActivityDefinition.SEB_CLIENT_CONFIG.displayName);
injectActivitySelection(
clientConfig,
actionBuilder
.newAction(ActionDefinition.SEB_CLIENT_CONFIG_LIST)
.create());
}
// SEB Exam Config
if (examConfigRead) {
final TreeItem examConfig = (sebConfigs != null)
? this.widgetFactory.treeItemLocalized(
sebConfigs,
ActivityDefinition.SEB_EXAM_CONFIG.displayName)
: this.widgetFactory.treeItemLocalized(
navigation,
ActivityDefinition.SEB_EXAM_CONFIG.displayName);
injectActivitySelection(
examConfig,
actionBuilder
.newAction(ActionDefinition.SEB_EXAM_CONFIG_LIST)
.create());
}
sebConfigs.setExpanded(true);
} }
// SEB Client Config // ---- SEB CONFIGURATION --------------------------------------------------------------
if (clientConfigRead) { //--------------------------------------------------------------------------------------
final TreeItem clientConfig = (sebConfigs != null)
? this.widgetFactory.treeItemLocalized( //--------------------------------------------------------------------------------------
sebConfigs, // ---- EXAM ADMINISTRATION ------------------------------------------------------------
ActivityDefinition.SEB_CLIENT_CONFIG.displayName)
: this.widgetFactory.treeItemLocalized( final boolean lmsRead = this.currentUser.hasInstitutionalPrivilege(PrivilegeType.READ, EntityType.LMS_SETUP);
navigation, final boolean examRead = this.currentUser.get().hasAnyRole(UserRole.EXAM_SUPPORTER, UserRole.EXAM_ADMIN) ||
ActivityDefinition.SEB_CLIENT_CONFIG.displayName); this.currentUser.hasInstitutionalPrivilege(PrivilegeType.READ, EntityType.EXAM);
injectActivitySelection(
clientConfig, // Exam Administration
actionBuilder final TreeItem examadmin = this.widgetFactory.treeItemLocalized(
.newAction(ActionDefinition.SEB_CLIENT_CONFIG_LIST) navigation,
.create()); ActivityDefinition.EXAM_ADMINISTRATION.displayName);
if (examRead || lmsRead) {
// LMS Setup
if (lmsRead) {
final TreeItem lmsSetup = this.widgetFactory.treeItemLocalized(
examadmin,
ActivityDefinition.LMS_SETUP.displayName);
injectActivitySelection(
lmsSetup,
actionBuilder
.newAction(ActionDefinition.LMS_SETUP_VIEW_LIST)
.create());
}
// Exam (Quiz Discovery)
if (examRead) {
// Quiz Discovery
final TreeItem quizDiscovery = this.widgetFactory.treeItemLocalized(
examadmin,
ActivityDefinition.QUIZ_DISCOVERY.displayName);
injectActivitySelection(
quizDiscovery,
actionBuilder
.newAction(ActionDefinition.QUIZ_DISCOVERY_VIEW_LIST)
.create());
// Exam
final TreeItem exam = this.widgetFactory.treeItemLocalized(
examadmin,
ActivityDefinition.EXAM.displayName);
injectActivitySelection(
exam,
actionBuilder
.newAction(ActionDefinition.EXAM_VIEW_LIST)
.create());
}
examadmin.setExpanded(true);
} }
// SEB Exam Config // ---- EXAM ADMINISTRATION ------------------------------------------------------------
if (examConfigRead) { //--------------------------------------------------------------------------------------
final TreeItem examConfig = (sebConfigs != null)
? this.widgetFactory.treeItemLocalized(
sebConfigs,
ActivityDefinition.SEB_EXAM_CONFIG.displayName)
: this.widgetFactory.treeItemLocalized(
navigation,
ActivityDefinition.SEB_EXAM_CONFIG.displayName);
injectActivitySelection(
examConfig,
actionBuilder
.newAction(ActionDefinition.SEB_EXAM_CONFIG_LIST)
.create());
}
// Monitoring exams //--------------------------------------------------------------------------------------
if (this.currentUser.get().hasAnyRole(UserRole.EXAM_SUPPORTER)) { // ---- MONITORING ---------------------------------------------------------------------
final TreeItem clientConfig = this.widgetFactory.treeItemLocalized(
navigation,
ActivityDefinition.MONITORING_EXAMS.displayName);
injectActivitySelection(
clientConfig,
actionBuilder
.newAction(ActionDefinition.RUNNING_EXAM_VIEW_LIST)
.create());
}
// Logs final boolean isSupporter = this.currentUser.get().hasAnyRole(UserRole.EXAM_SUPPORTER);
final boolean viewUserActivityLogs = this.currentUser.hasInstitutionalPrivilege(
PrivilegeType.READ,
EntityType.USER_ACTIVITY_LOG);
final boolean viewSebClientLogs = this.currentUser.hasInstitutionalPrivilege( final boolean viewSebClientLogs = this.currentUser.hasInstitutionalPrivilege(
PrivilegeType.READ, PrivilegeType.READ,
EntityType.EXAM) || EntityType.EXAM) ||
this.currentUser.get().hasRole(UserRole.EXAM_SUPPORTER); this.currentUser.get().hasRole(UserRole.EXAM_SUPPORTER);
TreeItem logRoot = null; if (isSupporter || viewSebClientLogs) {
if (viewUserActivityLogs && viewSebClientLogs) { // Monitoring
logRoot = this.widgetFactory.treeItemLocalized( final TreeItem monitoring = this.widgetFactory.treeItemLocalized(
navigation, navigation,
ActivityDefinition.LOGS.displayName); ActivityDefinition.MONITORING.displayName);
logRoot.setData(RWT.CUSTOM_VARIANT, CustomVariant.ACTIVITY_TREE_SECTION.key);
// Monitoring exams
if (isSupporter) {
final TreeItem clientConfig = this.widgetFactory.treeItemLocalized(
monitoring,
ActivityDefinition.MONITORING_EXAMS.displayName);
injectActivitySelection(
clientConfig,
actionBuilder
.newAction(ActionDefinition.RUNNING_EXAM_VIEW_LIST)
.create());
}
// SEB Client Logs
if (viewSebClientLogs) {
final TreeItem sebLogs = (monitoring != null)
? this.widgetFactory.treeItemLocalized(
monitoring,
ActivityDefinition.SEB_CLIENT_LOGS.displayName)
: this.widgetFactory.treeItemLocalized(
navigation,
ActivityDefinition.SEB_CLIENT_LOGS.displayName);
injectActivitySelection(
sebLogs,
actionBuilder
.newAction(ActionDefinition.LOGS_SEB_CLIENT)
.create());
}
monitoring.setExpanded(true);
} }
// User Activity Logs // ---- MONITORING ---------------------------------------------------------------------
if (viewUserActivityLogs) { //--------------------------------------------------------------------------------------
final TreeItem activityLogs = (logRoot != null)
? this.widgetFactory.treeItemLocalized(
logRoot,
ActivityDefinition.USER_ACTIVITY_LOGS.displayName)
: this.widgetFactory.treeItemLocalized(
navigation,
ActivityDefinition.USER_ACTIVITY_LOGS.displayName);
injectActivitySelection(
activityLogs,
actionBuilder
.newAction(ActionDefinition.LOGS_USER_ACTIVITY_LIST)
.create());
}
// SEB Client Logs
if (viewSebClientLogs) {
final TreeItem sebLogs = (logRoot != null)
? this.widgetFactory.treeItemLocalized(
logRoot,
ActivityDefinition.SEB_CLIENT_LOGS.displayName)
: this.widgetFactory.treeItemLocalized(
navigation,
ActivityDefinition.SEB_CLIENT_LOGS.displayName);
injectActivitySelection(
sebLogs,
actionBuilder
.newAction(ActionDefinition.LOGS_SEB_CLIENT)
.create());
}
// TODO other activities
// register page listener and initialize navigation data // register page listener and initialize navigation data
navigation.addListener(SWT.Selection, event -> handleSelection(pageContext, event)); navigation.addListener(SWT.Selection, event -> handleSelection(pageContext, event));
navigation.addListener(SWT.Expand, event -> { navigation.addListener(SWT.Expand, event -> {
final TreeItem item = (TreeItem) event.item;
selectCurrentItem(navigation, item);
});
navigation.addListener(SWT.Collapse, event -> {
final Tree tree = (Tree) event.widget;
tree.setData(SKIP_EXPAND, true);
});
navigation.addListener(SWT.MouseUp, event -> {
final Tree tree = (Tree) event.widget; final Tree tree = (Tree) event.widget;
final TreeItem treeItem = (TreeItem) event.item;
final TreeItem[] selection = tree.getSelection(); final TreeItem[] selection = tree.getSelection();
if (selection != null && selection.length >= 1 && selection[0].getParentItem() == treeItem) { if (ArrayUtils.isNotEmpty(selection)) {
tree.setSelection(selection[0]); final TreeItem item = selection[0];
//tree.select(selection[0]); final boolean skipExpand = BooleanUtils.isTrue((Boolean) tree.getData(SKIP_EXPAND));
if (item.getItemCount() > 0 && !item.getExpanded() && !skipExpand) {
item.setExpanded(true);
handleParentSelection(tree, item);
}
} }
tree.setData(SKIP_EXPAND, false);
}); });
navigation.setData( navigation.setData(
PageEventListener.LISTENER_ATTRIBUTE_KEY, PageEventListener.LISTENER_ATTRIBUTE_KEY,
@ -300,43 +350,58 @@ public class ActivitiesPane implements TemplateComposer {
final PageState state = this.pageService.getCurrentState(); final PageState state = this.pageService.getCurrentState();
if (state == null) { if (state == null) {
final TreeItem item = navigation.getItem(0); final TreeItem item = navigation.getItem(0);
final PageAction activityAction = getActivitySelection(item); final TreeItem actionItem = getActionItem(item);
final PageAction activityAction = getActivitySelection(actionItem);
this.pageService.executePageAction(activityAction); this.pageService.executePageAction(activityAction);
} else { } else {
final TreeItem item = findItemByActionDefinition(navigation.getItems(), state); final TreeItem item = findItemByActionDefinition(
navigation.getItems(),
state.activityAnchor());
if (item != null) { if (item != null) {
navigation.select(item); navigation.select(item);
} }
} }
} }
private void selectCurrentItem(final Tree navigation, final TreeItem item) {
final PageState currentState = this.pageService.getCurrentState();
final TreeItem currentItem = findItemByActionDefinition(
item.getItems(),
currentState.activityAnchor());
if (currentItem != null) {
navigation.select(currentItem);
}
}
private void handleSelection(final PageContext composerCtx, final Event event) { private void handleSelection(final PageContext composerCtx, final Event event) {
final Tree tree = (Tree) event.widget; final Tree tree = (Tree) event.widget;
final TreeItem treeItem = (TreeItem) event.item; final TreeItem treeItem = (TreeItem) event.item;
if (treeItem.getItemCount() > 0 && !treeItem.getExpanded()) {
return;
}
final PageAction action = getActivitySelection(treeItem); final PageAction action = getActivitySelection(treeItem);
// if there is no form action associated with the treeItem and the treeItem has sub items, toggle the item state // if there is no form action associated with the treeItem and the treeItem has sub items, toggle the item state
if (action == null) { if (action == null) {
if (treeItem.getItemCount() > 0) { handleParentSelection(tree, treeItem);
treeItem.setExpanded(true);
final PageState currentState = this.pageService.getCurrentState();
final TreeItem currentSelection = findItemByActionDefinition(tree.getItems(), currentState);
if (currentSelection != null) {
tree.select(currentSelection);
} else {
tree.deselectAll();
}
}
tree.layout();
return; return;
} }
final PageState currentState = this.pageService.getCurrentState();
if (currentState == action.definition.targetState) {
return;
}
this.pageService.executePageAction( this.pageService.executePageAction(
action, action,
result -> { result -> {
if (result.hasError()) { if (result.hasError()) {
tree.deselect(treeItem); tree.deselect(treeItem);
final PageState currentState = this.pageService.getCurrentState();
if (currentState != null) { if (currentState != null) {
final TreeItem item = findItemByActionDefinition(tree.getItems(), currentState); final TreeItem item = findItemByActionDefinition(
tree.getItems(),
currentState.activityAnchor());
if (item != null) { if (item != null) {
tree.select(item); tree.select(item);
} }
@ -345,10 +410,58 @@ public class ActivitiesPane implements TemplateComposer {
}); });
} }
private void handleParentSelection(final Tree tree, final TreeItem treeItem) {
if (treeItem.getItemCount() > 0) {
final PageState currentState = this.pageService.getCurrentState();
final TreeItem currentSelection = findItemByActionDefinition(
tree.getItems(),
currentState.activityAnchor());
if (currentSelection != null) {
if (isInSubTree(treeItem, currentSelection)) {
tree.setSelection(currentSelection);
} else {
selectFirstChild(tree, treeItem);
}
} else {
tree.deselectAll();
}
}
tree.layout();
}
private void selectFirstChild(final Tree tree, final TreeItem treeItem) {
final TreeItem actionItem = ActivitiesPane.getActionItem(treeItem);
final PageAction activitySelection = getActivitySelection(actionItem);
this.pageService.executePageAction(activitySelection, result -> {
if (!result.hasError()) {
tree.setSelection(actionItem);
}
});
}
private static final boolean isInSubTree(final TreeItem treeItem, final TreeItem currentSelection) {
if (treeItem == null) {
return false;
}
final TreeItem[] items = treeItem.getItems();
if (ArrayUtils.isEmpty(items)) {
return false;
}
for (final TreeItem item : items) {
if (item == currentSelection) {
return true;
}
}
return false;
}
private static final TreeItem findItemByActionDefinition( private static final TreeItem findItemByActionDefinition(
final TreeItem[] items, final TreeItem[] items,
final Activity activity, final Activity activity) {
final String modelId) {
if (items == null) { if (items == null) {
return null; return null;
@ -358,7 +471,7 @@ public class ActivitiesPane implements TemplateComposer {
final PageAction action = getActivitySelection(item); final PageAction action = getActivitySelection(item);
if (action == null) { if (action == null) {
if (item.getItemCount() > 0) { if (item.getItemCount() > 0) {
final TreeItem found = findItemByActionDefinition(item.getItems(), activity, modelId); final TreeItem found = findItemByActionDefinition(item.getItems(), activity);
if (found != null) { if (found != null) {
return found; return found;
} }
@ -367,13 +480,11 @@ public class ActivitiesPane implements TemplateComposer {
} }
final Activity activityAnchor = action.definition.targetState.activityAnchor(); final Activity activityAnchor = action.definition.targetState.activityAnchor();
final EntityKey entityKey = action.getEntityKey(); if (activityAnchor.name().equals(activity.name())) {
if (activityAnchor.name().equals(activity.name()) &&
(entityKey == null || (modelId != null && modelId.equals(entityKey.modelId)))) {
return item; return item;
} }
final TreeItem _item = findItemByActionDefinition(item.getItems(), activity, modelId); final TreeItem _item = findItemByActionDefinition(item.getItems(), activity);
if (_item != null) { if (_item != null) {
return _item; return _item;
} }
@ -382,27 +493,23 @@ public class ActivitiesPane implements TemplateComposer {
return null; return null;
} }
static final TreeItem findItemByActionDefinition(final TreeItem[] items, final PageState pageState) { private static final TreeItem getActionItem(final TreeItem item) {
if (pageState == null) { final PageAction action = (PageAction) item.getData(ATTR_ACTIVITY_SELECTION);
return null; if (action == null && item.getItemCount() > 0) {
} final TreeItem firstChild = item.getItem(0);
return findItemByActionDefinition(items, pageState.activityAnchor(), null); if (firstChild != null) {
} return firstChild;
}
static final void expand(final TreeItem item) {
if (item == null) {
return;
} }
item.setExpanded(true); return item;
expand(item.getParentItem());
} }
public static PageAction getActivitySelection(final TreeItem item) { private static final PageAction getActivitySelection(final TreeItem item) {
return (PageAction) item.getData(ATTR_ACTIVITY_SELECTION); return (PageAction) item.getData(ATTR_ACTIVITY_SELECTION);
} }
public static void injectActivitySelection(final TreeItem item, final PageAction action) { private final static void injectActivitySelection(final TreeItem item, final PageAction action) {
item.setData(ATTR_ACTIVITY_SELECTION, action); item.setData(ATTR_ACTIVITY_SELECTION, action);
} }
@ -415,12 +522,9 @@ public class ActivitiesPane implements TemplateComposer {
@Override @Override
public void notify(final ActionEvent event) { public void notify(final ActionEvent event) {
final EntityKey entityKey = event.action.getEntityKey();
final String modelId = (entityKey != null) ? entityKey.modelId : null;
final TreeItem item = findItemByActionDefinition( final TreeItem item = findItemByActionDefinition(
this.navigation.getItems(), this.navigation.getItems(),
event.action.definition.targetState.activityAnchor(), event.action.definition.targetState.activityAnchor());
modelId);
if (item != null) { if (item != null) {
this.navigation.select(item); this.navigation.select(item);
} }

View file

@ -12,17 +12,19 @@ import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
import ch.ethz.seb.sebserver.gui.service.page.Activity; import ch.ethz.seb.sebserver.gui.service.page.Activity;
public enum ActivityDefinition implements Activity { public enum ActivityDefinition implements Activity {
SEB_ADMINISTRATION(new LocTextKey("sebserver.overall.activity.title.serveradmin")),
INSTITUTION(new LocTextKey("sebserver.institution.action.list")), INSTITUTION(new LocTextKey("sebserver.institution.action.list")),
USER_ACCOUNT(new LocTextKey("sebserver.useraccount.action.list")), USER_ACCOUNT(new LocTextKey("sebserver.useraccount.action.list")),
USER_ACTIVITY_LOGS(new LocTextKey("sebserver.logs.activity.userlogs")),
LMS_SETUP(new LocTextKey("sebserver.lmssetup.action.list")), LMS_SETUP(new LocTextKey("sebserver.lmssetup.action.list")),
QUIZ_DISCOVERY(new LocTextKey("sebserver.quizdiscovery.action.list")), QUIZ_DISCOVERY(new LocTextKey("sebserver.quizdiscovery.action.list")),
EXAM_ADMINISTRATION(new LocTextKey("sebserver.overall.activity.title.examadmin")),
EXAM(new LocTextKey("sebserver.exam.action.list")), EXAM(new LocTextKey("sebserver.exam.action.list")),
SEB_CONFIGURATION(new LocTextKey("sebserver.sebconfig.activity.name")), SEB_CONFIGURATION(new LocTextKey("sebserver.overall.activity.title.sebconfig")),
SEB_CLIENT_CONFIG(new LocTextKey("sebserver.clientconfig.action.list")), SEB_CLIENT_CONFIG(new LocTextKey("sebserver.clientconfig.action.list")),
SEB_EXAM_CONFIG(new LocTextKey("sebserver.examconfig.action.list")), SEB_EXAM_CONFIG(new LocTextKey("sebserver.examconfig.action.list")),
MONITORING(new LocTextKey("sebserver.overall.activity.title.monitoring")),
MONITORING_EXAMS(new LocTextKey("sebserver.monitoring.action.list")), MONITORING_EXAMS(new LocTextKey("sebserver.monitoring.action.list")),
LOGS(new LocTextKey("sebserver.logs.activity.main")),
USER_ACTIVITY_LOGS(new LocTextKey("sebserver.logs.activity.userlogs")),
SEB_CLIENT_LOGS(new LocTextKey("sebserver.logs.activity.seblogs")); SEB_CLIENT_LOGS(new LocTextKey("sebserver.logs.activity.seblogs"));
public final LocTextKey displayName; public final LocTextKey displayName;

View file

@ -1,33 +0,0 @@
/*
* Copyright (c) 2018 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 org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Label;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import ch.ethz.seb.sebserver.gui.service.page.PageContext;
import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer;
@Lazy
@Component
public class TODOTemplate implements TemplateComposer {
@Override
public void compose(final PageContext composerCtx) {
final Label tree = new Label(composerCtx.getParent(), SWT.NONE);
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
tree.setText("[TODO]");
}
}

View file

@ -52,6 +52,11 @@ sebserver.overall.types.entityType.SEB_CLIENT_CONFIGURATION=Client Configuration
sebserver.overall.types.entityType.LMS_SETUP=LMS Setup sebserver.overall.types.entityType.LMS_SETUP=LMS Setup
sebserver.overall.types.entityType.USER=User Account sebserver.overall.types.entityType.USER=User Account
sebserver.overall.activity.title.serveradmin=SEB Server Administration
sebserver.overall.activity.title.sebconfig=SEB Configuration
sebserver.overall.activity.title.examadmin=Exam Administration
sebserver.overall.activity.title.monitoring=Monitoring
################################ ################################
# Form validation and messages # Form validation and messages
################################ ################################
@ -274,7 +279,7 @@ sebserver.exam.list.column.starttime=Start Time {0}
sebserver.exam.list.column.type=Type sebserver.exam.list.column.type=Type
sebserver.exam.list.empty=No Exams has been found. Please adapt the filter or import one from Quiz sebserver.exam.list.empty=No Exams has been found. Please adapt the filter or import one from Quiz
sebserver.exam.list.modify.out.dated=Running or finished exams cannot be modified. sebserver.exam.list.modify.out.dated=Finished exams cannot be modified.
sebserver.exam.list.action.no.modify.privilege=No Access: An Exam from other institution cannot be modified. sebserver.exam.list.action.no.modify.privilege=No Access: An Exam from other institution cannot be modified.
sebserver.exam.action.list=Exam sebserver.exam.action.list=Exam
@ -915,7 +920,7 @@ sebserver.examconfig.props.validation.WindowsSizeValidator=Invalid number
# Monitoring # Monitoring
################################ ################################
sebserver.monitoring.action.list=Monitoring sebserver.monitoring.action.list=Running Exams
sebserver.monitoring.exam.list.title=Running Exams sebserver.monitoring.exam.list.title=Running Exams
sebserver.monitoring.exam.list.actions=Selected Exam sebserver.monitoring.exam.list.actions=Selected Exam
sebserver.monitoring.exam.action.detail.view=Back To Overview sebserver.monitoring.exam.action.detail.view=Back To Overview