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