PageRenderTime 67ms CodeModel.GetById 10ms RepoModel.GetById 1ms app.codeStats 0ms

/bundles/plugins-trunk/RubyPlugin/src/org/jedit/ruby/icons/MemberIcon.java

#
Java | 71 lines | 36 code | 13 blank | 22 comment | 0 complexity | bd2dcb69bc5f2970372e52c87d706891 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. * MemberIcon.java -
  3. *
  4. * Copyright 2005 Robert McKinnon
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. */
  20. package org.jedit.ruby.icons;
  21. import javax.swing.Icon;
  22. import javax.swing.ImageIcon;
  23. import errorlist.ErrorList;
  24. import org.jedit.ruby.ast.*;
  25. import org.jedit.ruby.ast.Error;
  26. /**
  27. * @author robmckinnon at users.sourceforge.net
  28. */
  29. public final class MemberIcon extends MemberVisitorAdapter {
  30. private Icon icon;
  31. public MemberIcon(Member member) {
  32. member.accept(this);
  33. }
  34. public final Icon getIcon() {
  35. return icon;
  36. }
  37. public final void handleModule(Module module) {
  38. icon = loadIcon("module");
  39. }
  40. public final void handleClass(org.jedit.ruby.ast.ClassMember classMember) {
  41. icon = loadIcon("class");
  42. }
  43. public final void handleMethod(Method method) {
  44. icon = loadIcon("method");
  45. }
  46. public void handleMethodCallWithSelfAsAnImplicitReceiver(MethodCallWithSelfAsAnImplicitReceiver methodCall) {
  47. icon = loadIcon("method_call_to_self");
  48. }
  49. public final void handleWarning(Warning warning) {
  50. icon = ErrorList.WARNING_ICON;
  51. }
  52. public final void handleError(Error warning) {
  53. icon = ErrorList.ERROR_ICON;
  54. }
  55. private static Icon loadIcon(String name) {
  56. return new ImageIcon(MemberIcon.class.getResource(name + ".png"));
  57. }
  58. }