Changeset 6170 in josm for trunk


Ignore:
Timestamp:
2013-08-21T12:56:46+02:00 (11 years ago)
Author:
Don-vip
Message:

make ToggleDialog Destroyable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    r6104 r6170  
    7373 *
    7474 */
    75 public class ToggleDialog extends JPanel implements ShowHideButtonListener, Helpful, AWTEventListener {
     75public class ToggleDialog extends JPanel implements ShowHideButtonListener, Helpful, AWTEventListener, Destroyable {
    7676
    7777    public enum ButtonHiddingType {
     
    398398    }
    399399
     400    @Override
    400401    public void destroy() {
    401402        closeDetachedDialog();
     
    403404        Main.main.menu.windowMenu.remove(windowMenuItem);
    404405        Toolkit.getDefaultToolkit().removeAWTEventListener(this);
    405         destroyComponents(this);
    406     }
    407 
    408     private void destroyComponents(Component component) {
     406        destroyComponents(this, false);
     407    }
     408
     409    private void destroyComponents(Component component, boolean destroyItself) {
    409410        if (component instanceof Container) {
    410411            for (Component c: ((Container)component).getComponents()) {
    411                 destroyComponents(c);
    412             }
    413         }
    414         if (component instanceof Destroyable) {
     412                destroyComponents(c, true);
     413            }
     414        }
     415        if (destroyItself && component instanceof Destroyable) {
    415416            ((Destroyable) component).destroy();
    416417        }
Note: See TracChangeset for help on using the changeset viewer.