Source Code Cross Referenced for JavaElementLabelProvider.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » ui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » jdt » org.eclipse.jdt.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2005 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.jdt.ui;
011:
012:        import org.eclipse.core.resources.IStorage;
013:
014:        import org.eclipse.swt.graphics.Image;
015:
016:        import org.eclipse.jface.viewers.LabelProvider;
017:
018:        import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider;
019:        import org.eclipse.jdt.internal.ui.viewsupport.StorageLabelProvider;
020:
021:        /**
022:         * Standard label provider for Java elements.
023:         * Use this class when you want to present the Java elements in a viewer.
024:         * <p>
025:         * The implementation also handles non-Java elements by forwarding the requests to the
026:         * <code>IWorkbenchAdapter</code> of the element.
027:         * </p>
028:         * <p>
029:         * This class may be instantiated; it is not intended to be subclassed.
030:         * </p>
031:         */
032:        public class JavaElementLabelProvider extends LabelProvider {
033:
034:            /**
035:             * Flag (bit mask) indicating that methods labels include the method return type (appended).
036:             */
037:            public final static int SHOW_RETURN_TYPE = 0x001;
038:
039:            /**
040:             * Flag (bit mask) indicating that method label include parameter types.
041:             */
042:            public final static int SHOW_PARAMETERS = 0x002;
043:
044:            /**
045:             * Flag (bit mask) indicating that the label of a member should include the container.
046:             * For example, include the name of the type enclosing a field.
047:             * @deprecated Use SHOW_QUALIFIED or SHOW_ROOT instead
048:             */
049:            public final static int SHOW_CONTAINER = 0x004;
050:
051:            /**
052:             * Flag (bit mask) indicating that the label of a type should be fully qualified.
053:             * For example, include the fully qualified name of the type enclosing a type.
054:             * @deprecated Use SHOW_QUALIFIED instead
055:             */
056:            public final static int SHOW_CONTAINER_QUALIFICATION = 0x008;
057:
058:            /**
059:             * Flag (bit mask) indicating that the label should include overlay icons
060:             * for element type and modifiers.
061:             */
062:            public final static int SHOW_OVERLAY_ICONS = 0x010;
063:
064:            /**
065:             * Flag (bit mask) indicating that a field label should include the declared type.
066:             */
067:            public final static int SHOW_TYPE = 0x020;
068:
069:            /**
070:             * Flag (bit mask) indicating that the label should include the name of the
071:             * package fragment root (appended).
072:             */
073:            public final static int SHOW_ROOT = 0x040;
074:
075:            /**
076:             * Flag (bit mask) indicating that the label qualification of a type should
077:             * be shown after the name.
078:             * @deprecated SHOW_POST_QUALIFIED instead
079:             */
080:            public final static int SHOW_POSTIFIX_QUALIFICATION = 0x080;
081:
082:            /**
083:             * Flag (bit mask) indicating that the label should show the icons with no space
084:             * reserved for overlays.
085:             */
086:            public final static int SHOW_SMALL_ICONS = 0x100;
087:
088:            /**
089:             * Flag (bit mask) indicating that the package fragment roots from class path variables should
090:             * be rendered with the variable in the name
091:             */
092:            public final static int SHOW_VARIABLE = 0x200;
093:
094:            /**
095:             * Flag (bit mask) indicating that compilation units, class files, types, declarations and members
096:             * should be rendered qualified.
097:             * Examples: <code>java.lang.String</code>, <code>java.util.Vector.size()</code>
098:             * 
099:             * @since 2.0
100:             */
101:            public final static int SHOW_QUALIFIED = 0x400;
102:
103:            /**
104:             * Flag (bit mask) indicating that compilation units, class files, types, declarations and members
105:             * should be rendered qualified.The qualification is appended.
106:             * Examples: <code>String - java.lang</code>, <code>size() - java.util.Vector</code>
107:             * 
108:             * @since 2.0
109:             */
110:            public final static int SHOW_POST_QUALIFIED = 0x800;
111:
112:            /**
113:             * Constant (value <code>0</code>) indicating that the label should show 
114:             * the basic images only.
115:             */
116:            public final static int SHOW_BASICS = 0x000;
117:
118:            /**
119:             * Constant indicating the default label rendering.
120:             * Currently the default is equivalent to
121:             * <code>SHOW_PARAMETERS | SHOW_OVERLAY_ICONS</code>.
122:             */
123:            public final static int SHOW_DEFAULT = new Integer(SHOW_PARAMETERS
124:                    | SHOW_OVERLAY_ICONS).intValue();
125:
126:            private JavaElementImageProvider fImageLabelProvider;
127:
128:            private StorageLabelProvider fStorageLabelProvider;
129:            private int fFlags;
130:            private int fImageFlags;
131:            private long fTextFlags;
132:
133:            /**
134:             * Creates a new label provider with <code>SHOW_DEFAULT</code> flag.
135:             *
136:             * @see #SHOW_DEFAULT
137:             * @since 2.0
138:             */
139:            public JavaElementLabelProvider() {
140:                this (SHOW_DEFAULT);
141:            }
142:
143:            /**
144:             * Creates a new label provider.
145:             *
146:             * @param flags the initial options; a bitwise OR of <code>SHOW_* </code> constants
147:             */
148:            public JavaElementLabelProvider(int flags) {
149:                fImageLabelProvider = new JavaElementImageProvider();
150:                fStorageLabelProvider = new StorageLabelProvider();
151:                fFlags = flags;
152:                updateImageProviderFlags();
153:                updateTextProviderFlags();
154:            }
155:
156:            private boolean getFlag(int flag) {
157:                return (fFlags & flag) != 0;
158:            }
159:
160:            /**
161:             * Turns on the rendering options specified in the given flags.
162:             *
163:             * @param flags the options; a bitwise OR of <code>SHOW_* </code> constants
164:             */
165:            public void turnOn(int flags) {
166:                fFlags |= flags;
167:                updateImageProviderFlags();
168:                updateTextProviderFlags();
169:            }
170:
171:            /**
172:             * Turns off the rendering options specified in the given flags.
173:             *
174:             * @param flags the initial options; a bitwise OR of <code>SHOW_* </code> constants
175:             */
176:            public void turnOff(int flags) {
177:                fFlags &= (~flags);
178:                updateImageProviderFlags();
179:                updateTextProviderFlags();
180:            }
181:
182:            private void updateImageProviderFlags() {
183:                fImageFlags = 0;
184:                if (getFlag(SHOW_OVERLAY_ICONS)) {
185:                    fImageFlags |= JavaElementImageProvider.OVERLAY_ICONS;
186:                }
187:                if (getFlag(SHOW_SMALL_ICONS)) {
188:                    fImageFlags |= JavaElementImageProvider.SMALL_ICONS;
189:                }
190:            }
191:
192:            private void updateTextProviderFlags() {
193:                fTextFlags = JavaElementLabels.T_TYPE_PARAMETERS;
194:                if (getFlag(SHOW_RETURN_TYPE)) {
195:                    fTextFlags |= JavaElementLabels.M_APP_RETURNTYPE;
196:                }
197:                if (getFlag(SHOW_PARAMETERS)) {
198:                    fTextFlags |= JavaElementLabels.M_PARAMETER_TYPES;
199:                }
200:                if (getFlag(SHOW_CONTAINER)) {
201:                    fTextFlags |= JavaElementLabels.P_POST_QUALIFIED
202:                            | JavaElementLabels.T_POST_QUALIFIED
203:                            | JavaElementLabels.CF_POST_QUALIFIED
204:                            | JavaElementLabels.CU_POST_QUALIFIED
205:                            | JavaElementLabels.M_POST_QUALIFIED
206:                            | JavaElementLabels.F_POST_QUALIFIED;
207:                }
208:                if (getFlag(SHOW_POSTIFIX_QUALIFICATION)) {
209:                    fTextFlags |= (JavaElementLabels.T_POST_QUALIFIED
210:                            | JavaElementLabels.CF_POST_QUALIFIED | JavaElementLabels.CU_POST_QUALIFIED);
211:                } else if (getFlag(SHOW_CONTAINER_QUALIFICATION)) {
212:                    fTextFlags |= (JavaElementLabels.T_FULLY_QUALIFIED
213:                            | JavaElementLabels.CF_QUALIFIED | JavaElementLabels.CU_QUALIFIED);
214:                }
215:                if (getFlag(SHOW_TYPE)) {
216:                    fTextFlags |= JavaElementLabels.F_APP_TYPE_SIGNATURE;
217:                }
218:                if (getFlag(SHOW_ROOT)) {
219:                    fTextFlags |= JavaElementLabels.APPEND_ROOT_PATH;
220:                }
221:                if (getFlag(SHOW_VARIABLE)) {
222:                    fTextFlags |= JavaElementLabels.ROOT_VARIABLE;
223:                }
224:                if (getFlag(SHOW_QUALIFIED)) {
225:                    fTextFlags |= (JavaElementLabels.F_FULLY_QUALIFIED
226:                            | JavaElementLabels.M_FULLY_QUALIFIED
227:                            | JavaElementLabels.I_FULLY_QUALIFIED
228:                            | JavaElementLabels.T_FULLY_QUALIFIED
229:                            | JavaElementLabels.D_QUALIFIED
230:                            | JavaElementLabels.CF_QUALIFIED | JavaElementLabels.CU_QUALIFIED);
231:                }
232:                if (getFlag(SHOW_POST_QUALIFIED)) {
233:                    fTextFlags |= (JavaElementLabels.F_POST_QUALIFIED
234:                            | JavaElementLabels.M_POST_QUALIFIED
235:                            | JavaElementLabels.I_POST_QUALIFIED
236:                            | JavaElementLabels.T_POST_QUALIFIED
237:                            | JavaElementLabels.D_POST_QUALIFIED
238:                            | JavaElementLabels.CF_POST_QUALIFIED | JavaElementLabels.CU_POST_QUALIFIED);
239:                }
240:            }
241:
242:            /* (non-Javadoc)
243:             * @see ILabelProvider#getImage
244:             */
245:            public Image getImage(Object element) {
246:                Image result = fImageLabelProvider.getImageLabel(element,
247:                        fImageFlags);
248:                if (result != null) {
249:                    return result;
250:                }
251:
252:                if (element instanceof  IStorage)
253:                    return fStorageLabelProvider.getImage(element);
254:
255:                return result;
256:            }
257:
258:            /* (non-Javadoc)
259:             * @see ILabelProvider#getText
260:             */
261:            public String getText(Object element) {
262:                String text = JavaElementLabels.getTextLabel(element,
263:                        fTextFlags);
264:                if (text.length() > 0) {
265:                    return text;
266:                }
267:
268:                if (element instanceof  IStorage)
269:                    return fStorageLabelProvider.getText(element);
270:
271:                return text;
272:            }
273:
274:            /* (non-Javadoc)
275:             * 
276:             * @see IBaseLabelProvider#dispose
277:             */
278:            public void dispose() {
279:                fStorageLabelProvider.dispose();
280:                fImageLabelProvider.dispose();
281:            }
282:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.