/* $Id: SuspendAction.java 268 2011-07-19 10:00:29Z shayashi $ */
package smart_gs.image_search.normal.swingui;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import smart_gs.image_search.logical.SearchResult;

public class SuspendAction implements ItemListener {
    private SearchResult result;
    private SearchResultViewer parent;

    public SuspendAction(SearchResultViewer parent, SearchResult searchResult) {
	// TODO Auto-generated constructor stub
	this.result = searchResult;
	this.parent = parent;
    }
    
    public void itemStateChanged(ItemEvent arg0) {
	// TODO Auto-generated method stub
	if (arg0.getStateChange() == ItemEvent.SELECTED) {
	    if (parent.getSelectedResults().contains(result)) {
		parent.getBucket().remove(parent.getSelectedResults().indexOf(result) + 1);
		parent.getSelectedResults().remove(result);
		parent.updateBucket(false);
	    }
	    // parent.getBucket().add(result.toQuery());
	    parent.getRemovedResults().remove(result);
	    parent.updateRemoved();
	}/* else if (parent.getRemovedResults().contains(result)) {
	    // parent.getBucket().remove(parent.getSelectedResults().indexOf(result) + 1);
	    parent.getRemovedResults().remove(result);
	    parent.updateRemoved();
	}*/

    }

}
