From: Jens Jansson Date: Wed, 18 Jan 2012 13:16:12 +0000 (+0200) Subject: #8019 Did a bunch of null checks for possible faulty null states which was not possib... X-Git-Tag: 7.0.0.alpha2~540 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2b29b8298054617fef7e6a170b47a75d689be645;p=vaadin-framework.git #8019 Did a bunch of null checks for possible faulty null states which was not possible when we still used primitives. --- diff --git a/src/com/vaadin/data/validator/CompositeValidator.java b/src/com/vaadin/data/validator/CompositeValidator.java index 083af70f30..956d773032 100644 --- a/src/com/vaadin/data/validator/CompositeValidator.java +++ b/src/com/vaadin/data/validator/CompositeValidator.java @@ -155,7 +155,7 @@ public class CompositeValidator implements Validator { */ public void setMode(CombinationMode mode) { if (mode == null) { - throw new IllegalStateException( + throw new IllegalArgumentException( "The validator can't be set to null"); } this.mode = mode; diff --git a/src/com/vaadin/terminal/Sizeable.java b/src/com/vaadin/terminal/Sizeable.java index 055c74f20f..e3c98e0fa9 100644 --- a/src/com/vaadin/terminal/Sizeable.java +++ b/src/com/vaadin/terminal/Sizeable.java @@ -129,14 +129,14 @@ public interface Sizeable extends Serializable { public static Unit getUnitFromSymbol(String symbol) { if (symbol == null) { - return null; + return Unit.PIXELS; // Defaults to pixels } for (Unit unit : Unit.values()) { if (symbol.equals(unit.getSymbol())) { return unit; } } - return null; + return Unit.PIXELS; // Defaults to pixels } } diff --git a/src/com/vaadin/terminal/UserError.java b/src/com/vaadin/terminal/UserError.java index 1cb79c146a..8ec45ac725 100644 --- a/src/com/vaadin/terminal/UserError.java +++ b/src/com/vaadin/terminal/UserError.java @@ -89,6 +89,12 @@ public class UserError implements ErrorMessage { public UserError(String message, ContentMode contentMode, ErrorLevel errorLevel) { + if (contentMode == null) { + contentMode = ContentMode.TEXT; + } + if (errorLevel == null) { + errorLevel = ErrorLevel.ERROR; + } msg = message; mode = contentMode; level = errorLevel; diff --git a/src/com/vaadin/ui/AbstractComponent.java b/src/com/vaadin/ui/AbstractComponent.java index 4b9449c598..026b64299a 100644 --- a/src/com/vaadin/ui/AbstractComponent.java +++ b/src/com/vaadin/ui/AbstractComponent.java @@ -1324,9 +1324,12 @@ public abstract class AbstractComponent implements Component, MethodEventSource /* * (non-Javadoc) * - * @see com.vaadin.terminal.Sizeable#setHeight(float, int) + * @see com.vaadin.terminal.Sizeable#setHeight(float, Unit) */ public void setHeight(float height, Unit unit) { + if (unit == null) { + throw new IllegalArgumentException("Unit can not be null"); + } this.height = height; heightUnit = unit; requestRepaint(); @@ -1356,9 +1359,12 @@ public abstract class AbstractComponent implements Component, MethodEventSource /* * (non-Javadoc) * - * @see com.vaadin.terminal.Sizeable#setWidth(float, int) + * @see com.vaadin.terminal.Sizeable#setWidth(float, Unit) */ public void setWidth(float width, Unit unit) { + if (unit == null) { + throw new IllegalArgumentException("Unit can not be null"); + } this.width = width; widthUnit = unit; requestRepaint(); diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java index a51344b00f..ccc68e06b0 100644 --- a/src/com/vaadin/ui/Table.java +++ b/src/com/vaadin/ui/Table.java @@ -1058,13 +1058,13 @@ public class Table extends AbstractSelect implements Action.Container, * @return the header for the specified column if it has one. */ public String getColumnHeader(Object propertyId) { - if (getColumnHeaderMode() == COLUMN_HEADER_MODE_HIDDEN) { + if (getColumnHeaderMode() == ColumnHeaderMode.HIDDEN) { return null; } String header = columnHeaders.get(propertyId); - if ((header == null && getColumnHeaderMode() == COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID) - || getColumnHeaderMode() == COLUMN_HEADER_MODE_ID) { + if ((header == null && getColumnHeaderMode() == ColumnHeaderMode.EXPLICIT_DEFAULTS_ID) + || getColumnHeaderMode() == ColumnHeaderMode.ID) { header = propertyId.toString(); } @@ -1432,6 +1432,9 @@ public class Table extends AbstractSelect implements Action.Container, * the New value of property columnHeaderMode. */ public void setColumnHeaderMode(ColumnHeaderMode columnHeaderMode) { + if(columnHeaderMode == null){ + throw new IllegalArgumentException("Column header mode can not be null"); + } if (columnHeaderMode != this.columnHeaderMode) { this.columnHeaderMode = columnHeaderMode; requestRepaint(); @@ -2950,7 +2953,7 @@ public class Table extends AbstractSelect implements Action.Container, } private boolean areColumnHeadersEnabled() { - return getColumnHeaderMode() != COLUMN_HEADER_MODE_HIDDEN; + return getColumnHeaderMode() != ColumnHeaderMode.HIDDEN; } private void paintVisibleColumns(PaintTarget target) throws PaintException {