finished arguments dyn table
This commit is contained in:
parent
d717412c89
commit
fecedefe93
7 changed files with 94 additions and 62 deletions
|
@ -72,7 +72,7 @@ public class InlineTableFieldBuilder implements InputFieldBuilder {
|
||||||
Constants.FORM_URL_ENCODED_NAME_VALUE_SEPARATOR))
|
Constants.FORM_URL_ENCODED_NAME_VALUE_SEPARATOR))
|
||||||
.collect(Collectors.toMap(
|
.collect(Collectors.toMap(
|
||||||
valueMap -> valueMap[0],
|
valueMap -> valueMap[0],
|
||||||
valueMap -> (valueMap.length > 1) ? valueMap[1] : ""));
|
valueMap -> (valueMap.length > 1) ? valueMap[1] : StringUtils.EMPTY));
|
||||||
|
|
||||||
final List<ColumnDef> columns = Arrays.asList(StringUtils.split(
|
final List<ColumnDef> columns = Arrays.asList(StringUtils.split(
|
||||||
attribute.getResources(),
|
attribute.getResources(),
|
||||||
|
@ -84,7 +84,7 @@ public class InlineTableFieldBuilder implements InputFieldBuilder {
|
||||||
final GridTable gridTable = new GridTable(
|
final GridTable gridTable = new GridTable(
|
||||||
innerGrid,
|
innerGrid,
|
||||||
columns,
|
columns,
|
||||||
ExamConfigurationService.ATTRIBUTE_LABEL_LOC_TEXT_PREFIX,
|
ExamConfigurationService.ATTRIBUTE_LABEL_LOC_TEXT_PREFIX + attribute.name + ".",
|
||||||
this.widgetFactory);
|
this.widgetFactory);
|
||||||
|
|
||||||
final InlineTableInputField inlineTableInputField = new InlineTableInputField(
|
final InlineTableInputField inlineTableInputField = new InlineTableInputField(
|
||||||
|
|
|
@ -17,9 +17,6 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.eclipse.rap.rwt.RWT;
|
import org.eclipse.rap.rwt.RWT;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.custom.ScrolledComposite;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
@ -35,6 +32,7 @@ import ch.ethz.seb.sebserver.gui.service.examconfig.InputFieldBuilder;
|
||||||
import ch.ethz.seb.sebserver.gui.service.examconfig.impl.TableFieldBuilder.TableInputField;
|
import ch.ethz.seb.sebserver.gui.service.examconfig.impl.TableFieldBuilder.TableInputField;
|
||||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||||
import ch.ethz.seb.sebserver.gui.service.page.ModalInputDialogComposer;
|
import ch.ethz.seb.sebserver.gui.service.page.ModalInputDialogComposer;
|
||||||
|
import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
||||||
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.CustomVariant;
|
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.CustomVariant;
|
||||||
|
|
||||||
public class TableRowFormBuilder implements ModalInputDialogComposer<Map<Long, TableValue>> {
|
public class TableRowFormBuilder implements ModalInputDialogComposer<Map<Long, TableValue>> {
|
||||||
|
@ -56,39 +54,19 @@ public class TableRowFormBuilder implements ModalInputDialogComposer<Map<Long, T
|
||||||
@Override
|
@Override
|
||||||
public Supplier<Map<Long, TableValue>> compose(final Composite parent) {
|
public Supplier<Map<Long, TableValue>> compose(final Composite parent) {
|
||||||
|
|
||||||
final ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.BORDER | SWT.V_SCROLL);
|
final Composite grid = PageService.createManagedVScrolledComposite(
|
||||||
final GridData gridData3 = new GridData(SWT.LEFT, SWT.TOP, true, true);
|
parent,
|
||||||
// gridData3.horizontalSpan = 2;
|
scrolledComposite -> {
|
||||||
// gridData3.widthHint = 400;
|
final Composite result = this.tableContext
|
||||||
// gridData3.heightHint = 400;
|
.getWidgetFactory()
|
||||||
scrolledComposite.setLayoutData(gridData3);
|
.formGrid(scrolledComposite, 2);
|
||||||
|
final GridLayout layout = (GridLayout) result.getLayout();
|
||||||
|
layout.verticalSpacing = 0;
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
false);
|
||||||
|
|
||||||
final List<InputField> inputFields = new ArrayList<>();
|
final List<InputField> inputFields = new ArrayList<>();
|
||||||
final Composite grid = this.tableContext
|
|
||||||
.getWidgetFactory()
|
|
||||||
.formGrid(scrolledComposite, 2);
|
|
||||||
grid.setBackground(new Color(grid.getDisplay(), new RGB(100, 100, 100)));
|
|
||||||
final GridLayout layout = (GridLayout) grid.getLayout();
|
|
||||||
layout.verticalSpacing = 0;
|
|
||||||
final GridData gridData = (GridData) grid.getLayoutData();
|
|
||||||
gridData.grabExcessVerticalSpace = false;
|
|
||||||
gridData.verticalAlignment = SWT.ON_TOP;
|
|
||||||
|
|
||||||
scrolledComposite.setContent(grid);
|
|
||||||
scrolledComposite.setExpandHorizontal(true);
|
|
||||||
scrolledComposite.setExpandVertical(true);
|
|
||||||
scrolledComposite.setSize(parent.computeSize(400, SWT.DEFAULT));
|
|
||||||
scrolledComposite.setAlwaysShowScrollBars(true);
|
|
||||||
scrolledComposite.addListener(SWT.Resize, event -> {
|
|
||||||
scrolledComposite.setMinSize(grid.computeSize(400, SWT.DEFAULT));
|
|
||||||
// main.setSize(shell.computeSize(this.dialogWidth, SWT.DEFAULT));
|
|
||||||
System.out.println("*************************");
|
|
||||||
});
|
|
||||||
grid.addListener(SWT.Resize, event -> {
|
|
||||||
// main.setSize(shell.computeSize(this.dialogWidth, SWT.DEFAULT));
|
|
||||||
System.out.println("*************************");
|
|
||||||
});
|
|
||||||
|
|
||||||
for (final ConfigurationAttribute attribute : this.tableContext.getRowAttributes()) {
|
for (final ConfigurationAttribute attribute : this.tableContext.getRowAttributes()) {
|
||||||
createLabel(grid, attribute);
|
createLabel(grid, attribute);
|
||||||
inputFields.add(createInputField(grid, attribute));
|
inputFields.add(createInputField(grid, attribute));
|
||||||
|
|
|
@ -14,6 +14,10 @@ import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.custom.ScrolledComposite;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -157,6 +161,68 @@ public interface PageService {
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Key to store the ScrolledComposite update function within Control data map */
|
||||||
|
static String SCROLLED_COMPOSITE_UPDATE = "SCROLLED_COMPOSITE_UPDATE";
|
||||||
|
|
||||||
|
/** Creates a ScrolledComposite with content supplied the given content creation function.
|
||||||
|
* The content creation function is used to create the content Composite as a child of the
|
||||||
|
* newly created ScrolledComposite.
|
||||||
|
* Also adds an update function within the ScrolledComposite Data mapping. If a child inside
|
||||||
|
* the ScrolledComposite changes its dimensions the method updateScrolledComposite must be
|
||||||
|
* called to update the ScrolledComposite scrolled content.
|
||||||
|
*
|
||||||
|
* @param parent the parent Composite of the ScrolledComposite
|
||||||
|
* @param contentFunction the content creation function
|
||||||
|
* @param showScrollbars indicates whether the scrollbar shall always be shown
|
||||||
|
* @return the child composite that is scrolled by the newly created ScrolledComposite */
|
||||||
|
static Composite createManagedVScrolledComposite(
|
||||||
|
final Composite parent,
|
||||||
|
final Function<ScrolledComposite, Composite> contentFunction,
|
||||||
|
final boolean showScrollbars) {
|
||||||
|
|
||||||
|
final ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.BORDER | SWT.V_SCROLL);
|
||||||
|
scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
|
||||||
|
|
||||||
|
final Composite content = contentFunction.apply(scrolledComposite);
|
||||||
|
scrolledComposite.setContent(content);
|
||||||
|
scrolledComposite.setExpandHorizontal(true);
|
||||||
|
scrolledComposite.setExpandVertical(true);
|
||||||
|
scrolledComposite.setSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
||||||
|
if (showScrollbars) {
|
||||||
|
scrolledComposite.setAlwaysShowScrollBars(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Runnable update = () -> {
|
||||||
|
scrolledComposite.setMinSize(content.computeSize(SWT.DEFAULT - 20, SWT.DEFAULT));
|
||||||
|
;
|
||||||
|
};
|
||||||
|
|
||||||
|
scrolledComposite.addListener(SWT.Resize, event -> update.run());
|
||||||
|
scrolledComposite.setData(SCROLLED_COMPOSITE_UPDATE, update);
|
||||||
|
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Used to update the crolledComposite when some if its content has dynamically changed
|
||||||
|
* its dimensions.
|
||||||
|
*
|
||||||
|
* @param composite The Component that changed its dimensions */
|
||||||
|
static void updateScrolledComposite(final Composite composite) {
|
||||||
|
if (composite == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Composite parent = composite.getParent();
|
||||||
|
while (parent != null) {
|
||||||
|
final Object update = parent.getData(SCROLLED_COMPOSITE_UPDATE);
|
||||||
|
if (update != null) {
|
||||||
|
((Runnable) update).run();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
parent = parent.getParent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class PageActionBuilder {
|
public class PageActionBuilder {
|
||||||
private final PageService pageService;
|
private final PageService pageService;
|
||||||
private final PageContext originalPageContext;
|
private final PageContext originalPageContext;
|
||||||
|
|
|
@ -13,8 +13,6 @@ import java.util.function.Supplier;
|
||||||
|
|
||||||
import org.eclipse.rap.rwt.RWT;
|
import org.eclipse.rap.rwt.RWT;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
import org.eclipse.swt.graphics.Rectangle;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
@ -78,9 +76,7 @@ public class ModalInputDialog<T> extends Dialog {
|
||||||
final GridData gridData = new GridData(SWT.FILL, SWT.TOP, false, false);
|
final GridData gridData = new GridData(SWT.FILL, SWT.TOP, false, false);
|
||||||
gridData.horizontalSpan = 2;
|
gridData.horizontalSpan = 2;
|
||||||
gridData.widthHint = this.dialogWidth;
|
gridData.widthHint = this.dialogWidth;
|
||||||
// gridData.heightHint = 400;
|
|
||||||
main.setLayoutData(gridData);
|
main.setLayoutData(gridData);
|
||||||
main.setBackground(new Color(shell.getDisplay(), new RGB(1, 2, 3)));
|
|
||||||
|
|
||||||
final Supplier<T> valueSuppier = contentComposer.compose(main);
|
final Supplier<T> valueSuppier = contentComposer.compose(main);
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ import java.util.stream.Collectors;
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.custom.ScrolledComposite;
|
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Button;
|
import org.eclipse.swt.widgets.Button;
|
||||||
|
@ -34,6 +33,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import ch.ethz.seb.sebserver.gbl.Constants;
|
import ch.ethz.seb.sebserver.gbl.Constants;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.AttributeType;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.AttributeType;
|
||||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||||
|
import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
||||||
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.ImageIcon;
|
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.ImageIcon;
|
||||||
|
|
||||||
public class GridTable extends Composite {
|
public class GridTable extends Composite {
|
||||||
|
@ -66,21 +66,17 @@ public class GridTable extends Composite {
|
||||||
final GridLayout gridLayout = new GridLayout(columnDefs.size() + 1, false);
|
final GridLayout gridLayout = new GridLayout(columnDefs.size() + 1, false);
|
||||||
gridLayout.verticalSpacing = 1;
|
gridLayout.verticalSpacing = 1;
|
||||||
gridLayout.marginLeft = 0;
|
gridLayout.marginLeft = 0;
|
||||||
gridLayout.marginHeight = 0;
|
gridLayout.marginHeight = 5;
|
||||||
gridLayout.marginWidth = 0;
|
gridLayout.marginWidth = 0;
|
||||||
gridLayout.horizontalSpacing = 0;
|
gridLayout.horizontalSpacing = 0;
|
||||||
this.setLayout(gridLayout);
|
this.setLayout(gridLayout);
|
||||||
// this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
|
||||||
|
|
||||||
this.columns = new ArrayList<>();
|
this.columns = new ArrayList<>();
|
||||||
for (final ColumnDef columnDef : columnDefs) {
|
for (final ColumnDef columnDef : columnDefs) {
|
||||||
final Label label = new Label(this, SWT.NONE);
|
final Label label = widgetFactory.labelLocalized(
|
||||||
label.setText("column");
|
this,
|
||||||
//widgetFactory.labelLocalized(
|
new LocTextKey(locTextKeyPrefix + columnDef.name));
|
||||||
// this,
|
|
||||||
// new LocTextKey(locTextKeyPrefix + columnDef.name));
|
|
||||||
final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
// gridData.widthHint = 50;
|
|
||||||
label.setLayoutData(gridData);
|
label.setLayoutData(gridData);
|
||||||
this.columns.add(new Column(columnDef, label, gridData));
|
this.columns.add(new Column(columnDef, label, gridData));
|
||||||
}
|
}
|
||||||
|
@ -88,7 +84,7 @@ public class GridTable extends Composite {
|
||||||
this.addAction = widgetFactory.imageButton(
|
this.addAction = widgetFactory.imageButton(
|
||||||
ImageIcon.ADD_BOX,
|
ImageIcon.ADD_BOX,
|
||||||
this,
|
this,
|
||||||
new LocTextKey(locTextKeyPrefix + "addAction"),
|
new LocTextKey(locTextKeyPrefix + "removeAction"),
|
||||||
this::addRow);
|
this::addRow);
|
||||||
final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
gridData.widthHint = ACTION_COLUMN_WIDTH;
|
gridData.widthHint = ACTION_COLUMN_WIDTH;
|
||||||
|
@ -118,16 +114,7 @@ public class GridTable extends Composite {
|
||||||
|
|
||||||
public void adaptLayout() {
|
public void adaptLayout() {
|
||||||
this.getParent().getParent().layout(true, true);
|
this.getParent().getParent().layout(true, true);
|
||||||
|
PageService.updateScrolledComposite(this);
|
||||||
Composite parent = this.getParent();
|
|
||||||
while (parent != null && !(parent instanceof ScrolledComposite)) {
|
|
||||||
parent = parent.getParent();
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("********************** " + parent);
|
|
||||||
if (parent != null) {
|
|
||||||
((ScrolledComposite) parent).setMinSize(this.getParent().getParent().computeSize(400, SWT.DEFAULT));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void addRow(final String values) {
|
void addRow(final String values) {
|
||||||
|
|
|
@ -511,6 +511,9 @@ public class WidgetFactory {
|
||||||
return imageUpload;
|
return imageUpload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ************************************************************
|
||||||
|
// TODO code from below should move to PolyglotPageService or a utility of that
|
||||||
|
|
||||||
public void injectI18n(final ImageUpload imageUpload, final LocTextKey locTextKey) {
|
public void injectI18n(final ImageUpload imageUpload, final LocTextKey locTextKey) {
|
||||||
final Consumer<ImageUpload> imageUploadFunction = iu -> {
|
final Consumer<ImageUpload> imageUploadFunction = iu -> {
|
||||||
if (locTextKey != null) {
|
if (locTextKey != null) {
|
||||||
|
|
|
@ -558,8 +558,10 @@ sebserver.examconfig.props.label.permittedProcesses.originalName=Original Name
|
||||||
sebserver.examconfig.props.label.permittedProcesses.allowedExecutables=Window handling process
|
sebserver.examconfig.props.label.permittedProcesses.allowedExecutables=Window handling process
|
||||||
sebserver.examconfig.props.label.permittedProcesses.path=Path
|
sebserver.examconfig.props.label.permittedProcesses.path=Path
|
||||||
sebserver.examconfig.props.label.permittedProcesses.arguments=Arguments
|
sebserver.examconfig.props.label.permittedProcesses.arguments=Arguments
|
||||||
sebserver.examconfig.props.label.arguments.active=Activity
|
sebserver.examconfig.props.label.permittedProcesses.arguments.active=Active
|
||||||
sebserver.examconfig.props.label.arguments.argument=Argument
|
sebserver.examconfig.props.label.permittedProcesses.arguments.argument=Argument
|
||||||
|
sebserver.examconfig.props.label.permittedProcesses.arguments.addAction=Add new argument
|
||||||
|
sebserver.examconfig.props.label.permittedProcesses.arguments.removeAction=Remove this argument
|
||||||
sebserver.examconfig.props.label.permittedProcesses.identifier=Identifier
|
sebserver.examconfig.props.label.permittedProcesses.identifier=Identifier
|
||||||
sebserver.examconfig.props.label.permittedProcesses.iconInTaskbar=Icon in taskbar
|
sebserver.examconfig.props.label.permittedProcesses.iconInTaskbar=Icon in taskbar
|
||||||
sebserver.examconfig.props.label.permittedProcesses.autostart=Autostart
|
sebserver.examconfig.props.label.permittedProcesses.autostart=Autostart
|
||||||
|
|
Loading…
Reference in a new issue