Improve UX
authorMathieu <mbaudier@argeo.org>
Tue, 8 Nov 2022 04:34:49 +0000 (05:34 +0100)
committerMathieu <mbaudier@argeo.org>
Tue, 8 Nov 2022 04:34:49 +0000 (05:34 +0100)
swt/org.argeo.cms.swt/src/org/argeo/cms/swt/acr/ContentComposite.java
swt/org.argeo.cms.swt/src/org/argeo/cms/swt/acr/SwtSection.java

index 951889eeea24a4d3c435de6744f126c286c9da79..4a35a3bdd2b697e519662858f258989b7b752787 100644 (file)
@@ -10,7 +10,14 @@ public class ContentComposite extends Composite {
 
        public ContentComposite(Composite parent, int style, Content item) {
                super(parent, style);
-               setData(item);
+               if (item != null)
+                       setData(item);
+       }
+
+       public boolean hasContent() {
+               if (getData() == null)
+                       return false;
+               return getData() instanceof Content;
        }
 
        public Content getContent() {
index 57c4da00ce0ea502442080051655c779d8d41d48..f4f5961ca7c22530907c36800c5821a2a64ee587 100644 (file)
@@ -27,10 +27,14 @@ public class SwtSection extends ContentComposite {
                this(section, section, style, node);
        }
 
+       public SwtSection(SwtSection section, int style) {
+               this(section, style, null);
+       }
+
        protected SwtSection(Composite parent, SwtSection parentSection, int style, Content node) {
                super(parent, style, node);
                this.parentSection = parentSection;
-               if (parentSection != null) {
+               if (parentSection != null && hasContent() && parentSection.hasContent()) {
                        relativeDepth = getProvidedContent().getDepth() - parentSection.getProvidedContent().getDepth();
                } else {
                        relativeDepth = 0;