diff --git a/findbugs-excludes.xml b/findbugs-excludes.xml index 7586c635..da299227 100644 --- a/findbugs-excludes.xml +++ b/findbugs-excludes.xml @@ -19,7 +19,10 @@ - + + + + diff --git a/pom.xml b/pom.xml index f873ad42..2aa512e7 100644 --- a/pom.xml +++ b/pom.xml @@ -304,6 +304,10 @@ jncryptor 1.2.0 + + org.assertj + assertj-core + diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/LmsSetupForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/LmsSetupForm.java index 869dd5f3..994609bb 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/LmsSetupForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/LmsSetupForm.java @@ -178,7 +178,7 @@ public class LmsSetupForm implements TemplateComposer { .addField(FormBuilder.text( Domain.LMS_SETUP.ATTR_LMS_CLIENTNAME, FORM_CLIENTNAME_LMS_TEXT_KEY, - (lmsSetup.getLmsAuthName() != null) ? lmsSetup.getLmsAuthName().toString() : null)) + (lmsSetup.getLmsAuthName() != null) ? lmsSetup.getLmsAuthName() : null)) .addField(FormBuilder.text( Domain.LMS_SETUP.ATTR_LMS_CLIENTSECRET, FORM_SECRET_LMS_TEXT_KEY) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/form/FormBuilder.java b/src/main/java/ch/ethz/seb/sebserver/gui/form/FormBuilder.java index 38fdf9e2..e3d7787b 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/form/FormBuilder.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/form/FormBuilder.java @@ -14,6 +14,7 @@ import java.util.function.BooleanSupplier; import java.util.function.Supplier; import org.apache.commons.lang3.StringUtils; +import org.assertj.core.util.CheckReturnValue; import org.eclipse.rap.rwt.RWT; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; @@ -174,6 +175,7 @@ public class FormBuilder { return this; } + @CheckReturnValue public FormHandle build() { return buildFor(null); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/table/TableFilter.java b/src/main/java/ch/ethz/seb/sebserver/gui/table/TableFilter.java index e133c228..1c74230a 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/table/TableFilter.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/table/TableFilter.java @@ -62,10 +62,6 @@ public class TableFilter { layout.center = false; layout.fill = true; this.composite.setLayout(layout); - -// TODO just for debugging, remove when tested -// this.composite.setBackground(new Color(entityTable.composite.getDisplay(), new RGB(0, 0, 200))); - this.entityTable = entityTable; buildComponents(); } @@ -356,12 +352,14 @@ public class TableFilter { @Override FilterComponent reset() { - try { - final org.joda.time.DateTime parse = org.joda.time.DateTime.parse(this.attribute.initValue); - this.selector.setDate(parse.getYear(), parse.getMonthOfYear() - 1, parse.getDayOfMonth()); - } catch (final Exception e) { - final org.joda.time.DateTime now = org.joda.time.DateTime.now(DateTimeZone.UTC); - this.selector.setDate(now.getYear(), now.getMonthOfYear() - 1, now.getDayOfMonth()); + if (this.selector != null) { + try { + final org.joda.time.DateTime parse = org.joda.time.DateTime.parse(this.attribute.initValue); + this.selector.setDate(parse.getYear(), parse.getMonthOfYear() - 1, parse.getDayOfMonth()); + } catch (final Exception e) { + final org.joda.time.DateTime now = org.joda.time.DateTime.now(DateTimeZone.UTC); + this.selector.setDate(now.getYear(), now.getMonthOfYear() - 1, now.getDayOfMonth()); + } } return this; } @@ -429,13 +427,28 @@ public class TableFilter { @Override FilterComponent reset() { final org.joda.time.DateTime now = org.joda.time.DateTime.now(DateTimeZone.UTC); - try { - final org.joda.time.DateTime parse = org.joda.time.DateTime.parse(this.attribute.initValue); - this.fromSelector.setDate(parse.getYear(), parse.getMonthOfYear() - 1, parse.getDayOfMonth()); - } catch (final Exception e) { - this.fromSelector.setDate(now.getYear(), now.getMonthOfYear() - 1, now.getDayOfMonth()); + if (this.fromSelector != null) { + try { + final org.joda.time.DateTime parse = org.joda.time.DateTime.parse(this.attribute.initValue); + + this.fromSelector.setDate( + parse.getYear(), + parse.getMonthOfYear() - 1, + parse.getDayOfMonth()); + + } catch (final Exception e) { + this.fromSelector.setDate( + now.getYear(), + now.getMonthOfYear() - 1, + now.getDayOfMonth()); + } + } + if (this.toSelector != null) { + this.toSelector.setDate( + now.getYear(), + now.getMonthOfYear() - 1, + now.getDayOfMonth()); } - this.toSelector.setDate(now.getYear(), now.getMonthOfYear() - 1, now.getDayOfMonth()); return this; } diff --git a/src/main/resources/data-demo.sql b/src/main/resources/data-demo.sql index 97a06048..2a8c5a0e 100644 --- a/src/main/resources/data-demo.sql +++ b/src/main/resources/data-demo.sql @@ -165,7 +165,7 @@ INSERT IGNORE INTO configuration_attribute VALUES (203, 'URLFilterRules.active', 'CHECKBOX', 202, null, null, null, 'true'), (204, 'URLFilterRules.regex', 'CHECKBOX', 202, null, null, null, 'false'), (205, 'URLFilterRules.expression', 'TEXT_FIELD', 202, null, null, null, ''), - (206, 'URLFilterRules.action', 'SINGLE_SELECTION', 202, '0,1', null, null, ''), + (206, 'URLFilterRules.action', 'SINGLE_SELECTION', 202, '0,1', null, null, '0'), (210, 'proxySettingsPolicy', 'RADIO_SELECTION', null, '0,1', null, null, '0'), (220, 'proxies', 'COMPOSITE_TABLE', null, 'active,TABLE_ENTRY|autoDiscovery,autoConfiguration,http,https,ftp,socks,rtsp', null, null, null), diff --git a/src/main/resources/data-prod.sql b/src/main/resources/data-prod.sql index 11f846b3..a356599f 100644 --- a/src/main/resources/data-prod.sql +++ b/src/main/resources/data-prod.sql @@ -139,7 +139,7 @@ INSERT IGNORE INTO configuration_attribute VALUES (203, 'URLFilterRules.active', 'CHECKBOX', 202, null, null, null, 'true'), (204, 'URLFilterRules.regex', 'CHECKBOX', 202, null, null, null, 'false'), (205, 'URLFilterRules.expression', 'TEXT_FIELD', 202, null, null, null, ''), - (206, 'URLFilterRules.action', 'SINGLE_SELECTION', 202, '0,1', null, null, ''), + (206, 'URLFilterRules.action', 'SINGLE_SELECTION', 202, '0,1', null, null, '0'), (210, 'proxySettingsPolicy', 'RADIO_SELECTION', null, '0,1', null, null, '0'), (220, 'proxies', 'COMPOSITE_TABLE', null, 'active,TABLE_ENTRY|autoDiscovery,autoConfiguration,http,https,ftp,socks,rtsp', null, null, null),