Ticket #12904: patch-dialogs-panel-document.patch

File patch-dialogs-panel-document.patch, 6.0 KB (added by michael2402, 8 years ago)
  • src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java

    diff --git a/src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java b/src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java
    index 82b7edb..098bbe4 100644
    a b import org.openstreetmap.josm.gui.widgets.MultiSplitPane;  
    1717import org.openstreetmap.josm.tools.CheckParameterUtil;
    1818import org.openstreetmap.josm.tools.Destroyable;
    1919
     20/**
     21 * This is the panel displayed on the right side of JOSM. It displays a list of panels.
     22 */
    2023public class DialogsPanel extends JPanel implements Destroyable {
    2124    private final List<ToggleDialog> allDialogs = new ArrayList<>();
    2225    private final MultiSplitPane mSpltPane = new MultiSplitPane();
    public class DialogsPanel extends JPanel implements Destroyable {  
    2730     */
    2831    private final List<JPanel> panels = new ArrayList<>();
    2932
     33    /**
     34     * If {@link #initialize(List)} was called. read only from outside
     35     */
     36    public boolean initialized;
     37
    3038    private final JSplitPane parent;
    3139
     40    /**
     41     * Creates a new {@link DialogsPanel}.
     42     * @param parent The parent split pane that allows this panel to change it's size.
     43     */
    3244    public DialogsPanel(JSplitPane parent) {
    3345        this.parent = parent;
    3446    }
    3547
    36     public boolean initialized; // read only from outside
    37 
     48    /**
     49     * Initializes this panel
     50     * @param pAllDialogs The list of dialogs this panel should contain on start.
     51     */
    3852    public void initialize(List<ToggleDialog> pAllDialogs) {
    39         if (initialized)
    40             throw new IllegalStateException();
     53        if (initialized) {
     54            throw new IllegalStateException("Panel can only be initialized once.");
     55        }
    4156        initialized = true;
    4257        allDialogs.clear();
    4358
    public class DialogsPanel extends JPanel implements Destroyable {  
    4964        reconstruct(Action.ELEMENT_SHRINKS, null);
    5065    }
    5166
     67    /**
     68     * Add a new {@link ToggleDialog} to the list of known dialogs and trigger reconstruct.
     69     * @param dlg The dialog to add
     70     */
    5271    public void add(ToggleDialog dlg) {
    5372        add(dlg, true);
    5473    }
    5574
     75    /**
     76     * Add a new {@link ToggleDialog} to the list of known dialogs.
     77     * @param dlg The dialog to add
     78     * @param doReconstruct <code>true</code> if reconstruction should be triggered.
     79     */
    5680    public void add(ToggleDialog dlg, boolean doReconstruct) {
    5781        allDialogs.add(dlg);
    58         int i = allDialogs.size() - 1;
    5982        dlg.setDialogsPanel(this);
    6083        dlg.setVisible(false);
    6184        final JPanel p = new JPanel() {
    public class DialogsPanel extends JPanel implements Destroyable {  
    7194        p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    7295        p.setVisible(false);
    7396
    74         mSpltPane.add(p, 'L'+Integer.toString(i));
     97        int dialogIndex = allDialogs.size() - 1;
     98        mSpltPane.add(p, 'L'+Integer.toString(dialogIndex));
    7599        panels.add(p);
    76100
    77101        if (dlg.isDialogShowing()) {
    public class DialogsPanel extends JPanel implements Destroyable {  
    93117     * What action was performed to trigger the reconstruction
    94118     */
    95119    public enum Action {
     120        /**
     121         * The panel was invisible previously
     122         */
    96123        INVISIBLE_TO_DEFAULT,
     124        /**
     125         * The panel was collapsed by the user.
     126         */
    97127        COLLAPSED_TO_DEFAULT,
    98128        /*  INVISIBLE_TO_COLLAPSED,    does not happen */
    99         ELEMENT_SHRINKS         /* else. (Remaining elements have more space.) */
     129        /**
     130         * else. (Remaining elements have more space.)
     131         */
     132        ELEMENT_SHRINKS
    100133    }
    101134
    102135    /**
  • src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    diff --git a/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java b/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
    index 2b9ce25..052b9f7 100644
    a b public class ToggleDialog extends JPanel implements ShowHideButtonListener, Help  
    604604            return lblTitle.getText();
    605605        }
    606606
     607        /**
     608         * This is the popup menu used for the title bar.
     609         */
    607610        public class DialogPopupMenu extends JPopupMenu {
    608611
    609612            /**
    public class ToggleDialog extends JPanel implements ShowHideButtonListener, Help  
    626629            }
    627630        }
    628631
     632        /**
     633         * Registers the mouse listeners.
     634         * <p>
     635         * Should be called once after this title was added to the dialog.
     636         */
    629637        public final void registerMouseListener() {
    630638            popupMenu = new DialogPopupMenu();
    631639            addMouseListener(new MouseEventHandler());
    public class ToggleDialog extends JPanel implements ShowHideButtonListener, Help  
    825833        return isShowing && isDocked && isCollapsed;
    826834    }
    827835
     836    /**
     837     * Sets the button from the button list that is used to display this dialog.
     838     * <p>
     839     * Note: This is ignored by the {@link ToggleDialog} for now.
     840     * @param button The button for this dialog.
     841     */
    828842    public void setButton(JToggleButton button) {
    829843        this.button = button;
    830844    }
    831845
     846    /**
     847     * Gets the button from the button list that is used to display this dialog.
     848     * @return button The button for this dialog.
     849     */
    832850    public JToggleButton getButton() {
    833851        return button;
    834852    }
    public class ToggleDialog extends JPanel implements ShowHideButtonListener, Help  
    865883        // Do nothing
    866884    }
    867885
     886    /**
     887     * Create a component with the given layout for this component.
     888     * @param data The content to be displayed
     889     * @param scroll <code>true</code> if it should be wrapped in a {@link JScrollPane}
     890     * @param buttons The buttons to add.
     891     * @return The component.
     892     */
    868893    protected Component createLayout(Component data, boolean scroll, Collection<SideButton> buttons) {
    869894        return createLayout(data, scroll, buttons, (Collection<SideButton>[]) null);
    870895    }