Changeset 2475 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2009-11-19T08:51:27+01:00 (14 years ago)
Author:
jttt
Message:

Added methods showNotify and hideNotify to ToggleDialog. Useful to register listeners only when dialog is shown and expanded

Location:
trunk/src/org/openstreetmap/josm/gui/dialogs
Files:
2 edited

Legend:

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

    r2317 r2475  
    33package org.openstreetmap.josm.gui.dialogs;
    44
    5 import static org.openstreetmap.josm.tools.I18n.tr;
    6 
    75import java.awt.Dimension;
    8 
    96import java.util.ArrayList;
    107import java.util.List;
     
    1411import javax.swing.JSplitPane;
    1512
    16 import org.openstreetmap.josm.gui.MultiSplitLayout;
     13import org.openstreetmap.josm.gui.MultiSplitPane;
     14import org.openstreetmap.josm.gui.MultiSplitLayout.Divider;
     15import org.openstreetmap.josm.gui.MultiSplitLayout.Leaf;
    1716import org.openstreetmap.josm.gui.MultiSplitLayout.Node;
    18 import org.openstreetmap.josm.gui.MultiSplitLayout.Leaf;
    19 import org.openstreetmap.josm.gui.MultiSplitLayout.Divider;
    2017import org.openstreetmap.josm.gui.MultiSplitLayout.Split;
    21 import org.openstreetmap.josm.gui.MultiSplitPane;
    22 import org.openstreetmap.josm.Main;
    2318
    2419public class DialogsPanel extends JPanel {
     
    3126     */
    3227    private List<JPanel> panels = new ArrayList<JPanel>();
    33    
     28
    3429    final private JSplitPane parent;
    3530    public DialogsPanel(JSplitPane parent) {
     
    3934    private boolean initialized = false;
    4035    public void initialize(List<ToggleDialog> allDialogs) {
    41         if (initialized) {
     36        if (initialized)
    4237            throw new IllegalStateException();
    43         }
    4438        initialized = true;
    4539        this.allDialogs = allDialogs;
     
    5650                 * entire Window is resized.
    5751                 */
     52                @Override
    5853                public Dimension getMinimumSize() {
    5954                    return new Dimension(0, 40);
     
    8883        INVISIBLE_TO_DEFAULT,
    8984        COLLAPSED_TO_DEFAULT,
    90     /*  INVISIBLE_TO_COLLAPSED,    does not happen */
     85        /*  INVISIBLE_TO_COLLAPSED,    does not happen */
    9186        ELEMENT_SHRINKS         /* else. (Remaining elements have more space.) */
    9287    };
     
    157152            }
    158153        } else {
    159             if (triggeredBy == null) {
     154            if (triggeredBy == null)
    160155                throw new IllegalArgumentException();
    161             }
    162156
    163157            int sumP = 0;   // sum of preferred heights of dialogs in default view (without the triggering dialog)
     
    285279    public void destroy() {
    286280        for (ToggleDialog t : allDialogs) {
    287             t.closeDetachedDialog();
     281            t.destroy();
    288282        }
    289283    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    r2364 r2475  
    163163        toggleAction.putValue("selected", false);
    164164        toggleAction.putValue("selected", true);
     165        showNotify();
    165166    }
    166167
     
    173174        setIsShowing(false);
    174175        toggleAction.putValue("selected", false);
     176        hideNotify();
    175177    }
    176178
     
    204206     */
    205207    public void collapse() {
    206         setContentVisible(false);
    207         setIsCollapsed(true);
    208         setPreferredSize(new Dimension(0,20));
    209         setMaximumSize(new Dimension(Integer.MAX_VALUE,20));
    210         setMinimumSize(new Dimension(Integer.MAX_VALUE,20));
    211         lblMinimized.setIcon(ImageProvider.get("misc", "minimized"));
     208        if (isShowing && isDocked && !isCollapsed) {
     209            setContentVisible(false);
     210            setIsCollapsed(true);
     211            setPreferredSize(new Dimension(0,20));
     212            setMaximumSize(new Dimension(Integer.MAX_VALUE,20));
     213            setMinimumSize(new Dimension(Integer.MAX_VALUE,20));
     214            lblMinimized.setIcon(ImageProvider.get("misc", "minimized"));
     215            hideNotify();
     216        }
    212217    }
    213218
     
    216221     */
    217222    protected void expand() {
    218         setContentVisible(true);
    219         setIsCollapsed(false);
    220         setPreferredSize(new Dimension(0,preferredHeight));
    221         setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    222         lblMinimized.setIcon(ImageProvider.get("misc", "normal"));
     223        if (isShowing && isDocked && isCollapsed) {
     224            setContentVisible(true);
     225            setIsCollapsed(false);
     226            setPreferredSize(new Dimension(0,preferredHeight));
     227            setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
     228            lblMinimized.setIcon(ImageProvider.get("misc", "normal"));
     229            showNotify();
     230        }
    223231    }
    224232
     
    237245    }
    238246
     247    public void destroy() {
     248        closeDetachedDialog();
     249        hideNotify();
     250    }
     251
    239252    /**
    240253     * Closes the the detached dialog if this toggle dialog is currently displayed
     
    248261            detachedDialog.dispose();
    249262        }
     263    }
     264
     265    /**
     266     * Called when toggle dialog is shown (after it was created or expanded). Descendants may overwrite this
     267     * method, it's a good place to register listeners needed to keep dialog updated
     268     */
     269    public void showNotify() {
     270
     271    }
     272
     273    /**
     274     * Called when toggle dialog is hidden (collapsed, removed, MapFrame is removed, ...). Good place to unregister
     275     * listeners
     276     */
     277    public void hideNotify() {
     278
    250279    }
    251280
Note: See TracChangeset for help on using the changeset viewer.