Changeset 2138 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2009-09-14T23:02:59+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.