/**
 * Title:
 * @version:    $Id: SearchFieldChangeDocumentListener.java,v 1.1 2004/11/15 13:47:50 rob Exp $
 * Copyright:   Copyright (C) 2003 Ian Ibbotson
 * @author:     Ian Ibbotson
 * Company:
 * Description:
 */

package com.k_int.AdminApp.gui.SearchView;

import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import java.io.*;
import java.lang.reflect.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import com.k_int.QueryDescriptor.*;
import com.k_int.AdminApp.models.Search.*;

public class SearchFieldChangeDocumentListener implements DocumentListener
{
  private JTextField tf;
  private SearchModel sm;
  private String field_name;

  public SearchFieldChangeDocumentListener(JTextField tf, 
                                           SearchModel sm,
                                           String field_name)
  {
    // remeber the source text field itself
    // note where the updated value should be put.
    this.tf = tf;
    this.sm = sm;
    this.field_name = field_name;
  }

  public void insertUpdate(DocumentEvent e) 
  {
    String value = tf.getText();
    sm.setSearchValue(field_name, value);
  }

  public void removeUpdate(DocumentEvent e) 
  {
    String value = tf.getText();
    sm.setSearchValue(field_name, value);
  }

  public void changedUpdate(DocumentEvent e)  
  {
    // we won't ever get this with a PlainDocument
  }
}


