Source Code Cross Referenced for SplitPane.java in  » Web-Framework » swingweb » org » onemind » swingweb » client » gwt » widget » 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 » Web Framework » swingweb » org.onemind.swingweb.client.gwt.widget 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2004 TiongHiang Lee
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2.1 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not,  write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         *
018:         * Email: thlee@onemindsoft.org
019:         */
020:
021:        package org.onemind.swingweb.client.gwt.widget;
022:
023:        import com.google.gwt.user.client.DOM;
024:        import com.google.gwt.user.client.ui.*;
025:
026:        public class SplitPane extends AbsolutePanel implements  MouseListener,
027:                IContainer, HasOrientation {
028:
029:            private class Divider extends MousePanel {
030:
031:                public Divider() {
032:                    setStyleName("splitpane-divider");
033:                }
034:            }
035:
036:            public static final int HORIZONTAL_SPLIT = 0, VERTICAL_SPLIT = 1;
037:
038:            private OrientationConstant _orientation;
039:
040:            private ComponentLayout _layout = new ComponentLayout();
041:
042:            private CellPanel _dividerHalf;
043:
044:            private Widget _firstComponent, _secondComponent;
045:
046:            private int _dividerSize = 10, _dividerLoc = 100;
047:
048:            private boolean capture = false;
049:
050:            private int startX, startY;
051:
052:            private Divider _divider = new Divider();
053:
054:            private int _width;
055:
056:            private int _height;
057:
058:            public SplitPane() {
059:                this (VERTICAL);
060:            }
061:
062:            public SplitPane(OrientationConstant orientation) {
063:                _orientation = orientation;
064:                _divider.addMouseListener(this );
065:                initPanels();
066:            }
067:
068:            private void initPanels() {
069:                clear();
070:                if (_orientation == HORIZONTAL) {
071:                    if (_firstComponent != null) {
072:                        add(_firstComponent, 0, 0);
073:                    }
074:                    if (_secondComponent != null) {
075:                        _dividerHalf = new HorizontalPanel();
076:                        DOM.setStyleAttribute(_dividerHalf.getElement(),
077:                                "zOrder", "-1");
078:                        _dividerHalf.setHeight("100%");
079:                        _dividerHalf.add(_divider);
080:                        _dividerHalf.add(_secondComponent);
081:                        add(_dividerHalf, 0, 0);
082:                    }
083:                } else {//assume vertical
084:                    if (_firstComponent != null) {
085:                        add(_firstComponent, 0, 0);
086:                    }
087:                    if (_secondComponent != null) {
088:                        _dividerHalf = new VerticalPanel();
089:                        DOM.setStyleAttribute(_dividerHalf.getElement(),
090:                                "zOrder", "-1");
091:                        _dividerHalf.setWidth("100%");
092:                        _dividerHalf.add(_divider);
093:                        _dividerHalf.add(_secondComponent);
094:                        add(_dividerHalf, 0, 0);
095:                    }
096:                }
097:                setDividerLoc(_dividerLoc);
098:            }
099:
100:            public void setFirstComponent(Widget w) {
101:                _firstComponent = w;
102:                initPanels();
103:            }
104:
105:            public void setSecondComponent(Widget w) {
106:                _secondComponent = w;
107:                initPanels();
108:            }
109:
110:            public void setDividerLoc(int loc) {
111:                _dividerLoc = loc;
112:                if (_orientation == HORIZONTAL) {
113:                    if (_secondComponent != null) {
114:                        _divider.setHeight("100%");
115:                        _divider.setWidth(String.valueOf(_dividerSize));
116:                        setWidgetPosition(_dividerHalf, loc, 0);
117:                    }
118:                    resizeComponent(_firstComponent, loc);
119:                    resizeComponent(_secondComponent, _width - _dividerSize
120:                            - loc);
121:                } else {//assume vertical
122:                    if (_secondComponent != null) {
123:                        _divider.setHeight(String.valueOf(_dividerSize));
124:                        _divider.setWidth("100%");
125:                        setWidgetPosition(_dividerHalf, 0, loc);
126:                    }
127:                    resizeComponent(_firstComponent, loc);
128:                    resizeComponent(_secondComponent, _height - _dividerSize
129:                            - loc);
130:                }
131:            }
132:
133:            public void setWidth(String width) {
134:                _width = Integer.parseInt(width);
135:                super .setWidth(width);
136:            }
137:
138:            public void setHeight(String height) {
139:                _height = Integer.parseInt(height);
140:                super .setHeight(height);
141:            }
142:
143:            private void resizeComponent(Widget com, int size) {
144:                if (com != null && size > 0) {
145:                    if (_orientation == HORIZONTAL) {
146:                        com.setWidth(String.valueOf(size));
147:                        System.out.println("Set width to " + size);
148:                    } else {
149:                        com.setHeight(String.valueOf(size));
150:                        System.out.println("Set height to " + size);
151:                    }
152:                }
153:            }
154:
155:            public void setDividerSize(int size) {
156:                _dividerSize = size;
157:                setDividerLoc(_dividerLoc);
158:            }
159:
160:            public void onMouseDown(Widget sender, int x, int y) {
161:                capture = true;
162:                DOM.setCapture(sender.getElement());
163:                startX = x;
164:                startY = y;
165:            }
166:
167:            public void onMouseEnter(Widget sender) {
168:                // TODO Auto-generated method stub
169:            }
170:
171:            public void onMouseLeave(Widget sender) {
172:            }
173:
174:            public void onMouseMove(Widget sender, int x, int y) {
175:                if (capture) {
176:                    if (_orientation == HORIZONTAL) {
177:                        int absX = getWidgetLeft(_dividerHalf);
178:                        int newX = absX + (x - startX);
179:                        setDividerLoc(newX);
180:                    } else {
181:                        int absY = getWidgetTop(_dividerHalf);
182:                        int newY = absY + (y - startY);
183:                        setDividerLoc(newY);
184:                    }
185:                }
186:            }
187:
188:            public void onMouseUp(Widget sender, int x, int y) {
189:                capture = false;
190:                DOM.releaseCapture(sender.getElement());
191:            }
192:
193:            public void addChild(Widget widget, CellInfo info) {
194:                throw new IllegalArgumentException("Shouldn't be called");
195:            }
196:
197:            public ComponentLayout getLayout() {
198:                return _layout;
199:            }
200:
201:            public void removeChild(Widget child) {
202:                throw new IllegalArgumentException("Shouldn't be called");
203:            }
204:
205:            public void setOrientation(OrientationConstant orientation) {
206:                if (_orientation != orientation) {
207:                    _orientation = orientation;
208:                    initPanels();
209:                }
210:            }
211:
212:            public OrientationConstant getOrientation() {
213:                return _orientation;
214:            }
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.