/************************************************************************** /* A JList GUI-component for presentation of search-results. /* /* Copyright (c) 2003-2004 by Bernhard Bablok (mail@bablokb.de) /* /* This library is free software; you can redistribute it and/or modify /* it under the terms of the GNU Lesser General Public License as published /* by the Free Software Foundation; either version 2 of the License or /* (at your option) any later version. /* /* This library is distributed in the hope that it will be useful, but /* WITHOUT ANY WARRANTY; without even the implied warranty of /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /* GNU Lesser General Public License for more details. /* /* You should have received a copy of the GNU Lesser General Public License /* along with this library; see the file COPYING.LESSER. If not, write to /* the Free Software Foundation Inc., 59 Temple Place - Suite 330, /* Boston, MA 02111-1307 USA /**************************************************************************/ package de.bablokb.luala.lib.gui; import java.net.*; import java.awt.*; import java.awt.event.*; import java.io.*; import javax.swing.*; import javax.swing.event.*; import de.bablokb.luala.lib.event.*; /** A JList GUI-component for presentation of search-results. @version $Revision: 1.4 $ @author $Author: bablokb $ */ public class ListResultView implements ResultView { //////////////////////////////////////////////////////////////////////////// /** The JList for the presentation of the results. */ private JList iResultPane; //////////////////////////////////////////////////////////////////////////// /** The {@link ShowDocumentEventListener}. We actually nead a list, but in most cases a single {@link ShowDocumentEventListener} should do. */ private ShowDocumentEventListener iListener; //////////////////////////////////////////////////////////////////////////// /** Create a ListResultView object. */ public ListResultView() throws IOException { iResultPane = new JList(); iResultPane.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (iListener != null && e.getClickCount() == 2) { iListener.showDocument( new ShowDocumentEvent(e.getSource(), (String) iResultPane.getSelectedValue())); } } } ); } //////////////////////////////////////////////////////////////////////////// /** {@inheritDoc} */ public JComponent getGUI() { return new JScrollPane(iResultPane); } //////////////////////////////////////////////////////////////////////////// /** {@inheritDoc} */ public void addShowDocumentEventListener(ShowDocumentEventListener sdel) { iListener = sdel; } //////////////////////////////////////////////////////////////////////////// /** {@inheritDoc} */ public void setData(Object data) { iResultPane.setListData((String[]) data); } }