Changeset 5646 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2012-12-29T16:07:47+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r5638 r5646 447 447 } 448 448 449 protected final void rememberWindowGeometry(WindowGeometry geometry) { 450 if (geometry != null) { 451 geometry.remember(rememberSizePref); 452 } 453 } 454 455 protected final WindowGeometry initWindowGeometry() { 456 return new WindowGeometry(rememberSizePref, defaultWindowGeometry); 457 } 458 449 459 /** 450 460 * Override setVisible to be able to save the window geometry if required … … 459 469 if(rememberSizePref.length() != 0 && defaultWindowGeometry != null) { 460 470 if(visible) { 461 new WindowGeometry(rememberSizePref, 462 defaultWindowGeometry).applySafe(this); 471 initWindowGeometry().applySafe(this); 463 472 } else if (isShowing()) { // should fix #6438, #6981, #8295 464 new WindowGeometry(this).remember(rememberSizePref);473 rememberWindowGeometry(new WindowGeometry(this)); 465 474 } 466 475 } … … 473 482 474 483 /** 475 * Call this if you want the dialog to remember the sizeset by the user.484 * Call this if you want the dialog to remember the geometry (size and position) set by the user. 476 485 * Set the pref to <code>null</code> or to an empty string to disable again. 477 486 * By default, it's disabled. -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r5645 r5646 8 8 import java.awt.Component; 9 9 import java.awt.Cursor; 10 import java.awt.Dimension; 10 11 import java.awt.FlowLayout; 11 12 import java.awt.Font; … … 24 25 import java.awt.event.MouseEvent; 25 26 import java.awt.image.BufferedImage; 26 import java.security.KeyStore;27 27 import java.util.ArrayList; 28 28 import java.util.Arrays; … … 37 37 import java.util.Map; 38 38 import java.util.Vector; 39 39 40 import javax.swing.AbstractAction; 40 41 import javax.swing.Action; … … 50 51 import javax.swing.table.DefaultTableModel; 51 52 import javax.swing.text.JTextComponent; 53 52 54 import org.openstreetmap.josm.Main; 53 55 import org.openstreetmap.josm.actions.JosmAction; … … 67 69 import org.openstreetmap.josm.tools.GBC; 68 70 import org.openstreetmap.josm.tools.Shortcut; 71 import org.openstreetmap.josm.tools.WindowGeometry; 69 72 70 73 /** … … 206 209 207 210 208 public class EditTagDialog extends ExtendedDialog { 209 AutoCompletingComboBox keys; 210 AutoCompletingComboBox values; 211 public class EditTagDialog extends AbstractTagsDialog { 211 212 String oldValue; 212 213 String key; … … 257 258 this.m = map; 258 259 259 // TODO : How to remember position, allowing autosizing?260 // setRememberWindowGeometry(getClass().getName() + ".geometry",261 // WindowGeometry.centerInWindow(Main.parent, new Dimension(270, 180)));262 //setRememberWindowGeometry(getClass().getName() + ".geometry",263 // WindowGeometry.centerInWindow(Main.parent, new Dimension(270, 180)));264 265 260 JPanel mainPanel = new JPanel(new BorderLayout()); 266 261 … … 315 310 // @Override public void selectInitialValue() { 316 311 Clipboard sysSel = Toolkit.getDefaultToolkit().getSystemSelection(); 317 318 319 320 321 322 323 324 325 326 } 327 328 312 if(sysSel != null) { 313 Transferable old = sysSel.getContents(null); 314 values.requestFocusInWindow(); 315 values.getEditor().selectAll(); 316 sysSel.setContents(old, null); 317 } else { 318 values.requestFocusInWindow(); 319 values.getEditor().selectAll(); 320 } 321 } 322 323 /** 329 324 * Edit tags of multiple selected objects according to selected ComboBox values 330 325 * If value == "", tag will be deleted … … 399 394 } 400 395 } 401 402 class AddTagsDialog extends ExtendedDialog {396 397 abstract class AbstractTagsDialog extends ExtendedDialog { 403 398 AutoCompletingComboBox keys; 404 399 AutoCompletingComboBox values; 400 401 public AbstractTagsDialog(Component parent, String title, String[] buttonTexts) { 402 super(parent, title, buttonTexts); 403 } 404 405 @Override 406 public void setupDialog() { 407 setResizable(false); 408 super.setupDialog(); 409 410 setRememberWindowGeometry(getClass().getName() + ".geometry", 411 WindowGeometry.centerInWindow(Main.parent, getSize())); 412 } 413 414 @Override 415 public void setVisible(boolean visible) { 416 // Do not want dialog to be resizable, but its size may increase each time because of the recently added tags 417 // So need to modify the stored geometry (size part only) in order to use the automatic positioning mechanism 418 if (visible) { 419 WindowGeometry geometry = initWindowGeometry(); 420 Dimension storedSize = geometry.getSize(); 421 if (!storedSize.equals(getSize())) { 422 storedSize.setSize(getSize()); 423 rememberWindowGeometry(geometry); 424 } 425 } 426 super.setVisible(visible); 427 } 428 } 429 430 class AddTagsDialog extends AbstractTagsDialog { 405 431 List<JosmAction> recentTagsActions = new ArrayList<JosmAction>(); 406 432 … … 412 438 setButtonIcons(new String[] {"ok","cancel"}); 413 439 setCancelButton(2); 414 415 // TODO : How to remember position, allowing autosizing?416 // setRememberWindowGeometry(getClass().getName() + ".geometry",417 // WindowGeometry.centerInWindow(Main.parent, new Dimension(270, 180)));418 440 419 441 JPanel mainPanel = new JPanel(new GridBagLayout()); … … 486 508 setContent(mainPanel, false); 487 509 488 // TODO: Is it correct place for th ois code - was in510 // TODO: Is it correct place for this code - was in 489 511 // new JOptionPane(p, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION) { 490 512 // @Override public void selectInitialValue() { 491 513 Clipboard sysSel = Toolkit.getDefaultToolkit().getSystemSelection(); 492 if(sysSel != null) { 493 Transferable old = sysSel.getContents(null); 494 values.requestFocusInWindow(); 495 values.getEditor().selectAll(); 496 sysSel.setContents(old, null); 497 } else { 498 values.requestFocusInWindow(); 499 values.getEditor().selectAll(); 500 } 501 502 514 if(sysSel != null) { 515 Transferable old = sysSel.getContents(null); 516 values.requestFocusInWindow(); 517 values.getEditor().selectAll(); 518 sysSel.setContents(old, null); 519 } else { 520 values.requestFocusInWindow(); 521 values.getEditor().selectAll(); 522 } 503 523 } 504 524
Note:
See TracChangeset
for help on using the changeset viewer.