Source Code Cross Referenced for PageSite.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » part » 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.part 
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.ui.part;
011:
012:        import java.util.ArrayList;
013:        import java.util.HashSet;
014:        import java.util.Iterator;
015:
016:        import org.eclipse.core.expressions.Expression;
017:        import org.eclipse.core.runtime.Assert;
018:        import org.eclipse.core.runtime.Platform;
019:        import org.eclipse.jface.action.MenuManager;
020:        import org.eclipse.jface.viewers.ISelectionProvider;
021:        import org.eclipse.swt.widgets.Shell;
022:        import org.eclipse.ui.IActionBars;
023:        import org.eclipse.ui.IViewSite;
024:        import org.eclipse.ui.IWorkbenchPage;
025:        import org.eclipse.ui.IWorkbenchPart;
026:        import org.eclipse.ui.IWorkbenchWindow;
027:        import org.eclipse.ui.SubActionBars;
028:        import org.eclipse.ui.commands.ICommandService;
029:        import org.eclipse.ui.contexts.IContextService;
030:        import org.eclipse.ui.handlers.IHandlerService;
031:        import org.eclipse.ui.internal.PartSite;
032:        import org.eclipse.ui.internal.PopupMenuExtender;
033:        import org.eclipse.ui.internal.commands.SlaveCommandService;
034:        import org.eclipse.ui.internal.contexts.NestableContextService;
035:        import org.eclipse.ui.internal.expressions.ActivePartExpression;
036:        import org.eclipse.ui.internal.handlers.NestableHandlerService;
037:        import org.eclipse.ui.internal.services.INestable;
038:        import org.eclipse.ui.internal.services.ServiceLocator;
039:        import org.eclipse.ui.services.IServiceScopes;
040:
041:        /**
042:         * This implementation of <code>IPageSite</code> provides a site for a page
043:         * within a <code>PageBookView</code>. Most methods are forwarded to the
044:         * view's site.
045:         */
046:        public class PageSite implements  IPageSite, INestable {
047:
048:            /**
049:             * The list of menu extender for each registered menu.
050:             */
051:            private ArrayList menuExtenders;
052:
053:            /**
054:             * The "parent" view site
055:             */
056:            private IViewSite parentSite;
057:
058:            /**
059:             * A selection provider set by the page. Value is <code>null</code> until
060:             * set.
061:             */
062:            private ISelectionProvider selectionProvider;
063:
064:            /**
065:             * The localized service locator for this page site. This locator is never
066:             * <code>null</code>.
067:             */
068:            private final ServiceLocator serviceLocator;
069:
070:            /**
071:             * The action bars for this site
072:             */
073:            private SubActionBars subActionBars;
074:
075:            /**
076:             * Creates a new sub view site of the given parent view site.
077:             * 
078:             * @param parentViewSite
079:             *            the parent view site
080:             */
081:            public PageSite(IViewSite parentViewSite) {
082:                Assert.isNotNull(parentViewSite);
083:                parentSite = parentViewSite;
084:                subActionBars = new SubActionBars(parentViewSite
085:                        .getActionBars(), this );
086:
087:                // Initialize the service locator.
088:                this .serviceLocator = new ServiceLocator(parentSite);
089:                initializeDefaultServices();
090:            }
091:
092:            /**
093:             * Initialize the slave services for this site.
094:             */
095:            private void initializeDefaultServices() {
096:                final IWorkbenchPart parentPart = parentSite.getPart();
097:                final Expression defaultExpression = new ActivePartExpression(
098:                        parentPart);
099:
100:                final IHandlerService parentService = (IHandlerService) parentSite
101:                        .getService(IHandlerService.class);
102:                final IHandlerService slave = new NestableHandlerService(
103:                        parentService, defaultExpression);
104:                serviceLocator.registerService(IHandlerService.class, slave);
105:
106:                final IContextService contextParent = (IContextService) serviceLocator
107:                        .getService(IContextService.class);
108:                final IContextService contextSlave = new NestableContextService(
109:                        contextParent, defaultExpression);
110:                serviceLocator.registerService(IContextService.class,
111:                        contextSlave);
112:
113:                final ICommandService parentCommandService = (ICommandService) serviceLocator
114:                        .getService(ICommandService.class);
115:                final ICommandService commandService = new SlaveCommandService(
116:                        parentCommandService, IServiceScopes.PAGESITE_SCOPE,
117:                        this );
118:                serviceLocator.registerService(ICommandService.class,
119:                        commandService);
120:
121:            }
122:
123:            /**
124:             * Disposes of the menu extender contributions.
125:             */
126:            protected void dispose() {
127:                if (menuExtenders != null) {
128:                    HashSet managers = new HashSet(menuExtenders.size());
129:                    for (int i = 0; i < menuExtenders.size(); i++) {
130:                        PopupMenuExtender ext = (PopupMenuExtender) menuExtenders
131:                                .get(i);
132:                        managers.add(ext.getManager());
133:                        ext.dispose();
134:                    }
135:                    if (managers.size() > 0) {
136:                        for (Iterator iterator = managers.iterator(); iterator
137:                                .hasNext();) {
138:                            MenuManager mgr = (MenuManager) iterator.next();
139:                            mgr.dispose();
140:                        }
141:                    }
142:                    menuExtenders = null;
143:                }
144:                subActionBars.dispose();
145:                serviceLocator.dispose();
146:            }
147:
148:            /**
149:             * The PageSite implementation of this <code>IPageSite</code> method
150:             * returns the <code>SubActionBars</code> for this site.
151:             * 
152:             * @return the subactionbars for this site
153:             */
154:            public IActionBars getActionBars() {
155:                return subActionBars;
156:            }
157:
158:            /*
159:             * (non-Javadoc)
160:             * 
161:             * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
162:             */
163:            public Object getAdapter(Class adapter) {
164:                return Platform.getAdapterManager().getAdapter(this , adapter);
165:            }
166:
167:            /*
168:             * (non-Javadoc) Method declared on IPageSite.
169:             */
170:            public IWorkbenchPage getPage() {
171:                return parentSite.getPage();
172:            }
173:
174:            /*
175:             * (non-Javadoc) Method declared on IPageSite.
176:             */
177:            public ISelectionProvider getSelectionProvider() {
178:                return selectionProvider;
179:            }
180:
181:            public final Object getService(final Class key) {
182:                return serviceLocator.getService(key);
183:            }
184:
185:            /*
186:             * (non-Javadoc) Method declared on IPageSite.
187:             */
188:            public Shell getShell() {
189:                return parentSite.getShell();
190:            }
191:
192:            /*
193:             * (non-Javadoc) Method declared on IPageSite.
194:             */
195:            public IWorkbenchWindow getWorkbenchWindow() {
196:                return parentSite.getWorkbenchWindow();
197:            }
198:
199:            public final boolean hasService(final Class key) {
200:                return serviceLocator.hasService(key);
201:            }
202:
203:            /*
204:             * (non-Javadoc) Method declared on IPageSite.
205:             */
206:            public void registerContextMenu(String menuID, MenuManager menuMgr,
207:                    ISelectionProvider selProvider) {
208:                if (menuExtenders == null) {
209:                    menuExtenders = new ArrayList(1);
210:                }
211:                PartSite.registerContextMenu(menuID, menuMgr, selProvider,
212:                        false, parentSite.getPart(), menuExtenders);
213:            }
214:
215:            /*
216:             * (non-Javadoc) Method declared on IPageSite.
217:             */
218:            public void setSelectionProvider(ISelectionProvider provider) {
219:                selectionProvider = provider;
220:            }
221:
222:            /*
223:             * (non-Javadoc)
224:             * 
225:             * @see org.eclipse.ui.internal.services.INestable#activate()
226:             * 
227:             * @since 3.2
228:             */
229:            public void activate() {
230:                serviceLocator.activate();
231:            }
232:
233:            /*
234:             * (non-Javadoc)
235:             * 
236:             * @see org.eclipse.ui.internal.services.INestable#deactivate()
237:             * 
238:             * @since 3.2
239:             */
240:            public void deactivate() {
241:                serviceLocator.deactivate();
242:            }
243:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.