Source Code Cross Referenced for PerspectiveTracker.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) 2005, 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.core.runtime.Assert;
013:        import org.eclipse.jface.action.IAction;
014:        import org.eclipse.ui.IPageListener;
015:        import org.eclipse.ui.IPerspectiveDescriptor;
016:        import org.eclipse.ui.IWorkbenchPage;
017:        import org.eclipse.ui.IWorkbenchWindow;
018:        import org.eclipse.ui.PerspectiveAdapter;
019:
020:        /**
021:         * Utility class for tracking the active perspective in a window.
022:         *
023:         * @since 3.1
024:         */
025:        public class PerspectiveTracker extends PerspectiveAdapter implements 
026:                IPageListener {
027:
028:            private IWorkbenchWindow window;
029:
030:            private IAction action;
031:
032:            /**
033:             * Creates a perspective tracker for the given window.
034:             * Subclasses should override <code>update(IPerspectiveDescriptor)</code>
035:             * to get notified of perspective changes.
036:             * 
037:             * @param window the window to track
038:             */
039:            protected PerspectiveTracker(IWorkbenchWindow window) {
040:                Assert.isNotNull(window);
041:                this .window = window;
042:                window.addPageListener(this );
043:                window.addPerspectiveListener(this );
044:            }
045:
046:            /**
047:             * Creates a perspective tracker for the given window which will 
048:             * enable the given action only when there is an active perspective.
049:             * 
050:             * @param window the window to track
051:             * @param action the action to enable or disable
052:             */
053:            public PerspectiveTracker(IWorkbenchWindow window, IAction action) {
054:                this (window);
055:                this .action = action;
056:                update();
057:            }
058:
059:            /**
060:             * Disposes the tracker.
061:             */
062:            public void dispose() {
063:                if (window != null) {
064:                    window.removePageListener(this );
065:                    window.removePerspectiveListener(this );
066:                }
067:            }
068:
069:            public void pageActivated(IWorkbenchPage page) {
070:                update();
071:            }
072:
073:            public void pageClosed(IWorkbenchPage page) {
074:                update();
075:            }
076:
077:            public void pageOpened(IWorkbenchPage page) {
078:                // ignore
079:            }
080:
081:            public void perspectiveActivated(IWorkbenchPage page,
082:                    IPerspectiveDescriptor perspective) {
083:                update();
084:            }
085:
086:            /**
087:             * Determines the active perspective in the window 
088:             * and calls <code>update(IPerspectiveDescriptor)</code>.
089:             */
090:            private void update() {
091:                if (window != null) {
092:                    IPerspectiveDescriptor persp = null;
093:                    IWorkbenchPage page = window.getActivePage();
094:                    if (page != null) {
095:                        persp = page.getPerspective();
096:                    }
097:                    update(persp);
098:                }
099:            }
100:
101:            /**
102:             * Performs some function based on the active perspective in the window.
103:             * <p>
104:             * The default implementation enables the action (if given) if there
105:             * is an active perspective, otherwise it disables it.
106:             * </p>
107:             * <p> 
108:             * Subclasses may override or extend.
109:             * </p>
110:             * 
111:             * @param persp the active perspective in the window, or <code>null</code> if none
112:             */
113:            protected void update(IPerspectiveDescriptor persp) {
114:                if (action != null) {
115:                    action.setEnabled(persp != null);
116:                }
117:            }
118:
119:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.