001/*
002 * Copyright 2010-2015 Institut Pasteur.
003 * 
004 * This file is part of Icy.
005 * 
006 * Icy is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 * 
011 * Icy is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014 * GNU General Public License for more details.
015 * 
016 * You should have received a copy of the GNU General Public License
017 * along with Icy. If not, see <http://www.gnu.org/licenses/>.
018 */
019package icy.search;
020
021import java.awt.Image;
022
023import org.pushingpixels.flamingo.api.common.RichTooltip;
024
025/**
026 * Defines an item in the SearchResultPanel.
027 * 
028 * @author Thomas Provoost & Stephane Dallongeville
029 */
030public abstract class SearchResult implements Comparable<SearchResult>
031{
032    private final SearchResultProducer producer;
033
034    public SearchResult(SearchResultProducer producer)
035    {
036        super();
037
038        this.producer = producer;
039    }
040
041    /**
042     * @return Returns the producer.
043     */
044    public SearchResultProducer getProducer()
045    {
046        return producer;
047    }
048
049    /**
050     * Returns the title of the result.
051     */
052    public abstract String getTitle();
053
054    /**
055     * Returns the image of the result (can be null).
056     */
057    public abstract Image getImage();
058
059    /**
060     * Returns the description of the result.
061     */
062    public abstract String getDescription();
063
064    /**
065     * Returns the tooltip that will be displayed for this result.
066     */
067    public abstract String getTooltip();
068
069    /**
070     * Returns enabled state of the result.
071     */
072    public boolean isEnabled()
073    {
074        return true;
075    }
076
077    /**
078     * Executes the associated action for this result.
079     */
080    public abstract void execute();
081
082    /**
083     * Executes the associated alternate action (right mouse button) for this result.
084     */
085    public abstract void executeAlternate();
086
087    /**
088     * Get the RichTooltip associated to the result.
089     */
090    public abstract RichTooltip getRichToolTip();
091
092    /**
093     * Default implementation
094     */
095    @Override
096    public int compareTo(SearchResult o)
097    {
098        return getTitle().compareTo(o.getTitle());
099    }
100
101}