PageRenderTime 39ms CodeModel.GetById 9ms RepoModel.GetById 0ms 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
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  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. package common.gui.itemfinder;
  22. //{{{ Imports
  23. import java.awt.Component;
  24. import javax.swing.DefaultListCellRenderer;
  25. import javax.swing.JList;
  26. import org.gjt.sp.jedit.MiscUtilities;
  27. //}}}
  28. /**
  29. * A list cell renderer that renders path.
  30. * @author Matthieu Casanova
  31. */
  32. public class PathCellRenderer extends DefaultListCellRenderer
  33. {
  34. //{{{ getListCellRendererComponent() method
  35. @Override
  36. public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
  37. boolean cellHasFocus)
  38. {
  39. super.getListCellRendererComponent(list, value, index, isSelected,
  40. cellHasFocus);
  41. String path = String.valueOf(value);
  42. String fileName = MiscUtilities.getFileName(path);
  43. setText("<html><b>"+fileName+"</b>&nbsp;<gray>("+path+")</gray></html>");
  44. return this;
  45. } //}}}
  46. }