001    /*
002     * This file is part of McIDAS-V
003     *
004     * Copyright 2007-2013
005     * Space Science and Engineering Center (SSEC)
006     * University of Wisconsin - Madison
007     * 1225 W. Dayton Street, Madison, WI 53706, USA
008     * https://www.ssec.wisc.edu/mcidas
009     * 
010     * All Rights Reserved
011     * 
012     * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and
013     * some McIDAS-V source code is based on IDV and VisAD source code.  
014     * 
015     * McIDAS-V is free software; you can redistribute it and/or modify
016     * it under the terms of the GNU Lesser Public License as published by
017     * the Free Software Foundation; either version 3 of the License, or
018     * (at your option) any later version.
019     * 
020     * McIDAS-V is distributed in the hope that it will be useful,
021     * but WITHOUT ANY WARRANTY; without even the implied warranty of
022     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
023     * GNU Lesser Public License for more details.
024     * 
025     * You should have received a copy of the GNU Lesser Public License
026     * along with this program.  If not, see http://www.gnu.org/licenses.
027     */
028    package edu.wisc.ssec.mcidasv.control;
029    
030    import java.awt.Component;
031    import java.awt.Container;
032    import java.rmi.RemoteException;
033    import java.util.ArrayList;
034    import java.util.List;
035    
036    import javax.swing.JMenu;
037    import javax.swing.JMenuBar;
038    import javax.swing.JToolBar;
039    
040    import visad.VisADException;
041    
042    import ucar.unidata.util.GuiUtils;
043    
044    public class MultiDisplayHolder extends ucar.unidata.idv.control.multi.MultiDisplayHolder {
045    
046        /**
047         * Make the menu bar
048         *
049         * @return The menu bar
050         */
051        @Override protected JMenuBar doMakeMenuBar() {
052            List<JMenu> menus = doMakeMenuBarMenus(new ArrayList<JMenu>());
053            JMenuBar menuBar = new JMenuBar();
054            for (int i = 0; i < menus.size(); i++) {
055                menuBar.add((JMenu) menus.get(i));
056            }
057            return menuBar;
058        }
059    
060        /**
061         * Make the UI contents for this control.
062         *
063         * @return  UI container
064         *
065         * @throws RemoteException Java RMI error
066         * @throws VisADException VisAD Error
067         */
068        @Override protected Container doMakeContents()
069                throws VisADException, RemoteException {
070            Container container = super.doMakeContents();
071            Component first = container.getComponent(0);
072            if ((container.getComponentCount() == 2) && (first instanceof JToolBar)) {
073                return GuiUtils.center(container.getComponent(1));
074            }
075            return container;
076        }
077    }