From: Mathieu Baudier Date: Thu, 24 Dec 2020 10:32:00 +0000 (+0100) Subject: Better deal with missing layer when anonymous. X-Git-Tag: argeo-suite-2.1.17~5 X-Git-Url: https://git.argeo.org/?p=gpl%2Fargeo-suite.git;a=commitdiff_plain;h=377d822958ec57c8fe39716d8af129c3ff258eaf Better deal with missing layer when anonymous. --- diff --git a/org.argeo.suite.ui/src/org/argeo/suite/ui/SuiteUi.java b/org.argeo.suite.ui/src/org/argeo/suite/ui/SuiteUi.java index cad5a9b..d93c3a8 100644 --- a/org.argeo.suite.ui/src/org/argeo/suite/ui/SuiteUi.java +++ b/org.argeo.suite.ui/src/org/argeo/suite/ui/SuiteUi.java @@ -90,15 +90,16 @@ class SuiteUi extends Composite { private Composite getLayer(String id, Node context) { if (!layers.containsKey(id)) - throw new IllegalArgumentException("No layer " + id + " is available."); + return null; if (!workAreas.containsKey(id)) initLayer(id, layers.get(id), context); return workAreas.get(id); } Composite switchToLayer(String layerId, Node context) { + Composite current = null; if (currentLayerId != null) { - Composite current = getCurrentWorkArea(); + current = getCurrentWorkArea(); if (currentLayerId.equals(layerId)) return current; } @@ -107,16 +108,20 @@ class SuiteUi extends Composite { context = userDir; } Composite toShow = getLayer(layerId, context); - currentLayerId = layerId; - if (!isDisposed()) - getDisplay().syncExec(() -> { - if (!toShow.isDisposed()) - toShow.moveAbove(null); - else - log.warn("Cannot show work area because it is disposed."); - dynamicArea.layout(true, true); - }); - return toShow; + if (toShow != null) { + currentLayerId = layerId; + if (!isDisposed()) + getDisplay().syncExec(() -> { + if (!toShow.isDisposed()) + toShow.moveAbove(null); + else + log.warn("Cannot show work area because it is disposed."); + dynamicArea.layout(true, true); + }); + return toShow; + } else { + return current; + } } Composite switchToLayer(SuiteLayer layer, Node context) {