// (c) MIT 2003.  All rights reserved.

// $Id: UnselectTargetRecognizer.java,v 1.6 2003/03/06 00:40:47 moltmans Exp $
// Time-stamp: <2000-03-13 11:25:14 calvarad>
package rec.core.recognizers;



import java.util.*;
import java.awt.*;
import rec.util.*;
import rec.sys.*;
import rec.core.widgets.*;

public class UnselectTargetRecognizer extends TargetRecognizer
{
  public UnselectTargetRecognizer( )
  {
  }

  ///////////////////////////////////////////////////////////////////////////

  public boolean recognize( Surface s, Widget w )
  {
    // add the unselect code to the suitcase of the widget.

    DoTransition dt = new DoTransition( s ) {
      public void doDo()
      {
	((WSelection)getTarget()).removeSelection( m_Surface );
      }
      public void doUndo()
      {
	((WSelection)getTarget()).makeSelection( m_Surface );
      }
      public String getAction()
      {
	return "remove selection";
      }
    };

    Console.writeln( "adding unselect stuff to " + w );

    w.addToBeginningOfSuitcase( dt );
    w.addToSuitcase( new DieTransition( s, getTarget() ) );
    
    return( true );
  }

  public Iterator getInputTypes()
  {
    Vector v = new Vector();

    v.addElement( "rec.core.widgets.WClick" );
    v.addElement( "rec.core.widgets.WSelection" );
    v.addElement( "rec.core.widgets.WDeletion" );
    
    return( v.iterator() );
  }

  public Iterator getOutputTypes()
  {
    Vector v = new Vector();

    return( v.iterator() );
  }
}

////////////////////////////////////////////////////////////////////////////////
