Source Code Cross Referenced for PagePartSelectionTracker.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.jface.viewers.IPostSelectionProvider;
013:        import org.eclipse.jface.viewers.ISelection;
014:        import org.eclipse.jface.viewers.ISelectionChangedListener;
015:        import org.eclipse.jface.viewers.ISelectionProvider;
016:        import org.eclipse.jface.viewers.SelectionChangedEvent;
017:        import org.eclipse.ui.IPartListener;
018:        import org.eclipse.ui.IViewPart;
019:        import org.eclipse.ui.IWorkbenchPage;
020:        import org.eclipse.ui.IWorkbenchPart;
021:
022:        /**
023:         * Provides debug view selection management/notification for
024:         * a debug view in a specific workbench page. This selection
025:         * provider sheilds clients from a debug view openning and closing,
026:         * and still provides selection notification/information even
027:         * when the debug view is not the active part.
028:         */
029:        public class PagePartSelectionTracker extends
030:                AbstractPartSelectionTracker implements  IPartListener,
031:                ISelectionChangedListener {
032:
033:            /**
034:             * The workbench page for which this is tracking selection.
035:             */
036:            private IWorkbenchPage fPage;
037:
038:            /**
039:             * The part in this tracker's page, or <code>null</code> if one is not open.
040:             */
041:            private IWorkbenchPart fPart;
042:
043:            private ISelectionChangedListener selectionListener = new ISelectionChangedListener() {
044:                public void selectionChanged(SelectionChangedEvent event) {
045:                    fireSelection(getPart(), event.getSelection());
046:                }
047:            };
048:
049:            private ISelectionChangedListener postSelectionListener = new ISelectionChangedListener() {
050:                public void selectionChanged(SelectionChangedEvent event) {
051:                    firePostSelection(getPart(), event.getSelection());
052:                }
053:            };
054:
055:            public PagePartSelectionTracker(IWorkbenchPage page, String partId) {
056:                super (partId);
057:                setPage(page);
058:                page.addPartListener(this );
059:                IViewPart part = page.findView(partId);
060:                if (part != null) {
061:                    setPart(part, false);
062:                }
063:            }
064:
065:            /**
066:             * Disposes this selection provider - removes all listeners
067:             * currently registered.
068:             */
069:            public void dispose() {
070:                setPart(null, false);
071:                setPage(null);
072:                super .dispose();
073:            }
074:
075:            /*
076:             * @see IPartListener#partActivated(IWorkbenchPart)
077:             */
078:            public void partActivated(IWorkbenchPart part) {
079:            }
080:
081:            /*
082:             * @see IPartListener#partBroughtToTop(IWorkbenchPart)
083:             */
084:            public void partBroughtToTop(IWorkbenchPart part) {
085:            }
086:
087:            /**
088:             * @see IPartListener#partClosed(IWorkbenchPart)
089:             */
090:            public void partClosed(IWorkbenchPart part) {
091:                if (getPartId(part).equals(getPartId())) {
092:                    setPart(null, true);
093:                }
094:            }
095:
096:            /*
097:             * @see IPartListener#partDeactivated(IWorkbenchPart)
098:             */
099:            public void partDeactivated(IWorkbenchPart part) {
100:            }
101:
102:            /**
103:             * @see IPartListener#partOpened(IWorkbenchPart)
104:             */
105:            public void partOpened(IWorkbenchPart part) {
106:                if (getPartId(part).equals(getPartId())) {
107:                    setPart(part, true);
108:                }
109:            }
110:
111:            /**
112:             * Returns the id for the given part, taking into account
113:             * multi-view instances which may have a secondary id.
114:             * 
115:             * @since 3.0
116:             */
117:            private Object getPartId(IWorkbenchPart part) {
118:                String id = part.getSite().getId();
119:                if (part instanceof  IViewPart) {
120:                    String secondaryId = ((IViewPart) part).getViewSite()
121:                            .getSecondaryId();
122:                    if (secondaryId != null) {
123:                        id = id + ':' + secondaryId;
124:                    }
125:                }
126:                return id;
127:            }
128:
129:            /**
130:             * The selection has changed in the part being tracked.
131:             * Forward it to the listeners.
132:             * 
133:             * @see ISelectionChangedListener#selectionChanged
134:             */
135:            public void selectionChanged(SelectionChangedEvent event) {
136:                fireSelection(getPart(), event.getSelection());
137:            }
138:
139:            /**
140:             * Sets the page this selection provider works for
141:             * 
142:             * @param page workbench page
143:             */
144:            private void setPage(IWorkbenchPage page) {
145:                fPage = page;
146:            }
147:
148:            /**
149:             * Returns the page this selection provider works for
150:             * 
151:             * @return workbench page
152:             */
153:            protected IWorkbenchPage getPage() {
154:                return fPage;
155:            }
156:
157:            /**
158:             * Returns the part this is tracking, 
159:             * or <code>null</code> if it is not open
160:             * 
161:             * @return part., or <code>null</code>
162:             */
163:            protected IWorkbenchPart getPart() {
164:                return fPart;
165:            }
166:
167:            /*
168:             * @see AbstractPartSelectionTracker#getSelection()
169:             */
170:            public ISelection getSelection() {
171:                IWorkbenchPart part = getPart();
172:                if (part != null) {
173:                    ISelectionProvider sp = part.getSite()
174:                            .getSelectionProvider();
175:                    if (sp != null) {
176:                        return sp.getSelection();
177:                    }
178:                }
179:                return null;
180:            }
181:
182:            /**
183:             * @see AbstractDebugSelectionProvider#getSelectionProvider()
184:             */
185:            protected ISelectionProvider getSelectionProvider() {
186:                IWorkbenchPart part = getPart();
187:                if (part != null) {
188:                    return part.getSite().getSelectionProvider();
189:                }
190:                return null;
191:            }
192:
193:            /**
194:             * Sets the part for this selection tracker.
195:             * 
196:             * @param part the part
197:             * @param notify whether to send notification that the selection has changed.
198:             */
199:            private void setPart(IWorkbenchPart part, boolean notify) {
200:                if (fPart != null) {
201:                    // remove myself as a listener from the existing part
202:                    ISelectionProvider sp = fPart.getSite()
203:                            .getSelectionProvider();
204:                    if (sp != null) {
205:                        sp.removeSelectionChangedListener(selectionListener);
206:                        if (sp instanceof  IPostSelectionProvider) {
207:                            ((IPostSelectionProvider) sp)
208:                                    .removePostSelectionChangedListener(postSelectionListener);
209:                        } else {
210:                            sp
211:                                    .removeSelectionChangedListener(postSelectionListener);
212:                        }
213:                    }
214:                }
215:                fPart = part;
216:                ISelection sel = null;
217:                if (part != null) {
218:                    ISelectionProvider sp = part.getSite()
219:                            .getSelectionProvider();
220:                    if (sp != null) {
221:                        sp.addSelectionChangedListener(selectionListener);
222:                        if (sp instanceof  IPostSelectionProvider) {
223:                            ((IPostSelectionProvider) sp)
224:                                    .addPostSelectionChangedListener(postSelectionListener);
225:                        } else {
226:                            sp
227:                                    .addSelectionChangedListener(postSelectionListener);
228:                        }
229:                        if (notify) {
230:                            // get the selection to send below
231:                            sel = sp.getSelection();
232:                        }
233:                    }
234:                }
235:                if (notify) {
236:                    fireSelection(part, sel);
237:                    firePostSelection(part, sel);
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.