Changeset 13774 in josm for trunk


Ignore:
Timestamp:
2018-05-15T22:52:56+02:00 (13 months ago)
Author:
wiktorn
Message:

Remember Add Imagery dialog position

See: #16249

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddImageryDialog.java

    r12530 r13774  
    77import java.awt.Dimension;
    88
     9import org.openstreetmap.josm.Main;
    910import org.openstreetmap.josm.gui.ExtendedDialog;
    1011import org.openstreetmap.josm.gui.preferences.imagery.AddImageryPanel.ContentValidationListener;
     12import org.openstreetmap.josm.gui.util.WindowGeometry;
    1113
    1214/**
     
    1517 */
    1618public class AddImageryDialog extends ExtendedDialog implements ContentValidationListener {
     19
     20    private final String saveGeometryEntryName;
    1721
    1822    /**
     
    2933        setMinimumSize(new Dimension(300, 400));
    3034        panel.addContentValidationListener(this);
     35        this.saveGeometryEntryName = panel.getClass().getName() + ".geometry";
    3136    }
    3237
     
    4146        buttons.get(0).setEnabled(isValid);
    4247    }
     48
     49    @Override
     50    public void setVisible(boolean visible) {
     51        if (visible) {
     52            new WindowGeometry(saveGeometryEntryName, WindowGeometry.centerInWindow(Main.parent,
     53                    new Dimension(800, 600))).applySafe(this);
     54        } else if (isShowing()) { // Avoid IllegalComponentStateException like in #8775
     55            new WindowGeometry(this).remember(saveGeometryEntryName);
     56        }
     57        super.setVisible(visible);
     58    }
    4359}
Note: See TracChangeset for help on using the changeset viewer.