/*
 * @(#)GeneralViewWrapper.java    2.3  3 December 2003
 *
 * Copyright 2004
 * College of Computer and Information Science
 * Northeastern University
 * Boston, MA  02115
 *
 * The Java Power Tools software may be used for educational
 * purposes as long as this copyright notice is retained intact
 * at the top of all source files.
 *
 * To discuss possible commercial use of this software, 
 * contact Richard Rasala at Northeastern University, 
 * College of Computer and Information Science,
 * 617-373-2462 or rasala@ccs.neu.edu.
 *
 * The Java Power Tools software has been designed and built
 * in collaboration with Viera Proulx and Jeff Raab.
 *
 * Should this software be modified, the words "Modified from 
 * Original" must be included as a comment below this notice.
 *
 * All publication rights are retained.  This software or its 
 * documentation may not be published in any media either
 * in whole or in part without explicit permission.
 *
 * This software was created with support from Northeastern 
 * University and from NSF grant DUE-9950829.
 */

package edu.neu.ccs.gui;

import edu.neu.ccs.*;
import edu.neu.ccs.filter.*;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

/**
 * <P>Wrapper for a <CODE>GeneralView</CODE> that uses a <CODE>CenterLayout</CODE>
 * and faithfully respects minimum, maximum, and preferred sizes.</P>
 *
 * @author  Jeff Raab
 * @author  Richard Rasala
 * @version 2.3
 * @since   1.0
 * @see ComponentWrapper
 * @see DisplayWrapper
 * @see TypedViewWrapper
 */
public class GeneralViewWrapper
    extends TypedViewWrapper
    implements GeneralView 
{
    /**
     * Constructs a wrapper for the given <CODE>GeneralView</CODE>.
     *
     * @param view the general view to be wrapped
     */
    public GeneralViewWrapper(GeneralView view) {
        super((TypedView) view);
    }
    
    
    /////////////////
    // GeneralView //
    /////////////////
    
    
    /**
     * Returns a new <CODE>GeneralViewWrapper</CODE> that wraps a copy of
     * the wrapped <CODE>GeneralView</CODE> encapsulated in this view.
     *
     * @return a copy of this view
     */
    public GeneralView makeCopy() {
        return new GeneralViewWrapper(getWrappedGeneralView().makeCopy());
    }
    

    public void setDataType(Class dataType) {
        getWrappedGeneralView().setDataType(dataType);
    }
    
    
    public void setFilter(StringableFilter filter) {
        getWrappedGeneralView().setFilter(filter);
    }
    
    
    public StringableFilter getFilter() {
        return getWrappedGeneralView().getFilter();
    }
    
    
    public Stringable demandObject(StringableFilter filter) {
        return getWrappedGeneralView().demandObject(filter);
    }
    
    
    public Stringable requestObject(StringableFilter filter)
        throws CancelledException
    {
        return getWrappedGeneralView().requestObject(filter);
    }
    
    
    public Stringable demandObject(Class dataType, StringableFilter filter) {
        return getWrappedGeneralView().demandObject(dataType, filter);
    }
    
    
    public Stringable requestObject(Class dataType, StringableFilter filter)
        throws CancelledException
    {
        return getWrappedGeneralView().requestObject(dataType, filter);
    }
    
    
    ////////////////
    // Public API //
    ////////////////
    
    /**
     * <P>Sets the wrapped general view to the given component.</P>
     *
     * <P>This method should not be called directly.</P>
     *
     * <P>Rather, <CODE>setWrappedGeneralView</CODE> should be called
     * in order to set the wrapped <CODE>GeneralView</CODE>.</P>
     *
     * <P>If the given component is not a <CODE>GeneralView</CODE>,
     * the currently wrapped general view is not changed.</P>
     *
     * @param  component the component to be wrapped
     * @throws NullPointerException if the given object is <CODE>null</CODE>
     * @see #setWrappedGeneralView(GeneralView)
     */
    public void setWrappedComponent(Component component) {
        if (component instanceof GeneralView)
            super.setWrappedComponent(component);
    }
    
    
    /**
     * Sets the wrapped general view to the given <CODE>GeneralView</CODE>.
     *
     * @param display the general view to be wrapped
     * @throws NullPointerException if the given object is <CODE>null</CODE>
     * @see #getWrappedGeneralView()
     */
    public void setWrappedGeneralView(GeneralView view) {
        setWrappedDisplay(view);
    }
    
    
    /**
     * Returns the wrapped general view.
     *
     * @see #setWrappedGeneralView(GeneralView)
     */
    public GeneralView getWrappedGeneralView() {
        return (GeneralView)getWrappedComponent();
    }
    
    
    public void setErrorPromptTitleSuggestion(
        String errorPrompt,
        String dialogTitle,
        String suggestion )
    {
         getWrappedGeneralView().
            setErrorPromptTitleSuggestion(errorPrompt, dialogTitle, suggestion );
    }
    
    
    /**
     * Adds an <CODE>ActionListener</CODE>.
     *
     * @param listener the ActionListener that is to be notified
     * @see #removeActionListener(ActionListener)
     */
    public void addActionListener(ActionListener listener) {
        getWrappedGeneralView().addActionListener(listener);
    }
    
    
    /**
     * Removes an <CODE>ActionListener</CODE>.
     *
     * @param listener the ActionListener to remove
     * @see #addActionListener(ActionListener)
     */
    public void removeActionListener(ActionListener listener) {
        getWrappedGeneralView().removeActionListener(listener);
    }
    
}
