/plugins/CtagsSideKick/tags/release-1_2/ctags/sidekick/Tag.java

#
Java | 101 lines | 75 code | 9 blank | 17 comment | 16 complexity | 05e76595661cd93338b87792fb945c9e MD5 | raw file

✨ Summary
  1. /*
  2. Copyright (C) 2006 Shlomy Reinstein
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  14. */
  15. package ctags.sidekick;
  16. import java.net.URL;
  17. import java.util.Hashtable;
  18. import javax.swing.ImageIcon;
  19. import org.gjt.sp.jedit.Buffer;
  20. import org.gjt.sp.jedit.jEdit;
  21. import sidekick.enhanced.SourceAsset;
  22. public class Tag extends SourceAsset
  23. {
  24. static final String ICON_PREFIX = "icons.";
  25. Hashtable info;
  26. String tag;
  27. String pat;
  28. int line;
  29. String signature = null;
  30. String kind = null;
  31. static Hashtable<String, ImageIcon> icons =
  32. new Hashtable<String, ImageIcon>();
  33. Tag(final Buffer buffer, final Hashtable info)
  34. {
  35. super((String)info.get("k_tag"),
  36. Integer.parseInt((String)info.get("line")),
  37. new LinePosition(buffer,
  38. Integer.parseInt((String) info.get("line")) - 1, true));
  39. this.info = info;
  40. tag = (String)info.get("k_tag");
  41. pat = (String)info.get("k_pat");
  42. line = Integer.parseInt((String)info.get("line")) - 1;
  43. signature = (String)info.get("signature");
  44. if (signature != null && signature.length() > 0)
  45. setShortDescription(tag + signature);
  46. kind = (String)info.get("kind");
  47. if (jEdit.getBooleanProperty(OptionPane.SHOW_ICONS, true))
  48. {
  49. String iconName =
  50. jEdit.getProperty(OptionPane.ICONS + kind);
  51. if (iconName == null || iconName.length() == 0)
  52. iconName = "unknown.png";
  53. ImageIcon icon = (ImageIcon) icons.get(kind);
  54. if (icon == null)
  55. {
  56. URL url = Tag.class.getClassLoader().getResource(
  57. "icons/" + iconName);
  58. try {
  59. icon = new ImageIcon(url);
  60. }
  61. catch (Exception e) {
  62. e.printStackTrace();
  63. }
  64. if (icon != null)
  65. icons.put(kind, icon);
  66. }
  67. if (icon != null)
  68. setIcon(icon);
  69. }
  70. }
  71. int getLine()
  72. {
  73. return line;
  74. }
  75. String getKind()
  76. {
  77. return kind;
  78. }
  79. Hashtable getInfo()
  80. {
  81. return info;
  82. }
  83. public boolean equals(Object obj)
  84. {
  85. if (this == obj)
  86. return true;
  87. return (getShortString().equals(obj));
  88. }
  89. };