Ignore:
Timestamp:
2009-08-10T05:10:14+02:00 (15 years ago)
Author:
Gubaer
Message:

fixed #3230: Bug affecting conflict resolving

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/conflict/ConflictResolver.java

    r1904 r1942  
    77import java.beans.PropertyChangeEvent;
    88import java.beans.PropertyChangeListener;
    9 import java.beans.PropertyChangeSupport;
    109import java.util.ArrayList;
    1110import java.util.logging.Logger;
     
    4847 */
    4948public class ConflictResolver extends JPanel implements PropertyChangeListener  {
     49
     50    /* -------------------------------------------------------------------------------------- */
     51    /* Property names                                                                         */
     52    /* -------------------------------------------------------------------------------------- */
     53    /** name of the property indicating whether all conflicts are resolved,
     54     *  {@see #isResolvedCompletely()}
     55     */
    5056    static public final String RESOLVED_COMPLETELY_PROP = ConflictResolver.class.getName() + ".resolvedCompletely";
     57    /**
     58     * name of the property for the {@see OsmPrimitive} in the role "my"
     59     */
    5160    static public final String MY_PRIMITIVE_PROP = ConflictResolver.class.getName() + ".myPrimitive";
     61
     62    /**
     63     * name of the property for the {@see OsmPrimitive} in the role "my"
     64     */
    5265    static public final String THEIR_PRIMITIVE_PROP = ConflictResolver.class.getName() + ".theirPrimitive";
    5366
     
    6679    private ImageIcon mergeIncomplete;
    6780
    68     /** the property change listeners */
    69     private PropertyChangeSupport listeners;
    70 
    7181    /** indicates whether the current conflict is resolved completely */
    7282    private boolean resolvedCompletely;
    7383
     84    /**
     85     * loads the required icons
     86     */
    7487    protected void loadIcons() {
    7588        mergeComplete = ImageProvider.get("dialogs/conflict","mergecomplete.png" );
     
    7790    }
    7891
     92    /**
     93     * builds the UI
     94     */
    7995    protected void build() {
    8096        tabbedPane = new JTabbedPane();
     
    104120    }
    105121
    106 
     122    /**
     123     * constructor
     124     */
    107125    public ConflictResolver() {
    108         listeners = new PropertyChangeSupport(this);
    109126        resolvedCompletely = false;
    110127        build();
     
    112129    }
    113130
    114 
     131    /**
     132     * Sets the {@see OsmPrimitive} in the role "my"
     133     *
     134     * @param my the primitive in the role "my"
     135     */
    115136    protected void setMy(OsmPrimitive my) {
    116137        OsmPrimitive old = this.my;
    117138        this.my = my;
    118139        if (old != this.my) {
    119             fireMyPrimitive(old, this.my);
    120         }
    121     }
    122 
     140            firePropertyChange(MY_PRIMITIVE_PROP, old, this.my);
     141        }
     142    }
     143
     144    /**
     145     * Sets the {@see OsmPrimitive} in the role "their".
     146     *
     147     * @param their the primitive in the role "their"
     148     */
    123149    protected void setTheir(OsmPrimitive their) {
    124150        OsmPrimitive old = this.their;
    125151        this.their = their;
    126152        if (old != this.their) {
    127             fireTheirPrimitive(old, this.their);
    128         }
    129     }
    130 
    131     protected void fireResolvedCompletely(boolean oldValue,boolean newValue) {
    132         if (listeners == null) return;
    133         listeners.firePropertyChange(RESOLVED_COMPLETELY_PROP, oldValue, newValue);
    134     }
    135 
    136     protected void fireMyPrimitive(OsmPrimitive oldValue,OsmPrimitive newValue) {
    137         if (listeners == null) return;
    138         listeners.firePropertyChange(MY_PRIMITIVE_PROP, oldValue, newValue);
    139     }
    140 
    141     protected void fireTheirPrimitive(OsmPrimitive oldValue,OsmPrimitive newValue) {
    142         if (listeners == null) return;
    143         listeners.firePropertyChange(THEIR_PRIMITIVE_PROP, oldValue, newValue);
    144     }
    145 
    146     /**
    147      * Adds a property change listener
    148      *
    149      *  @param listener the listener
    150      */
    151     @Override
    152     public void addPropertyChangeListener(PropertyChangeListener listener) {
    153         listeners.addPropertyChangeListener(listener);
    154     }
    155 
    156     /**
    157      * Removes a property change listener
    158      *
    159      *  @param listener the listener
    160      */
    161 
    162     @Override
    163     public void removePropertyChangeListener(PropertyChangeListener listener) {
    164         listeners.removePropertyChangeListener(listener);
    165     }
    166 
     153            firePropertyChange(THEIR_PRIMITIVE_PROP, old, this.their);
     154        }
     155    }
     156
     157    /**
     158     * handles property change events
     159     */
    167160    public void propertyChange(PropertyChangeEvent evt) {
    168161        if (evt.getPropertyName().equals(TagMergeModel.PROP_NUM_UNDECIDED_TAGS)) {
     
    213206        }
    214207    }
    215 
    216208
    217209    /**
     
    288280    }
    289281
     282    /**
     283     * Updates the state of the property {@see #RESOLVED_COMPLETELY_PROP}
     284     *
     285     */
    290286    protected void updateResolvedCompletely() {
    291287        boolean oldValueResolvedCompletely = resolvedCompletely;
     
    317313        }
    318314        if (this.resolvedCompletely != oldValueResolvedCompletely) {
    319             fireResolvedCompletely(oldValueResolvedCompletely, this.resolvedCompletely);
     315            firePropertyChange(RESOLVED_COMPLETELY_PROP, oldValueResolvedCompletely, this.resolvedCompletely);
    320316        }
    321317    }
Note: See TracChangeset for help on using the changeset viewer.