Changeset 10210 in josm for trunk/src


Ignore:
Timestamp:
2016-05-14T15:45:35+02:00 (9 years ago)
Author:
Don-vip
Message:

see #11924 - Java 9 - replace calls to deprecated classes java.util.Observable / java.util.Observer by a new class ChangeNotifier + swing's ChangeListener

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
1 added
17 edited

Legend:

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

    r8840 r10210  
    1717import java.util.List;
    1818import java.util.Map;
    19 import java.util.Observable;
    2019import java.util.Set;
    2120
     
    3635import org.openstreetmap.josm.gui.HelpAwareOptionPane;
    3736import org.openstreetmap.josm.gui.help.HelpUtil;
     37import org.openstreetmap.josm.gui.util.ChangeNotifier;
    3838import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTableModel;
    3939import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    7272 * @see ListMerger
    7373 */
    74 public abstract class ListMergeModel<T extends PrimitiveId> extends Observable {
     74public abstract class ListMergeModel<T extends PrimitiveId> extends ChangeNotifier {
    7575    public static final String FROZEN_PROP = ListMergeModel.class.getName() + ".frozen";
    7676
     
    270270        theirEntriesTableModel.fireTableDataChanged();
    271271        mergedEntriesTableModel.fireTableDataChanged();
    272         setChanged();
    273         notifyObservers();
     272        fireStateChanged();
    274273    }
    275274
     
    458457        copy(source, rows, current + 1);
    459458        mergedEntriesSelectionModel.setSelectionInterval(current+1, current + rows.length-1);
    460         notifyObservers();
     459        fireStateChanged();
    461460    }
    462461
     
    505504        }
    506505        fireModelDataChanged();
    507         notifyObservers();
    508506        mergedEntriesSelectionModel.clearSelection();
    509507        for (int row: rows) {
     
    532530        }
    533531        fireModelDataChanged();
    534         notifyObservers();
    535532        mergedEntriesSelectionModel.clearSelection();
    536533        for (int row: rows) {
     
    555552        }
    556553        fireModelDataChanged();
    557         notifyObservers();
    558554        mergedEntriesSelectionModel.clearSelection();
    559555    }
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMerger.java

    r10001 r10210  
    1515import java.beans.PropertyChangeListener;
    1616import java.util.Collection;
    17 import java.util.Observable;
    18 import java.util.Observer;
    1917
    2018import javax.swing.AbstractAction;
     
    2826import javax.swing.JTable;
    2927import javax.swing.JToggleButton;
     28import javax.swing.event.ChangeEvent;
     29import javax.swing.event.ChangeListener;
    3030import javax.swing.event.ListSelectionEvent;
    3131import javax.swing.event.ListSelectionListener;
     
    4949 * @since 1631
    5050 */
    51 public abstract class ListMerger<T extends PrimitiveId> extends JPanel implements PropertyChangeListener, Observer, IConflictResolver {
     51public abstract class ListMerger<T extends PrimitiveId> extends JPanel implements PropertyChangeListener, ChangeListener, IConflictResolver {
    5252    protected OsmPrimitivesTable myEntriesTable;
    5353    protected OsmPrimitivesTable mergedEntriesTable;
     
    120120        mergedEntriesTable.getSelectionModel().addListSelectionListener(removeMergedAction);
    121121
    122         model.addObserver(copyAllLeft);
    123         model.addObserver(copyAllRight);
     122        model.addChangeListener(copyAllLeft);
     123        model.addChangeListener(copyAllRight);
    124124        model.addPropertyChangeListener(copyAllLeft);
    125125        model.addPropertyChangeListener(copyAllRight);
     
    408408    public ListMerger(ListMergeModel<T> model) {
    409409        this.model = model;
    410         model.addObserver(this);
     410        model.addChangeListener(this);
    411411        build();
    412412        model.addPropertyChangeListener(this);
     
    621621    }
    622622
    623     class CopyAllLeft extends AbstractAction implements Observer, PropertyChangeListener {
     623    class CopyAllLeft extends AbstractAction implements ChangeListener, PropertyChangeListener {
    624624
    625625        CopyAllLeft() {
     
    640640
    641641        @Override
    642         public void update(Observable o, Object arg) {
     642        public void stateChanged(ChangeEvent e) {
    643643            updateEnabledState();
    644644        }
     
    650650    }
    651651
    652     class CopyAllRight extends AbstractAction implements Observer, PropertyChangeListener {
     652    class CopyAllRight extends AbstractAction implements ChangeListener, PropertyChangeListener {
    653653
    654654        CopyAllRight() {
     
    669669
    670670        @Override
    671         public void update(Observable o, Object arg) {
     671        public void stateChanged(ChangeEvent e) {
    672672            updateEnabledState();
    673673        }
     
    871871
    872872    @Override
    873     public void update(Observable o, Object arg) {
     873    public void stateChanged(ChangeEvent e) {
    874874        lblMyVersion.setText(
    875875                trn("My version ({0} entry)", "My version ({0} entries)", model.getMyEntriesSize(), model.getMyEntriesSize())
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergeModel.java

    r9243 r10210  
    99import java.util.Collections;
    1010import java.util.List;
    11 import java.util.Observable;
    1211
    1312import org.openstreetmap.josm.command.Command;
     
    1918import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2019import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
     20import org.openstreetmap.josm.gui.util.ChangeNotifier;
    2121import org.openstreetmap.josm.tools.CheckParameterUtil;
    2222
     
    2626 * the deleted or visible state of {@link OsmPrimitive}s.
    2727 *
    28  * This model is an {@link Observable}. It notifies registered {@link java.util.Observer}s whenever the
     28 * This model is a {@link ChangeNotifier}. It notifies registered {@link javax.swing.event.ChangeListener}s whenever the
    2929 * internal state changes.
    3030 *
     
    3737 *
    3838 */
    39 public class PropertiesMergeModel extends Observable {
     39public class PropertiesMergeModel extends ChangeNotifier {
    4040
    4141    public static final String RESOLVED_COMPLETELY_PROP = PropertiesMergeModel.class.getName() + ".resolvedCompletely";
     
    145145        coordMergeDecision = UNDECIDED;
    146146        deletedMergeDecision = UNDECIDED;
    147         setChanged();
    148         notifyObservers();
     147        fireStateChanged();
    149148        fireCompletelyResolved();
    150149    }
     
    196195    public void decideCoordsConflict(MergeDecisionType decision) {
    197196        coordMergeDecision = decision;
    198         setChanged();
    199         notifyObservers();
     197        fireStateChanged();
    200198        fireCompletelyResolved();
    201199    }
     
    271269
    272270        this.deletedMergeDecision = decision;
    273         setChanged();
    274         notifyObservers();
     271        fireStateChanged();
    275272        fireCompletelyResolved();
    276273
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMerger.java

    r10179 r10210  
    1010import java.text.DecimalFormat;
    1111import java.util.List;
    12 import java.util.Observable;
    13 import java.util.Observer;
    1412
    1513import javax.swing.AbstractAction;
     
    1917import javax.swing.JLabel;
    2018import javax.swing.JPanel;
     19import javax.swing.event.ChangeEvent;
     20import javax.swing.event.ChangeListener;
    2121
    2222import org.openstreetmap.josm.data.conflict.Conflict;
     
    3434 * @since 1654
    3535 */
    36 public class PropertiesMerger extends JPanel implements Observer, IConflictResolver {
     36public class PropertiesMerger extends JPanel implements ChangeListener, IConflictResolver {
    3737    private static final DecimalFormat COORD_FORMATTER = new DecimalFormat("###0.0000000");
    3838
     
    5757    public PropertiesMerger() {
    5858        model = new PropertiesMergeModel();
    59         model.addObserver(this);
     59        model.addChangeListener(this);
    6060        build();
    6161    }
     
    137137        gc.weighty = 0.0;
    138138        KeepMyCoordinatesAction actKeepMyCoordinates = new KeepMyCoordinatesAction();
    139         model.addObserver(actKeepMyCoordinates);
     139        model.addChangeListener(actKeepMyCoordinates);
    140140        JButton btnKeepMyCoordinates = new JButton(actKeepMyCoordinates);
    141141        btnKeepMyCoordinates.setName("button.keepmycoordinates");
     
    155155        gc.weighty = 0.0;
    156156        KeepTheirCoordinatesAction actKeepTheirCoordinates = new KeepTheirCoordinatesAction();
    157         model.addObserver(actKeepTheirCoordinates);
     157        model.addChangeListener(actKeepTheirCoordinates);
    158158        JButton btnKeepTheirCoordinates = new JButton(actKeepTheirCoordinates);
    159159        add(btnKeepTheirCoordinates, gc);
     
    174174        gc.weighty = 0.0;
    175175        UndecideCoordinateConflictAction actUndecideCoordinates = new UndecideCoordinateConflictAction();
    176         model.addObserver(actUndecideCoordinates);
     176        model.addChangeListener(actUndecideCoordinates);
    177177        JButton btnUndecideCoordinates = new JButton(actUndecideCoordinates);
    178178        add(btnUndecideCoordinates, gc);
     
    206206        gc.weighty = 0.0;
    207207        KeepMyDeletedStateAction actKeepMyDeletedState = new KeepMyDeletedStateAction();
    208         model.addObserver(actKeepMyDeletedState);
     208        model.addChangeListener(actKeepMyDeletedState);
    209209        JButton btnKeepMyDeletedState = new JButton(actKeepMyDeletedState);
    210210        btnKeepMyDeletedState.setName("button.keepmydeletedstate");
     
    224224        gc.weighty = 0.0;
    225225        KeepTheirDeletedStateAction actKeepTheirDeletedState = new KeepTheirDeletedStateAction();
    226         model.addObserver(actKeepTheirDeletedState);
     226        model.addChangeListener(actKeepTheirDeletedState);
    227227        JButton btnKeepTheirDeletedState = new JButton(actKeepTheirDeletedState);
    228228        btnKeepTheirDeletedState.setName("button.keeptheirdeletedstate");
     
    244244        gc.weighty = 0.0;
    245245        UndecideDeletedStateConflictAction actUndecideDeletedState = new UndecideDeletedStateConflictAction();
    246         model.addObserver(actUndecideDeletedState);
     246        model.addChangeListener(actUndecideDeletedState);
    247247        JButton btnUndecideDeletedState = new JButton(actUndecideDeletedState);
    248248        btnUndecideDeletedState.setName("button.undecidedeletedstate");
     
    384384
    385385    @Override
    386     public void update(Observable o, Object arg) {
     386    public void stateChanged(ChangeEvent e) {
    387387        updateCoordinates();
    388388        updateDeletedState();
     
    398398    }
    399399
    400     class KeepMyCoordinatesAction extends AbstractAction implements Observer {
     400    class KeepMyCoordinatesAction extends AbstractAction implements ChangeListener {
    401401        KeepMyCoordinatesAction() {
    402402            putValue(Action.SMALL_ICON, ImageProvider.get("dialogs/conflict", "tagkeepmine"));
     
    410410
    411411        @Override
    412         public void update(Observable o, Object arg) {
     412        public void stateChanged(ChangeEvent e) {
    413413            setEnabled(model.hasCoordConflict() && !model.isDecidedCoord() && model.getMyCoords() != null);
    414414        }
    415415    }
    416416
    417     class KeepTheirCoordinatesAction extends AbstractAction implements Observer {
     417    class KeepTheirCoordinatesAction extends AbstractAction implements ChangeListener {
    418418        KeepTheirCoordinatesAction() {
    419419            putValue(Action.SMALL_ICON, ImageProvider.get("dialogs/conflict", "tagkeeptheir"));
     
    427427
    428428        @Override
    429         public void update(Observable o, Object arg) {
     429        public void stateChanged(ChangeEvent e) {
    430430            setEnabled(model.hasCoordConflict() && !model.isDecidedCoord() && model.getTheirCoords() != null);
    431431        }
    432432    }
    433433
    434     class UndecideCoordinateConflictAction extends AbstractAction implements Observer {
     434    class UndecideCoordinateConflictAction extends AbstractAction implements ChangeListener {
    435435        UndecideCoordinateConflictAction() {
    436436            putValue(Action.SMALL_ICON, ImageProvider.get("dialogs/conflict", "tagundecide"));
     
    444444
    445445        @Override
    446         public void update(Observable o, Object arg) {
     446        public void stateChanged(ChangeEvent e) {
    447447            setEnabled(model.hasCoordConflict() && model.isDecidedCoord());
    448448        }
    449449    }
    450450
    451     class KeepMyDeletedStateAction extends AbstractAction implements Observer {
     451    class KeepMyDeletedStateAction extends AbstractAction implements ChangeListener {
    452452        KeepMyDeletedStateAction() {
    453453            putValue(Action.SMALL_ICON, ImageProvider.get("dialogs/conflict", "tagkeepmine"));
     
    461461
    462462        @Override
    463         public void update(Observable o, Object arg) {
     463        public void stateChanged(ChangeEvent e) {
    464464            setEnabled(model.hasDeletedStateConflict() && !model.isDecidedDeletedState());
    465465        }
    466466    }
    467467
    468     class KeepTheirDeletedStateAction extends AbstractAction implements Observer {
     468    class KeepTheirDeletedStateAction extends AbstractAction implements ChangeListener {
    469469        KeepTheirDeletedStateAction() {
    470470            putValue(Action.SMALL_ICON, ImageProvider.get("dialogs/conflict", "tagkeeptheir"));
     
    478478
    479479        @Override
    480         public void update(Observable o, Object arg) {
     480        public void stateChanged(ChangeEvent e) {
    481481            setEnabled(model.hasDeletedStateConflict() && !model.isDecidedDeletedState());
    482482        }
    483483    }
    484484
    485     class UndecideDeletedStateConflictAction extends AbstractAction implements Observer {
     485    class UndecideDeletedStateConflictAction extends AbstractAction implements ChangeListener {
    486486        UndecideDeletedStateConflictAction() {
    487487            putValue(Action.SMALL_ICON, ImageProvider.get("dialogs/conflict", "tagundecide"));
     
    495495
    496496        @Override
    497         public void update(Observable o, Object arg) {
     497        public void stateChanged(ChangeEvent e) {
    498498            setEnabled(model.hasDeletedStateConflict() && model.isDecidedDeletedState());
    499499        }
  • trunk/src/org/openstreetmap/josm/gui/help/HelpBrowser.java

    r9972 r10210  
    2020import java.nio.charset.StandardCharsets;
    2121import java.util.Locale;
    22 import java.util.Observable;
    23 import java.util.Observer;
    2422
    2523import javax.swing.AbstractAction;
     
    3533import javax.swing.KeyStroke;
    3634import javax.swing.SwingUtilities;
     35import javax.swing.event.ChangeEvent;
     36import javax.swing.event.ChangeListener;
    3737import javax.swing.event.HyperlinkEvent;
    3838import javax.swing.event.HyperlinkListener;
     
    495495    }
    496496
    497     static class BackAction extends AbstractBrowserAction implements Observer {
     497    static class BackAction extends AbstractBrowserAction implements ChangeListener {
    498498
    499499        /**
     
    503503        BackAction(IHelpBrowser browser) {
    504504            super(browser);
    505             browser.getHistory().addObserver(this);
     505            browser.getHistory().addChangeListener(this);
    506506            putValue(SHORT_DESCRIPTION, tr("Go to the previous page"));
    507507            putValue(SMALL_ICON, ImageProvider.get("help", "previous"));
     
    515515
    516516        @Override
    517         public void update(Observable o, Object arg) {
     517        public void stateChanged(ChangeEvent e) {
    518518            setEnabled(browser.getHistory().canGoBack());
    519519        }
    520520    }
    521521
    522     static class ForwardAction extends AbstractBrowserAction implements Observer {
     522    static class ForwardAction extends AbstractBrowserAction implements ChangeListener {
    523523
    524524        /**
     
    528528        ForwardAction(IHelpBrowser browser) {
    529529            super(browser);
    530             browser.getHistory().addObserver(this);
     530            browser.getHistory().addChangeListener(this);
    531531            putValue(SHORT_DESCRIPTION, tr("Go to the next page"));
    532532            putValue(SMALL_ICON, ImageProvider.get("help", "next"));
     
    540540
    541541        @Override
    542         public void update(Observable o, Object arg) {
     542        public void stateChanged(ChangeEvent e) {
    543543            setEnabled(browser.getHistory().canGoForward());
    544544        }
  • trunk/src/org/openstreetmap/josm/gui/help/HelpBrowserHistory.java

    r9644 r10210  
    55import java.util.Collections;
    66import java.util.List;
    7 import java.util.Observable;
     7
     8import org.openstreetmap.josm.gui.util.ChangeNotifier;
    89
    910/**
     
    1112 * @since 2274
    1213 */
    13 public class HelpBrowserHistory extends Observable {
     14public class HelpBrowserHistory extends ChangeNotifier {
    1415    private final IHelpBrowser browser;
    1516    private List<String> history;
     
    3132        history.clear();
    3233        historyPos = 0;
    33         setChanged();
    34         notifyObservers();
     34        fireStateChanged();
    3535    }
    3636
     
    6060        String url = history.get(historyPos);
    6161        browser.openUrl(url);
    62         setChanged();
    63         notifyObservers();
     62        fireStateChanged();
    6463    }
    6564
     
    7372        String url = history.get(historyPos);
    7473        browser.openUrl(url);
    75         setChanged();
    76         notifyObservers();
     74        fireStateChanged();
    7775    }
    7876
     
    9997            historyPos = history.size()-1;
    10098        }
    101         setChanged();
    102         notifyObservers();
     99        fireStateChanged();
    103100    }
    104101}
  • trunk/src/org/openstreetmap/josm/gui/history/CoordinateInfoViewer.java

    r10179 r10210  
    77import java.awt.GridBagLayout;
    88import java.awt.Insets;
    9 import java.util.Observable;
    10 import java.util.Observer;
    119
    1210import javax.swing.BorderFactory;
     
    1412import javax.swing.JPanel;
    1513import javax.swing.UIManager;
     14import javax.swing.event.ChangeEvent;
     15import javax.swing.event.ChangeListener;
    1616
    1717import org.openstreetmap.gui.jmapviewer.JMapViewer;
     
    127127        setModel(model);
    128128        build();
    129         registerAsObserver(model);
    130     }
    131 
    132     protected void unregisterAsObserver(HistoryBrowserModel model) {
     129        registerAsChangeListener(model);
     130    }
     131
     132    protected void unregisterAsChangeListener(HistoryBrowserModel model) {
    133133        if (currentInfoPanel != null) {
    134             model.deleteObserver(currentInfoPanel);
     134            model.removeChangeListener(currentInfoPanel);
    135135        }
    136136        if (referenceInfoPanel != null) {
    137             model.deleteObserver(referenceInfoPanel);
     137            model.removeChangeListener(referenceInfoPanel);
    138138        }
    139139        if (currentLatLonViewer != null) {
    140             model.deleteObserver(currentLatLonViewer);
     140            model.removeChangeListener(currentLatLonViewer);
    141141        }
    142142        if (referenceLatLonViewer != null) {
    143             model.deleteObserver(referenceLatLonViewer);
     143            model.removeChangeListener(referenceLatLonViewer);
    144144        }
    145145        if (distanceViewer != null) {
    146             model.deleteObserver(distanceViewer);
     146            model.removeChangeListener(distanceViewer);
    147147        }
    148148        if (mapViewer != null) {
    149             model.deleteObserver(mapViewer);
    150         }
    151     }
    152 
    153     protected void registerAsObserver(HistoryBrowserModel model) {
     149            model.removeChangeListener(mapViewer);
     150        }
     151    }
     152
     153    protected void registerAsChangeListener(HistoryBrowserModel model) {
    154154        if (currentInfoPanel != null) {
    155             model.addObserver(currentInfoPanel);
     155            model.addChangeListener(currentInfoPanel);
    156156        }
    157157        if (referenceInfoPanel != null) {
    158             model.addObserver(referenceInfoPanel);
     158            model.addChangeListener(referenceInfoPanel);
    159159        }
    160160        if (currentLatLonViewer != null) {
    161             model.addObserver(currentLatLonViewer);
     161            model.addChangeListener(currentLatLonViewer);
    162162        }
    163163        if (referenceLatLonViewer != null) {
    164             model.addObserver(referenceLatLonViewer);
     164            model.addChangeListener(referenceLatLonViewer);
    165165        }
    166166        if (distanceViewer != null) {
    167             model.addObserver(distanceViewer);
     167            model.addChangeListener(distanceViewer);
    168168        }
    169169        if (mapViewer != null) {
    170             model.addObserver(mapViewer);
     170            model.addChangeListener(mapViewer);
    171171        }
    172172    }
     
    179179    public void setModel(HistoryBrowserModel model) {
    180180        if (this.model != null) {
    181             unregisterAsObserver(model);
     181            unregisterAsChangeListener(model);
    182182        }
    183183        this.model = model;
    184184        if (this.model != null) {
    185             registerAsObserver(model);
     185            registerAsChangeListener(model);
    186186        }
    187187    }
     
    241241     * A UI widgets which displays the Lan/Lon-coordinates of a {@link HistoryNode}.
    242242     */
    243     private static class LatLonViewer extends JPanel implements Observer {
     243    private static class LatLonViewer extends JPanel implements ChangeListener {
    244244
    245245        private final JosmTextArea lblLat = newTextArea();
     
    324324
    325325        @Override
    326         public void update(Observable o, Object arg) {
     326        public void stateChanged(ChangeEvent e) {
    327327            refresh();
    328328        }
    329329    }
    330330
    331     private static class MapViewer extends JMapViewer implements Observer {
     331    private static class MapViewer extends JMapViewer implements ChangeListener {
    332332
    333333        private final Updater updater;
     
    339339
    340340        @Override
    341         public void update(Observable o, Object arg) {
     341        public void stateChanged(ChangeEvent e) {
    342342            final Pair<LatLon, LatLon> coordinates = updater.getCoordinates();
    343343            if (coordinates == null) {
     
    362362    }
    363363
    364     private static class DistanceViewer extends JPanel implements Observer {
     364    private static class DistanceViewer extends JPanel implements ChangeListener {
    365365
    366366        private final JosmTextArea lblDistance = newTextArea();
     
    417417
    418418        @Override
    419         public void update(Observable o, Object arg) {
     419        public void stateChanged(ChangeEvent e) {
    420420            refresh();
    421421        }
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java

    r10194 r10210  
    99import java.util.HashSet;
    1010import java.util.List;
    11 import java.util.Observable;
    1211import java.util.Set;
    1312
     
    4645import org.openstreetmap.josm.gui.layer.Layer;
    4746import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     47import org.openstreetmap.josm.gui.util.ChangeNotifier;
    4848import org.openstreetmap.josm.tools.CheckParameterUtil;
    4949import org.openstreetmap.josm.tools.date.DateUtils;
     
    7474 * @see HistoryBrowser
    7575 */
    76 public class HistoryBrowserModel extends Observable implements LayerChangeListener, DataSetListener {
     76public class HistoryBrowserModel extends ChangeNotifier implements LayerChangeListener, DataSetListener {
    7777    /** the history of an OsmPrimitive */
    7878    private History history;
     
    198198        initNodeListTableModels();
    199199        initMemberListTableModels();
    200         setChanged();
    201         notifyObservers();
     200        fireStateChanged();
    202201        versionTableModel.fireTableDataChanged();
    203202    }
     
    317316        initNodeListTableModels();
    318317        initMemberListTableModels();
    319         setChanged();
    320         notifyObservers();
     318        fireStateChanged();
    321319    }
    322320
     
    348346        initNodeListTableModels();
    349347        initMemberListTableModels();
    350         setChanged();
    351         notifyObservers();
     348        fireStateChanged();
    352349    }
    353350
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryViewerPanel.java

    r8510 r10210  
    4141    public final void setModel(HistoryBrowserModel model) {
    4242        if (this.model != null) {
    43             unregisterAsObserver(model);
     43            unregisterAsChangeListener(model);
    4444        }
    4545        this.model = model;
    4646        if (this.model != null) {
    47             registerAsObserver(model);
     47            registerAsChangeListener(model);
    4848        }
    4949    }
    5050
    51     protected final void unregisterAsObserver(HistoryBrowserModel model) {
     51    protected final void unregisterAsChangeListener(HistoryBrowserModel model) {
    5252        if (currentInfoPanel != null) {
    53             model.deleteObserver(currentInfoPanel);
     53            model.removeChangeListener(currentInfoPanel);
    5454        }
    5555        if (referenceInfoPanel != null) {
    56             model.deleteObserver(referenceInfoPanel);
     56            model.removeChangeListener(referenceInfoPanel);
    5757        }
    5858    }
    5959
    60     protected final void registerAsObserver(HistoryBrowserModel model) {
     60    protected final void registerAsChangeListener(HistoryBrowserModel model) {
    6161        if (currentInfoPanel != null) {
    62             model.addObserver(currentInfoPanel);
     62            model.addChangeListener(currentInfoPanel);
    6363        }
    6464        if (referenceInfoPanel != null) {
    65             model.addObserver(referenceInfoPanel);
     65            model.addChangeListener(referenceInfoPanel);
    6666        }
    6767    }
  • trunk/src/org/openstreetmap/josm/gui/history/NodeListViewer.java

    r9816 r10210  
    173173    }
    174174
    175     protected void unregisterAsObserver(HistoryBrowserModel model) {
     175    protected void unregisterAsChangeListener(HistoryBrowserModel model) {
    176176        if (currentInfoPanel != null) {
    177             model.deleteObserver(currentInfoPanel);
     177            model.removeChangeListener(currentInfoPanel);
    178178        }
    179179        if (referenceInfoPanel != null) {
    180             model.deleteObserver(referenceInfoPanel);
    181         }
    182     }
    183 
    184     protected void registerAsObserver(HistoryBrowserModel model) {
     180            model.removeChangeListener(referenceInfoPanel);
     181        }
     182    }
     183
     184    protected void registerAsChangeListener(HistoryBrowserModel model) {
    185185        if (currentInfoPanel != null) {
    186             model.addObserver(currentInfoPanel);
     186            model.addChangeListener(currentInfoPanel);
    187187        }
    188188        if (referenceInfoPanel != null) {
    189             model.addObserver(referenceInfoPanel);
     189            model.addChangeListener(referenceInfoPanel);
    190190        }
    191191    }
     
    197197    public void setModel(HistoryBrowserModel model) {
    198198        if (this.model != null) {
    199             unregisterAsObserver(model);
     199            unregisterAsChangeListener(model);
    200200        }
    201201        this.model = model;
    202202        if (this.model != null) {
    203             registerAsObserver(model);
     203            registerAsChangeListener(model);
    204204        }
    205205    }
  • trunk/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java

    r9680 r10210  
    1515import java.util.Collections;
    1616import java.util.Date;
    17 import java.util.Observable;
    18 import java.util.Observer;
    1917
    2018import javax.swing.AbstractAction;
     
    2422import javax.swing.JPanel;
    2523import javax.swing.JTextArea;
     24import javax.swing.event.ChangeEvent;
     25import javax.swing.event.ChangeListener;
    2626
    2727import org.openstreetmap.josm.Main;
     
    4848 * @since 1709
    4949 */
    50 public class VersionInfoPanel extends JPanel implements Observer {
     50public class VersionInfoPanel extends JPanel implements ChangeListener {
    5151    private final PointInTimeType pointInTimeType;
    5252    private final transient HistoryBrowserModel model;
     
    189189        this.model = model;
    190190        this.pointInTimeType = pointInTimeType;
    191         model.addObserver(this);
     191        model.addChangeListener(this);
    192192        build();
    193193    }
     
    198198
    199199    @Override
    200     public void update(Observable o, Object arg) {
     200    public void stateChanged(ChangeEvent e) {
    201201        HistoryOsmPrimitive primitive = getPrimitive();
    202202        if (primitive != null) {
  • trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java

    r10021 r10210  
    1414import java.awt.event.KeyEvent;
    1515import java.awt.event.MouseEvent;
    16 import java.util.Observable;
    17 import java.util.Observer;
    1816
    1917import javax.swing.DefaultCellEditor;
     
    2523import javax.swing.SwingConstants;
    2624import javax.swing.UIManager;
     25import javax.swing.event.ChangeEvent;
     26import javax.swing.event.ChangeListener;
    2727import javax.swing.event.TableModelEvent;
    2828import javax.swing.event.TableModelListener;
     
    4545 * @since 1709
    4646 */
    47 public class VersionTable extends JTable implements Observer {
     47public class VersionTable extends JTable implements ChangeListener {
    4848    private VersionTablePopupMenu popupMenu;
    4949    private final transient HistoryBrowserModel model;
     
    5555    public VersionTable(HistoryBrowserModel model) {
    5656        super(model.getVersionTableModel(), new VersionTableColumnModel());
    57         model.addObserver(this);
     57        model.addChangeListener(this);
    5858        build();
    5959        this.model = model;
     
    117117
    118118    @Override
    119     public void update(Observable o, Object arg) {
     119    public void stateChanged(ChangeEvent e) {
    120120        repaint();
    121121    }
  • trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java

    r10173 r10210  
    1616import java.util.LinkedList;
    1717import java.util.List;
    18 import java.util.Observable;
    19 import java.util.Observer;
    2018
    2119import javax.swing.Action;
     
    2321import javax.swing.JEditorPane;
    2422import javax.swing.JPanel;
     23import javax.swing.event.ChangeEvent;
     24import javax.swing.event.ChangeListener;
    2525import javax.swing.event.HyperlinkEvent;
    2626import javax.swing.event.HyperlinkListener;
     
    122122        this.changesetCommentModel = changesetCommentModel;
    123123        this.changesetSourceModel = changesetSourceModel;
    124         changesetCommentModel.addObserver(new ChangesetCommentObserver(hcbUploadComment));
    125         changesetSourceModel.addObserver(new ChangesetCommentObserver(hcbUploadSource));
     124        changesetCommentModel.addChangeListener(new ChangesetCommentChangeListener(hcbUploadComment));
     125        changesetSourceModel.addChangeListener(new ChangesetCommentChangeListener(hcbUploadSource));
    126126        build();
    127127    }
     
    215215     * in sync with the current changeset comment
    216216     */
    217     static class ChangesetCommentObserver implements Observer {
     217    static class ChangesetCommentChangeListener implements ChangeListener {
    218218
    219219        private final HistoryComboBox destination;
    220220
    221         ChangesetCommentObserver(HistoryComboBox destination) {
     221        ChangesetCommentChangeListener(HistoryComboBox destination) {
    222222            this.destination = destination;
    223223        }
    224224
    225225        @Override
    226         public void update(Observable o, Object arg) {
    227             if (!(o instanceof ChangesetCommentModel)) return;
    228             String newComment = (String) arg;
     226        public void stateChanged(ChangeEvent e) {
     227            if (!(e.getSource() instanceof ChangesetCommentModel)) return;
     228            String newComment = ((ChangesetCommentModel) e.getSource()).getComment();
    229229            if (!destination.getText().equals(newComment)) {
    230230                destination.setText(newComment);
  • trunk/src/org/openstreetmap/josm/gui/io/ChangesetCommentModel.java

    r8510 r10210  
    33
    44import java.util.Objects;
    5 import java.util.Observable;
     5
     6import org.openstreetmap.josm.gui.util.ChangeNotifier;
    67
    78/**
     
    1011 * @since 3133
    1112 */
    12 public class ChangesetCommentModel extends Observable {
     13public class ChangesetCommentModel extends ChangeNotifier {
    1314    private String comment = "";
    1415
     
    2223        this.comment = comment == null ? "" : comment;
    2324        if (!Objects.equals(oldValue, this.comment)) {
    24             setChanged();
    25             notifyObservers(this.comment);
     25            fireStateChanged();
    2626        }
    2727    }
  • trunk/src/org/openstreetmap/josm/gui/io/TagSettingsPanel.java

    r9685 r10210  
    44import java.awt.BorderLayout;
    55import java.util.Map;
    6 import java.util.Observable;
    7 import java.util.Observer;
    86
    97import javax.swing.JPanel;
     8import javax.swing.event.ChangeEvent;
     9import javax.swing.event.ChangeListener;
    1010import javax.swing.event.TableModelEvent;
    1111import javax.swing.event.TableModelListener;
     
    4141        this.changesetCommentModel = changesetCommentModel;
    4242        this.changesetSourceModel = changesetSourceModel;
    43         this.changesetCommentModel.addObserver(new ChangesetCommentObserver("comment"));
    44         this.changesetSourceModel.addObserver(new ChangesetCommentObserver("source"));
     43        this.changesetCommentModel.addChangeListener(new ChangesetCommentChangeListener("comment"));
     44        this.changesetSourceModel.addChangeListener(new ChangesetCommentChangeListener("source"));
    4545        build();
    4646        pnlTagEditor.getModel().addTableModelListener(this);
     
    113113     * with the current changeset comment
    114114     */
    115     class ChangesetCommentObserver implements Observer {
     115    class ChangesetCommentChangeListener implements ChangeListener {
    116116
    117117        private final String key;
    118118
    119         ChangesetCommentObserver(String key) {
     119        ChangesetCommentChangeListener(String key) {
    120120            this.key = key;
    121121        }
    122122
    123123        @Override
    124         public void update(Observable o, Object arg) {
    125             if (o instanceof ChangesetCommentModel) {
    126                 String newValue = (String) arg;
     124        public void stateChanged(ChangeEvent e) {
     125            if (e.getSource() instanceof ChangesetCommentModel) {
     126                String newValue = ((ChangesetCommentModel) e.getSource()).getComment();
    127127                String oldValue = getTagEditorValue(key);
    128128                if (oldValue == null) {
     
    130130                }
    131131                if (!oldValue.equals(newValue)) {
    132                     setProperty(key, (String) arg);
     132                    setProperty(key, newValue);
    133133                }
    134134            }
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferencesModel.java

    r9611 r10210  
    1414import java.util.Map;
    1515import java.util.Map.Entry;
    16 import java.util.Observable;
    1716import java.util.Set;
    1817
    1918import org.openstreetmap.josm.Main;
     19import org.openstreetmap.josm.gui.util.ChangeNotifier;
    2020import org.openstreetmap.josm.plugins.PluginException;
    2121import org.openstreetmap.josm.plugins.PluginHandler;
     
    2525 * The plugin model behind a {@code PluginListPanel}.
    2626 */
    27 public class PluginPreferencesModel extends Observable {
     27public class PluginPreferencesModel extends ChangeNotifier {
    2828    // remember the initial list of active plugins
    2929    private final Set<String> currentActivePlugins;
     
    6161        }
    6262        filterExpression = filter;
    63         clearChanged();
    64         notifyObservers();
     63        fireStateChanged();
    6564    }
    6665
     
    8786            }
    8887        }
    89         clearChanged();
    90         notifyObservers();
     88        fireStateChanged();
    9189    }
    9290
  • trunk/src/org/openstreetmap/josm/gui/util/AdjustmentSynchronizer.java

    r9231 r10210  
    1212import java.util.HashSet;
    1313import java.util.Map;
    14 import java.util.Observable;
    15 import java.util.Observer;
    1614import java.util.Set;
    1715
    1816import javax.swing.JCheckBox;
     17import javax.swing.event.ChangeEvent;
     18import javax.swing.event.ChangeListener;
    1919
    2020import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    3131    private final Map<Adjustable, Boolean> enabledMap;
    3232
    33     private final Observable observable;
     33    private final ChangeNotifier observable;
    3434
    3535    /**
     
    3939        synchronizedAdjustables = new HashSet<>();
    4040        enabledMap = new HashMap<>();
    41         observable = new Observable();
     41        observable = new ChangeNotifier();
    4242    }
    4343
     
    8484
    8585        enabledMap.put(adjustable, isParticipating);
    86         observable.notifyObservers();
     86        observable.fireStateChanged();
    8787    }
    8888
     
    143143        });
    144144
    145         observable.addObserver(
    146                 new Observer() {
     145        observable.addChangeListener(
     146                new ChangeListener() {
    147147                    @Override
    148                     public void update(Observable o, Object arg) {
     148                    public void stateChanged(ChangeEvent e) {
    149149                        boolean sync = isParticipatingInSynchronizedScrolling(adjustable);
    150150                        if (view.isSelected() != sync) {
Note: See TracChangeset for help on using the changeset viewer.