- Timestamp:
- 2009-09-14T23:02:59+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/DownloadAction.java
r2132 r2138 46 46 47 47 final String prefName = dialog.getClass().getName()+ ".geometry"; 48 ExtendedDialog dialog = new ExtendedDialog(Main.parent, tr("Download"), new String[] {tr("OK"), tr("Cancel")}) { 49 @Override 50 public void setVisible(boolean visible) { 51 if (visible) { 52 new WindowGeometry( 53 prefName, 54 WindowGeometry.centerInWindow(Main.parent, new Dimension(1000,600)) 55 ).apply(this); 56 } else { 57 new WindowGeometry(this).remember(prefName); 58 } 59 super.setVisible(visible); 60 } 61 }; 48 final WindowGeometry wg = WindowGeometry.centerInWindow(Main.parent, 49 new Dimension(1000,600)); 50 51 ExtendedDialog dialog = new ExtendedDialog(Main.parent, 52 tr("Download"), 53 new String[] {tr("OK"), tr("Cancel")}); 62 54 dialog.setContent(downPanel, false /* don't use a scroll pane inside the dialog */); 63 55 dialog.setButtonIcons(new String[] {"ok", "cancel"}); 56 dialog.setRememberWindowGeometry(prefName, wg); 64 57 return dialog; 65 58 } -
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r2135 r2138 25 25 import org.openstreetmap.josm.tools.GBC; 26 26 import org.openstreetmap.josm.tools.ImageProvider; 27 import org.openstreetmap.josm.tools.WindowGeometry; 27 28 28 29 … … 32 33 public static final int DialogClosedOtherwise = 0; 33 34 private boolean toggleable = false; 35 private String rememberSizePref = ""; 36 private WindowGeometry defaultWindowGeometry = null; 34 37 private String togglePref = ""; 35 38 private String toggleCheckboxText = tr("Do not show again"); … … 59 62 * <li><code>toggleDisable</code></li> 60 63 * <li><code>setToggleCheckboxText</code></li> 64 * <li><code>setRememberWindowGeometry</code></li> 61 65 * </ul> 62 66 * … … 286 290 @Override 287 291 public void setVisible(boolean visible) { 288 super.setVisible(visible);289 292 if (visible) { 290 293 repaint(); 291 294 } 295 296 // Ensure all required variables are available 297 if(!rememberSizePref.isEmpty() && defaultWindowGeometry != null) { 298 if(visible) { 299 new WindowGeometry(rememberSizePref, 300 defaultWindowGeometry).apply(this); 301 } else { 302 new WindowGeometry(this).remember(rememberSizePref); 303 } 304 } 305 super.setVisible(visible); 306 } 307 308 /** 309 * Call this if you want the dialog to remember the size set by the user. 310 * Set the pref to <code>null</code> or to an empty string to disable again. 311 * By default, it's disabled. 312 * 313 * Note: If you want to set the width of this dialog directly use the usual 314 * setSize, setPreferredSize, setMaxSize, setMinSize 315 * 316 * @param pref The preference to save the dimension to 317 * @param wg The default window geometry that should be used if no 318 * existing preference is found (only takes effect if 319 * <code>pref</code> is not null or empty 320 * 321 */ 322 public void setRememberWindowGeometry(String pref, WindowGeometry wg) { 323 rememberSizePref = pref == null ? "" : pref; 324 defaultWindowGeometry = wg; 292 325 } 293 326
Note:
See TracChangeset
for help on using the changeset viewer.