Author: chatellier Date: 2009-11-02 16:53:44 +0000 (Mon, 02 Nov 2009) New Revision: 2734 Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUtils.java Removed: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/util/UtilsUI.java Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx Log: Move UtilsUI to SensitivityUtils since it's sensitivity specific code. Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx 2009-11-02 16:39:25 UTC (rev 2733) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentUI.jaxx 2009-11-02 16:53:44 UTC (rev 2734) @@ -59,7 +59,7 @@ import fr.ifremer.isisfish.entities.FisheryRegion; import org.nuiton.topia.persistence.TopiaEntity; import javax.swing.JComponent; -import fr.ifremer.isisfish.ui.util.UtilsUI; +import fr.ifremer.isisfish.ui.sensitivity.SensitivityUtils; import fr.ifremer.isisfish.ui.sensitivity.FactorWizardUI; import fr.ifremer.isisfish.ui.sensitivity.EditorHelper; import fr.ifremer.isisfish.ui.sensitivity.SensitivityTabbedPaneListener; @@ -133,7 +133,7 @@ String method = (String)boxed.getClientProperty("method"); boolean isSensitivityFactorEnabled = false; if (classBean != null) { - isSensitivityFactorEnabled = UtilsUI.isSensitivityFactorEnabled(classBean.getSimpleName().replace("Impl", "") + "." + method); + isSensitivityFactorEnabled = SensitivityUtils.isSensitivityFactorEnabled(classBean.getSimpleName().replace("Impl", "") + "." + method); } if (isSensitivityFactorEnabled) { jaxx.runtime.swing.BlockingLayerUI2 ui = layerUI2.clone(); Copied: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUtils.java (from rev 2668, isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/util/UtilsUI.java) =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUtils.java (rev 0) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUtils.java 2009-11-02 16:53:44 UTC (rev 2734) @@ -0,0 +1,94 @@ +/* *##% + * Copyright (C) 2002-2009 Code Lutin, Benjamin Poussin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + * ##%*/ + +package fr.ifremer.isisfish.ui.sensitivity; + +import java.io.InputStream; +import java.io.IOException; +import java.util.Properties; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Utility class to parse Sensitivity properties file. + * + * @author letellier + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author$ + */ +public class SensitivityUtils { + + /** Log. */ + private static final Log log = LogFactory.getLog(SensitivityUtils.class); + + /** Properties file resource path. */ + private final static String PROPERTIES_PATH = "/sensitivity.properties"; + + /** Cached properties. */ + private static Properties sensitivityProperties; + + /** + * Is field sensitivity enabled. + * + * Return true, if field name is present in properties file. + * + * @param sensitivityFactorName name + * @return <tt>true</tt> if factor name is sensitivity enabled + */ + public static boolean isSensitivityFactorEnabled(String sensitivityFactorName) { + Properties data = loadProperties(); + return data.getProperty(sensitivityFactorName) != null; + + } + + /** + * Return cached properties file. + * Load it at first call. + * + * @return properties + */ + private static Properties loadProperties() { + + if (sensitivityProperties == null) { + sensitivityProperties = new Properties(); + InputStream stream = null; + try { + stream = SensitivityUtils.class.getResourceAsStream(PROPERTIES_PATH); + sensitivityProperties.load(stream); + } catch (IOException ex) { + if (log.isErrorEnabled()) { + log.error("Can't load sensitivity properties file", ex); + } + } finally { + try { + if (stream != null) { + stream.close(); + } + } catch (IOException ex) { + if (log.isErrorEnabled()) { + log.error("Can't load sensitivity properties file", ex); + } + } + } + } + return sensitivityProperties; + } +} Deleted: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/util/UtilsUI.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/util/UtilsUI.java 2009-11-02 16:39:25 UTC (rev 2733) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/util/UtilsUI.java 2009-11-02 16:53:44 UTC (rev 2734) @@ -1,94 +0,0 @@ -/* *##% - * Copyright (C) 2002-2009 Code Lutin, Benjamin Poussin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - * USA. - * ##%*/ - -package fr.ifremer.isisfish.ui.util; - -import java.io.InputStream; -import java.io.IOException; -import java.util.Properties; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Utility class to parse Sensitivity properties file. - * - * @author letellier - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ - */ -public class UtilsUI { - - /** Log. */ - private static final Log log = LogFactory.getLog(UtilsUI.class); - - /** Properties file resource path. */ - private final static String PROPERTIES_PATH = "/sensitivity.properties"; - - /** Cached properties. */ - private static Properties sensitivityProperties; - - /** - * Is field sensitivity enabled. - * - * Return true, if field name is present in properties file. - * - * @param sensitivityFactorName name - * @return <tt>true</tt> if factor name is sensitivity enabled - */ - public static boolean isSensitivityFactorEnabled(String sensitivityFactorName) { - Properties data = loadProperties(); - return data.getProperty(sensitivityFactorName) != null; - - } - - /** - * Return cached properties file. - * Load it at first call. - * - * @return properties - */ - private static Properties loadProperties() { - - if (sensitivityProperties == null) { - sensitivityProperties = new Properties(); - InputStream stream = null; - try { - stream = UtilsUI.class.getResourceAsStream(PROPERTIES_PATH); - sensitivityProperties.load(stream); - } catch (IOException ex) { - if (log.isErrorEnabled()) { - log.error("Can't load sensitivity properties file", ex); - } - } finally { - try { - if (stream != null) { - stream.close(); - } - } catch (IOException ex) { - if (log.isErrorEnabled()) { - log.error("Can't load sensitivity properties file", ex); - } - } - } - } - return sensitivityProperties; - } -}