diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/MainPage.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/MainPage.java index af283fee..009a67fd 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/MainPage.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/MainPage.java @@ -82,12 +82,18 @@ public class MainPage implements TemplateComposer { navLayout.marginWidth = 0; nav.setLayout(navLayout); - final Composite content = new Composite(mainSash, SWT.NONE); - content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - final GridLayout contentOuterlayout = new GridLayout(); - contentOuterlayout.marginHeight = 0; - contentOuterlayout.marginWidth = 0; - content.setLayout(contentOuterlayout); + final Composite content = PageService.createManagedVScrolledComposite( + mainSash, + scrolledComposite -> { + final Composite reusult = new Composite(scrolledComposite, SWT.NONE); + reusult.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + final GridLayout contentOuterlayout = new GridLayout(); + contentOuterlayout.marginHeight = 0; + contentOuterlayout.marginWidth = 0; + reusult.setLayout(contentOuterlayout); + return reusult; + }, + false); final Label toggleView = this.widgetFactory.imageButton( ImageIcon.MAXIMIZE, @@ -130,7 +136,7 @@ public class MainPage implements TemplateComposer { event.action.pageContext().copyOf(contentObjects)), 2)); final Composite actionPane = new Composite(mainSash, SWT.NONE); - actionPane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + actionPane.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); final GridLayout actionPaneGrid = new GridLayout(); actionPane.setLayout(actionPaneGrid); actionPane.setData(RWT.CUSTOM_VARIANT, "actionPane"); 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 b9d39822..9e05da1a 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 @@ -16,6 +16,7 @@ import java.util.function.Supplier; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.slf4j.Logger; @@ -187,14 +188,16 @@ public interface PageService { scrolledComposite.setContent(content); scrolledComposite.setExpandHorizontal(true); scrolledComposite.setExpandVertical(true); - scrolledComposite.setSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); + final Point parentSize = parent.computeSize(SWT.DEFAULT, SWT.DEFAULT); + scrolledComposite.setSize(parentSize); if (showScrollbars) { scrolledComposite.setAlwaysShowScrollBars(true); } final Runnable update = () -> { - scrolledComposite.setMinSize(content.computeSize(SWT.DEFAULT - 20, SWT.DEFAULT)); - ; + final Point computeSize = content.computeSize(SWT.DEFAULT - 20, SWT.DEFAULT); + scrolledComposite.setMinSize(computeSize); + }; scrolledComposite.addListener(SWT.Resize, event -> update.run()); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java b/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java index ed43eb11..f66b8920 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java @@ -100,8 +100,8 @@ public class EntityTable { layout.horizontalSpacing = 0; layout.verticalSpacing = 0; this.composite.setLayout(layout); - GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, true); - gridData.heightHint = (pageSize + 2) * 40; + GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); + // gridData.heightHint = (pageSize + 2) * 40; this.composite.setLayoutData(gridData); // TODO just for debugging, remove when tested @@ -296,6 +296,9 @@ public class EntityTable { // TODO error handling }); + final GridData gridData = (GridData) this.composite.getLayoutData(); + gridData.heightHint = (this.table.getItemCount() + 2) * 50; + this.composite.layout(true, true); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/table/TableNavigator.java b/src/main/java/ch/ethz/seb/sebserver/gui/table/TableNavigator.java index a160c33a..b00b164e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/table/TableNavigator.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/table/TableNavigator.java @@ -29,7 +29,8 @@ public class TableNavigator { TableNavigator(final EntityTable entityTable) { this.composite = new Composite(entityTable.composite, SWT.NONE); - this.composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true)); + final GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); + this.composite.setLayoutData(gridData); // TODO just for debugging, remove when tested // this.composite.setBackground(new Color(entityTable.composite.getDisplay(), new RGB(200, 0, 0))); 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 5ba371c1..6b56f394 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 @@ -160,7 +160,7 @@ public class WidgetFactory { public Composite defaultPageLayout(final Composite parent, final LocTextKey title) { final Composite defaultPageLayout = defaultPageLayout(parent); final Label labelLocalizedTitle = labelLocalizedTitle(defaultPageLayout, title); - final GridData gridData = new GridData(SWT.TOP, SWT.LEFT, true, false); + final GridData gridData = new GridData(SWT.TOP, SWT.TOP, true, false); labelLocalizedTitle.setLayoutData(gridData); return defaultPageLayout; } @@ -172,7 +172,7 @@ public class WidgetFactory { final Composite defaultPageLayout = defaultPageLayout(parent); final Label labelLocalizedTitle = labelLocalizedTitle(defaultPageLayout, title); - labelLocalizedTitle.setLayoutData(new GridData(SWT.TOP, SWT.LEFT, true, false)); + labelLocalizedTitle.setLayoutData(new GridData(SWT.TOP, SWT.TOP, true, false)); return defaultPageLayout; }