Ticket #3674: hide-dialogspanel.patch

File hide-dialogspanel.patch, 2.7 KB (added by bastiK, 16 years ago)
  • src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java

     
    1111
    1212import javax.swing.BoxLayout;
    1313import javax.swing.JPanel;
     14import javax.swing.JSplitPane;
    1415
    1516import org.openstreetmap.josm.gui.MultiSplitLayout;
    1617import org.openstreetmap.josm.gui.MultiSplitLayout.Node;
     
    2930     * Panels that are added to the multisplitpane.
    3031     */
    3132    private List<JPanel> panels = new ArrayList<JPanel>();
     33   
     34    final private JSplitPane parent;
     35    public DialogsPanel(JSplitPane parent) {
     36        this.parent = parent;
     37    }
    3238
    3339    private boolean initialized = false;
    3440    public void initialize(List<ToggleDialog> allDialogs) {
     
    258264        mSpltPane.getMultiSplitLayout().setDividerSize(DIVIDER_SIZE);
    259265        mSpltPane.getMultiSplitLayout().setFloatingDividers(true);
    260266        mSpltPane.revalidate();
     267
     268        /**
     269         * Hide the Panel, if there is nothing to show
     270         */
     271        if (numPanels == 1 && panels.get(N-1).getComponents().length == 0)
     272        {
     273            this.setVisible(false);
     274        } else {
     275            if (this.getWidth() != 0) { // only if josm started with hidden panel
     276                this.setPreferredSize(new Dimension(this.getWidth(), 0));
     277            }
     278            this.setVisible(true);
     279            parent.resetToPreferredSizes();
     280        }
    261281    }
    262282
    263283    public void destroy() {
  • src/org/openstreetmap/josm/gui/MapFrame.java

     
    7777     * instead of adding directly to this list.
    7878     */
    7979    private List<ToggleDialog> allDialogs = new ArrayList<ToggleDialog>();
    80     private DialogsPanel dialogsPanel = new DialogsPanel();
     80    private DialogsPanel dialogsPanel;
    8181
    8282    public final ButtonGroup toolGroup = new ButtonGroup();
    8383
     
    107107
    108108        toolGroup.setSelected(((AbstractButton)toolBarActions.getComponent(0)).getModel(), true);
    109109
    110         JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true,
    111                              mapView, dialogsPanel);
     110        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
     111        dialogsPanel = new DialogsPanel(splitPane);
     112        splitPane.setLeftComponent(mapView);
     113        splitPane.setRightComponent(dialogsPanel);
    112114
    113115        /**
    114116         * All additional space goes to the mapView