Source Code Cross Referenced for ViewIntroAdapterPart.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) 2004, 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.internal;
011:
012:        import org.eclipse.core.runtime.CoreException;
013:        import org.eclipse.core.runtime.IStatus;
014:        import org.eclipse.core.runtime.Status;
015:        import org.eclipse.swt.custom.BusyIndicator;
016:        import org.eclipse.swt.graphics.Image;
017:        import org.eclipse.swt.widgets.Composite;
018:        import org.eclipse.swt.widgets.Control;
019:        import org.eclipse.ui.IMemento;
020:        import org.eclipse.ui.IPropertyListener;
021:        import org.eclipse.ui.IViewSite;
022:        import org.eclipse.ui.IWorkbenchPartSite;
023:        import org.eclipse.ui.PartInitException;
024:        import org.eclipse.ui.internal.intro.IntroMessages;
025:        import org.eclipse.ui.intro.IIntroPart;
026:        import org.eclipse.ui.intro.IIntroSite;
027:        import org.eclipse.ui.part.ViewPart;
028:
029:        /**
030:         * Simple view that will wrap an <code>IIntroPart</code>.
031:         * 
032:         * @since 3.0
033:         */
034:        public final class ViewIntroAdapterPart extends ViewPart {
035:
036:            private IIntroPart introPart;
037:
038:            private IIntroSite introSite;
039:
040:            private boolean handleZoomEvents = true;
041:
042:            /**
043:             * Adds a listener that toggles standby state if the view pane is zoomed. 
044:             */
045:            private void addPaneListener() {
046:                IWorkbenchPartSite site = getSite();
047:                if (site instanceof  PartSite) {
048:                    final WorkbenchPartReference ref = ((WorkbenchPartReference) ((PartSite) site)
049:                            .getPartReference());
050:                    ref.addInternalPropertyListener(new IPropertyListener() {
051:                        public void propertyChanged(Object source, int propId) {
052:                            if (handleZoomEvents) {
053:                                if (propId == WorkbenchPartReference.INTERNAL_PROPERTY_ZOOMED) {
054:                                    setStandby(!ref.getPane().isZoomed());
055:                                }
056:                            }
057:                        }
058:                    });
059:                }
060:            }
061:
062:            /**
063:             * Forces the standby state of the intro part.
064:             * 
065:             * @param standby update the standby state
066:             */
067:            public void setStandby(final boolean standby) {
068:                final Control control = ((PartSite) getSite()).getPane()
069:                        .getControl();
070:                BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
071:                    public void run() {
072:                        try {
073:                            control.setRedraw(false);
074:                            introPart.standbyStateChanged(standby);
075:                        } finally {
076:                            control.setRedraw(true);
077:                        }
078:
079:                        setBarVisibility(standby);
080:                    }
081:                });
082:            }
083:
084:            /**
085:             * Toggles handling of zoom events.
086:             * 
087:             * @param handle whether to handle zoom events
088:             */
089:            public void setHandleZoomEvents(boolean handle) {
090:                handleZoomEvents = handle;
091:            }
092:
093:            /* (non-Javadoc)
094:             * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
095:             */
096:            public void createPartControl(Composite parent) {
097:                addPaneListener();
098:                introPart.createPartControl(parent);
099:            }
100:
101:            /* (non-Javadoc)
102:             * @see org.eclipse.ui.IWorkbenchPart#dispose()
103:             */
104:            public void dispose() {
105:                setBarVisibility(true);
106:                super .dispose();
107:                getSite().getWorkbenchWindow().getWorkbench().getIntroManager()
108:                        .closeIntro(introPart);
109:                introPart.dispose();
110:            }
111:
112:            /* (non-Javadoc)
113:             * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
114:             */
115:            public Object getAdapter(Class adapter) {
116:                return introPart.getAdapter(adapter);
117:            }
118:
119:            /* (non-Javadoc)
120:             * @see org.eclipse.ui.IWorkbenchPart#getTitleImage()
121:             */
122:            public Image getTitleImage() {
123:                return introPart.getTitleImage();
124:            }
125:
126:            /* (non-Javadoc)
127:             * @see org.eclipse.ui.part.WorkbenchPart#getTitle()
128:             */
129:            public String getTitle() {
130:                // this method is called eagerly before our init method is called (and
131:                // therefore before our intropart is created).  By default return 
132:                // the view title from the view declaration.  We will fire a property
133:                // change to set the title to the proper value in the init method.
134:                return introPart == null ? super .getTitle() : introPart
135:                        .getTitle();
136:            }
137:
138:            /* (non-Javadoc)
139:             * @see org.eclipse.ui.IViewPart#init(org.eclipse.ui.IViewSite, org.eclipse.ui.IMemento)
140:             */
141:            public void init(IViewSite site, IMemento memento)
142:                    throws PartInitException {
143:                super .init(site);
144:                Workbench workbench = (Workbench) site.getWorkbenchWindow()
145:                        .getWorkbench();
146:                try {
147:                    introPart = workbench.getWorkbenchIntroManager()
148:                            .createNewIntroPart();
149:                    // reset the part name of this view to be that of the intro title
150:                    setPartName(introPart.getTitle());
151:                    introPart.addPropertyListener(new IPropertyListener() {
152:                        public void propertyChanged(Object source, int propId) {
153:                            firePropertyChange(propId);
154:                        }
155:                    });
156:                    introSite = new ViewIntroAdapterSite(site, workbench
157:                            .getIntroDescriptor());
158:                    introPart.init(introSite, memento);
159:
160:                } catch (CoreException e) {
161:                    WorkbenchPlugin.log(
162:                            IntroMessages.Intro_could_not_create_proxy,
163:                            new Status(IStatus.ERROR,
164:                                    WorkbenchPlugin.PI_WORKBENCH,
165:                                    IStatus.ERROR,
166:                                    IntroMessages.Intro_could_not_create_proxy,
167:                                    e));
168:                }
169:            }
170:
171:            /*
172:             * (non-Javadoc)
173:             * 
174:             * @see org.eclipse.ui.IWorkbenchPart#setFocus()
175:             */
176:            public void setFocus() {
177:                introPart.setFocus();
178:            }
179:
180:            /* (non-Javadoc)
181:             * @see org.eclipse.ui.IViewPart#saveState(org.eclipse.ui.IMemento)
182:             */
183:            public void saveState(IMemento memento) {
184:                introPart.saveState(memento);
185:            }
186:
187:            /**
188:             * Sets whether the CoolBar/PerspectiveBar should be visible.
189:             * 
190:             * @param visible whether the CoolBar/PerspectiveBar should be visible
191:             * @since 3.1
192:             */
193:            private void setBarVisibility(final boolean visible) {
194:                WorkbenchWindow window = (WorkbenchWindow) getSite()
195:                        .getWorkbenchWindow();
196:
197:                final boolean layout = (visible != window.getCoolBarVisible())
198:                        || (visible != window.getPerspectiveBarVisible()); // don't layout unless things have actually changed
199:                if (visible) {
200:                    window.setCoolBarVisible(true);
201:                    window.setPerspectiveBarVisible(true);
202:                } else {
203:                    window.setCoolBarVisible(false);
204:                    window.setPerspectiveBarVisible(false);
205:                }
206:
207:                if (layout) {
208:                    window.getShell().layout();
209:                }
210:            }
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.