Changeset 2577 in josm for trunk/src/org/openstreetmap/josm
- Timestamp:
- 2009-12-05T17:54:49+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r2566 r2577 46 46 public class ToggleDialog extends JPanel implements Helpful { 47 47 /** The action to toggle this dialog */ 48 pr ivateToggleDialogAction toggleAction;49 pr ivateString preferencePrefix;48 protected ToggleDialogAction toggleAction; 49 protected String preferencePrefix; 50 50 51 51 /** DialogsPanel that manages all ToggleDialogs */ 52 pr ivateDialogsPanel dialogsPanel;53 54 pr ivateTitleBar titleBar;52 protected DialogsPanel dialogsPanel; 53 54 protected TitleBar titleBar; 55 55 56 56 /** 57 57 * Indicates whether the dialog is showing or not. 58 58 */ 59 pr ivateboolean isShowing;59 protected boolean isShowing; 60 60 /** 61 61 * If isShowing is true, indicates whether the dialog is docked or not, e. g. 62 62 * shown as part of the main window or as a seperate dialog window. 63 63 */ 64 pr ivateboolean isDocked;64 protected boolean isDocked; 65 65 /** 66 66 * If isShowing and isDocked are true, indicates whether the dialog is 67 67 * currently minimized or not. 68 68 */ 69 boolean isCollapsed;69 protected boolean isCollapsed; 70 70 71 71 /** the preferred height if the toggle dialog is expanded */ … … 139 139 140 140 public void actionPerformed(ActionEvent e) { 141 toggleButtonHook(); 141 142 if (isShowing) { 142 143 hideDialog(); … … 204 205 detachedDialog = new DetachedDialog(); 205 206 detachedDialog.setVisible(true); 207 setIsShowing(true); 206 208 setIsDocked(false); 207 209 } … … 213 215 public void collapse() { 214 216 // if (isShowing && isDocked && !isCollapsed) { 217 if (isDialogInDefaultView()) { 215 218 setContentVisible(false); 216 219 setIsCollapsed(true); … … 220 223 lblMinimized.setIcon(ImageProvider.get("misc", "minimized")); 221 224 hideNotify(); 222 //}223 // else throw ... 225 } 226 else throw new IllegalStateException(); 224 227 } 225 228 … … 229 232 protected void expand() { 230 233 // if (isShowing && isDocked && isCollapsed) { 234 if (isDialogInCollapsedView()) { 231 235 setContentVisible(true); 232 236 setIsCollapsed(false); … … 235 239 lblMinimized.setIcon(ImageProvider.get("misc", "normal")); 236 240 showNotify(); 237 //}238 // else throw ... 241 } 242 else throw new IllegalStateException(); 239 243 } 240 244 … … 392 396 getContentPane().removeAll(); 393 397 dispose(); 394 dock(); 395 expand(); 396 dialogsPanel.reconstruct(Action.INVISIBLE_TO_DEFAULT, ToggleDialog.this); 398 if (dockWhenClosingDetachedDlg()) { 399 dock(); 400 if (isDialogInCollapsedView()) { 401 expand(); 402 } 403 dialogsPanel.reconstruct(Action.INVISIBLE_TO_DEFAULT, ToggleDialog.this); 404 } else { 405 hideDialog(); 406 } 397 407 } 398 408 }); … … 426 436 427 437 /** 428 * Change the Geometry of the detached dialog to better fit the content.429 * Overrride this to make it useful.430 */431 protected Rectangle getDetachedGeometry(Rectangle last) {432 return last;433 }434 435 /**436 * Default size of the detached dialog.437 * Override this method to customize the initial dialog size.438 */439 protected Dimension getDefaultDetachedSize() {440 return new Dimension(Main.map.DEF_TOGGLE_DLG_WIDTH, preferredHeight);441 }442 443 /**444 438 * Replies the action to toggle the visible state of this toggle dialog 445 439 * … … 481 475 } 482 476 483 pr ivatevoid setIsShowing(boolean val) {477 protected void setIsShowing(boolean val) { 484 478 isShowing = val; 485 479 Main.pref.put(preferencePrefix+".visible", val); 486 480 } 487 481 488 pr ivatevoid setIsDocked(boolean val) {482 protected void setIsDocked(boolean val) { 489 483 isDocked = val; 490 484 Main.pref.put(preferencePrefix+".docked", val); 491 485 } 492 486 493 pr ivatevoid setIsCollapsed(boolean val) {487 protected void setIsCollapsed(boolean val) { 494 488 isCollapsed = val; 495 489 Main.pref.put(preferencePrefix+".minimized", val); … … 498 492 public int getPreferredHeight() { 499 493 return preferredHeight; 500 }501 502 /**503 * Replies true if this dialog is showing either as docked or as detached dialog504 */505 public boolean isDialogShowing() {506 return isShowing;507 }508 509 /**510 * Replies true if this dialog is docked and expanded511 */512 public boolean isDialogInDefaultView() {513 return isShowing && isDocked && (! isCollapsed);514 }515 516 /**517 * Replies true if this dialog is docked and collapsed518 */519 public boolean isDialogInCollapsedView() {520 return isShowing && isDocked && isCollapsed;521 494 } 522 495 … … 526 499 return "Dialog/"+help; 527 500 } 501 /** 502 * Replies true if this dialog is showing either as docked or as detached dialog 503 */ 504 public boolean isDialogShowing() { 505 return isShowing; 506 } 507 508 /** 509 * Replies true if this dialog is docked and expanded 510 */ 511 public boolean isDialogInDefaultView() { 512 return isShowing && isDocked && (! isCollapsed); 513 } 514 515 /** 516 * Replies true if this dialog is docked and collapsed 517 */ 518 public boolean isDialogInCollapsedView() { 519 return isShowing && isDocked && isCollapsed; 520 } 521 522 /*** 523 * The following methods are intended to be overridden, in order to customize 524 * the toggle dialog behavior. 525 **/ 526 527 /** 528 * Change the Geometry of the detached dialog to better fit the content. 529 */ 530 protected Rectangle getDetachedGeometry(Rectangle last) { 531 return last; 532 } 533 534 /** 535 * Default size of the detached dialog. 536 * Override this method to customize the initial dialog size. 537 */ 538 protected Dimension getDefaultDetachedSize() { 539 return new Dimension(dialogsPanel.getWidth(), preferredHeight); 540 } 541 542 /** 543 * Do something when the toggleButton is pressed. 544 */ 545 protected void toggleButtonHook() { 546 } 547 548 protected boolean dockWhenClosingDetachedDlg() { 549 return true; 550 } 551 552 /*** 553 * End of override hooks 554 **/ 528 555 } -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r2566 r2577 322 322 return; 323 323 } 324 JFileChooser fc = new JFileChooser(Main.pref.get("tagimages.lastdirectory" ));324 JFileChooser fc = new JFileChooser(Main.pref.get("tagimages.lastdirectory", Main.pref.get("lastDirectory"))); 325 325 fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); 326 326 fc.setMultiSelectionEnabled(true); -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java
r2566 r2577 21 21 import org.openstreetmap.josm.Main; 22 22 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 23 import org.openstreetmap.josm.gui.dialogs.DialogsPanel.Action; 23 24 import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer.ImageEntry; 24 25 import org.openstreetmap.josm.tools.ImageProvider; … … 45 46 return INSTANCE; 46 47 } 47 48 48 49 private JButton btnNext; 49 50 private JButton btnPrevious; … … 52 53 super(tr("Geotagged Images"), "geoimage", tr("Display geotagged images"), Shortcut.registerShortcut("tools:geotagged", tr("Tool: {0}", tr("Display geotagged images")), KeyEvent.VK_Y, Shortcut.GROUP_EDIT), 200); 53 54 55 /* Don't show a detached dialog right from the start. */ 56 if (isShowing && !isDocked) { 57 setIsShowing(false); 58 } 59 54 60 if (INSTANCE != null) { 55 61 throw new IllegalStateException("Image viewer dialog should not be instanciated twice !"); … … 57 63 58 64 INSTANCE = this; 59 65 60 66 JPanel content = new JPanel(); 61 67 content.setLayout(new BorderLayout()); … … 188 194 imgDisplay.setOsdText(""); 189 195 } 190 } 191 196 if (! isDialogShowing()) { 197 setIsDocked(false); // always open a detached window when an image is clicked and dialog is closed 198 showDialog(); 199 } else { 200 if (isDocked && isCollapsed) { 201 expand(); 202 dialogsPanel.reconstruct(Action.COLLAPSED_TO_DEFAULT, this); 203 } 204 } 205 206 } 207 208 /** 209 * When pressing the Toggle button always show the docked dialog. 210 */ 211 @Override 212 protected void toggleButtonHook() { 213 if (! isShowing) { 214 setIsDocked(true); 215 setIsCollapsed(false); 216 } 217 } 218 219 /** 220 * When an image is closed, really close it and do not pop 221 * up the side dialog. 222 */ 223 @Override 224 protected boolean dockWhenClosingDetachedDlg() { 225 return false; 226 } 227 192 228 /** 193 229 * Returns whether an image is currently displayed
Note:
See TracChangeset
for help on using the changeset viewer.