SEBSERV-127 fix
This commit is contained in:
parent
4f34898e79
commit
7fe3e5f6db
3 changed files with 41 additions and 38 deletions
|
@ -137,11 +137,11 @@ public class MonitoringRunningExam implements TemplateComposer {
|
||||||
|
|
||||||
clientTable
|
clientTable
|
||||||
.withDefaultAction(
|
.withDefaultAction(
|
||||||
actionBuilder
|
actionBuilder
|
||||||
.newAction(ActionDefinition.MONITOR_EXAM_CLIENT_CONNECTION)
|
.newAction(ActionDefinition.MONITOR_EXAM_CLIENT_CONNECTION)
|
||||||
.withParentEntityKey(entityKey)
|
.withParentEntityKey(entityKey)
|
||||||
.create(),
|
.create(),
|
||||||
this.pageService)
|
this.pageService)
|
||||||
.withSelectionListener(this.pageService.getSelectionPublisher(
|
.withSelectionListener(this.pageService.getSelectionPublisher(
|
||||||
pageContext,
|
pageContext,
|
||||||
ActionDefinition.MONITOR_EXAM_CLIENT_CONNECTION,
|
ActionDefinition.MONITOR_EXAM_CLIENT_CONNECTION,
|
||||||
|
|
|
@ -8,17 +8,10 @@
|
||||||
|
|
||||||
package ch.ethz.seb.sebserver.gui.content.action;
|
package ch.ethz.seb.sebserver.gui.content.action;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
import java.util.ArrayList;
|
||||||
import ch.ethz.seb.sebserver.gui.service.i18n.PolyglotPageService;
|
import java.util.HashMap;
|
||||||
import ch.ethz.seb.sebserver.gui.service.page.PageContext;
|
import java.util.Map;
|
||||||
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.apache.commons.lang3.StringUtils;
|
||||||
import org.eclipse.rap.rwt.RWT;
|
import org.eclipse.rap.rwt.RWT;
|
||||||
import org.eclipse.rap.rwt.template.ImageCell;
|
import org.eclipse.rap.rwt.template.ImageCell;
|
||||||
|
@ -38,9 +31,17 @@ import org.eclipse.swt.widgets.TreeItem;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||||
import java.util.HashMap;
|
import ch.ethz.seb.sebserver.gui.service.i18n.PolyglotPageService;
|
||||||
import java.util.Map;
|
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;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
|
@ -52,8 +53,6 @@ public class ActionPane implements TemplateComposer {
|
||||||
private final PageService pageService;
|
private final PageService pageService;
|
||||||
private final WidgetFactory widgetFactory;
|
private final WidgetFactory widgetFactory;
|
||||||
|
|
||||||
private final Map<String, Tree> actionTrees = new HashMap<>();
|
|
||||||
|
|
||||||
protected ActionPane(final PageService pageService) {
|
protected ActionPane(final PageService pageService) {
|
||||||
this.pageService = pageService;
|
this.pageService = pageService;
|
||||||
this.widgetFactory = pageService.getWidgetFactory();
|
this.widgetFactory = pageService.getWidgetFactory();
|
||||||
|
@ -61,7 +60,7 @@ public class ActionPane implements TemplateComposer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void compose(final PageContext pageContext) {
|
public void compose(final PageContext pageContext) {
|
||||||
|
final Map<String, Tree> actionTrees = new HashMap<>();
|
||||||
final Label label = this.widgetFactory.labelLocalized(
|
final Label label = this.widgetFactory.labelLocalized(
|
||||||
pageContext.getParent(),
|
pageContext.getParent(),
|
||||||
CustomVariant.TEXT_H2,
|
CustomVariant.TEXT_H2,
|
||||||
|
@ -79,7 +78,7 @@ public class ActionPane implements TemplateComposer {
|
||||||
PageEventListener.LISTENER_ATTRIBUTE_KEY,
|
PageEventListener.LISTENER_ATTRIBUTE_KEY,
|
||||||
(ActionPublishEventListener) event -> {
|
(ActionPublishEventListener) event -> {
|
||||||
final Composite parent = pageContext.getParent();
|
final Composite parent = pageContext.getParent();
|
||||||
final Tree treeForGroup = getTreeForGroup(parent, event.action.definition, true);
|
final Tree treeForGroup = getTreeForGroup(actionTrees, parent, event.action.definition, true);
|
||||||
final TreeItem actionItem = ActionPane.this.widgetFactory.treeItemLocalized(
|
final TreeItem actionItem = ActionPane.this.widgetFactory.treeItemLocalized(
|
||||||
treeForGroup,
|
treeForGroup,
|
||||||
event.action.definition.title);
|
event.action.definition.title);
|
||||||
|
@ -110,7 +109,7 @@ public class ActionPane implements TemplateComposer {
|
||||||
(ActionActivationEventListener) event -> {
|
(ActionActivationEventListener) event -> {
|
||||||
final Composite parent = pageContext.getParent();
|
final Composite parent = pageContext.getParent();
|
||||||
for (final ActionDefinition ad : event.actions) {
|
for (final ActionDefinition ad : event.actions) {
|
||||||
final TreeItem actionItem = findAction(parent, ad);
|
final TreeItem actionItem = findAction(actionTrees, parent, ad);
|
||||||
if (actionItem == null) {
|
if (actionItem == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +127,7 @@ public class ActionPane implements TemplateComposer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.decoration != null) {
|
if (event.decoration != null) {
|
||||||
final TreeItem actionItemToDecorate = findAction(parent, event.decoration._1);
|
final TreeItem actionItemToDecorate = findAction(actionTrees, parent, event.decoration._1);
|
||||||
if (actionItemToDecorate != null && event.decoration._2 != null) {
|
if (actionItemToDecorate != null && event.decoration._2 != null) {
|
||||||
actionItemToDecorate.setImage(0,
|
actionItemToDecorate.setImage(0,
|
||||||
event.decoration._2.icon.getImage(parent.getDisplay()));
|
event.decoration._2.icon.getImage(parent.getDisplay()));
|
||||||
|
@ -140,8 +139,11 @@ public class ActionPane implements TemplateComposer {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private TreeItem findAction(final Composite parent, final ActionDefinition actionDefinition) {
|
private TreeItem findAction(
|
||||||
final Tree treeForGroup = getTreeForGroup(parent, actionDefinition, false);
|
final Map<String, Tree> actionTrees,
|
||||||
|
final Composite parent,
|
||||||
|
final ActionDefinition actionDefinition) {
|
||||||
|
final Tree treeForGroup = getTreeForGroup(actionTrees, parent, actionDefinition, false);
|
||||||
if (treeForGroup == null) {
|
if (treeForGroup == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -166,19 +168,20 @@ public class ActionPane implements TemplateComposer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Tree getTreeForGroup(
|
private Tree getTreeForGroup(
|
||||||
|
final Map<String, Tree> actionTrees,
|
||||||
final Composite parent,
|
final Composite parent,
|
||||||
final ActionDefinition actionDefinition,
|
final ActionDefinition actionDefinition,
|
||||||
boolean create) {
|
final boolean create) {
|
||||||
|
|
||||||
clearDisposedTrees();
|
clearDisposedTrees(actionTrees);
|
||||||
|
|
||||||
final ActionCategory category = actionDefinition.category;
|
final ActionCategory category = actionDefinition.category;
|
||||||
if (!this.actionTrees.containsKey(category.name()) && create) {
|
if (!actionTrees.containsKey(category.name()) && create) {
|
||||||
final Tree actionTree = createActionTree(parent, actionDefinition.category);
|
final Tree actionTree = createActionTree(parent, actionDefinition.category);
|
||||||
this.actionTrees.put(category.name(), actionTree);
|
actionTrees.put(category.name(), actionTree);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.actionTrees.get(category.name());
|
return actionTrees.get(category.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Tree createActionTree(final Composite parent, final ActionCategory category) {
|
private Tree createActionTree(final Composite parent, final ActionCategory category) {
|
||||||
|
@ -257,19 +260,19 @@ public class ActionPane implements TemplateComposer {
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearDisposedTrees() {
|
private void clearDisposedTrees(final Map<String, Tree> actionTrees) {
|
||||||
new ArrayList<>(this.actionTrees.entrySet())
|
new ArrayList<>(actionTrees.entrySet())
|
||||||
.forEach(entry -> {
|
.forEach(entry -> {
|
||||||
final Control c = entry.getValue();
|
final Control c = entry.getValue();
|
||||||
// of tree is already disposed.. remove it
|
// of tree is already disposed.. remove it
|
||||||
if (c.isDisposed()) {
|
if (c.isDisposed()) {
|
||||||
this.actionTrees.remove(entry.getKey());
|
actionTrees.remove(entry.getKey());
|
||||||
}
|
}
|
||||||
// check access from current thread
|
// check access from current thread
|
||||||
try {
|
try {
|
||||||
c.getBounds();
|
c.getBounds();
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
this.actionTrees.remove(entry.getKey());
|
actionTrees.remove(entry.getKey());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,8 +191,8 @@ public abstract class RestCall<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug(
|
log.debug(
|
||||||
"Webservice answered with well defined error- or validation-failure-response: ",
|
"Webservice answered with well defined error- or validation-failure-response: {}",
|
||||||
restCallError);
|
restCallError.toString());
|
||||||
|
|
||||||
return Result.ofError(restCallError);
|
return Result.ofError(restCallError);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue