/*
 * @(#)TypedViewWrapper.java    1.0.1  13 June 2001
 *
 * 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 java.awt.*;
import javax.swing.*;

/**
 * <P>Wrapper for a <CODE>TypedView</CODE>
 * that uses a <CODE>CenterLayout</CODE> and 
 * faithfully respects minimum, maximum, and preferred sizes.</P>
 *
 * @author  Jeff Raab
 * @version 2.2
 * @since   1.0
 * @see ComponentWrapper
 * @see DisplayWrapper
 * @see GeneralViewWrapper
 */
public class TypedViewWrapper
    extends DisplayWrapper
    implements TypedView 
{
    /**
     * Constructs a wrapper for the given 
     * <CODE>TypedView</CODE>.
     *
     * @param view the typed view to be wrapped
     */
    public TypedViewWrapper(TypedView view) {
        super(view);
    }
    
    ///////////////
    // TypedView //
    ///////////////
    
    public Stringable demandObject() {
        return getWrappedTypedView().demandObject();
    }
    
    public Stringable requestObject() throws CancelledException {
        return getWrappedTypedView().requestObject();
    }

    public void setInputProperties(InputProperties p) {
        getWrappedTypedView().setInputProperties(p);
    }

    public InputProperties getInputProperties() {
        return getWrappedTypedView().getInputProperties();
    }

    public Class getDataType() {
        return getWrappedTypedView().getDataType();
    }
    
    ////////////////
    // Public API //
    ////////////////
    
    /**
     * Sets the wrapped typed view to the given component.
     *
     * This method should not be called directly.
     *
     * Rather, <CODE>setWrappedTypedView</CODE> should be called
     * in order to set the wrapped <CODE>TypedView</CODE>.
     *
     * If the given component is not a <CODE>TypedView</CODE>,
     * the currently wrapped typed view is not changed.
     *
     * @param component the component to be wrapped
     * @throws NullPointerException
     *      if the given object is <CODE>null</CODE>
     * @see #setWrappedTypedView(TypedView)
     */
    public void setWrappedComponent(Component component) {
        if (component instanceof TypedView)
            super.setWrappedComponent(component);
    }

    /**
     * Sets the wrapped typed view
     * to the given <CODE>TypedView</CODE>.
     *
     * @param display the typed view to be wrapped
     * @throws NullPointerException
     *      if the given object is <CODE>null</CODE>
     * @see #getWrappedTypedView()
     */
    public void setWrappedTypedView(TypedView view) {
        setWrappedDisplay(view);
    }

    /**
     * Returns the wrapped typed view.
     *
     * @see #setWrappedTypedView(TypedView)
     */
    public TypedView getWrappedTypedView() {
        return (TypedView)getWrappedComponent();
    }
}
