From: Mathieu Baudier Date: Wed, 22 Jul 2015 12:32:27 +0000 (+0000) Subject: Improve UI initialisation, making sure there is always a state (and thus a node)... X-Git-Tag: argeo-commons-2.1.30~216 X-Git-Url: https://git.argeo.org/?a=commitdiff_plain;h=43d0424cdc143c98c0d07ac0485341a41bfb821b;p=lgpl%2Fargeo-commons.git Improve UI initialisation, making sure there is always a state (and thus a node) available, even in the header. git-svn-id: https://svn.argeo.org/commons/trunk@8282 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/org.argeo.cms/src/org/argeo/cms/util/SimpleErgonomics.java b/org.argeo.cms/src/org/argeo/cms/util/SimpleErgonomics.java index 7835b7efa..40e5fecf8 100644 --- a/org.argeo.cms/src/org/argeo/cms/util/SimpleErgonomics.java +++ b/org.argeo.cms/src/org/argeo/cms/util/SimpleErgonomics.java @@ -24,6 +24,7 @@ import org.eclipse.swt.widgets.Control; public class SimpleErgonomics extends AbstractCmsEntryPoint { private final static Log log = LogFactory.getLog(SimpleErgonomics.class); + private boolean uiInitialized = false; private Composite headerArea; private Composite bodyArea; private final CmsUiProvider uiProvider; @@ -56,11 +57,16 @@ public class SimpleErgonomics extends AbstractCmsEntryPoint { bodyArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); bodyArea.setLayout(CmsUtils.noSpaceGridLayout()); + uiInitialized = true; refresh(); } @Override protected void refresh() { + if (!uiInitialized) + return; + if (getState() == null) + setState(""); refreshHeader(); refreshBody(); if (log.isTraceEnabled()) @@ -68,8 +74,6 @@ public class SimpleErgonomics extends AbstractCmsEntryPoint { } protected void refreshHeader() { - if (headerArea == null) - return; for (Control child : headerArea.getChildren()) child.dispose(); try { @@ -81,8 +85,6 @@ public class SimpleErgonomics extends AbstractCmsEntryPoint { } protected void refreshBody() { - if (bodyArea == null) - return; // Exception Throwable exception = getException(); if (exception != null) { @@ -99,11 +101,7 @@ public class SimpleErgonomics extends AbstractCmsEntryPoint { child.dispose(); bodyArea.setLayout(CmsUtils.noSpaceGridLayout()); - String state = getState(); try { - if (state == null) - setState(""); - // throw new CmsException("State cannot be null"); uiProvider.createUi(bodyArea, getNode()); } catch (RepositoryException e) { throw new CmsException("Cannot refresh body", e);