Source Code Cross Referenced for JavaNavigatorLabelProvider.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » internal » ui » navigator » 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.internal.ui.navigator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2007 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.internal.ui.navigator;
011:
012:        import org.eclipse.core.resources.IContainer;
013:        import org.eclipse.core.resources.IResource;
014:
015:        import org.eclipse.swt.graphics.Color;
016:        import org.eclipse.swt.graphics.Image;
017:
018:        import org.eclipse.jface.util.IPropertyChangeListener;
019:        import org.eclipse.jface.util.PropertyChangeEvent;
020:        import org.eclipse.jface.viewers.ILabelDecorator;
021:        import org.eclipse.jface.viewers.ILabelProviderListener;
022:
023:        import org.eclipse.ui.IMemento;
024:        import org.eclipse.ui.navigator.ICommonContentExtensionSite;
025:        import org.eclipse.ui.navigator.ICommonLabelProvider;
026:        import org.eclipse.ui.navigator.IExtensionStateModel;
027:
028:        import org.eclipse.jdt.core.IJavaElement;
029:
030:        import org.eclipse.jdt.ui.JavaElementLabels;
031:
032:        import org.eclipse.jdt.internal.ui.navigator.IExtensionStateConstants.Values;
033:        import org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider;
034:        import org.eclipse.jdt.internal.ui.packageview.PackageExplorerLabelProvider;
035:
036:        /**
037:         * Provides the labels for the Project Explorer.
038:         * <p>
039:         * It provides labels for the packages in hierarchical layout and in all other
040:         * cases delegates it to its super class.
041:         * </p>
042:         * 
043:         * @since 3.2
044:         */
045:        public class JavaNavigatorLabelProvider implements  ICommonLabelProvider {
046:
047:            private final long LABEL_FLAGS = JavaElementLabels.DEFAULT_QUALIFIED
048:                    | JavaElementLabels.ROOT_POST_QUALIFIED
049:                    | JavaElementLabels.APPEND_ROOT_PATH
050:                    | JavaElementLabels.M_PARAMETER_TYPES
051:                    | JavaElementLabels.M_PARAMETER_NAMES
052:                    | JavaElementLabels.M_APP_RETURNTYPE
053:                    | JavaElementLabels.M_EXCEPTIONS
054:                    | JavaElementLabels.F_APP_TYPE_SIGNATURE
055:                    | JavaElementLabels.T_TYPE_PARAMETERS;
056:
057:            private PackageExplorerLabelProvider delegeteLabelProvider;
058:
059:            private PackageExplorerContentProvider fContentProvider;
060:
061:            private IExtensionStateModel fStateModel;
062:
063:            private IPropertyChangeListener fLayoutPropertyListener;
064:
065:            public JavaNavigatorLabelProvider() {
066:
067:            }
068:
069:            public void init(
070:                    ICommonContentExtensionSite commonContentExtensionSite) {
071:                fStateModel = commonContentExtensionSite
072:                        .getExtensionStateModel();
073:                fContentProvider = (PackageExplorerContentProvider) commonContentExtensionSite
074:                        .getExtension().getContentProvider();
075:                delegeteLabelProvider = createLabelProvider();
076:
077:                delegeteLabelProvider.setIsFlatLayout(fStateModel
078:                        .getBooleanProperty(Values.IS_LAYOUT_FLAT));
079:                fLayoutPropertyListener = new IPropertyChangeListener() {
080:                    public void propertyChange(PropertyChangeEvent event) {
081:                        if (Values.IS_LAYOUT_FLAT.equals(event.getProperty())) {
082:                            if (event.getNewValue() != null) {
083:                                boolean newValue = ((Boolean) event
084:                                        .getNewValue()).booleanValue() ? true
085:                                        : false;
086:                                delegeteLabelProvider.setIsFlatLayout(newValue);
087:                            }
088:                        }
089:
090:                    }
091:                };
092:                fStateModel.addPropertyChangeListener(fLayoutPropertyListener);
093:            }
094:
095:            public String getDescription(Object element) {
096:                return formatMessage(element);
097:            }
098:
099:            private PackageExplorerLabelProvider createLabelProvider() {
100:                return new PackageExplorerLabelProvider(fContentProvider);
101:            }
102:
103:            public void dispose() {
104:                delegeteLabelProvider.dispose();
105:                fStateModel
106:                        .removePropertyChangeListener(fLayoutPropertyListener);
107:            }
108:
109:            public void propertyChange(PropertyChangeEvent event) {
110:                delegeteLabelProvider.propertyChange(event);
111:            }
112:
113:            public void addLabelDecorator(ILabelDecorator decorator) {
114:                delegeteLabelProvider.addLabelDecorator(decorator);
115:            }
116:
117:            public void addListener(ILabelProviderListener listener) {
118:                delegeteLabelProvider.addListener(listener);
119:            }
120:
121:            public Color getBackground(Object element) {
122:                return delegeteLabelProvider.getBackground(element);
123:            }
124:
125:            public Color getForeground(Object element) {
126:                return delegeteLabelProvider.getForeground(element);
127:            }
128:
129:            public Image getImage(Object element) {
130:                return delegeteLabelProvider.getImage(element);
131:            }
132:
133:            public boolean isLabelProperty(Object element, String property) {
134:                return delegeteLabelProvider.isLabelProperty(element, property);
135:            }
136:
137:            public void removeListener(ILabelProviderListener listener) {
138:                delegeteLabelProvider.removeListener(listener);
139:            }
140:
141:            public boolean equals(Object obj) {
142:                return delegeteLabelProvider.equals(obj);
143:            }
144:
145:            public int hashCode() {
146:                return delegeteLabelProvider.hashCode();
147:            }
148:
149:            public String toString() {
150:                return delegeteLabelProvider.toString();
151:            }
152:
153:            public String getText(Object element) {
154:                return delegeteLabelProvider.getText(element);
155:            }
156:
157:            public void setIsFlatLayout(boolean state) {
158:                delegeteLabelProvider.setIsFlatLayout(state);
159:            }
160:
161:            // Taken from StatusBarUpdater
162:
163:            private String formatMessage(Object element) {
164:                if (element instanceof  IJavaElement) {
165:                    return formatJavaElementMessage((IJavaElement) element);
166:                } else if (element instanceof  IResource) {
167:                    return formatResourceMessage((IResource) element);
168:                }
169:                return ""; //$NON-NLS-1$
170:            }
171:
172:            private String formatJavaElementMessage(IJavaElement element) {
173:                return JavaElementLabels.getElementLabel(element, LABEL_FLAGS);
174:            }
175:
176:            private String formatResourceMessage(IResource element) {
177:                IContainer parent = element.getParent();
178:                if (parent != null && parent.getType() != IResource.ROOT)
179:                    return element.getName() + JavaElementLabels.CONCAT_STRING
180:                            + parent.getFullPath().makeRelative().toString();
181:                else
182:                    return element.getName();
183:            }
184:
185:            public void restoreState(IMemento memento) {
186:
187:            }
188:
189:            public void saveState(IMemento memento) {
190:
191:            }
192:
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.