Changeset 4765 in josm
- Timestamp:
- 2012-01-04T13:34:49+01:00 (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r4609 r4765 83 83 */ 84 84 protected boolean isCollapsed; 85 /** 86 * Indicates whether dynamic button hiding is active or not. 87 */ 88 protected boolean isButtonHiding; 85 89 86 90 /** the preferred height if the toggle dialog is expanded */ … … 89 93 /** the label in the title bar which shows whether the toggle dialog is expanded or collapsed */ 90 94 private JLabel lblMinimized; 95 96 /** the label in the title bar which shows whether buttons are dynamic or not */ 97 private JButton buttonsHide = null; 91 98 92 99 /** the JDialog displaying the toggle dialog as undocked dialog */ … … 132 139 toggleAction.putValue("help", helpId.substring(0, helpId.length()-6)); 133 140 134 /** show the minimize button */135 lblMinimized = new JLabel(ImageProvider.get("misc", "normal"));136 titleBar = new TitleBar(name, iconName);137 add(titleBar, BorderLayout.NORTH);138 139 setBorder(BorderFactory.createEtchedBorder());140 141 141 isShowing = Main.pref.getBoolean(preferencePrefix+".visible", defShow); 142 142 isDocked = Main.pref.getBoolean(preferencePrefix+".docked", true); 143 143 isCollapsed = Main.pref.getBoolean(preferencePrefix+".minimized", false); 144 isButtonHiding = Main.pref.getBoolean(preferencePrefix+".buttonhiding", true); 145 146 /** show the minimize button */ 147 titleBar = new TitleBar(name, iconName); 148 add(titleBar, BorderLayout.NORTH); 149 150 setBorder(BorderFactory.createEtchedBorder()); 144 151 145 152 RedirectInputMap.redirectToMainContentPane(this); … … 222 229 dialogsPanel.reconstruct(Action.COLLAPSED_TO_DEFAULT, this); 223 230 } else if (!isDialogShowing()) { 224 // if (isButtonHidden()) {225 // showButtonImpl();226 // }227 231 showDialog(); 228 232 if (isDocked && isCollapsed) { … … 289 293 */ 290 294 public void collapse() { 291 // if (isShowing && isDocked && !isCollapsed) {292 295 if (isDialogInDefaultView()) { 293 296 setContentVisible(false); … … 305 308 */ 306 309 protected void expand() { 307 // if (isShowing && isDocked && isCollapsed) {308 310 if (isDialogInCollapsedView()) { 309 311 setContentVisible(true); … … 375 377 public TitleBar(String toggleDialogName, String iconName) { 376 378 setLayout(new GridBagLayout()); 379 377 380 lblMinimized = new JLabel(ImageProvider.get("misc", "normal")); 378 381 add(lblMinimized); … … 404 407 @Override 405 408 public void mouseClicked(MouseEvent e) { 406 // toggleExpandedState407 409 if (isCollapsed) { 408 410 expand(); … … 415 417 } 416 418 ); 419 420 if(Main.pref.getBoolean("dialog.dynamic.buttons", true)) { 421 buttonsHide = new JButton(ImageProvider.get("misc", isButtonHiding ? "buttonhide" : "buttonshow")); 422 buttonsHide.setToolTipText(tr("Toggle dynamic buttons")); 423 buttonsHide.setBorder(BorderFactory.createEmptyBorder()); 424 buttonsHide.addActionListener( 425 new ActionListener(){ 426 public void actionPerformed(ActionEvent e) { 427 setIsButtonHiding(!isButtonHiding); 428 } 429 } 430 ); 431 add(buttonsHide); 432 } 417 433 418 434 // show the sticky button … … 574 590 } 575 591 592 protected void setIsButtonHiding(boolean val) { 593 isButtonHiding = val; 594 Main.pref.put(preferencePrefix+".buttonhiding", val); 595 buttonsHide.setIcon(ImageProvider.get("misc", val ? "buttonhide" : "buttonshow")); 596 stateChanged(); 597 } 598 576 599 public int getPreferredHeight() { 577 600 return preferredHeight; … … 652 675 */ 653 676 protected void stateChanged() { 654 }655 656 /* use createLayout() instead of self-constructed dialogs */657 @Deprecated658 protected JPanel getButtonPanel(int columns) {659 JPanel pnl = new JPanel();660 pnl.setLayout(Main.pref.getBoolean("dialog.align.left", false)661 ? new FlowLayout(FlowLayout.LEFT) : new GridLayout(1,columns));662 return pnl;663 677 } 664 678 … … 677 691 buttonsPanel.setVisible(false); 678 692 } 693 } else if(buttonsHide != null) { 694 buttonsHide.setVisible(false); 679 695 } 680 696 return data; … … 683 699 @Override 684 700 public void eventDispatched(AWTEvent event) { 685 if(isShowing() && !isCollapsed) { 701 if(isShowing() && !isCollapsed && isButtonHiding) { 686 702 Rectangle b = this.getBounds(); 687 703 b.setLocation(getLocationOnScreen());
Note:
See TracChangeset
for help on using the changeset viewer.