r2039 - in trunk: jaxx-runtime/src/test/java/jaxx/runtime jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model
Author: tchemit Date: 2010-08-26 13:25:01 +0200 (Thu, 26 Aug 2010) New Revision: 2039 Url: http://nuiton.org/repositories/revision/jaxx/2039 Log: reformat api + remove synchronized on listener methods Modified: trunk/jaxx-runtime/src/test/java/jaxx/runtime/UtilTest.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBackFinalizer.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/MyConfig.java Modified: trunk/jaxx-runtime/src/test/java/jaxx/runtime/UtilTest.java =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/UtilTest.java 2010-08-26 11:24:28 UTC (rev 2038) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/UtilTest.java 2010-08-26 11:25:01 UTC (rev 2039) @@ -37,10 +37,10 @@ @Test public void testGetEventListener() { count = 0; - DocumentListener listener = (DocumentListener) JAXXUtil.getEventListener(DocumentListener.class, this, "incCount"); + DocumentListener listener = JAXXUtil.getEventListener(DocumentListener.class, this, "incCount"); listener.insertUpdate(null); Assert.assertEquals(count, 1); - DocumentListener listener2 = (DocumentListener) JAXXUtil.getEventListener(DocumentListener.class, this, "incCount"); + DocumentListener listener2 = JAXXUtil.getEventListener(DocumentListener.class, this, "incCount"); listener2.removeUpdate(null); Assert.assertEquals(count, 2); //assertTrue("Received two different event listeners despite using identical parameters", listener == listener2); Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBackFinalizer.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBackFinalizer.java 2010-08-26 11:24:28 UTC (rev 2038) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CallBackFinalizer.java 2010-08-26 11:25:01 UTC (rev 2039) @@ -36,7 +36,7 @@ /** * Do finalize the result. * - * @param result unfinalize result + * @param result unfinalized result * @return the finalized result */ CallBackMap finalize(CallBackMap result); Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java 2010-08-26 11:24:28 UTC (rev 2038) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java 2010-08-26 11:25:01 UTC (rev 2039) @@ -189,15 +189,15 @@ pcs.removePropertyChangeListener(propertyName, listener); } - public synchronized boolean hasListeners(String propertyName) { + public boolean hasListeners(String propertyName) { return pcs.hasListeners(propertyName); } - public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { + public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { return pcs.getPropertyChangeListeners(propertyName); } - public synchronized PropertyChangeListener[] getPropertyChangeListeners() { + public PropertyChangeListener[] getPropertyChangeListeners() { return pcs.getPropertyChangeListeners(); } Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java 2010-08-26 11:24:28 UTC (rev 2038) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java 2010-08-26 11:25:01 UTC (rev 2039) @@ -206,9 +206,9 @@ for (OptionModel option : categoryModel) { if (option.isModified()) { Object value = option.getValue(); - //TODO TC-20090245 : should try to seek for a mutator, since if (option.getPropertyName() != null) { - // this is a javaBean option + + // this is a javaBean option, push value via mutator try { PropertyUtils.setProperty(config, option.getPropertyName(), value); @@ -219,8 +219,9 @@ "] with value = " + value, e); } } else { - // mutator could have extra code to be done when - // modify an option + + // simple option with no javabeans, just push the option + // value config.setOption(option.getKey(), value == null ? null : value.toString()); } @@ -305,16 +306,16 @@ pcs.removePropertyChangeListener(propertyName, listener); } - public synchronized boolean hasListeners(String propertyName) { + public boolean hasListeners(String propertyName) { return pcs.hasListeners(propertyName); } - public synchronized PropertyChangeListener[] getPropertyChangeListeners( + public PropertyChangeListener[] getPropertyChangeListeners( String propertyName) { return pcs.getPropertyChangeListeners(propertyName); } - public synchronized PropertyChangeListener[] getPropertyChangeListeners() { + public PropertyChangeListener[] getPropertyChangeListeners() { return pcs.getPropertyChangeListeners(); } Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java 2010-08-26 11:24:28 UTC (rev 2038) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java 2010-08-26 11:25:01 UTC (rev 2039) @@ -265,7 +265,7 @@ checkNoCurrent(category, "category"); category = categoryModel; if (log.isDebugEnabled()) { - log.debug("new current category : " + this.category); + log.debug("new current category : " + category); } option = null; } @@ -284,7 +284,7 @@ checkNoCurrent(option, "option"); option = optionModel; if (log.isDebugEnabled()) { - log.debug("new current option : " + this.option); + log.debug("new current option : " + option); } } Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java 2010-08-26 11:24:28 UTC (rev 2038) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java 2010-08-26 11:25:01 UTC (rev 2039) @@ -37,35 +37,26 @@ public class OptionModel implements OptionDef { private static final long serialVersionUID = 1L; - /** - * la definition de l'option ( venant de la config) - */ + + /** la definition de l'option (venant de la config) */ protected final OptionDef def; - /** - * un drapeau pour savoir si l'option est valide (n'est pas utilisé actuellement) - */ + + /** un drapeau pour savoir si l'option est valide (n'est pas utilisé actuellement) */ protected boolean valid = true; - /** - * un drapeau pour savoir si l'option a été sauvée - */ + /** un drapeau pour savoir si l'option a été sauvée */ protected boolean saved; - /** - * la valeur non modifié de l'option - */ + + /** la valeur non modifié de l'option */ protected Object originalValue; - /** - * la valeur actuelle de l'option (peut être la valeur orignal si non modifée) - */ + + /** la valeur actuelle de l'option (peut être la valeur orignal si non modifée) */ protected Object value; - /** - * le nom de la propriété javaBean (peut etre null, si option sans support javaBean) - */ + + /** le nom de la propriété javaBean (peut etre null, si option sans support javaBean) */ protected String propertyName; - /** - * l'editeur utilise pour modifier graphiquement l'option - */ + /** l'editeur utilise pour modifier graphiquement l'option */ protected TableCellEditor editor; protected OptionModel(OptionDef def, Object value) { Modified: trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/MyConfig.java =================================================================== --- trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/MyConfig.java 2010-08-26 11:24:28 UTC (rev 2038) +++ trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/MyConfig.java 2010-08-26 11:25:01 UTC (rev 2039) @@ -29,27 +29,28 @@ import org.apache.commons.logging.LogFactory; import org.nuiton.util.ApplicationConfig; -import static org.nuiton.i18n.I18n._; - import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Date; import java.util.Locale; +import static org.nuiton.i18n.I18n._; + /** * @author tchemit <chemit@codelutin.com> * @since 2.0.0 */ public class MyConfig extends ApplicationConfig { - /** - * to use log facility, just put in your code: log.info(\"...\"); - */ + /** Logger */ static private Log log = LogFactory.getLog(MyConfig.class); public static final String PROPERTY_FULLSCREEN = "fullscreen"; + public static final String PROPERTY_LOCALE = "locale"; + public static final String PROPERTY_FONT_SIZE = "fontSize"; + public static final String PROPERTY_ADJUSTING = "adjusting"; /** @@ -57,6 +58,7 @@ * via les setter. */ protected boolean adjusting; + protected final PropertyChangeListener saveAction = new PropertyChangeListener() { @Override @@ -124,13 +126,11 @@ public void setFullscreen(boolean fullscreen) { Object oldValue = null; setOption(Option.FULL_SCREEN.key, fullscreen + ""); -// saveForUser(); firePropertyChange(PROPERTY_FULLSCREEN, oldValue, fullscreen); } public void setLocale(Locale newLocale) { setOption(Option.LOCALE.key, newLocale.toString()); -// saveForUser(); firePropertyChange(PROPERTY_LOCALE, null, newLocale); } @@ -140,7 +140,6 @@ log.debug("changing font-size to " + newFontSize); } setOption(Option.FONT_SIZE.key, newFontSize.toString()); -// saveForUser(); firePropertyChange(PROPERTY_FONT_SIZE, oldValue, newFontSize); } @@ -160,17 +159,24 @@ ////////////////////////////////////////////////// // Toutes les options disponibles ////////////////////////////////////////////////// + public enum Option implements OptionDef { CONFIG_FILE(CONFIG_FILE_NAME, _("jaxxdemo.config.configFileName.description"), "jaxxdemo", String.class, true, true), FULL_SCREEN("ui.fullscreen", _("jaxxdemo.config.ui.fullscreen"), "false", Boolean.class, false, false), LOCALE("ui." + PROPERTY_LOCALE, _("jaxxdemo.config.ui." + PROPERTY_LOCALE), Locale.FRANCE.toString(), Locale.class, false, false), FONT_SIZE("ui." + PROPERTY_FONT_SIZE, _("jaxxdemo.config.ui." + PROPERTY_FONT_SIZE), "10f", Float.class, false, false); + public final String key; + public final String description; + public String defaultValue; + public final Class<?> type; + public boolean _transient; + public boolean _final; Option(String key, String description, String defaultValue, Class<?> type, boolean _transient, boolean _final) { @@ -189,7 +195,7 @@ @Override public void setDefaultValue(String defaultValue) { - this.defaultValue=defaultValue; + this.defaultValue = defaultValue; } @Override @@ -199,7 +205,7 @@ @Override public void setFinal(boolean _final) { - this._final= _final; + this._final = _final; } @Override @@ -226,7 +232,5 @@ public Class<?> getType() { return type; } - - } }
participants (1)
-
tchemit@users.nuiton.org