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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 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.text.folding;
011:
012:        import java.util.Collections;
013:        import java.util.HashMap;
014:        import java.util.Map;
015:
016:        import org.eclipse.core.runtime.Assert;
017:        import org.eclipse.core.runtime.CoreException;
018:        import org.eclipse.core.runtime.IConfigurationElement;
019:        import org.eclipse.core.runtime.IExtensionRegistry;
020:        import org.eclipse.core.runtime.IStatus;
021:        import org.eclipse.core.runtime.Platform;
022:        import org.eclipse.core.runtime.Status;
023:
024:        import org.eclipse.jface.preference.IPreferenceStore;
025:
026:        import org.eclipse.jdt.internal.corext.util.Messages;
027:
028:        import org.eclipse.jdt.ui.PreferenceConstants;
029:        import org.eclipse.jdt.ui.text.folding.IJavaFoldingStructureProvider;
030:
031:        import org.eclipse.jdt.internal.ui.JavaPlugin;
032:
033:        /**
034:         * @since 3.0
035:         */
036:        public class JavaFoldingStructureProviderRegistry {
037:
038:            private static final String EXTENSION_POINT = "foldingStructureProviders"; //$NON-NLS-1$
039:
040:            /** The map of descriptors, indexed by their identifiers. */
041:            private Map fDescriptors;
042:
043:            /**
044:             * Creates a new instance.
045:             */
046:            public JavaFoldingStructureProviderRegistry() {
047:            }
048:
049:            /**
050:             * Returns an array of <code>JavaFoldingStructureProviderDescriptor</code> describing
051:             * all extension to the <code>foldingProviders</code> extension point.
052:             *
053:             * @return the list of extensions to the
054:             *         <code>quickDiffReferenceProvider</code> extension point
055:             */
056:            public JavaFoldingStructureProviderDescriptor[] getFoldingProviderDescriptors() {
057:                synchronized (this ) {
058:                    ensureRegistered();
059:                    return (JavaFoldingStructureProviderDescriptor[]) fDescriptors
060:                            .values()
061:                            .toArray(
062:                                    new JavaFoldingStructureProviderDescriptor[fDescriptors
063:                                            .size()]);
064:                }
065:            }
066:
067:            /**
068:             * Returns the folding provider descriptor with identifier <code>id</code> or
069:             * <code>null</code> if no such provider is registered.
070:             *
071:             * @param id the identifier for which a provider is wanted
072:             * @return the corresponding provider descriptor, or <code>null</code> if none can be
073:             *         found
074:             */
075:            public JavaFoldingStructureProviderDescriptor getFoldingProviderDescriptor(
076:                    String id) {
077:                synchronized (this ) {
078:                    ensureRegistered();
079:                    return (JavaFoldingStructureProviderDescriptor) fDescriptors
080:                            .get(id);
081:                }
082:            }
083:
084:            /**
085:             * Instantiates and returns the provider that is currently configured in the
086:             * preferences.
087:             *
088:             * @return the current provider according to the preferences
089:             */
090:            public IJavaFoldingStructureProvider getCurrentFoldingProvider() {
091:                IPreferenceStore preferenceStore = JavaPlugin.getDefault()
092:                        .getPreferenceStore();
093:                String currentProviderId = preferenceStore
094:                        .getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
095:                JavaFoldingStructureProviderDescriptor desc = getFoldingProviderDescriptor(currentProviderId);
096:
097:                // Fallback to default if extension has gone
098:                if (desc == null) {
099:                    String message = Messages
100:                            .format(
101:                                    FoldingMessages.JavaFoldingStructureProviderRegistry_warning_providerNotFound_resetToDefault,
102:                                    currentProviderId);
103:                    JavaPlugin.log(new Status(IStatus.WARNING, JavaPlugin
104:                            .getPluginId(), IStatus.OK, message, null));
105:
106:                    String defaultProviderId = preferenceStore
107:                            .getDefaultString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
108:
109:                    desc = getFoldingProviderDescriptor(defaultProviderId);
110:                    Assert.isNotNull(desc);
111:
112:                    preferenceStore
113:                            .setToDefault(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
114:                }
115:
116:                try {
117:                    return desc.createProvider();
118:                } catch (CoreException e) {
119:                    JavaPlugin.log(e);
120:                    return null;
121:                }
122:            }
123:
124:            /**
125:             * Ensures that the extensions are read and stored in
126:             * <code>fDescriptors</code>.
127:             */
128:            private void ensureRegistered() {
129:                if (fDescriptors == null)
130:                    reloadExtensions();
131:            }
132:
133:            /**
134:             * Reads all extensions.
135:             * <p>
136:             * This method can be called more than once in
137:             * order to reload from a changed extension registry.
138:             * </p>
139:             */
140:            public void reloadExtensions() {
141:                IExtensionRegistry registry = Platform.getExtensionRegistry();
142:                Map map = new HashMap();
143:
144:                IConfigurationElement[] elements = registry
145:                        .getConfigurationElementsFor(JavaPlugin.getPluginId(),
146:                                EXTENSION_POINT);
147:                for (int i = 0; i < elements.length; i++) {
148:                    JavaFoldingStructureProviderDescriptor desc = new JavaFoldingStructureProviderDescriptor(
149:                            elements[i]);
150:                    map.put(desc.getId(), desc);
151:                }
152:
153:                synchronized (this) {
154:                    fDescriptors = Collections.unmodifiableMap(map);
155:                }
156:            }
157:
158:        }
w__w___w__._j__a___va_2___s_._c___o__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.