001    /*
002     * This file is part of muCommander, http://www.mucommander.com
003     * Copyright (C) 2002-2008 Maxence Bernard
004     *
005     * muCommander is free software; you can redistribute it and/or modify
006     * it under the terms of the GNU General Public License as published by
007     * the Free Software Foundation; either version 3 of the License, or
008     * (at your option) any later version.
009     *
010     * muCommander is distributed in the hope that it will be useful,
011     * but WITHOUT ANY WARRANTY; without even the implied warranty of
012     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013     * GNU General Public License for more details.
014     *
015     * You should have received a copy of the GNU General Public License
016     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
017     */
018    
019    package com.mucommander.ui.action;
020    
021    import com.mucommander.ui.main.MainFrame;
022    import com.mucommander.ui.main.WindowManager;
023    
024    import java.util.Hashtable;
025    import java.util.Vector;
026    
027    /**
028     * Brings all MainFrame windows to front, from the last window index to the first, except for the current
029     * (or last active) MainFrame which is brought to the front last. .
030     * After this action has been performed, minimized windows will return to a normal state and windows will be stacked
031     * in the following order:
032     * <ul>
033     *  <li>Current MainFrame
034     *  <li>MainFrame #1
035     *  <li>MainFrame #2
036     *  <li>...
037     *  <li>MainFrame #N
038     * </ul>
039     *
040     * @author Maxence Bernard
041     */
042    public class BringAllToFrontAction extends MuAction {
043    
044        public BringAllToFrontAction(MainFrame mainFrame, Hashtable properties) {
045            super(mainFrame, properties);
046        }
047    
048        public void performAction() {
049            Vector mainFrames = WindowManager.getMainFrames();
050            MainFrame currentMainFrame = WindowManager.getCurrentMainFrame();
051    
052            int nbMainFrames = mainFrames.size();
053            MainFrame mainFrame;
054            for(int i=nbMainFrames-1; i>=0; i--) {
055                mainFrame = (MainFrame)mainFrames.elementAt(i);
056                if(mainFrame!=currentMainFrame) {
057                    mainFrame.toFront();
058                }
059            }
060    
061            currentMainFrame.toFront();
062        }
063    }