Source Code Cross Referenced for LayoutHelper.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) 2003, 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.IPerspectiveDescriptor;
013:        import org.eclipse.ui.IPerspectiveListener;
014:        import org.eclipse.ui.IPluginContribution;
015:        import org.eclipse.ui.IWorkbenchPage;
016:        import org.eclipse.ui.PartInitException;
017:        import org.eclipse.ui.PlatformUI;
018:        import org.eclipse.ui.activities.IIdentifier;
019:        import org.eclipse.ui.activities.IIdentifierListener;
020:        import org.eclipse.ui.activities.IWorkbenchActivitySupport;
021:        import org.eclipse.ui.activities.IdentifierEvent;
022:        import org.eclipse.ui.activities.WorkbenchActivityHelper;
023:        import org.eclipse.ui.views.IViewDescriptor;
024:
025:        /**
026:         * Helper methods that the internal layout classes (<code>PageLayout</code> and 
027:         * <code>FolderLayout</code>) utilize for activities support and view creation.
028:         * 
029:         * @since 3.0
030:         */
031:        class LayoutHelper {
032:
033:            /**
034:             * Not intended to be instantiated.
035:             */
036:            private LayoutHelper() {
037:                //no-op
038:            }
039:
040:            /**
041:             * Creates a series of listeners that will activate the provided view on the
042:             * provided page layout when <code>IIdenfier</code> enablement changes. The 
043:             * rules for this activation are as follows: <p>
044:             * <ul>
045:             * <li> if the identifier becomes enabled and the perspective of the page 
046:             * layout is the currently active perspective in its window, then activate 
047:             * the views immediately.
048:             * <li> if the identifier becomes enabled and the perspective of the page 
049:             * layout is not the currently active perspecitve in its window, then add an
050:             * <code>IPerspectiveListener</code> to the window and activate the views 
051:             * when the perspective becomes active. 
052:             * 
053:             * @param pageLayout <code>PageLayout</code>.
054:             * @param viewId the view id to activate upon <code>IIdentifier</code> enablement.
055:             */
056:            public static final void addViewActivator(PageLayout pageLayout,
057:                    final String viewId) {
058:                if (viewId == null) {
059:                    return;
060:                }
061:
062:                ViewFactory viewFactory = pageLayout.getViewFactory();
063:
064:                final IWorkbenchPage partPage = viewFactory.getWorkbenchPage();
065:                if (partPage == null) {
066:                    return;
067:                }
068:
069:                final IPerspectiveDescriptor partPerspective = pageLayout
070:                        .getDescriptor();
071:
072:                IWorkbenchActivitySupport support = PlatformUI.getWorkbench()
073:                        .getActivitySupport();
074:
075:                IViewDescriptor descriptor = viewFactory.getViewRegistry()
076:                        .find(viewId);
077:                if (!(descriptor instanceof  IPluginContribution)) {
078:                    return;
079:                }
080:
081:                IIdentifier identifier = support
082:                        .getActivityManager()
083:                        .getIdentifier(
084:                                WorkbenchActivityHelper
085:                                        .createUnifiedId((IPluginContribution) descriptor));
086:
087:                identifier.addIdentifierListener(new IIdentifierListener() {
088:
089:                    /* (non-Javadoc)
090:                     * @see org.eclipse.ui.activities.IIdentifierListener#identifierChanged(org.eclipse.ui.activities.IdentifierEvent)
091:                     */
092:                    public void identifierChanged(
093:                            IdentifierEvent identifierEvent) {
094:                        if (identifierEvent.hasEnabledChanged()) {
095:                            IIdentifier this Identifier = identifierEvent
096:                                    .getIdentifier();
097:                            if (this Identifier.isEnabled()) {
098:                                // show view
099:                                this Identifier.removeIdentifierListener(this );
100:                                IWorkbenchPage activePage = partPage
101:                                        .getWorkbenchWindow().getActivePage();
102:                                if (partPage == activePage
103:                                        && partPerspective == activePage
104:                                                .getPerspective()) {
105:                                    // show immediately.
106:                                    try {
107:                                        partPage.showView(viewId);
108:                                    } catch (PartInitException e) {
109:                                        WorkbenchPlugin.log(getClass(),
110:                                                "identifierChanged", e); //$NON-NLS-1$
111:                                    }
112:                                } else { // show when the perspective becomes active							
113:                                    partPage.getWorkbenchWindow()
114:                                            .addPerspectiveListener(
115:                                                    new IPerspectiveListener() {
116:
117:                                                        /* (non-Javadoc)
118:                                                         * @see org.eclipse.ui.IPerspectiveListener#perspectiveActivated(org.eclipse.ui.IWorkbenchPage, org.eclipse.ui.IPerspectiveDescriptor)
119:                                                         */
120:                                                        public void perspectiveActivated(
121:                                                                IWorkbenchPage page,
122:                                                                IPerspectiveDescriptor newPerspective) {
123:                                                            if (partPerspective == newPerspective) {
124:                                                                partPage
125:                                                                        .getWorkbenchWindow()
126:                                                                        .removePerspectiveListener(
127:                                                                                this );
128:                                                                try {
129:                                                                    page
130:                                                                            .showView(viewId);
131:                                                                } catch (PartInitException e) {
132:                                                                    WorkbenchPlugin
133:                                                                            .log(
134:                                                                                    getClass(),
135:                                                                                    "perspectiveActivated", e); //$NON-NLS-1$
136:                                                                }
137:                                                            }
138:                                                        }
139:
140:                                                        /* (non-Javadoc)
141:                                                         * @see org.eclipse.ui.IPerspectiveListener#perspectiveChanged(org.eclipse.ui.IWorkbenchPage, org.eclipse.ui.IPerspectiveDescriptor, java.lang.String)
142:                                                         */
143:                                                        public void perspectiveChanged(
144:                                                                IWorkbenchPage page,
145:                                                                IPerspectiveDescriptor perspective,
146:                                                                String changeId) {
147:                                                            // no-op
148:                                                        }
149:                                                    });
150:                                }
151:                            }
152:                        }
153:                    }
154:                });
155:            }
156:
157:            /**
158:             * Create the view.  If it's already been been created in the provided 
159:             * factory, return the shared instance.
160:             * 
161:             * @param factory the <code>ViewFactory</code> to use.
162:             * @param viewID the view id to use.
163:             * @return the new <code>ViewPane</code>.
164:             * @throws PartInitException thrown if there is a problem creating the view.
165:             */
166:            public static final ViewPane createView(ViewFactory factory,
167:                    String viewId) throws PartInitException {
168:                WorkbenchPartReference ref = (WorkbenchPartReference) factory
169:                        .createView(ViewFactory.extractPrimaryId(viewId),
170:                                ViewFactory.extractSecondaryId(viewId));
171:                ViewPane newPart = (ViewPane) ref.getPane();
172:                return newPart;
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.