Source Code Cross Referenced for CellLayoutUtil.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » internal » layout » 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.layout 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2004, 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.layout;
011:
012:        import org.eclipse.swt.SWT;
013:        import org.eclipse.swt.graphics.Point;
014:        import org.eclipse.swt.layout.GridData;
015:        import org.eclipse.swt.widgets.Composite;
016:        import org.eclipse.swt.widgets.Control;
017:        import org.eclipse.swt.widgets.Shell;
018:
019:        /**
020:         * Contains helper methods for CellLayout. Many of these methods are workarounds for
021:         * known SWT bugs. They should be updated once the original bugs are fixed in SWT.
022:         * 
023:         * @since 3.0
024:         */
025:        class CellLayoutUtil {
026:
027:            private static Point zero = new Point(0, 0);
028:
029:            private static Point minimumShellSize;
030:
031:            private static CellData defaultData = new CellData();
032:
033:            /**
034:             * Returns the minimum size for the given composite. That is, 
035:             * this returns the smallest values that will have any effect 
036:             * when passed into the composite's setSize method. Passing any
037:             * smaller value is equivalent to passing the minimum size.
038:             * <p>
039:             * This method is intended for use by layouts. The layout can
040:             * use this information when determining its preferred size. 
041:             * Returning a preferred size smaller than the composite's 
042:             * minimum size is pointless since the composite could never
043:             * be set to that size. The layout may choose a different preferred
044:             * size in this situation. 
045:             * </p><p>
046:             * Note that this method is only concerned with restrictions imposed
047:             * by the composite; not it's layout. If the only restriction on the 
048:             * composite's size is imposed by the layout, then this method returns (0,0). 
049:             * </p><p>
050:             * Currently SWT does not expose this information through
051:             * API, so this method is developed using trial-and-error. Whenever
052:             * a composite is discovered that will not accept sizes below
053:             * a certain threshold on some platform, this method should be
054:             * updated to reflect that fact. 
055:             * </p><p>
056:             * At this time, the only known composite that has a minimum size
057:             * are Shells. 
058:             * </p>
059:             * 
060:             * @param toCompute the composite whose minimum size is being computed
061:             * @return a size, in pixels, which is the smallest value that can be
062:             * passed into the composite's setSize(...) method.
063:             */
064:            static Point computeMinimumSize(Composite toCompute) {
065:                if (toCompute instanceof  Shell) {
066:                    if (minimumShellSize == null) {
067:                        Shell testShell = new Shell((Shell) toCompute,
068:                                SWT.DIALOG_TRIM | SWT.RESIZE);
069:                        testShell.setSize(0, 0);
070:                        minimumShellSize = testShell.getSize();
071:                        testShell.dispose();
072:                    }
073:
074:                    return minimumShellSize;
075:                }
076:
077:                // If any other composites are discovered to have minimum sizes,
078:                // add heuristics for them here.
079:
080:                // Otherwise, the composite can be reduced to size (0,0)
081:
082:                return zero;
083:            }
084:
085:            /**
086:             * Returns the CellData associated with the given control. If the control
087:             * does not have any layout data associated with it, a default object is returned.
088:             * If the control has a GridData object associated with it, an equivalent
089:             * CellData object will be returned.
090:             *  
091:             * @param control
092:             * @return
093:             */
094:            static CellData getData(Control control) {
095:                Object layoutData = control.getLayoutData();
096:                CellData data = null;
097:
098:                if (layoutData instanceof  CellData) {
099:                    data = (CellData) layoutData;
100:                } else if (layoutData instanceof  GridData) {
101:                    data = new CellData((GridData) layoutData);
102:                }
103:
104:                if (data == null) {
105:                    data = defaultData;
106:                }
107:
108:                return data;
109:            }
110:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.