Source Code Cross Referenced for WWinPartService.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » internal » 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 
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.ui.internal;
011:
012:        import org.eclipse.ui.IPartListener;
013:        import org.eclipse.ui.IPartListener2;
014:        import org.eclipse.ui.IPartService;
015:        import org.eclipse.ui.ISelectionService;
016:        import org.eclipse.ui.IWorkbenchPage;
017:        import org.eclipse.ui.IWorkbenchPart;
018:        import org.eclipse.ui.IWorkbenchPartReference;
019:        import org.eclipse.ui.IWorkbenchWindow;
020:        import org.eclipse.ui.internal.misc.UIListenerLogging;
021:
022:        /**
023:         * A part service for a workbench window.
024:         */
025:        public class WWinPartService implements  IPartService {
026:            private PartService partService = new PartService(
027:                    UIListenerLogging.WINDOW_PARTLISTENER_EVENTS,
028:                    UIListenerLogging.WINDOW_PARTLISTENER2_EVENTS);
029:
030:            private WindowSelectionService selectionService;
031:
032:            private IWorkbenchPage activePage;
033:
034:            private IPartListener2 partListner = new IPartListener2() {
035:                public void partActivated(IWorkbenchPartReference ref) {
036:                    updateActivePart();
037:                }
038:
039:                public void partBroughtToTop(IWorkbenchPartReference ref) {
040:                    partService.firePartBroughtToTop(ref);
041:                }
042:
043:                public void partClosed(IWorkbenchPartReference ref) {
044:                    partService.firePartClosed(ref);
045:                }
046:
047:                public void partDeactivated(IWorkbenchPartReference ref) {
048:                    updateActivePart();
049:                }
050:
051:                public void partOpened(IWorkbenchPartReference ref) {
052:                    partService.firePartOpened(ref);
053:                }
054:
055:                public void partHidden(IWorkbenchPartReference ref) {
056:                    partService.firePartHidden(ref);
057:                }
058:
059:                public void partVisible(IWorkbenchPartReference ref) {
060:                    partService.firePartVisible(ref);
061:                }
062:
063:                public void partInputChanged(IWorkbenchPartReference ref) {
064:                    partService.firePartInputChanged(ref);
065:                }
066:            };
067:
068:            /**
069:             * Creates a new part service for a workbench window.
070:             */
071:            public WWinPartService(IWorkbenchWindow window) {
072:                selectionService = new WindowSelectionService(window);
073:            }
074:
075:            /*
076:             * (non-Javadoc)
077:             * Method declared on IPartService
078:             */
079:            public void addPartListener(IPartListener l) {
080:                partService.addPartListener(l);
081:            }
082:
083:            /*
084:             * (non-Javadoc)
085:             * Method declared on IPartService
086:             */
087:            public void addPartListener(IPartListener2 l) {
088:                partService.addPartListener(l);
089:            }
090:
091:            /*
092:             * (non-Javadoc)
093:             * Method declared on IPartService
094:             */
095:            public void removePartListener(IPartListener l) {
096:                partService.removePartListener(l);
097:            }
098:
099:            /*
100:             * (non-Javadoc)
101:             * Method declared on IPartService
102:             */
103:            public void removePartListener(IPartListener2 l) {
104:                partService.removePartListener(l);
105:            }
106:
107:            /*
108:             * (non-Javadoc)
109:             * Method declared on IPartService
110:             */
111:            public IWorkbenchPart getActivePart() {
112:                return partService.getActivePart();
113:            }
114:
115:            private void updateActivePart() {
116:                IWorkbenchPartReference activeRef = null;
117:                IWorkbenchPart activePart = null;
118:
119:                if (activePage != null) {
120:                    activePart = activePage.getActivePart();
121:                    activeRef = activePage.getActivePartReference();
122:                }
123:
124:                partService.setActivePart(activeRef);
125:                selectionService.setActivePart(activePart);
126:            }
127:
128:            /*
129:             * (non-Javadoc)
130:             * Method declared on IPartService
131:             */
132:            public IWorkbenchPartReference getActivePartReference() {
133:                return partService.getActivePartReference();
134:            }
135:
136:            /*
137:             * Returns the selection service.
138:             */
139:            ISelectionService getSelectionService() {
140:                return selectionService;
141:            }
142:
143:            /*
144:             * Notifies that a page has been activated.
145:             */
146:            void pageActivated(IWorkbenchPage newPage) {
147:                // Optimize.
148:                if (newPage == activePage) {
149:                    return;
150:                }
151:
152:                // Fire events in the following order:
153:
154:                // 1. For each open part in the new page, open it and then (if applicable) make it visible
155:                // 2. Deactivate old active part
156:                // 3. Activate the new active part
157:                // 4. For each open part in the old page, make it invisible then close it        
158:
159:                // Hook listener on the new page.
160:                if (newPage != null) {
161:                    IWorkbenchPartReference[] refs = ((WorkbenchPage) newPage)
162:                            .getOpenParts();
163:
164:                    for (int i = 0; i < refs.length; i++) {
165:                        IWorkbenchPartReference reference = refs[i];
166:
167:                        partService.firePartOpened(reference);
168:
169:                        IWorkbenchPart part = reference.getPart(false);
170:                        if (part != null && newPage.isPartVisible(part)) {
171:                            partService.firePartVisible(reference);
172:                        }
173:                    }
174:
175:                    partService.setActivePart(newPage.getActivePartReference());
176:                    selectionService.setActivePart(newPage.getActivePart());
177:                } else {
178:                    partService.setActivePart(null);
179:                    selectionService.setActivePart(null);
180:                }
181:
182:                // Unhook listener from the old page.
183:                reset();
184:
185:                // Update active page.
186:                activePage = newPage;
187:
188:                if (newPage != null) {
189:                    newPage.addPartListener(partListner);
190:                }
191:
192:            }
193:
194:            /*
195:             * Notifies that a page has been closed
196:             */
197:            void pageClosed(IWorkbenchPage page) {
198:                // Unhook listener from the old page.
199:                if (page == activePage) {
200:                    reset();
201:                }
202:            }
203:
204:            /*
205:             * Notifies that a page has been opened.
206:             */
207:            void pageOpened(IWorkbenchPage page) {
208:                pageActivated(page);
209:            }
210:
211:            /*
212:             * Resets the part service.  The active page, part and selection are
213:             * dereferenced.
214:             */
215:            private void reset() {
216:                IWorkbenchPage tempPage = activePage;
217:                activePage = null;
218:                if (tempPage != null) {
219:                    WorkbenchPage page = (WorkbenchPage) tempPage;
220:
221:                    IWorkbenchPartReference[] refs = page.getOpenParts();
222:
223:                    for (int i = 0; i < refs.length; i++) {
224:                        IWorkbenchPartReference reference = refs[i];
225:
226:                        if (page.isPartVisible(reference)) {
227:                            partService.firePartHidden(reference);
228:                        }
229:
230:                        partService.firePartClosed(reference);
231:                    }
232:
233:                    tempPage.removePartListener(partListner);
234:                }
235:
236:            }
237:
238:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.