001/*
002 * Copyright (c) 1997-2010 The Regents of the University of California.
003 * All rights reserved.
004 *
005 * '$Author: welker $'
006 * '$Date: 2010-05-06 05:21:26 +0000 (Thu, 06 May 2010) $' 
007 * '$Revision: 24234 $'
008 * 
009 * Permission is hereby granted, without written agreement and without
010 * license or royalty fees, to use, copy, modify, and distribute this
011 * software and its documentation for any purpose, provided that the above
012 * copyright notice and the following two paragraphs appear in all copies
013 * of this software.
014 *
015 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
016 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
017 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
018 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
019 * SUCH DAMAGE.
020 *
021 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
022 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
024 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
025 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
026 * ENHANCEMENTS, OR MODIFICATIONS.
027 *
028 */
029
030package org.kepler.gui;
031
032import java.util.Iterator;
033
034import ptolemy.kernel.util.Attribute;
035import ptolemy.kernel.util.IllegalActionException;
036import ptolemy.kernel.util.NameDuplicationException;
037import ptolemy.kernel.util.NamedObj;
038import ptolemy.vergil.tree.PTree;
039
040/**
041 * This class creates a pane that displays the search results. This is a
042 * pluggable interface defined in the kepler configuration.
043 * 
044 *@author Chad Berkley
045 *@since February 17, 2005
046 *@version $Id: LibrarySearchResultPaneFactory.java,v 1.3 2004/08/25 20:50:46
047 *          berkley Exp $
048 *@since Kepler 1.0 alpha 2
049 */
050public class LibrarySearchResultPaneFactory extends Attribute {
051
052        /**
053         * Create a factory with the given name and container.
054         * 
055         *@param container
056         *            The container.
057         *@param name
058         *            The name.
059         *@exception IllegalActionException
060         *                If the container is incompatible with this attribute.
061         *@exception NameDuplicationException
062         *                If the name coincides with an attribute already in the
063         *                container.
064         */
065        public LibrarySearchResultPaneFactory(NamedObj container, String name)
066                        throws IllegalActionException, NameDuplicationException {
067                super(container, name);
068        }
069
070        // /////////////////////////////////////////////////////////////////
071        // // public methods ////
072
073        /**
074         * This method returns a LibrarySearchResultPane which is used in the
075         * pluggable interface for the search result pane
076         * 
077         *@param library
078         *            Description of the Parameter
079         *@param results
080         *            Description of the Parameter
081         *@return A tableau for the effigy, or null if one cannot be created.
082         *@exception IllegalActionException
083         *                Description of the Exception
084         */
085        public LibrarySearchResultPane createLibrarySearchResultPane(PTree library,
086                        LibrarySearchResults results) throws IllegalActionException {
087                LibrarySearchResultPane pane = null;
088                Iterator factories = attributeList(LibrarySearchResultPaneFactory.class)
089                                .iterator();
090                while (factories.hasNext() && pane == null) {
091                        LibrarySearchResultPaneFactory factory = (LibrarySearchResultPaneFactory) factories
092                                        .next();
093                        pane = factory.createLibrarySearchResultPane(library, results);
094                }
095                return pane;
096        }
097}