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


001:        /*******************************************************************************
002:         * Copyright (c) 2005, 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.ui.internal.contexts;
011:
012:        import java.util.ArrayList;
013:        import java.util.List;
014:
015:        import org.eclipse.core.commands.common.HandleObject;
016:        import org.eclipse.core.commands.contexts.Context;
017:        import org.eclipse.core.commands.contexts.ContextManager;
018:        import org.eclipse.core.runtime.IConfigurationElement;
019:        import org.eclipse.core.runtime.IExtensionDelta;
020:        import org.eclipse.core.runtime.IExtensionRegistry;
021:        import org.eclipse.core.runtime.IRegistryChangeEvent;
022:        import org.eclipse.core.runtime.Platform;
023:        import org.eclipse.ui.PlatformUI;
024:        import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
025:        import org.eclipse.ui.internal.services.RegistryPersistence;
026:
027:        /**
028:         * <p>
029:         * A static class for accessing the registry.
030:         * </p>
031:         * 
032:         * @since 3.1
033:         */
034:        final class ContextPersistence extends RegistryPersistence {
035:
036:            /**
037:             * The index of the context elements in the indexed array.
038:             * 
039:             * @see ContextPersistence#read()
040:             */
041:            private static final int INDEX_CONTEXT_DEFINITIONS = 0;
042:
043:            /**
044:             * Reads all of the command definitions from the commands extension point.
045:             * 
046:             * @param configurationElements
047:             *            The configuration elements in the commands extension point;
048:             *            must not be <code>null</code>, but may be empty.
049:             * @param configurationElementCount
050:             *            The number of configuration elements that are really in the
051:             *            array.
052:             * @param contextManager
053:             *            The context manager to which the commands should be added;
054:             *            must not be <code>null</code>.
055:             */
056:            private static final void readContextsFromRegistry(
057:                    final IConfigurationElement[] configurationElements,
058:                    final int configurationElementCount,
059:                    final ContextManager contextManager) {
060:                // Undefine all the previous handle objects.
061:                final HandleObject[] handleObjects = contextManager
062:                        .getDefinedContexts();
063:                if (handleObjects != null) {
064:                    for (int i = 0; i < handleObjects.length; i++) {
065:                        handleObjects[i].undefine();
066:                    }
067:                }
068:
069:                final List warningsToLog = new ArrayList(1);
070:
071:                for (int i = 0; i < configurationElementCount; i++) {
072:                    final IConfigurationElement configurationElement = configurationElements[i];
073:
074:                    // Read out the command identifier.
075:                    final String contextId = readRequired(configurationElement,
076:                            ATT_ID, warningsToLog, "Contexts need an id"); //$NON-NLS-1$
077:                    if (contextId == null) {
078:                        continue;
079:                    }
080:
081:                    // Read out the name.
082:                    final String name = readRequired(configurationElement,
083:                            ATT_NAME, warningsToLog, "Contexts need a name", //$NON-NLS-1$
084:                            contextId);
085:                    if (name == null) {
086:                        continue;
087:                    }
088:
089:                    // Read out the description.
090:                    final String description = readOptional(
091:                            configurationElement, ATT_DESCRIPTION);
092:
093:                    // Read out the parent id.
094:                    String parentId = configurationElement
095:                            .getAttribute(ATT_PARENT_ID);
096:                    if ((parentId == null) || (parentId.length() == 0)) {
097:                        parentId = configurationElement
098:                                .getAttribute(ATT_PARENT);
099:                        if ((parentId == null) || (parentId.length() == 0)) {
100:                            parentId = configurationElement
101:                                    .getAttribute(ATT_PARENT_SCOPE);
102:                        }
103:                    }
104:                    if ((parentId != null) && (parentId.length() == 0)) {
105:                        parentId = null;
106:                    }
107:
108:                    final Context context = contextManager
109:                            .getContext(contextId);
110:                    context.define(name, description, parentId);
111:                }
112:
113:                logWarnings(
114:                        warningsToLog,
115:                        "Warnings while parsing the contexts from the 'org.eclipse.ui.contexts', 'org.eclipse.ui.commands' and 'org.eclipse.ui.acceleratorScopes' extension points."); //$NON-NLS-1$
116:            }
117:
118:            /**
119:             * The context manager for this instance; must not be <code>null</code>.
120:             */
121:            private final ContextManager contextManager;
122:
123:            /**
124:             * Constructs a new instance of <code>ContextPersistence</code>.
125:             */
126:            ContextPersistence(final ContextManager contextManager) {
127:                if (contextManager == null) {
128:                    throw new NullPointerException(
129:                            "The context manager must not be null"); //$NON-NLS-1$
130:                }
131:                this .contextManager = contextManager;
132:            }
133:
134:            protected final boolean isChangeImportant(
135:                    final IRegistryChangeEvent event) {
136:                final IExtensionDelta[] acceleratorScopeDeltas = event
137:                        .getExtensionDeltas(
138:                                PlatformUI.PLUGIN_ID,
139:                                IWorkbenchRegistryConstants.PL_ACCELERATOR_SCOPES);
140:                if (acceleratorScopeDeltas.length == 0) {
141:                    final IExtensionDelta[] contextDeltas = event
142:                            .getExtensionDeltas(PlatformUI.PLUGIN_ID,
143:                                    IWorkbenchRegistryConstants.PL_CONTEXTS);
144:                    if (contextDeltas.length == 0) {
145:                        final IExtensionDelta[] commandDeltas = event
146:                                .getExtensionDeltas(PlatformUI.PLUGIN_ID,
147:                                        IWorkbenchRegistryConstants.PL_COMMANDS);
148:                        if (commandDeltas.length == 0) {
149:                            return false;
150:                        }
151:                    }
152:                }
153:
154:                return true;
155:            }
156:
157:            /**
158:             * Reads all of the contexts from the registry,
159:             * 
160:             * @param contextManager
161:             *            The context manager which should be populated with the values
162:             *            from the registry; must not be <code>null</code>.
163:             */
164:            protected final void read() {
165:                super .read();
166:
167:                // Create the extension registry mementos.
168:                final IExtensionRegistry registry = Platform
169:                        .getExtensionRegistry();
170:                int contextDefinitionCount = 0;
171:                final IConfigurationElement[][] indexedConfigurationElements = new IConfigurationElement[1][];
172:
173:                /*
174:                 * Retrieve the accelerator scopes from the accelerator scopes extension
175:                 * point.
176:                 */
177:                final IConfigurationElement[] acceleratorScopesExtensionPoint = registry
178:                        .getConfigurationElementsFor(EXTENSION_ACCELERATOR_SCOPES);
179:                for (int i = 0; i < acceleratorScopesExtensionPoint.length; i++) {
180:                    final IConfigurationElement configurationElement = acceleratorScopesExtensionPoint[i];
181:                    final String name = configurationElement.getName();
182:
183:                    // Check if it is a binding definition.
184:                    if (TAG_ACCELERATOR_SCOPE.equals(name)) {
185:                        addElementToIndexedArray(configurationElement,
186:                                indexedConfigurationElements,
187:                                INDEX_CONTEXT_DEFINITIONS,
188:                                contextDefinitionCount++);
189:                    }
190:                }
191:
192:                /*
193:                 * Retrieve the deprecated scopes and contexts from the commands
194:                 * extension point.
195:                 */
196:                final IConfigurationElement[] commandsExtensionPoint = registry
197:                        .getConfigurationElementsFor(EXTENSION_COMMANDS);
198:                for (int i = 0; i < commandsExtensionPoint.length; i++) {
199:                    final IConfigurationElement configurationElement = commandsExtensionPoint[i];
200:                    final String name = configurationElement.getName();
201:
202:                    // Check if it is a binding definition.
203:                    if (TAG_SCOPE.equals(name)) {
204:                        addElementToIndexedArray(configurationElement,
205:                                indexedConfigurationElements,
206:                                INDEX_CONTEXT_DEFINITIONS,
207:                                contextDefinitionCount++);
208:                    } else if (TAG_CONTEXT.equals(name)) {
209:                        addElementToIndexedArray(configurationElement,
210:                                indexedConfigurationElements,
211:                                INDEX_CONTEXT_DEFINITIONS,
212:                                contextDefinitionCount++);
213:
214:                    }
215:                }
216:
217:                /*
218:                 * Retrieve the contexts from the contexts extension point.
219:                 */
220:                final IConfigurationElement[] contextsExtensionPoint = registry
221:                        .getConfigurationElementsFor(EXTENSION_CONTEXTS);
222:                for (int i = 0; i < contextsExtensionPoint.length; i++) {
223:                    final IConfigurationElement configurationElement = contextsExtensionPoint[i];
224:                    final String name = configurationElement.getName();
225:
226:                    // Check if it is a binding definition.
227:                    if (TAG_CONTEXT.equals(name)) {
228:                        addElementToIndexedArray(configurationElement,
229:                                indexedConfigurationElements,
230:                                INDEX_CONTEXT_DEFINITIONS,
231:                                contextDefinitionCount++);
232:                    }
233:                }
234:
235:                readContextsFromRegistry(
236:                        indexedConfigurationElements[INDEX_CONTEXT_DEFINITIONS],
237:                        contextDefinitionCount, contextManager);
238:            }
239:
240:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.