diff -r e0d6e9bd3ca7 -r bf7ee68962da javauis/lcdui_qt/src/javax/microedition/lcdui/Gauge.java --- a/javauis/lcdui_qt/src/javax/microedition/lcdui/Gauge.java Tue Jul 06 14:10:26 2010 +0300 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/Gauge.java Wed Aug 18 09:43:15 2010 +0300 @@ -23,7 +23,6 @@ */ public class Gauge extends Item { - /** * Indefinite constant. */ @@ -49,9 +48,17 @@ */ public static final int INCREMENTAL_UPDATING = 3; + /** + * If Gauge is changed, reasons for Re-layouting. + */ + static final int UPDATE_MAXVALUE = UPDATE_ITEM_MAX << 1; + static final int UPDATE_VALUE = UPDATE_ITEM_MAX << 2; + + private int maxValue; private int value; private boolean interactive; + private boolean isGaugeCreation; /** * Constructor. @@ -64,9 +71,11 @@ public Gauge(String name, boolean interactive, int maxVal, int initVal) { setLabel(name); + isGaugeCreation = true; this.interactive = interactive; setMaxValue(maxVal); setValue(initVal); + isGaugeCreation = false; } /** @@ -76,22 +85,30 @@ * @param maxVal the maximum value. * @return validated value. */ - private static int checkValue(int value, int maxVal) + private int checkValue(int value, int maxVal) { if(maxVal == INDEFINITE) { - switch(value) + if(isGaugeCreation) { - case CONTINUOUS_IDLE: - case INCREMENTAL_IDLE: - case CONTINUOUS_RUNNING: - case INCREMENTAL_UPDATING: - break; - default: - throw new IllegalArgumentException( - MsgRepository.GAUGE_EXCEPTION_INVALID_VALUE); + switch(value) + { + case CONTINUOUS_IDLE: + case INCREMENTAL_IDLE: + case CONTINUOUS_RUNNING: + case INCREMENTAL_UPDATING: + break; + default: + throw new IllegalArgumentException( + MsgRepository.GAUGE_EXCEPTION_INVALID_VALUE); + } + + return value; } - return value; + else + { + return CONTINUOUS_IDLE; + } } else { @@ -111,18 +128,14 @@ */ private static int checkMaxValue(int maxVal, boolean interactive) { - if(!interactive) + if(interactive) { - if(maxVal == INDEFINITE) + if(maxVal <= 0) { - return maxVal; + throw new IllegalArgumentException( + MsgRepository.GAUGE_EXCEPTION_INVALID_MAXVALUE); } } - if(maxVal <= 0) - { - throw new IllegalArgumentException( - MsgRepository.GAUGE_EXCEPTION_INVALID_MAXVALUE); - } return maxVal; } @@ -140,7 +153,7 @@ * that requires eSWT extension. */ this.value = checkValue(value, this.maxValue); - updateParent(UPDATE_CONTENT); + updateParent(UPDATE_VALUE); } /** @@ -162,7 +175,7 @@ { this.maxValue = checkMaxValue(maxValue, interactive); this.value = checkValue(getValue(), this.maxValue); - updateParent(UPDATE_CONTENT); + updateParent(UPDATE_MAXVALUE); } /** @@ -257,7 +270,7 @@ { return (!isInteractive() && getParent() == null - && !hasLabel() + && getLabel() == null && getLayout() == Item.LAYOUT_DEFAULT && !isSizeLocked() && getNumCommands() == 0