KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > ajde > ui > swing > IconRegistry


1
2 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3  *
4  * This file is part of the IDE support for the AspectJ(tm)
5  * programming language; see http://aspectj.org
6  *
7  * The contents of this file are subject to the Mozilla Public License
8  * Version 1.1 (the "License"); you may not use this file except in
9  * compliance with the License. You may obtain a copy of the License at
10  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is AspectJ.
18  *
19  * The Initial Developer of the Original Code is Xerox Corporation. Portions
20  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
21  * All Rights Reserved.
22  *
23  * Contributor(s):
24  */

25
26 package org.aspectj.ajde.ui.swing;
27
28 import javax.swing.*;
29 import java.util.*;
30 import java.net.URL JavaDoc;
31 import org.aspectj.asm.*;
32 import org.aspectj.ajde.ui.*;
33
34 /**
35  * Default icons. Override behavior for custom icons.
36  *
37  * @author Mik Kersten
38  */

39 public class IconRegistry extends AbstractIconRegistry {
40
41     //public static IconRegistry INSTANCE = null;
42
protected String JavaDoc RESOURCE_PATH = "org/aspectj/ajde/resources/";
43     
44     private final Icon START_AJDE = makeIcon("actions/startAjde.gif");
45     private final Icon STOP_AJDE = makeIcon("actions/stopAjde.gif");
46     private final Icon BUILD = makeIcon("actions/build.gif");
47     private final Icon DEBUG = makeIcon("actions/debug.gif");
48     private final Icon EXECUTE = makeIcon("actions/execute.gif");
49     private final Icon AJBROWSER = makeIcon("structure/advice.gif");
50     private final Icon AJBROWSER_ENABLED = makeIcon("actions/browserEnabled.gif");
51     private final Icon AJBROWSER_DISABLED = makeIcon("actions/browserDisabled.gif");
52     private final Icon STRUCTURE_VIEW = makeIcon("actions/structureView.gif");
53
54     private final Icon HIDE_ASSOCIATIONS = makeIcon("actions/hideAssociations.gif");
55     private final Icon HIDE_NON_AJ = makeIcon("actions/hideNonAJ.gif");
56     private final Icon GRANULARITY = makeIcon("actions/granularity.gif");
57     private final Icon AJDE_SMALL = makeIcon("actions/ajdeSmall.gif");
58
59     private final Icon ERROR = makeIcon("structure/error.gif");
60     private final Icon WARNING = makeIcon("structure/warning.gif");
61     private final Icon INFO = makeIcon("structure/info.gif");
62
63     private final Icon POPUP = makeIcon("actions/popup.gif");
64     private final Icon FILTER = makeIcon("actions/filter.gif");
65     private final Icon RELATIONS = makeIcon("actions/relations.gif");
66     private final Icon ORDER = makeIcon("actions/order.gif");
67     
68     private final Icon ZOOM_STRUCTURE_TO_FILE_MODE = makeIcon("actions/zoomStructureToFileMode.gif");
69     private final Icon ZOOM_STRUCTURE_TO_GLOBAL_MODE = makeIcon("actions/zoomStructureToGlobalMode.gif");
70     private final Icon SPLIT_STRUCTURE_VIEW = makeIcon("actions/splitStructureView.gif");
71     private final Icon MERGE_STRUCTURE_VIEW = makeIcon("actions/mergeStructureView.gif");
72      
73     private final Icon BACK = makeIcon("actions/back.gif");
74     private final Icon FORWARD = makeIcon("actions/forward.gif");
75     private final Icon SEARCH = makeIcon("actions/search.gif");
76     private final Icon OPEN_CONFIG = makeIcon("actions/openConfig.gif");
77     private final Icon CLOSE_CONFIG = makeIcon("actions/closeConfig.gif");
78     private final Icon SAVE = makeIcon("actions/save.gif");
79     private final Icon SAVE_ALL = makeIcon("actions/saveAll.gif");
80     private final Icon BROWSER_OPTIONS = makeIcon("actions/browseroptions.gif");
81    
82     private final Icon ACCESSIBILITY_PUBLIC = makeIcon("structure/accessibility-public.gif");
83     private final Icon ACCESSIBILITY_PACKAGE = makeIcon("structure/accessibility-package.gif");
84     private final Icon ACCESSIBILITY_PROTECTED = makeIcon("structure/accessibility-protected.gif");
85     private final Icon ACCESSIBILITY_PRIVATE = makeIcon("structure/accessibility-private.gif");
86     private final Icon ACCESSIBILITY_PRIVILEGED = makeIcon("structure/accessibility-privileged.gif");
87
88     public Icon getAjdeSmallIcon() { return AJDE_SMALL; }
89     public Icon getHideAssociationsIcon() { return HIDE_ASSOCIATIONS; }
90     public Icon getHideNonAJIcon() { return HIDE_NON_AJ; }
91     public Icon getGranularityIcon() { return GRANULARITY; }
92     public Icon getErrorIcon() { return ERROR; }
93     public Icon getWarningIcon() { return WARNING; }
94     public Icon getInfoIcon() { return INFO; }
95     public Icon getAJBrowserIcon() { return AJBROWSER; }
96     public Icon getAJBrowserEnabledIcon() { return AJBROWSER_ENABLED; }
97     public Icon getAJBrowserDisabledIcon() { return AJBROWSER_DISABLED; }
98     public Icon getPopupIcon() { return POPUP; }
99     public Icon getFilterIcon() { return FILTER; }
100     public Icon getOrderIcon() { return ORDER; }
101     public Icon getRelationsIcon() { return RELATIONS; }
102     public Icon getStartAjdeIcon() { return START_AJDE; }
103     public Icon getStopAjdeIcon() { return STOP_AJDE; }
104     public Icon getBackIcon() { return BACK; }
105     public Icon getForwardIcon() { return FORWARD; }
106     public Icon getSearchIcon() { return SEARCH; }
107     public Icon getBuildIcon() { return BUILD; }
108     public Icon getDebugIcon() { return DEBUG; }
109     public Icon getExecuteIcon() { return EXECUTE; }
110     public Icon getOpenConfigIcon() { return OPEN_CONFIG; }
111     public Icon getCloseConfigIcon() { return CLOSE_CONFIG; }
112     public Icon getOpenIcon() { return OPEN_CONFIG; }
113     public Icon getSaveIcon() { return SAVE; }
114     public Icon getSaveAllIcon() { return SAVE_ALL; }
115     public Icon getBrowserOptionsIcon() { return BROWSER_OPTIONS; }
116     public Icon getZoomStructureToFileModeIcon() { return ZOOM_STRUCTURE_TO_FILE_MODE; }
117     public Icon getZoomStructureToGlobalModeIcon() { return ZOOM_STRUCTURE_TO_GLOBAL_MODE; }
118     public Icon getSplitStructureViewIcon() { return SPLIT_STRUCTURE_VIEW; }
119     public Icon getMergeStructureViewIcon() { return MERGE_STRUCTURE_VIEW; }
120     public Icon getStructureViewIcon() { return STRUCTURE_VIEW; }
121
122     public Icon getAssociationSwingIcon(Relation relation) {
123         return convertToSwingIcon(getRelationIcon(relation));
124     }
125     
126     protected AbstractIcon getStructureIcon(ProgramElementNode.Kind kind, ProgramElementNode.Accessibility accessibility) {
127         return getStructureIcon(kind);
128     }
129     
130     public Icon getStructureSwingIcon(ProgramElementNode.Kind kind, ProgramElementNode.Accessibility accessibility) {
131         return convertToSwingIcon(getStructureIcon(kind, accessibility));
132     }
133     
134     public Icon getStructureSwingIcon(ProgramElementNode.Kind kind) {
135         return convertToSwingIcon(getStructureIcon(kind));
136     }
137
138     public Icon getAccessibilitySwingIcon(ProgramElementNode.Accessibility accessibility) {
139         if (accessibility == ProgramElementNode.Accessibility.PUBLIC) {
140             return ACCESSIBILITY_PUBLIC;
141         } else if (accessibility == ProgramElementNode.Accessibility.PACKAGE) {
142             return ACCESSIBILITY_PACKAGE;
143         } else if (accessibility == ProgramElementNode.Accessibility.PROTECTED) {
144             return ACCESSIBILITY_PROTECTED;
145         } else if (accessibility == ProgramElementNode.Accessibility.PRIVATE) {
146             return ACCESSIBILITY_PRIVATE;
147         } else if (accessibility == ProgramElementNode.Accessibility.PRIVILEGED) {
148             return ACCESSIBILITY_PRIVILEGED;
149         } else {
150             return null;
151         }
152     }
153
154     public Icon convertToSwingIcon(AbstractIcon iconAdapter) {
155         if (iconAdapter != null) {
156             return (Icon)iconAdapter.getIconResource();
157         } else {
158             return null;
159         }
160     }
161
162     protected AbstractIcon createIcon(String JavaDoc path) {
163         return new AbstractIcon(new ImageIcon(ClassLoader.getSystemResource(path)));
164     }
165
166     protected Icon makeIcon(String JavaDoc iconPath) {
167         return new ImageIcon(ClassLoader.getSystemResource(RESOURCE_PATH + iconPath));
168     }
169 }
Popular Tags