Author: chatellier Date: 2009-06-04 09:34:22 +0000 (Thu, 04 Jun 2009) New Revision: 2317 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/RegionMonitor.java Log: Refactor and comment data change monitoring class. 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-06-04 09:16:46 UTC (rev 2316) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/RegionMonitor.java 2009-06-04 09:34:22 UTC (rev 2317) @@ -1,7 +1,20 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ +/* *##% + * Copyright (C) 2009 Ifremer, 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.ui; @@ -9,45 +22,49 @@ import java.beans.PropertyChangeSupport; /** + * Class to listen for region change. + * + * For adding region, removing region... + * + * @author letellier + * @version $Revision$ * - * @author letellier + * Last update: $Date$ + * by : $Author$ */ public class RegionMonitor { - /** pour le support des modifications de propriétés */ + /** pour le support des modifications de propriétés. */ protected final PropertyChangeSupport pcs; - protected Boolean regionChanged = false; + + protected boolean regionChanged = false; + protected static String REGION_PROPERTY = "regionChanged"; public RegionMonitor() { this.pcs = new PropertyChangeSupport(this); } - public void changeRegion(){ + public void changeRegion() { setRegionChanged(!regionChanged); } - protected Boolean getRegionChanged() { + protected boolean isRegionChanged() { return regionChanged; } - protected void setRegionChanged(Boolean regionChanged) { - pcs.firePropertyChange(REGION_PROPERTY, this.regionChanged, regionChanged); + protected void setRegionChanged(boolean regionChanged) { + boolean oldValue = this.regionChanged; this.regionChanged = regionChanged; + pcs.firePropertyChange(REGION_PROPERTY, oldValue, this.regionChanged); } public void addRegionPropertyChangeListener(PropertyChangeListener listener) { pcs.addPropertyChangeListener(REGION_PROPERTY, listener); } - public void removeRegionPropertyChangeListener(PropertyChangeListener listener) { + public void removeRegionPropertyChangeListener( + PropertyChangeListener listener) { pcs.removePropertyChangeListener(REGION_PROPERTY, listener); } - - public void removePropertyChangeListeners() { - for (PropertyChangeListener listener : pcs.getPropertyChangeListeners()) { - pcs.removePropertyChangeListener(listener); - } - } - } Property changes on: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/RegionMonitor.java ___________________________________________________________________ Name: svn:keywords + Date Author Revision