Changeset 2488 in josm for trunk/src


Ignore:
Timestamp:
2009-11-21T13:44:33+01:00 (15 years ago)
Author:
Gubaer
Message:

fixed #3997: relation-list does not update
RelationListDialog now listening to dataChanged events too

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

    r2487 r2488  
    4545import org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditor;
    4646import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor;
     47import org.openstreetmap.josm.gui.layer.DataChangeListener;
    4748import org.openstreetmap.josm.gui.layer.Layer;
    4849import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    5960 * objects are visible on the map and can be selected there. Relations are not.
    6061 */
    61 public class RelationListDialog extends ToggleDialog implements LayerChangeListener, DataSetListener {
     62public class RelationListDialog extends ToggleDialog implements LayerChangeListener, DataSetListener, DataChangeListener {
    6263    //private static final Logger logger = Logger.getLogger(RelationListDialog.class.getName());
    6364
     
    522523
    523524        public synchronized void setRelations(Collection<Relation> relations) {
     525            List<Relation> sel =  getSelectedRelations();
    524526            if (relations == null) {
    525527                this.relations = null;
     
    534536            sort();
    535537            fireIntervalAdded(this, 0, getSize());
    536             selectionModel.clearSelection();
     538            setSelectedRelations(sel);
    537539        }
    538540
     
    631633        public List<Relation> getSelectedNonNewRelations() {
    632634            ArrayList<Relation> ret = new ArrayList<Relation>();
     635            if (relations == null) return ret;
    633636            for (int i=0; i<getSize();i++) {
    634637                if (!selectionModel.isSelectedIndex(i)) {
     
    651654        public List<Relation> getSelectedRelations() {
    652655            ArrayList<Relation> ret = new ArrayList<Relation>();
     656            if (relations == null) return ret;
    653657            for (int i=0; i<getSize();i++) {
    654658                if (!selectionModel.isSelectedIndex(i)) {
     
    706710        if (a != null && a instanceof OsmDataLayer) {
    707711            ((OsmDataLayer)a).data.removeDataSetListener(this);
     712            ((OsmDataLayer)a).listenerDataChanged.remove(this);
    708713        }
    709714        if (b != null && b instanceof OsmDataLayer) {
    710715            ((OsmDataLayer)b).data.addDataSetListener(this);
     716            ((OsmDataLayer)b).listenerDataChanged.add(this);
    711717        }
    712718
     
    786792        }
    787793    }
     794
     795    /* ---------------------------------------------------------------------------------- */
     796    /* DataSetListener                                                                    */
     797    /* ---------------------------------------------------------------------------------- */
     798    public void dataChanged(OsmDataLayer l) {
     799        if (l != null && l == Main.main.getEditLayer()) {
     800            initFromLayer(l);
     801        }
     802    }
    788803}
Note: See TracChangeset for help on using the changeset viewer.