PageRenderTime 12ms CodeModel.GetById 8ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/bundles/plugins-trunk/CommonControls/common/gui/itemfinder/PathCellRenderer.java

#
Java | 51 lines | 19 code | 5 blank | 27 comment | 0 complexity | d9e9632554f2a474077e845a5c45e509 MD5 | raw file
 1/*
 2 * jEdit - Programmer's Text Editor
 3 * :tabSize=8:indentSize=8:noTabs=false:
 4 * :folding=explicit:collapseFolds=1:
 5 *
 6 * Copyright Š 2011 Matthieu Casanova
 7 *
 8 * This program is free software; you can redistribute it and/or
 9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 */
21
22package common.gui.itemfinder;
23
24//{{{ Imports
25import java.awt.Component;
26import javax.swing.DefaultListCellRenderer;
27import javax.swing.JList;
28
29import org.gjt.sp.jedit.MiscUtilities;
30//}}}
31
32/**
33 * A list cell renderer that renders path.
34 * @author Matthieu Casanova
35 */
36public class PathCellRenderer extends DefaultListCellRenderer
37{
38	//{{{ getListCellRendererComponent() method
39	@Override
40	public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
41						      boolean cellHasFocus)
42	{
43		super.getListCellRendererComponent(list, value, index, isSelected,
44							  cellHasFocus);
45		String path = String.valueOf(value);
46		String fileName = MiscUtilities.getFileName(path);
47		setText("<html><b>"+fileName+"</b>&nbsp;<gray>("+path+")</gray></html>");
48		return this;
49	} //}}}
50
51}