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;
|
| 17 | 17 | import org.openstreetmap.josm.tools.CheckParameterUtil; |
| 18 | 18 | import org.openstreetmap.josm.tools.Destroyable; |
| 19 | 19 | |
| | 20 | /** |
| | 21 | * This is the panel displayed on the right side of JOSM. It displays a list of panels. |
| | 22 | */ |
| 20 | 23 | public class DialogsPanel extends JPanel implements Destroyable { |
| 21 | 24 | private final List<ToggleDialog> allDialogs = new ArrayList<>(); |
| 22 | 25 | private final MultiSplitPane mSpltPane = new MultiSplitPane(); |
| … |
… |
public class DialogsPanel extends JPanel implements Destroyable {
|
| 27 | 30 | */ |
| 28 | 31 | private final List<JPanel> panels = new ArrayList<>(); |
| 29 | 32 | |
| | 33 | /** |
| | 34 | * If {@link #initialize(List)} was called. read only from outside |
| | 35 | */ |
| | 36 | public boolean initialized; |
| | 37 | |
| 30 | 38 | private final JSplitPane parent; |
| 31 | 39 | |
| | 40 | /** |
| | 41 | * Creates a new {@link DialogsPanel}. |
| | 42 | * @param parent The parent split pane that allows this panel to change it's size. |
| | 43 | */ |
| 32 | 44 | public DialogsPanel(JSplitPane parent) { |
| 33 | 45 | this.parent = parent; |
| 34 | 46 | } |
| 35 | 47 | |
| 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 | */ |
| 38 | 52 | 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 | } |
| 41 | 56 | initialized = true; |
| 42 | 57 | allDialogs.clear(); |
| 43 | 58 | |
| … |
… |
public class DialogsPanel extends JPanel implements Destroyable {
|
| 49 | 64 | reconstruct(Action.ELEMENT_SHRINKS, null); |
| 50 | 65 | } |
| 51 | 66 | |
| | 67 | /** |
| | 68 | * Add a new {@link ToggleDialog} to the list of known dialogs and trigger reconstruct. |
| | 69 | * @param dlg The dialog to add |
| | 70 | */ |
| 52 | 71 | public void add(ToggleDialog dlg) { |
| 53 | 72 | add(dlg, true); |
| 54 | 73 | } |
| 55 | 74 | |
| | 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 | */ |
| 56 | 80 | public void add(ToggleDialog dlg, boolean doReconstruct) { |
| 57 | 81 | allDialogs.add(dlg); |
| 58 | | int i = allDialogs.size() - 1; |
| 59 | 82 | dlg.setDialogsPanel(this); |
| 60 | 83 | dlg.setVisible(false); |
| 61 | 84 | final JPanel p = new JPanel() { |
| … |
… |
public class DialogsPanel extends JPanel implements Destroyable {
|
| 71 | 94 | p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); |
| 72 | 95 | p.setVisible(false); |
| 73 | 96 | |
| 74 | | mSpltPane.add(p, 'L'+Integer.toString(i)); |
| | 97 | int dialogIndex = allDialogs.size() - 1; |
| | 98 | mSpltPane.add(p, 'L'+Integer.toString(dialogIndex)); |
| 75 | 99 | panels.add(p); |
| 76 | 100 | |
| 77 | 101 | if (dlg.isDialogShowing()) { |
| … |
… |
public class DialogsPanel extends JPanel implements Destroyable {
|
| 93 | 117 | * What action was performed to trigger the reconstruction |
| 94 | 118 | */ |
| 95 | 119 | public enum Action { |
| | 120 | /** |
| | 121 | * The panel was invisible previously |
| | 122 | */ |
| 96 | 123 | INVISIBLE_TO_DEFAULT, |
| | 124 | /** |
| | 125 | * The panel was collapsed by the user. |
| | 126 | */ |
| 97 | 127 | COLLAPSED_TO_DEFAULT, |
| 98 | 128 | /* 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 |
| 100 | 133 | } |
| 101 | 134 | |
| 102 | 135 | /** |
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
|
| 604 | 604 | return lblTitle.getText(); |
| 605 | 605 | } |
| 606 | 606 | |
| | 607 | /** |
| | 608 | * This is the popup menu used for the title bar. |
| | 609 | */ |
| 607 | 610 | public class DialogPopupMenu extends JPopupMenu { |
| 608 | 611 | |
| 609 | 612 | /** |
| … |
… |
public class ToggleDialog extends JPanel implements ShowHideButtonListener, Help
|
| 626 | 629 | } |
| 627 | 630 | } |
| 628 | 631 | |
| | 632 | /** |
| | 633 | * Registers the mouse listeners. |
| | 634 | * <p> |
| | 635 | * Should be called once after this title was added to the dialog. |
| | 636 | */ |
| 629 | 637 | public final void registerMouseListener() { |
| 630 | 638 | popupMenu = new DialogPopupMenu(); |
| 631 | 639 | addMouseListener(new MouseEventHandler()); |
| … |
… |
public class ToggleDialog extends JPanel implements ShowHideButtonListener, Help
|
| 825 | 833 | return isShowing && isDocked && isCollapsed; |
| 826 | 834 | } |
| 827 | 835 | |
| | 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 | */ |
| 828 | 842 | public void setButton(JToggleButton button) { |
| 829 | 843 | this.button = button; |
| 830 | 844 | } |
| 831 | 845 | |
| | 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 | */ |
| 832 | 850 | public JToggleButton getButton() { |
| 833 | 851 | return button; |
| 834 | 852 | } |
| … |
… |
public class ToggleDialog extends JPanel implements ShowHideButtonListener, Help
|
| 865 | 883 | // Do nothing |
| 866 | 884 | } |
| 867 | 885 | |
| | 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 | */ |
| 868 | 893 | protected Component createLayout(Component data, boolean scroll, Collection<SideButton> buttons) { |
| 869 | 894 | return createLayout(data, scroll, buttons, (Collection<SideButton>[]) null); |
| 870 | 895 | } |