package eas.ui;

public class SearchButton
extends mit.swing.xJButton
implements mit.event.Listener
         , eas.event.SearchRaiser
{

    public void addNotify()
    {
        super.addNotify();

        try
        {
            eas.Settings settings = eas.Settings.getInstance();
            setIcon(new javax.swing.ImageIcon(settings.getSearchImage()));
            setPressedIcon(new javax.swing.ImageIcon(settings.getSearchInProgressImage()));

            getAdapter().addHandled( mit.awt.event.ActionEvent.class );
            getAdapter().addHandled( eas.event.EnableSearchEvent.class );
            getAdapter().addHandled( eas.event.DisableSearchEvent.class );
            getAdapter().addContained( mit.awt.event.ActionEvent.class );
        }
        catch( Exception ex )
        {
            ex.printStackTrace();
        }
    }

    public void eventRaised( mit.event.Event e )
    {
        if( e instanceof mit.awt.event.ActionEvent )
        {
            HandleActionEvent( ( mit.awt.event.ActionEvent ) e ) ;
        }
/*
        else if( e instanceof eas.event.EnableSearchEvent )
        {
            HandleEnableSearchEvent( ( eas.event.EnableSearchEvent ) e ) ;
        }
        else if( e instanceof eas.event.DisableSearchEvent )
        {
            HandleDisableSearchEvent( ( eas.event.DisableSearchEvent ) e ) ;
        }
*/
    }

    public void HandleActionEvent( mit.awt.event.ActionEvent e )
    {
        if( this.equals( e.getSource() ) || isDefaultButton() )
        {
            new eas.event.SearchEvent( this ).raise();
            eas.ui.GUIServices guiServices = eas.ui.GUIServices.getInstance();
            guiServices.raiseSearchAction();
        }
    }

/*
    public void HandleEnableSearchEvent( eas.event.EnableSearchEvent e )
    {
        eas.event.EnableSearchRaiser raiser = (eas.event.EnableSearchRaiser)e.getSource();
        setEnabled(true);
    }

    public void HandleDisableSearchEvent( eas.event.DisableSearchEvent e )
    {
        eas.event.DisableSearchRaiser raiser = (eas.event.DisableSearchRaiser)e.getSource();
        setEnabled(false);
    }
*/
/**
<p>MIT O.K.I&#46; SID Implementation License.
  <p>	<b>Copyright and license statement:</b>
  </p>  <p>	Copyright &copy; 2003 Massachusetts Institute of
	Technology &lt;or copyright holder&gt;
  </p>  <p>	This work is being provided by the copyright holder(s)
	subject to the terms of the O.K.I&#46; SID Implementation
	License. By obtaining, using and/or copying this Work,
	you agree that you have read, understand, and will comply
	with the O.K.I&#46; SID Implementation License. 
  </p>  <p>	THE WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
	KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
	THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
	PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
	MASSACHUSETTS INSTITUTE OF TECHNOLOGY, THE AUTHORS, OR
	COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
	OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
	OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
	THE WORK OR THE USE OR OTHER DEALINGS IN THE WORK.
  </p>  <p>	<b>O.K.I&#46; SID Implementation License</b>
  </p>  <p>	This work (the &ldquo;Work&rdquo;), including software,
	documents, or other items related to O.K.I&#46; SID
	implementations, is being provided by the copyright
	holder(s) subject to the terms of the O.K.I&#46; SID
	Implementation License. By obtaining, using and/or
	copying this Work, you agree that you have read,
	understand, and will comply with the following terms and
	conditions of the O.K.I&#46; SID Implementation License:
  </p>  <p>	Permission to use, copy, modify, and distribute this Work
	and its documentation, with or without modification, for
	any purpose and without fee or royalty is hereby granted,
	provided that you include the following on ALL copies of
	the Work or portions thereof, including modifications or
	derivatives, that you make:
  </p>  <ul>	<li>	  The full text of the O.K.I&#46; SID Implementation
	  License in a location viewable to users of the
	  redistributed or derivative work.
	</li>  </ul>  <ul>	<li>	  Any pre-existing intellectual property disclaimers,
	  notices, or terms and conditions. If none exist, a
	  short notice similar to the following should be used
	  within the body of any redistributed or derivative
	  Work: &ldquo;Copyright &copy; 2003 Massachusetts
	  Institute of Technology. All Rights Reserved.&rdquo;
	</li>  </ul>  <ul>	<li>	  Notice of any changes or modifications to the
	  O.K.I&#46; Work, including the date the changes were
	  made. Any modified software must be distributed in such
	  as manner as to avoid any confusion with the original
	  O.K.I&#46; Work.
	</li>  </ul>  <p>	THE WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
	KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
	THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
	PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
	MASSACHUSETTS INSTITUTE OF TECHNOLOGY, THE AUTHORS, OR
	COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
	OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
	OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
	THE WORK OR THE USE OR OTHER DEALINGS IN THE WORK.
  </p>  <p>	The name and trademarks of copyright holder(s) and/or
	O.K.I&#46; may NOT be used in advertising or publicity
	pertaining to the Work without specific, written prior
	permission. Title to copyright in the Work and any
	associated documentation will at all times remain with
	the copyright holders.
  </p>  <p>	The export of software employing encryption technology
	may require a specific license from the United States
	Government. It is the responsibility of any person or
	organization contemplating export to obtain such a
	license before exporting this Work.
  </p>*/

/**
The icons are included under the condition that the following is present:

Copyright 2000 by Sun Microsystems, Inc. All
Rights Reserved.

Sun grants you (&quot;Licensee&quot;) a non-exclusive,
royalty free, license to use, and redistribute
this software graphics artwork, as individual
graphics or as a collection, as part of software
code or programs that you develop, provided that
i) this copyright notice and license accompany
the software graphics artwork; and ii) you do not
utilize the software graphics artwork in a manner
which is disparaging to Sun. Unless enforcement
is prohibited by applicable law, you may not
modify the graphics, and must use them true to
color and unmodified in every way.

This software graphics artwork is provided &quot;AS
IS,&quot; without a warranty of any kind. ALL EXPRESS
OR IMPLIED CONDITIONS, REPRESENTATIONS AND
WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND
ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
SUFFERED BY LICENSEE AS A RESULT OF USING,
MODIFYING OR DISTRIBUTING THE SOFTWARE GRAPHICS
ARTWORK.

IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE
FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
AND REGARDLESS OF THE THEORY OF LIABILITY,
ARISING OUT OF THE USE OF OR INABILITY TO USE
SOFTWARE GRAPHICS ARTWORK, EVEN IF SUN HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

If any of the above provisions are held to be in
violation of applicable law, void, or
unenforceable in any jurisdiction, then such
provisions are waived to the extent necessary for
this Disclaimer to be otherwise enforceable in
such jurisdiction.
*/
}
