/*
 * PopupHandler.java  $Revision: 1.2 $  $Date: 2007/10/03 04:39:40 $
 *
 * Copyright (C) 2007 Meldcraft Corporation
 *
 * This file is part of Scaffold.
 * 
 * Scaffold is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Scaffold is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with Scaffold.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.meldcraft.gui.swing;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JPopupMenu;

/**
 * @version $Revision: 1.2 $ $Date: 2007/10/03 04:39:40 $
 * @author Rob Richards
 */
public class PopupHandler extends MouseAdapter
{
// Static variables
// Member variables
    private JPopupMenu  mPopup;

// Constructors and initialization
    public PopupHandler(JPopupMenu popup)
    {
        mPopup = popup;
    }

// Interface implemenations
// Public methods
    public void mousePressed(MouseEvent e)
    {
        checkPopup(e);
    }

    public void mouseReleased(MouseEvent e)
    {
        checkPopup(e);
    }

// Protected methods
    protected void checkPopup(MouseEvent e)
    {
        if (e.isPopupTrigger())
        {
            mPopup.show(e.getComponent(), e.getX(), e.getY());
        }
    }

// Private methods
// Inner classes
}
