SEBSERV-45 SEBSERV-48 added v-scrolling to main content page

This commit is contained in:
anhefti 2019-05-25 12:29:28 +02:00
parent bdf8ea8bd9
commit 66608e0953
5 changed files with 28 additions and 15 deletions

View file

@ -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");

View file

@ -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());

View file

@ -100,8 +100,8 @@ public class EntityTable<ROW extends Entity> {
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<ROW extends Entity> {
// TODO error handling
});
final GridData gridData = (GridData) this.composite.getLayoutData();
gridData.heightHint = (this.table.getItemCount() + 2) * 50;
this.composite.layout(true, true);
}

View file

@ -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)));

View file

@ -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;
}