Changeset 10317 in josm


Ignore:
Timestamp:
2016-06-02T23:01:09+02:00 (4 years ago)
Author:
Don-vip
Message:

fix #12904 - Documentation of DialogsPanel (patch by michael2402)

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

Legend:

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

    r10316 r10317  
    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<>();
     
    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();
     
    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);
     
    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
     
    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
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    r10173 r10317  
    605605        }
    606606
     607        /**
     608         * This is the popup menu used for the title bar.
     609         */
    607610        public class DialogPopupMenu extends JPopupMenu {
    608611
     
    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();
     
    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;
     
    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);
Note: See TracChangeset for help on using the changeset viewer.