Author: chatellier Date: 2009-07-24 16:23:34 +0000 (Fri, 24 Jul 2009) New Revision: 2511 Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/StorageChangeListener.java Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/RegionMonitor.java Log: Begin of listener implementation on storage Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/StorageChangeListener.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/StorageChangeListener.java (rev 0) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/StorageChangeListener.java 2009-07-24 16:23:34 UTC (rev 2511) @@ -0,0 +1,46 @@ +/* *##% + * Copyright (C) 2009 Code Lutin + * + * 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.datastore; + +import java.awt.Event; +import java.util.EventListener; + +/** + * Listener for change made on storage. + * + * Such as : + * <li>region added</li> + * <li>script removed</li> + * <li>plan renamed</li> + * + * @author chatellier + * @version $Revision: 1.0 $ + * + * Last update : $Date: 24 juil. 2009 $ + * By : $Author: chatellier $ + */ +public interface StorageChangeListener extends EventListener { + + /** + * Fire data changed event. + * + * @param e event to fire + */ + void versionDataChanged(Event e); +} Property changes on: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/StorageChangeListener.java ___________________________________________________________________ Name: svn:executable + * Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2009-07-22 17:03:33 UTC (rev 2510) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2009-07-24 16:23:34 UTC (rev 2511) @@ -1,5 +1,5 @@ /* *##% - * Copyright (C) 2006 + * Copyright (C) 2006 - 2009 * Code Lutin, Cédric Pineau, Benjamin Poussin * * This program is free software; you can redistribute it and/or @@ -17,22 +17,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *##%*/ -/* * - * VersionStorage.java - * - * Created: 21 janv. 2006 16:56:25 - * - * @author poussin - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ - */ - package fr.ifremer.isisfish.datastore; import static org.codelutin.i18n.I18n._; +import java.awt.Event; import java.io.File; import java.util.ArrayList; import java.util.Collections; @@ -41,6 +30,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.codelutin.util.FileUtil; +import org.codelutin.util.ListenerSet; import org.codelutin.util.VersionNumber; import fr.ifremer.isisfish.IsisConfig; @@ -52,16 +42,19 @@ * Classe permettant de géré l'interaction avec le cvs * * @author poussin + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author$ */ public abstract class VersionStorage { /** Logger for this class */ private static final Log log = LogFactory.getLog(VersionStorage.class); - - static protected VCS getVCS() { - return IsisFish.vcs; - } - + + /** Listener set. Manage single reference and weak reference. */ + protected static ListenerSet<StorageChangeListener> changeListeners = new ListenerSet<StorageChangeListener>(); + protected File root = null; protected File file = null; @@ -78,12 +71,15 @@ this.file = file; } + protected static VCS getVCS() { + return IsisFish.vcs; + } + /** * Permet de demander la preparation des fichiers pour etre envoyé - * vers le VCSNone - * + * vers le VCS. */ - abstract protected void prepare(); + protected abstract void prepare(); /** * @return Returns the root. @@ -319,6 +315,20 @@ return result; } + /** + * Fire a change event to all registred listeners. + * + * @param event event to fire + */ + protected void fireDataChanged(Event event) { + try { + changeListeners.fire("dataChanged", event); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Can't fire data change event", e); + } + } + } } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/RegionMonitor.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/RegionMonitor.java 2009-07-22 17:03:33 UTC (rev 2510) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/RegionMonitor.java 2009-07-24 16:23:34 UTC (rev 2511) @@ -32,8 +32,9 @@ * Last update: $Date$ * by : $Author$ * - * @deprecated don't work with rule, plans... use refresh on affected uis + * @deprecated use {@link fr.ifremer.isisfish.datastore.VersionStorage#fireDataChanged(java.awt.Event)} instead */ + at Deprecated public class RegionMonitor { /** pour le support des modifications de propriétés. */