Changeset 1783 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2009-07-13T18:47:57+02:00 (15 years ago)
Author:
Gubaer
Message:

fixed #2929: Relation Editor: Cancel button does not cancel edits

Location:
trunk/src/org/openstreetmap/josm/gui/dialogs/relation
Files:
3 edited

Legend:

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

    r1775 r1783  
    5050import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    5151import org.openstreetmap.josm.gui.SideButton;
    52 import org.openstreetmap.josm.gui.dialogs.ConflictDialog;
    5352import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionCache;
    5453import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionList;
     
    536535     */
    537536    private void applyChanges() {
     537        System.out.println("applying changes ...");
    538538        if (getRelation()== null) {
    539539            // If the user wanted to create a new relation, but hasn't added any members or
     
    880880        Main.worker.submit(new DownloadTask());
    881881    }
     882
     883    @Override
     884    public void setVisible(boolean visible) {
     885        super.setVisible(visible);
     886        if (!visible) {
     887            dispose();
     888        }
     889    }
    882890}
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java

    r1772 r1783  
    1717 *
    1818 */
    19 public class RelationDialogManager extends WindowAdapter implements LayerChangeListener {
     19public class RelationDialogManager extends WindowAdapter implements LayerChangeListener{
     20
     21    /**
     22     * Helper class for keeping the context of a relation editor. A relation editor
     23     * is open for a specific relation managed by a specific {@see OsmDataLayer}
     24     *
     25     */
    2026    static private class DialogContext {
    2127        public Relation relation;
     
    6167            return this.layer.equals(layer);
    6268        }
     69
     70        @Override
     71        public String toString() {
     72            return "[Context: layer=" + layer.getName() + ",relation=" + relation.id + "]";
     73        }
    6374    }
    6475
     76    /** the map of open dialogs */
    6577    private HashMap<DialogContext, RelationEditor> openDialogs;
    6678
     79    /**
     80     * constructor
     81     */
    6782    public RelationDialogManager(){
     83        System.out.println("RelationDialogManager: creating");
    6884        openDialogs = new HashMap<DialogContext, RelationEditor>();
    6985    }
    7086
     87    /**
     88     * Register the relation editor for a relation managed by a
     89     * {@see OsmDataLayer}.
     90     *
     91     * @param layer the layer
     92     * @param relation the relation
     93     * @param editor the editor
     94     */
    7195    public void register(OsmDataLayer layer, Relation relation, RelationEditor editor) {
    7296        DialogContext context = new DialogContext(layer, relation);
     
    7599    }
    76100
     101    /**
     102     * Replies true if there is an open relation editor for the relation managed
     103     * by the given layer
     104     *
     105     * @param layer  the layer
     106     * @param relation  the relation
     107     * @return true if there is an open relation editor for the relation managed
     108     * by the given layer; false otherwise
     109     */
    77110    public boolean isOpenInEditor(OsmDataLayer layer, Relation relation) {
    78111        DialogContext context = new DialogContext(layer, relation);
    79112        return openDialogs.keySet().contains(context);
     113
    80114    }
    81115
     116    /**
     117     * Replies the editor for the relation managed by layer. Null, if no such editor
     118     * is currently open.
     119     *
     120     * @param layer the layer
     121     * @param relation the relation
     122     * @return the editor for the relation managed by layer. Null, if no such editor
     123     * is currently open.
     124     *
     125     * @see #isOpenInEditor(OsmDataLayer, Relation)
     126     */
    82127    public RelationEditor getEditorForRelation(OsmDataLayer layer, Relation relation) {
    83128        DialogContext context = new DialogContext(layer, relation);
     
    85130    }
    86131
    87     @Override
    88     public void windowClosed(WindowEvent e) {
    89         RelationEditor editor = ((RelationEditor)e.getWindow());
    90         DialogContext context = null;
    91         for (DialogContext c : openDialogs.keySet()) {
    92             if (openDialogs.get(c).equals(editor)) {
    93                 context = c;
    94                 break;
    95             }
    96         }
    97         if (context != null) {
    98             openDialogs.remove(context);
    99         }
    100     }
    101 
     132    /**
     133     * called when a layer is removed
     134     *
     135     */
    102136    public void layerRemoved(Layer oldLayer) {
    103137        if (oldLayer == null || ! (oldLayer instanceof OsmDataLayer))
     
    124158        // do nothing
    125159    }
     160
     161    @Override
     162    public void windowClosed(WindowEvent e) {
     163        RelationEditor editor = (RelationEditor)e.getWindow();
     164        DialogContext context = null;
     165        for (DialogContext c : openDialogs.keySet()) {
     166            if (openDialogs.get(c).equals(editor)) {
     167                context = c;
     168                break;
     169            }
     170        }
     171        if (context != null) {
     172            openDialogs.remove(context);
     173        }
     174    }
    126175}
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java

    r1773 r1783  
    1010
    1111import org.openstreetmap.josm.Main;
    12 import org.openstreetmap.josm.data.osm.OsmPrimitive;
    13 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1412import org.openstreetmap.josm.data.osm.Relation;
    1513import org.openstreetmap.josm.data.osm.RelationMember;
Note: See TracChangeset for help on using the changeset viewer.