fixed import of InlineTable and added new icons

This commit is contained in:
anhefti 2019-11-14 12:44:16 +01:00
parent 943017073b
commit 12b4776b87
10 changed files with 82 additions and 32 deletions

View file

@ -24,7 +24,7 @@ public enum ActionDefinition {
PageStateDefinitionImpl.INSTITUTION_VIEW),
INSTITUTION_NEW(
new LocTextKey("sebserver.institution.action.new"),
ImageIcon.NEW,
ImageIcon.INSTITUTION,
PageStateDefinitionImpl.INSTITUTION_EDIT),
INSTITUTION_VIEW_FROM_LIST(
new LocTextKey("sebserver.institution.action.list.view"),
@ -70,7 +70,7 @@ public enum ActionDefinition {
PageStateDefinitionImpl.USER_ACCOUNT_VIEW),
USER_ACCOUNT_NEW(
new LocTextKey("sebserver.useraccount.action.new"),
ImageIcon.NEW,
ImageIcon.USER,
PageStateDefinitionImpl.USER_ACCOUNT_EDIT),
USER_ACCOUNT_VIEW_FROM_LIST(
new LocTextKey("sebserver.useraccount.action.view"),
@ -123,7 +123,7 @@ public enum ActionDefinition {
PageStateDefinitionImpl.LMS_SETUP_LIST),
LMS_SETUP_NEW(
new LocTextKey("sebserver.lmssetup.action.new"),
ImageIcon.NEW,
ImageIcon.LMS_SETUP,
PageStateDefinitionImpl.LMS_SETUP_EDIT),
LMS_SETUP_VIEW_FROM_LIST(
new LocTextKey("sebserver.lmssetup.action.list.view"),
@ -279,7 +279,7 @@ public enum ActionDefinition {
EXAM_INDICATOR_NEW(
new LocTextKey("sebserver.exam.indicator.action.list.new"),
ImageIcon.NEW,
ImageIcon.INDICATOR,
PageStateDefinitionImpl.INDICATOR_EDIT,
ActionCategory.INDICATOR_LIST),
EXAM_INDICATOR_MODIFY_FROM_LIST(
@ -441,7 +441,7 @@ public enum ActionDefinition {
SEB_EXAM_CONFIG_TEMPLATE_NEW(
new LocTextKey("sebserver.configtemplate.action.list.new"),
ImageIcon.NEW,
ImageIcon.TEMPLATE,
PageStateDefinitionImpl.SEB_EXAM_CONFIG_TEMPLATE_EDIT,
ActionCategory.VARIA),
SEB_EXAM_CONFIG_TEMPLATE_VIEW_FROM_LIST(

View file

@ -203,20 +203,6 @@ public class GridTable extends Composite {
private void adaptColumnWidth(final Event event) {
try {
// 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 = 200;

View file

@ -89,7 +89,12 @@ public class WidgetFactory {
DELETE("delete.png"),
SEARCH("lens.png"),
UNDO("undo.png"),
COLOR("color.png");
COLOR("color.png"),
USER("user.png"),
INSTITUTION("institution.png"),
LMS_SETUP("lmssetup.png"),
INDICATOR("indicator.png"),
TEMPLATE("template.png");
private String fileName;
private ImageData image = null;

View file

@ -41,6 +41,9 @@ public class ExamConfigImportHandler extends DefaultHandler {
Constants.XML_PLIST_DATA,
Constants.XML_PLIST_INTEGER));
private static final Set<String> KNOWN_INLINE_TABLES = new HashSet<>(Arrays.asList(
"arguments"));
private final Consumer<ConfigurationValue> valueConsumer;
private final Function<String, ConfigurationAttribute> attributeResolver;
private final Long institutionId;
@ -126,6 +129,7 @@ public class ExamConfigImportHandler extends DefaultHandler {
final PListNode array = new PListNode(type);
switch (top.type) {
case KEY: {
array.inlineTable = isInlineTable(top.name);
array.name = top.name;
array.listIndex = top.listIndex;
this.stack.pop();
@ -137,6 +141,10 @@ public class ExamConfigImportHandler extends DefaultHandler {
}
}
private boolean isInlineTable(final String name) {
return KNOWN_INLINE_TABLES.contains(name);
}
private void startDict(final Type type, final PListNode top) {
final PListNode dict = new PListNode(type);
switch (top.type) {
@ -218,7 +226,7 @@ public class ExamConfigImportHandler extends DefaultHandler {
final PListNode grandParent = this.stack.peek();
this.stack.push(parent);
// if we are in an values-array
// if we are in a values-array
if (parent.type == Type.ARRAY) {
if (StringUtils.isBlank(parent.value)) {
parent.value = top.value;
@ -228,6 +236,21 @@ public class ExamConfigImportHandler extends DefaultHandler {
return;
}
// if we are in an inline table array
if (grandParent.type == Type.ARRAY && grandParent.inlineTable) {
if (StringUtils.isBlank(grandParent.value)) {
grandParent.value = top.value;
} else {
grandParent.value += "," + top.value;
}
if (StringUtils.isBlank(grandParent.valueName)) {
grandParent.valueName = top.name;
} else {
grandParent.valueName += "," + top.name;
}
return;
}
final String attrName = (parent.type == Type.DICT && grandParent.type == Type.ARRAY)
? parent.name + "." + top.name
: top.name;
@ -251,6 +274,11 @@ public class ExamConfigImportHandler extends DefaultHandler {
return;
}
if (top.inlineTable) {
createInlineTableValue(top, attrName, attribute);
return;
}
// check if we have a simple values array
if (attribute.type == AttributeType.MULTI_CHECKBOX_SELECTION
|| attribute.type == AttributeType.MULTI_SELECTION) {
@ -263,6 +291,35 @@ public class ExamConfigImportHandler extends DefaultHandler {
}
}
private void createInlineTableValue(
final PListNode top,
final String attrName,
final ConfigurationAttribute attribute) {
final String[] names = StringUtils.split(top.valueName, Constants.LIST_SEPARATOR);
final String[] values = StringUtils.split(top.value, Constants.LIST_SEPARATOR);
final String[] columns = StringUtils.split(attribute.getResources(), Constants.EMBEDDED_LIST_SEPARATOR);
final int numColumns = columns.length;
if (names.length != values.length) {
throw new IllegalArgumentException(
"Failed to import InlineTable values. value/name array length mismatch");
}
String val = "";
for (int i = 0; i < names.length; i++) {
if (i != 0) {
if (i % numColumns == 0) {
val = val + Constants.LIST_SEPARATOR;
} else {
val = val + Constants.EMBEDDED_LIST_SEPARATOR;
}
}
val = val + names[i] + Constants.FORM_URL_ENCODED_NAME_VALUE_SEPARATOR + values[i];
}
saveValue(attrName, attribute, top.listIndex, val);
}
@Override
public void characters(
final char[] ch,
@ -390,9 +447,11 @@ public class ExamConfigImportHandler extends DefaultHandler {
}
final Type type;
boolean inlineTable = false;
String name;
int arrayCounter = 0;
int listIndex = 0;
String valueName;
String value;
boolean saveNullValueAsBlank = false;

View file

@ -368,9 +368,9 @@ sebserver.exam.indicator.type.ERROR_COUNT=Error Count
sebserver.exam.indicator.info.pleaseSelect=Please select an indicator first
sebserver.exam.indicator.action.list.new=New
sebserver.exam.indicator.action.list.modify=Edit Selected
sebserver.exam.indicator.action.list.delete=Delete Selected
sebserver.exam.indicator.action.list.new=Add Indicator
sebserver.exam.indicator.action.list.modify=Edit Selected Indicator
sebserver.exam.indicator.action.list.delete=Delete Selected Indicator
sebserver.exam.indicator.action.save=Save
sebserver.exam.indicator.form.title=Indicator
@ -458,7 +458,7 @@ sebserver.examconfig.action.undo.success=Successfully reverted to last saved sta
sebserver.examconfig.action.copy=Copy Configuration
sebserver.examconfig.action.export.plainxml=Export Configuration
sebserver.examconfig.action.get-config-key=Export Config-Key
sebserver.examconfig.action.import-config=Import Configuration
sebserver.examconfig.action.import-config=Import Exam Configuration
sebserver.examconfig.action.import-file-select=Import From File
sebserver.examconfig.action.import-file-password=Password
sebserver.examconfig.action.import-config.confirm=Configuration successfully imported
@ -953,17 +953,17 @@ sebserver.configtemplate.list.actions=Selected Template
sebserver.configtemplate.info.pleaseSelect=Please select an exam configuration template first
sebserver.configtemplate.action.list.new=Add Template
sebserver.configtemplate.action.list.view=View Template
sebserver.configtemplate.action.view=View Template
sebserver.configtemplate.action.list.modify=Edit Template
sebserver.configtemplate.action.modify=Edit Template
sebserver.configtemplate.action.list.new=Add Configuration Template
sebserver.configtemplate.action.list.view=View Configuration Template
sebserver.configtemplate.action.view=View Configuration Template
sebserver.configtemplate.action.list.modify=Edit Configuration Template
sebserver.configtemplate.action.modify=Edit Configuration Template
sebserver.configtemplate.form.title.new=Add Template
sebserver.configtemplate.form.title.new=Add Configuration Template
sebserver.configtemplate.form.title=Configuration Template
sebserver.configtemplate.form.name=Name
sebserver.configtemplate.form.description=Description
sebserver.configtemplate.action.save=Save Template
sebserver.configtemplate.action.save=Save Configuration Template
sebserver.configtemplate.attr.type.TEXT_FIELD=Text Field
sebserver.configtemplate.attr.type.PASSWORD_FIELD=Password Field

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B