Source Code Cross Referenced for DocumentLayouter.java in  » Workflow-Engines » osbl-1_0 » org » osbl » client » wings » form » layouter » 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 » Workflow Engines » osbl 1_0 » org.osbl.client.wings.form.layouter 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.osbl.client.wings.form.layouter;
002:
003:        import org.wings.*;
004:        import org.wings.event.*;
005:        import org.osbl.client.wings.form.ComponentProvider;
006:        import org.osbl.client.wings.shell.Templates;
007:        import org.wingx.XDivision;
008:
009:        import java.util.*;
010:        import java.util.List;
011:        import java.awt.*;
012:        import java.awt.event.ActionListener;
013:        import java.awt.event.ActionEvent;
014:
015:        // TODO: add lazyness for divisions
016:        public class DocumentLayouter extends AbstractLayouter {
017:            PageSet pageSet;
018:
019:            public DocumentLayouter(PageSet pageSet) {
020:                this .pageSet = pageSet;
021:            }
022:
023:            public DocumentLayouter(Page... pages) {
024:                this .pageSet = new PageSet(pages);
025:            }
026:
027:            public DocumentLayouter(Page page) {
028:                this .pageSet = new PageSet(page);
029:            }
030:
031:            public SContainer build(final ComponentProvider componentProvider) {
032:                DocumentBuilder documentBuilder = new DocumentBuilder(
033:                        componentProvider);
034:                documentBuilder.build(pageSet);
035:                SContainer container = documentBuilder.getContainer();
036:                collectComponents(container);
037:                return container;
038:            }
039:
040:            protected void setApplicability(Page page, SComponent component,
041:                    boolean applicable) {
042:                System.out.println("TODO: applicability of pages");
043:            }
044:
045:            protected void setApplicability(Division division,
046:                    SComponent component, boolean applicable) {
047:                component.setEnabled(applicable);
048:            }
049:
050:            class DocumentBuilder implements  Builder {
051:                private ComponentProvider componentProvider;
052:
053:                private PageSet pageSet;
054:                private Page page;
055:                private Division division;
056:                private Column column;
057:
058:                boolean divisionsHaveWeight = false;
059:                List<SContainer> pagePanels = new ArrayList<SContainer>();
060:
061:                private SPanel documentPanel;
062:                private NavigationPanel headerPanel;
063:                private NavigationPanel footerPanel;
064:                private SContainer pagePanel;
065:                private SContainer divisionPanel;
066:                private SContainer columnPanel;
067:
068:                public DocumentBuilder(ComponentProvider componentProvider) {
069:                    this .componentProvider = componentProvider;
070:                }
071:
072:                public SContainer getContainer() {
073:                    return documentPanel;
074:                }
075:
076:                public void build(PageSet pageSet) {
077:                    this .pageSet = pageSet;
078:
079:                    documentPanel = new SPanel(Templates
080:                            .loadLayout("document.thtml"));
081:                    documentPanel
082:                            .setHorizontalAlignment(SConstants.CENTER_ALIGN);
083:                    documentPanel.setVerticalAlignment(SConstants.TOP_ALIGN);
084:                    documentPanel
085:                            .setPreferredSize(new SDimension("90%", "100%"));
086:
087:                    pageSet.follow(this );
088:
089:                    if (pageSet.pages.size() > 1) {
090:                        headerPanel = new NavigationPanel(documentPanel,
091:                                pagePanels);
092:                        documentPanel.add(headerPanel, "header");
093:                        footerPanel = new NavigationPanel(documentPanel,
094:                                pagePanels);
095:                        documentPanel.add(footerPanel, "footer");
096:                    }
097:                    documentPanel.add(pagePanels.get(0), "content");
098:                }
099:
100:                public void build(final Page page) {
101:                    this .page = page;
102:                    pagePanel = new SContainer(new SGridBagLayout());
103:                    pagePanel.putClientProperty("instruction", page);
104:                    pagePanel.setVerticalAlignment(SConstants.TOP_ALIGN);
105:                    //pagePanel.setPreferredSize(SDimension.FULLAREA);
106:
107:                    page.follow(this );
108:
109:                    if (!divisionsHaveWeight) {
110:                        divisionConstraints.weighty = 1d;
111:                        pagePanel.add(new SRawTextComponent("<!-- filler -->"),
112:                                divisionConstraints);
113:                    }
114:
115:                    pagePanels.add(pagePanel);
116:                }
117:
118:                GridBagConstraints divisionConstraints = new GridBagConstraints();
119:                {
120:                    divisionConstraints.gridwidth = GridBagConstraints.REMAINDER;
121:                    divisionConstraints.insets = new Insets(10, 10, 10, 10);
122:                    divisionConstraints.fill = GridBagConstraints.BOTH;
123:                    divisionConstraints.anchor = GridBagConstraints.NORTH;
124:                }
125:
126:                public void build(Division division) {
127:                    this .division = division;
128:
129:                    if (division.titleCode != null) {
130:                        divisionPanel = new XDivision(new SGridBagLayout());
131:                        ((XDivision) divisionPanel).setTitle(componentProvider
132:                                .createTitle(division.titleCode).getText());
133:                    } else
134:                        divisionPanel = new SPanel(new SGridBagLayout());
135:
136:                    divisionPanel.putClientProperty("instruction", division);
137:                    boolean hasWeight = division.weight != 0d;
138:                    divisionsHaveWeight |= hasWeight;
139:                    divisionPanel
140:                            .setPreferredSize(hasWeight ? SDimension.FULLAREA
141:                                    : SDimension.FULLWIDTH);
142:                    divisionPanel.setVerticalAlignment(SConstants.TOP_ALIGN);
143:                    divisionConstraints.weighty = division.weight;
144:                    pagePanel.add(divisionPanel, divisionConstraints);
145:
146:                    division.follow(this );
147:                }
148:
149:                GridBagConstraints columnConstraints = new GridBagConstraints();
150:                {
151:                    columnConstraints.fill = GridBagConstraints.BOTH;
152:                    columnConstraints.anchor = GridBagConstraints.NORTH;
153:                    columnConstraints.weighty = 1d;
154:                }
155:
156:                public void build(Column column) {
157:                    this .column = column;
158:
159:                    columnPanel = new SPanel(new SGridBagLayout());
160:                    columnPanel.putClientProperty("instruction", column);
161:                    //columnPanel.setPreferredSize(column.weight != 0d ? SDimension.FULLWIDTH: null);
162:                    columnPanel.setVerticalAlignment(SConstants.TOP_ALIGN);
163:                    int c = divisionPanel.getComponentCount();
164:                    columnConstraints.gridwidth = c == division.columns.size() - 1 ? GridBagConstraints.REMAINDER
165:                            : 1;
166:                    columnConstraints.weightx = column.weight != 0d ? column.weight
167:                            : 1d;
168:                    columnConstraints.insets = new Insets(10, c > 1 ? 20 : 10,
169:                            10, c < division.columns.size() - 1 ? 20 : 10);
170:                    divisionPanel.add(columnPanel, columnConstraints);
171:
172:                    if (column.titleCode != null)
173:                        new Title(column.titleCode).build(componentProvider,
174:                                columnPanel);
175:
176:                    column.follow(this );
177:                }
178:
179:                public void build(Line line) {
180:                    line.build(componentProvider, columnPanel);
181:                }
182:            }
183:
184:            class NavigationPanel extends SPanel implements  ActionListener,
185:                    SContainerListener {
186:                SPanel documentPanel;
187:                List<SContainer> pagePanels = new ArrayList<SContainer>();
188:
189:                private SButton previousButton = new SButton("<<");
190:                private SButton nextButton = new SButton(">>");
191:                private SLabel pageLabel = new SLabel("1");
192:
193:                public NavigationPanel(SPanel documentPanel,
194:                        List<SContainer> pagePanels) {
195:                    super (new SGridLayout(1, 3, 10, 0));
196:                    this .documentPanel = documentPanel;
197:                    this .pagePanels = pagePanels;
198:
199:                    previousButton.setStyle("SButton borderless");
200:                    nextButton.setStyle("SButton borderless");
201:                    add(previousButton);
202:                    add(pageLabel);
203:                    add(nextButton);
204:
205:                    previousButton.addActionListener(this );
206:                    nextButton.addActionListener(this );
207:
208:                    previousButton.setEnabled(false);
209:                    documentPanel.addContainerListener(this );
210:                }
211:
212:                public void actionPerformed(ActionEvent e) {
213:                    int i = index();
214:
215:                    if (e.getSource() == previousButton)
216:                        i--;
217:                    else
218:                        i++;
219:                    i %= pagePanels.size();
220:
221:                    panel(i);
222:                }
223:
224:                private void buttons() {
225:                    int i = index();
226:                    previousButton.setEnabled(i > 0);
227:                    nextButton.setEnabled(i < pagePanels.size() - 1);
228:                    pageLabel.setText("" + (i + 1));
229:                }
230:
231:                private int index() {
232:                    if (documentPanel.getComponentCount() > 2)
233:                        return pagePanels
234:                                .indexOf(documentPanel.getComponent(2));
235:                    else
236:                        return -1;
237:                }
238:
239:                private void panel(int i) {
240:                    documentPanel.remove(2);
241:                    documentPanel.add(pagePanels.get(i), "content");
242:                    fireVisibilityEvent();
243:                }
244:
245:                public void componentAdded(SContainerEvent e) {
246:                    if (documentPanel.getComponentCount() == 3)
247:                        buttons();
248:                }
249:
250:                public void componentRemoved(SContainerEvent e) {
251:                }
252:            }
253:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.