From 24d5c4feea092090a4ae22fa5197b09660a7c288 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 29 Jun 2021 13:26:21 +0200 Subject: [PATCH] SEBSERV-203 fixed --- .../gui/content/action/ActionPane.java | 31 ++++++++++++------- .../gui/service/page/PageService.java | 11 +++++-- .../sebserver/gui/widget/WidgetFactory.java | 2 ++ src/main/resources/static/css/sebserver.css | 8 ++--- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/action/ActionPane.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/action/ActionPane.java index 0d59014f..de67612f 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/action/ActionPane.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/action/ActionPane.java @@ -61,9 +61,10 @@ public class ActionPane implements TemplateComposer { @Override public void compose(final PageContext pageContext) { + final Composite root = pageContext.getParent(); final Map actionTrees = new HashMap<>(); final Label label = this.widgetFactory.labelLocalized( - pageContext.getParent(), + root, CustomVariant.TEXT_H2, TITLE_KEY); @@ -75,10 +76,24 @@ public class ActionPane implements TemplateComposer { } label.setLayoutData(titleLayout); + final Composite scroll = PageService.createManagedVScrolledComposite( + root, + scrolledComposite -> { + final Composite composite = new Composite(scrolledComposite, SWT.NONE); + final GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); + final GridLayout gridLayout = new GridLayout(); + gridLayout.horizontalSpacing = 0; + gridData.heightHint = 0; + composite.setLayoutData(gridData); + composite.setLayout(gridLayout); + return composite; + }, + false, false, true); + label.setData( PageEventListener.LISTENER_ATTRIBUTE_KEY, (ActionPublishEventListener) event -> { - final Composite parent = pageContext.getParent(); + final Composite parent = scroll; final Tree treeForGroup = getTreeForGroup(actionTrees, parent, event.action.definition, true); final TreeItem actionItem = ActionPane.this.widgetFactory.treeItemLocalized( treeForGroup, @@ -101,18 +116,10 @@ public class ActionPane implements TemplateComposer { parent.layout(); }); - final Composite composite = new Composite(pageContext.getParent(), SWT.NONE); - final GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); - final GridLayout gridLayout = new GridLayout(); - gridLayout.horizontalSpacing = 0; - gridData.heightHint = 0; - composite.setLayoutData(gridData); - composite.setLayout(gridLayout); - - composite.setData( + scroll.setData( PageEventListener.LISTENER_ATTRIBUTE_KEY, (ActionActivationEventListener) event -> { - final Composite parent = pageContext.getParent(); + final Composite parent = scroll; for (final ActionDefinition ad : event.actions) { final TreeItem actionItem = findAction(actionTrees, parent, ad); if (actionItem == null) { diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/PageService.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/PageService.java index 0f4be109..4cee4db2 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/PageService.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/PageService.java @@ -378,7 +378,7 @@ public interface PageService { final Composite parent, final Function contentFunction, final boolean showScrollbars) { - return createManagedVScrolledComposite(parent, contentFunction, showScrollbars, false); + return createManagedVScrolledComposite(parent, contentFunction, showScrollbars, true, false); } /** Creates a ScrolledComposite with content supplied the given content creation function. @@ -391,16 +391,21 @@ public interface PageService { * @param parent the parent Composite of the ScrolledComposite * @param contentFunction the content creation function * @param showScrollbars indicates whether the scrollbar shall always be shown + * @param showBorder indicates whether a border is shown for the composite or not * @param fill indicates if the content shall be vertically filled * @return the child composite that is scrolled by the newly created ScrolledComposite */ static Composite createManagedVScrolledComposite( final Composite parent, final Function contentFunction, final boolean showScrollbars, + final boolean showBorder, final boolean fill) { - final ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.BORDER | SWT.V_SCROLL); - scrolledComposite.setLayoutData(new GridData(SWT.FILL, (fill) ? SWT.FILL : SWT.TOP, true, true)); + final ScrolledComposite scrolledComposite = new ScrolledComposite( + parent, + (showBorder) ? SWT.BORDER | SWT.V_SCROLL : SWT.V_SCROLL); + final GridData gridData = new GridData(SWT.FILL, (fill) ? SWT.FILL : SWT.TOP, true, true); + scrolledComposite.setLayoutData(gridData); final Composite content = contentFunction.apply(scrolledComposite); scrolledComposite.setContent(content); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/widget/WidgetFactory.java b/src/main/java/ch/ethz/seb/sebserver/gui/widget/WidgetFactory.java index 885aa7b0..142525c1 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/widget/WidgetFactory.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/widget/WidgetFactory.java @@ -323,6 +323,7 @@ public class WidgetFactory { return g; }, false, + true, false); } @@ -340,6 +341,7 @@ public class WidgetFactory { return g; }, false, + true, true); } diff --git a/src/main/resources/static/css/sebserver.css b/src/main/resources/static/css/sebserver.css index e2d0cf42..8f36434c 100644 --- a/src/main/resources/static/css/sebserver.css +++ b/src/main/resources/static/css/sebserver.css @@ -3,7 +3,8 @@ color: #4a4a4a; background-image: none; background-color: #FFFFFF; - padding: 0; + padding: 0; + border: none; } *:disabled { @@ -142,10 +143,9 @@ Label.colorlight { Composite { background-color: transparent; + border: none; } - - Composite.bordered { border: 2px; } @@ -402,7 +402,7 @@ Combo-Field { padding: 3px 0px 1px 10px; } -Combo.error, , Combo[BORDER].error { +Combo.error, Combo[BORDER].error { border: 1px solid #aa0000; border-radius: 0 2px 2px 0; }