// Copyright 1996, Marimba Inc. All Rights Reserved.


// @(#)PresentationWidget.java, 1.25, 11/17/96





package marimba.gui;





import java.net.*;


import java.awt.*;





import marimba.persist.*;





/**


 * A widget for displaying presentations.


 *


 * @author	Arthur van Hoff


 * @version 	1.25, 11/17/96


 */


public class PresentationWidget extends ResourceWidget {


    Presentation presentation;





    /**


     * Constructor


     */


    public PresentationWidget() {


	src = "~builder/embed.gui";


    }





    /**


     * Don't bother saving the content.


     */


    public void getChildProperties(PropertyList list) {


    }





    /**


     * Set the properties of this widget.


     */


    public void setProperties(PropertyList list) {


	super.setProperties(list);


	presentation = null;


    }





    /**


     * Load the presentation when the widget is started.


     */


    public void init() {


	if (preload) {


	    start();


	}


    }





    /**


     * Load the presentation when the widget is started.


     */


    public void start() {


	if ((src != null) && (presentation == null)) {


	    setValue(src);


	}


    }





    /**


     * Get the presentation resource string.


     */


    public String getStringValue() {


	return src;


    }





    /**


     * Get the presentation.


     */


    public Presentation getPresentationValue() {


	return presentation;


    }





    /**


     * Get the presentation resource string.


     */


    public Object getValue() {


	return src;


    }





    /**


     * Set a new presentation.


     */


    public void setValue(Object value) {


	if (value instanceof String) {


	    setValue((String)value);


	} else if (value instanceof Presentation) {


	    setValue((Presentation)value);


	} else if (value == null) {


	    setValue((Presentation)null);


	}


    }





    /**


     * Set a new presentation


     */


    public void setValue(String src) {


	Presentation p = getPresentation();


	if ((src != null) && (p != null)) {


	    setValue(Presentation.getPresentation(p.getURL(src)));


	}


    }





    /**


     * Set a new presentation


     */


    public void setValue(Presentation p) {


	if (p != this.presentation) {


	    if (presentation != null) {


		presentation.hide();


		remove(presentation);


	    }


	    presentation = p;


	    if (p != null) {


		add(p);


		p.show();


		layout();


	    }


	}


    }


}





