PageRenderTime 24ms CodeModel.GetById 16ms app.highlight 4ms 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
 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 */
20package org.jedit.ruby.icons;
21
22import javax.swing.Icon;
23import javax.swing.ImageIcon;
24
25import errorlist.ErrorList;
26import org.jedit.ruby.ast.*;
27import org.jedit.ruby.ast.Error;
28
29/**
30 * @author robmckinnon at users.sourceforge.net
31 */
32public final class MemberIcon extends MemberVisitorAdapter {
33
34    private Icon icon;
35
36    public MemberIcon(Member member) {
37        member.accept(this);
38    }
39
40    public final Icon getIcon() {
41        return icon;
42    }
43
44    public final void handleModule(Module module) {
45        icon = loadIcon("module");
46    }
47
48    public final void handleClass(org.jedit.ruby.ast.ClassMember classMember) {
49        icon = loadIcon("class");
50    }
51
52    public final void handleMethod(Method method) {
53        icon = loadIcon("method");
54    }
55
56    public void handleMethodCallWithSelfAsAnImplicitReceiver(MethodCallWithSelfAsAnImplicitReceiver methodCall) {
57        icon = loadIcon("method_call_to_self");
58    }
59
60    public final void handleWarning(Warning warning) {
61        icon = ErrorList.WARNING_ICON;
62    }
63
64    public final void handleError(Error warning) {
65        icon = ErrorList.ERROR_ICON;
66    }
67
68    private static Icon loadIcon(String name) {
69       return new ImageIcon(MemberIcon.class.getResource(name + ".png"));
70    }
71}