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


001:        /*******************************************************************************
002:         * Copyright (c) 2005, 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.ui.internal.menus;
011:
012:        import java.util.List;
013:
014:        import org.eclipse.core.runtime.IConfigurationElement;
015:        import org.eclipse.core.runtime.IExtensionDelta;
016:        import org.eclipse.core.runtime.IExtensionRegistry;
017:        import org.eclipse.core.runtime.IRegistryChangeEvent;
018:        import org.eclipse.core.runtime.Platform;
019:        import org.eclipse.ui.PlatformUI;
020:        import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
021:        import org.eclipse.ui.internal.services.RegistryPersistence;
022:
023:        /**
024:         * <p>
025:         * A static class for accessing the registry.
026:         * </p>
027:         * <p>
028:         * This class is not intended for use outside of the
029:         * <code>org.eclipse.ui.workbench</code> plug-in.
030:         * </p>
031:         * 
032:         * @since 3.2
033:         */
034:        final class MenuPersistence extends RegistryPersistence {
035:
036:            private final WorkbenchMenuService menuService;
037:
038:            /**
039:             * Constructs a new instance of {@link MenuPersistence}.
040:             * @param workbenchMenuService 
041:             * 
042:             * @param workbenchMenuService
043:             *            The menu service which should be populated with the values
044:             *            from the registry; must not be <code>null</code>.
045:             */
046:            MenuPersistence(final WorkbenchMenuService workbenchMenuService) {
047:                if (workbenchMenuService == null) {
048:                    throw new NullPointerException(
049:                            "The menu service cannot be null"); //$NON-NLS-1$
050:                }
051:
052:                this .menuService = workbenchMenuService;
053:            }
054:
055:            public final void dispose() {
056:                super .dispose();
057:            }
058:
059:            protected final boolean isChangeImportant(
060:                    final IRegistryChangeEvent event) {
061:                /*
062:                 * TODO Menus will need to be re-read (i.e., re-verified) if any of the
063:                 * menu extensions change (i.e., menus), or if any of the command
064:                 * extensions change (i.e., action definitions).
065:                 */
066:                final IExtensionDelta[] menuDeltas = event.getExtensionDeltas(
067:                        PlatformUI.PLUGIN_ID,
068:                        IWorkbenchRegistryConstants.PL_MENUS);
069:                if (menuDeltas.length == 0) {
070:                    return false;
071:                }
072:
073:                return true;
074:            }
075:
076:            /**
077:             * <p>
078:             * Reads all of the menu elements and action sets from the registry.
079:             * </p>
080:             * <p>
081:             * TODO Add support for modifications.
082:             * </p>
083:             */
084:            protected final void read() {
085:                super .read();
086:
087:                // Read legacy 3.2 'trim' additions
088:                readTrimAdditions();
089:
090:                // read the 3.3 menu additions
091:                readAdditions();
092:            }
093:
094:            //
095:            // 3.3 menu extension code
096:            // 
097:
098:            public void readTrimAdditions() {
099:                if (menuService == null)
100:                    return;
101:
102:                final IExtensionRegistry registry = Platform
103:                        .getExtensionRegistry();
104:                final IConfigurationElement[] configElements = registry
105:                        .getConfigurationElementsFor(EXTENSION_MENUS);
106:
107:                // Create a cache entry for every menu addition
108:                for (int i = 0; i < configElements.length; i++) {
109:                    // Only process 'group' entries
110:                    if (!TAG_GROUP.equals(configElements[i].getName()))
111:                        continue;
112:
113:                    String id = configElements[i]
114:                            .getAttribute(IWorkbenchRegistryConstants.ATT_ID);
115:
116:                    // Define the initial URI spec
117:                    String uriSpec = "toolbar:" + id; //$NON-NLS-1$
118:                    if (configElements[i].getChildren(TAG_LOCATION).length > 0) {
119:                        IConfigurationElement location = configElements[i]
120:                                .getChildren(TAG_LOCATION)[0];
121:                        if (location.getChildren(TAG_ORDER).length > 0) {
122:                            IConfigurationElement order = location
123:                                    .getChildren(TAG_ORDER)[0];
124:
125:                            String pos = order
126:                                    .getAttribute(IWorkbenchRegistryConstants.ATT_POSITION);
127:                            String relTo = order
128:                                    .getAttribute(IWorkbenchRegistryConstants.ATT_RELATIVE_TO);
129:                            uriSpec += "?" + pos + "=" + relTo; //$NON-NLS-1$ //$NON-NLS-2$
130:
131:                            // HACK! We expect that the new trim group is -always- relative to
132:                            // one of the 'default' groups; indicating which trim area they're in
133:                            MenuLocationURI uri = new MenuLocationURI(
134:                                    "toolbar:" + relTo); //$NON-NLS-1$
135:                            List trimAdditions = menuService
136:                                    .getAdditionsForURI(uri);
137:
138:                            //
139:                            // TODO convert the TrimAdditionCacheEntry over to use the
140:                            //      new MenuCacheEntry and addCacheForURI(*)
141:                            // OK, add the addition to this area
142:                            uri = new MenuLocationURI(uriSpec);
143:                            trimAdditions.add(new TrimAdditionCacheEntry(
144:                                    configElements[i], uri, menuService));
145:                        } else {
146:                            // Must be a default group; make a new entry cache
147:                            MenuLocationURI uri = new MenuLocationURI(uriSpec);
148:
149:                            // NOTE: 'getAdditionsForURI' forces creation
150:                            menuService.getAdditionsForURI(uri);
151:                        }
152:                    }
153:                }
154:            }
155:
156:            public void readAdditions() {
157:                final IExtensionRegistry registry = Platform
158:                        .getExtensionRegistry();
159:                final IConfigurationElement[] menusExtensionPoint = registry
160:                        .getConfigurationElementsFor(EXTENSION_MENUS);
161:
162:                // Create a cache entry for every menu addition
163:                for (int i = 0; i < menusExtensionPoint.length; i++) {
164:                    if (PL_MENU_CONTRIBUTION.equals(menusExtensionPoint[i]
165:                            .getName())) {
166:                        // Determine the insertion location by parsing the URI
167:                        String location = menusExtensionPoint[i]
168:                                .getAttribute(TAG_LOCATION_URI);
169:
170:                        menuService
171:                                .addContributionFactory(new MenuAdditionCacheEntry(
172:                                        menuService, menusExtensionPoint[i],
173:                                        location, menusExtensionPoint[i]
174:                                                .getNamespaceIdentifier()));
175:                    }
176:                }
177:            }
178:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.