Source Code Cross Referenced for BareBonesPartPresentation.java in  » IDE-Eclipse » ui-examples » org » eclipse » ui » examples » presentation » barebones » 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 examples » org.eclipse.ui.examples.presentation.barebones 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2004 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials 
004:         * are made available under the terms of the Common Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/cpl-v10.html
007:         * 
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.examples.presentation.barebones;
011:
012:        import org.eclipse.swt.SWT;
013:        import org.eclipse.swt.events.DisposeEvent;
014:        import org.eclipse.swt.events.DisposeListener;
015:        import org.eclipse.swt.graphics.Point;
016:        import org.eclipse.swt.graphics.Rectangle;
017:        import org.eclipse.swt.widgets.Composite;
018:        import org.eclipse.swt.widgets.Control;
019:        import org.eclipse.ui.presentations.IPresentablePart;
020:        import org.eclipse.ui.presentations.IStackPresentationSite;
021:        import org.eclipse.ui.presentations.StackDropResult;
022:        import org.eclipse.ui.presentations.StackPresentation;
023:
024:        /**
025:         * Bare-bones stack presentation. The currently selected part fills the entire
026:         * presentation area, and all other parts are invisible. Does not provide a 
027:         * system menu, pane menu, trim, drag/drop, toolbars, or any way to switch 
028:         * parts.
029:         */
030:        public class BareBonesPartPresentation extends StackPresentation {
031:
032:            /**
033:             * Main widget for the presentation
034:             */
035:            private Composite presentationControl;
036:
037:            /**
038:             * Currently selected part
039:             */
040:            private IPresentablePart current;
041:
042:            /**
043:             * Creates a new bare-bones part presentation, given the parent composite and 
044:             * an IStackPresentationSite interface that will be used to communicate with 
045:             * the workbench.
046:             * 
047:             * @param stackSite interface to the workbench
048:             */
049:            public BareBonesPartPresentation(Composite parent,
050:                    IStackPresentationSite stackSite) {
051:                super (stackSite);
052:
053:                // Create a top-level control for the presentation.
054:                presentationControl = new Composite(parent, SWT.NONE);
055:
056:                // Add a dispose listener. This will call the presentationDisposed()
057:                // method when the widget is destroyed.
058:                presentationControl.addDisposeListener(new DisposeListener() {
059:                    public void widgetDisposed(DisposeEvent e) {
060:                        presentationDisposed();
061:                    }
062:                });
063:            }
064:
065:            public void dispose() {
066:                // Dispose the main presentation widget. This will cause 
067:                // presentationDisposed to be called, which will do the real cleanup.
068:                presentationControl.dispose();
069:            }
070:
071:            /**
072:             * Perform any cleanup. This method should remove any listeners that were
073:             * attached to other objects. This gets called when the presentation
074:             * widget is disposed. This is safer than cleaning up in the dispose() 
075:             * method, since this code will run even if some unusual circumstance 
076:             * destroys the Shell without first calling dispose().
077:             */
078:            protected void presentationDisposed() {
079:                // Remove any listeners that were attached to any IPresentableParts or
080:                // global Eclipse resources. This is necessary in order to prevent
081:                // memory leaks. Currently, there is nothing to do.
082:            }
083:
084:            public void setBounds(Rectangle bounds) {
085:                // Set the bounds of the presentation widget
086:                presentationControl.setBounds(bounds);
087:
088:                // Update the bounds of the currently visible part
089:                updatePartBounds();
090:            }
091:
092:            private void updatePartBounds() {
093:                if (current != null) {
094:                    current.setBounds(presentationControl.getBounds());
095:                }
096:            }
097:
098:            public Point computeMinimumSize() {
099:                return new Point(16, 16);
100:            }
101:
102:            public void setVisible(boolean isVisible) {
103:
104:                // Make the presentation widget visible
105:                presentationControl.setVisible(isVisible);
106:
107:                // Make the currently visible part visible
108:                if (current != null) {
109:                    current.setVisible(isVisible);
110:                }
111:
112:                if (isVisible) {
113:                    // Restore the bounds of the currently visible part. 
114:                    // IPartPresentations can be used by multiple StackPresentations,
115:                    // although only one such presentation is ever visible at a time.
116:                    // It is possible that some other presentation has changed the
117:                    // bounds of the part since it was last visible, so we need to
118:                    // update the part's bounds when the presentation becomes visible.
119:                    updatePartBounds();
120:                }
121:            }
122:
123:            public void selectPart(IPresentablePart toSelect) {
124:                // Ignore redundant selections
125:                if (toSelect == current) {
126:                    return;
127:                }
128:
129:                // If there was an existing part selected, make it invisible
130:                if (current != null) {
131:                    current.setVisible(false);
132:                }
133:
134:                // Select the new part
135:                current = toSelect;
136:
137:                // Ordering is important here. We need to make the part
138:                // visible before updating its bounds, or the call to setBounds
139:                // may be ignored.
140:
141:                if (current != null) {
142:                    // Make the newly selected part visible
143:                    current.setVisible(true);
144:                }
145:
146:                // Update the bounds of the newly selected part
147:                updatePartBounds();
148:            }
149:
150:            public Control[] getTabList(IPresentablePart part) {
151:                return new Control[] { part.getControl() };
152:            }
153:
154:            public Control getControl() {
155:                return presentationControl;
156:            }
157:
158:            // Methods that don't do anything yet
159:            public void setActive(int newState) {
160:            }
161:
162:            public void setState(int state) {
163:            }
164:
165:            public void addPart(IPresentablePart newPart, Object cookie) {
166:            }
167:
168:            public void removePart(IPresentablePart oldPart) {
169:            }
170:
171:            public StackDropResult dragOver(Control currentControl,
172:                    Point location) {
173:                return null;
174:            }
175:
176:            public void showSystemMenu() {
177:            }
178:
179:            public void showPaneMenu() {
180:            }
181:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.