From f95485fb7db36c552185dd5c6a05a00415ce7d56 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 3 Jun 2019 13:52:16 +0200 Subject: [PATCH] SEBSERV-45 some styles and GridTable adaptColumnWidth with TODO --- .../examconfig/impl/TableFieldBuilder.java | 3 +- .../service/page/impl/ModalInputDialog.java | 11 +++++ .../seb/sebserver/gui/widget/GridTable.java | 39 ++++++++++------- .../config/application-demo.properties | 4 +- src/main/resources/static/css/sebserver.css | 42 +------------------ 5 files changed, 42 insertions(+), 57 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/TableFieldBuilder.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/TableFieldBuilder.java index f61d569c..143e6a90 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/TableFieldBuilder.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/TableFieldBuilder.java @@ -193,7 +193,8 @@ public class TableFieldBuilder extends AbstractTableFieldBuilder { new ModalInputDialog>( this.control.getShell(), this.tableContext.getWidgetFactory()) - .setDialogWidth(500) + .setDialogWidth(600) + .setDialogHeight(550) .open( ExamConfigurationService.getTablePopupTitleKey( this.attribute, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/ModalInputDialog.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/ModalInputDialog.java index 1962703e..e695dbbe 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/ModalInputDialog.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/ModalInputDialog.java @@ -13,6 +13,7 @@ import java.util.function.Supplier; import org.eclipse.rap.rwt.RWT; import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -40,6 +41,7 @@ public class ModalInputDialog extends Dialog { private final WidgetFactory widgetFactory; private int dialogWidth = 400; + private int dialogHeight = 600; public ModalInputDialog( final Shell parent, @@ -55,6 +57,11 @@ public class ModalInputDialog extends Dialog { return this; } + public ModalInputDialog setDialogHeight(final int dialogHeight) { + this.dialogHeight = dialogHeight; + return this; + } + public void open( final LocTextKey title, final Consumer callback, @@ -69,6 +76,7 @@ public class ModalInputDialog extends Dialog { shell.setLayout(new GridLayout(2, true)); final GridData gridData2 = new GridData(SWT.FILL, SWT.TOP, false, false); gridData2.widthHint = this.dialogWidth; + //gridData2.heightHint = this.dialogHeight; shell.setLayoutData(gridData2); final Composite main = new Composite(shell, SWT.NONE); @@ -80,6 +88,9 @@ public class ModalInputDialog extends Dialog { final Supplier valueSuppier = contentComposer.compose(main); + final Point computeSize = main.computeSize(SWT.DEFAULT, SWT.DEFAULT); + gridData.heightHint = (computeSize.y < this.dialogHeight) ? computeSize.y : this.dialogHeight; + final Button ok = this.widgetFactory.buttonLocalized(shell, OK_TEXT_KEY); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END); data.widthHint = 100; diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/widget/GridTable.java b/src/main/java/ch/ethz/seb/sebserver/gui/widget/GridTable.java index b680b0d6..c8c50da9 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/widget/GridTable.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/widget/GridTable.java @@ -72,6 +72,8 @@ public class GridTable extends Composite { gridLayout.horizontalSpacing = 0; this.setLayout(gridLayout); + this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + this.columns = new ArrayList<>(); for (final ColumnDef columnDef : columnDefs) { final Label label = widgetFactory.labelLocalized( @@ -85,14 +87,15 @@ public class GridTable extends Composite { this.addAction = widgetFactory.imageButton( ImageIcon.ADD_BOX, this, - new LocTextKey(locTextKeyPrefix + "removeAction"), + new LocTextKey(locTextKeyPrefix + "addAction"), this::addRow); - final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); + final GridData gridData = new GridData(SWT.CENTER, SWT.FILL, true, true); gridData.widthHint = ACTION_COLUMN_WIDTH; this.addAction.setLayoutData(gridData); this.rows = new ArrayList<>(); this.addListener(SWT.Resize, this::adaptColumnWidth); + } public void setListener(final Listener listener) { @@ -198,14 +201,22 @@ public class GridTable extends Composite { private void adaptColumnWidth(final Event event) { try { -// final int currentTableWidth = this.getClientArea().width; -// final int dynWidth = currentTableWidth - ACTION_COLUMN_WIDTH; -// final int colWidth = dynWidth / this.columns.size(); -// for (final Column column : this.columns) { -// column.header.widthHint = 200;// colWidth; -// } + + // TODO the computeSize seems not to correspond with the width of of parent when display +// final Point computeSize = this.computeSize(SWT.DEFAULT, SWT.DEFAULT); +// final int widthUnits = this.columns +// .stream() +// .reduce( +// 0, +// (acc, c) -> acc + c.columnDef.widthFactor, +// (acc1, acc2) -> acc1 + acc2); +// final int widthUnit = computeSize.x / widthUnits; +// this.columns +// .stream() +// .forEach(c -> c.header.widthHint = c.columnDef.widthFactor * widthUnit); + this.columns.get(0).header.widthHint = 50; - this.columns.get(1).header.widthHint = 150; + this.columns.get(1).header.widthHint = 200; } catch (final Exception e) { log.warn("Failed to adaptColumnWidth: ", e); @@ -221,9 +232,10 @@ public class GridTable extends Composite { this.removeAction = GridTable.this.widgetFactory.imageButton( ImageIcon.REMOVE_BOX, GridTable.this, - new LocTextKey(GridTable.this.locTextKeyPrefix + "addAction"), + new LocTextKey(GridTable.this.locTextKeyPrefix + "removeAction"), event -> deleteRow(this)); - final GridData gridData = new GridData(SWT.LEFT, SWT.TOP, true, false); + final GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, true, true); + gridData.widthHint = ACTION_COLUMN_WIDTH; this.removeAction.setLayoutData(gridData); } @@ -263,7 +275,6 @@ public class GridTable extends Composite { this.defaultValue = defaultValue; } - // 2:argument:TEXT_FIELD public static final ColumnDef fromString( final String string, final Map defaultValueMap) { @@ -348,7 +359,7 @@ public class GridTable extends Composite { CheckBox(final Composite parent, final ColumnDef columnDef, final Listener listener) { this.checkbox = new Button(parent, SWT.CHECK); - this.checkbox.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + this.checkbox.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); this.columnDef = columnDef; if (listener != null) { this.checkbox.addListener(SWT.Selection, listener); @@ -385,7 +396,7 @@ public class GridTable extends Composite { TextField(final Composite parent, final ColumnDef columnDef, final Listener listener) { this.textField = new Text(parent, SWT.LEFT | SWT.BORDER); - this.textField.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + this.textField.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); this.columnDef = columnDef; this.textField.addListener(SWT.FocusOut, listener); this.textField.addListener(SWT.Traverse, listener); diff --git a/src/main/resources/config/application-demo.properties b/src/main/resources/config/application-demo.properties index b9fc1908..c85c0bae 100644 --- a/src/main/resources/config/application-demo.properties +++ b/src/main/resources/config/application-demo.properties @@ -15,7 +15,9 @@ sebserver.webservice.api.admin.clientId=guiClient sebserver.webservice.api.admin.endpoint=/admin-api/v1 sebserver.webservice.api.admin.accessTokenValiditySeconds=1800 sebserver.webservice.api.admin.refreshTokenValiditySeconds=-1 -sebserver.webservice.api.exam.endpoint=/exam-api/v1 +sebserver.webservice.api.exam.endpoint=/exam-api +sebserver.webservice.api.exam.endpoint.discovery=${sebserver.webservice.api.exam.endpoint}/discovery +sebserver.webservice.api.exam.endpoint.v1=${sebserver.webservice.api.exam.endpoint}/v1 sebserver.webservice.api.exam.accessTokenValiditySeconds=1800 sebserver.webservice.api.exam.refreshTokenValiditySeconds=-1 sebserver.webservice.api.redirect.unauthorized=http://0.0.0.0:8080/gui diff --git a/src/main/resources/static/css/sebserver.css b/src/main/resources/static/css/sebserver.css index 683c435a..dd62c281 100644 --- a/src/main/resources/static/css/sebserver.css +++ b/src/main/resources/static/css/sebserver.css @@ -250,7 +250,7 @@ Text[BORDER]:focused, Text[MULTI][BORDER]:focused { Text[BORDER]:disabled, Text[MULTI][BORDER]:disabled, Text[BORDER]:read-only, Text[MULTI][BORDER]:read-only { box-shadow: none; - color: #CFCFCF; + background-color: #f0f0f0; } @@ -678,46 +678,6 @@ TabItem:selected:hover:first { } -/* ScrollBar default theme */ -ScrollBar { - background-color: #c0c0c0; - background-image: none; - border: none; - border-radius: 0; - width: 10px; -} - -ScrollBar-Thumb { - background-color: #c0c0c0; - border: 1px solid #bdbdbd; - border-radius: 15px; - /*background-image: url( themes/images/scrollbar/scrollbar-background.png );*/ - min-height: 20px; -} - -ScrollBar-UpButton, ScrollBar-DownButton { - background-color: transparent; - border: none; - border-radius: 0; - cursor: default; -} -/* -ScrollBar-UpButton[HORIZONTAL] { - background-image: url( themes/images/scrollbar/right.png ); -} - -ScrollBar-DownButton[HORIZONTAL] { - background-image: url( themes/images/scrollbar/left.png ); -} - -ScrollBar-UpButton[VERTICAL] { - background-image: url( themes/images/scrollbar/down.png ) -} - -ScrollBar-DownButton[VERTICAL] { - background-image: url( themes/images/scrollbar/up.png ); -} -*/ Widget-ToolTip { padding: 1px 3px 2px 3px;