Source Code Cross Referenced for MultiPageSelectionProvider.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 org.eclipse.core.runtime.Assert;
013:        import org.eclipse.core.runtime.ListenerList;
014:        import org.eclipse.core.runtime.SafeRunner;
015:        import org.eclipse.jface.util.SafeRunnable;
016:        import org.eclipse.jface.viewers.IPostSelectionProvider;
017:        import org.eclipse.jface.viewers.ISelection;
018:        import org.eclipse.jface.viewers.ISelectionChangedListener;
019:        import org.eclipse.jface.viewers.ISelectionProvider;
020:        import org.eclipse.jface.viewers.SelectionChangedEvent;
021:        import org.eclipse.jface.viewers.StructuredSelection;
022:        import org.eclipse.ui.IEditorPart;
023:
024:        /**
025:         * Manages the current selection in a multi-page editor by tracking the active
026:         * nested editor within the multi-page editor. When the selection changes,
027:         * notifications are sent to all registered listeners.
028:         * <p>
029:         * This class may be instantiated; it is not intended to be subclassed.
030:         * The base implementation of <code>MultiPageEditor.init</code> creates 
031:         * an instance of this class.
032:         * </p>
033:         */
034:        public class MultiPageSelectionProvider implements 
035:                IPostSelectionProvider {
036:
037:            /**
038:             * Registered selection changed listeners (element type: 
039:             * <code>ISelectionChangedListener</code>).
040:             */
041:            private ListenerList listeners = new ListenerList();
042:
043:            /**
044:             * Registered post selection changed listeners.
045:             */
046:            private ListenerList postListeners = new ListenerList();
047:
048:            /**
049:             * The multi-page editor.
050:             */
051:            private MultiPageEditorPart multiPageEditor;
052:
053:            /**
054:             * Creates a selection provider for the given multi-page editor.
055:             *
056:             * @param multiPageEditor the multi-page editor
057:             */
058:            public MultiPageSelectionProvider(
059:                    MultiPageEditorPart multiPageEditor) {
060:                Assert.isNotNull(multiPageEditor);
061:                this .multiPageEditor = multiPageEditor;
062:            }
063:
064:            /* (non-Javadoc)
065:             * Method declared on <code>ISelectionProvider</code>.
066:             */
067:            public void addSelectionChangedListener(
068:                    ISelectionChangedListener listener) {
069:                listeners.add(listener);
070:            }
071:
072:            /**
073:             * Adds a listener for post selection changes in this multi page selection provider.
074:             *
075:             * @param listener a selection changed listener
076:             * @since 3.2
077:             */
078:            public void addPostSelectionChangedListener(
079:                    ISelectionChangedListener listener) {
080:                postListeners.add(listener);
081:            }
082:
083:            /**
084:             * Notifies all registered selection changed listeners that the editor's 
085:             * selection has changed. Only listeners registered at the time this method is
086:             * called are notified.
087:             *
088:             * @param event the selection changed event
089:             */
090:            public void fireSelectionChanged(final SelectionChangedEvent event) {
091:                Object[] listeners = this .listeners.getListeners();
092:                fireEventChange(event, listeners);
093:            }
094:
095:            /**
096:             * Notifies all post selection changed listeners that the editor's
097:             * selection has changed.
098:             * 
099:             * @param event the event to propogate.
100:             * @since 3.2
101:             */
102:            public void firePostSelectionChanged(
103:                    final SelectionChangedEvent event) {
104:                Object[] listeners = postListeners.getListeners();
105:                fireEventChange(event, listeners);
106:            }
107:
108:            private void fireEventChange(final SelectionChangedEvent event,
109:                    Object[] listeners) {
110:                for (int i = 0; i < listeners.length; ++i) {
111:                    final ISelectionChangedListener l = (ISelectionChangedListener) listeners[i];
112:                    SafeRunner.run(new SafeRunnable() {
113:                        public void run() {
114:                            l.selectionChanged(event);
115:                        }
116:                    });
117:                }
118:            }
119:
120:            /**
121:             * Returns the multi-page editor.
122:             * @return the multi-page editor.
123:             */
124:            public MultiPageEditorPart getMultiPageEditor() {
125:                return multiPageEditor;
126:            }
127:
128:            /* (non-Javadoc)
129:             * Method declared on <code>ISelectionProvider</code>.
130:             */
131:            public ISelection getSelection() {
132:                IEditorPart activeEditor = multiPageEditor.getActiveEditor();
133:                if (activeEditor != null) {
134:                    ISelectionProvider selectionProvider = activeEditor
135:                            .getSite().getSelectionProvider();
136:                    if (selectionProvider != null) {
137:                        return selectionProvider.getSelection();
138:                    }
139:                }
140:                return StructuredSelection.EMPTY;
141:            }
142:
143:            /* (non-JavaDoc)
144:             * Method declaed on <code>ISelectionProvider</code>.
145:             */
146:            public void removeSelectionChangedListener(
147:                    ISelectionChangedListener listener) {
148:                listeners.remove(listener);
149:            }
150:
151:            /**
152:             * Removes a listener for post selection changes in this multi page selection provider.
153:             *
154:             * @param listener a selection changed listener
155:             * @since 3.2
156:             */
157:            public void removePostSelectionChangedListener(
158:                    ISelectionChangedListener listener) {
159:                postListeners.remove(listener);
160:            }
161:
162:            /* (non-Javadoc)
163:             * Method declared on <code>ISelectionProvider</code>.
164:             */
165:            public void setSelection(ISelection selection) {
166:                IEditorPart activeEditor = multiPageEditor.getActiveEditor();
167:                if (activeEditor != null) {
168:                    ISelectionProvider selectionProvider = activeEditor
169:                            .getSite().getSelectionProvider();
170:                    if (selectionProvider != null) {
171:                        selectionProvider.setSelection(selection);
172:                    }
173:                }
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.