Source Code Cross Referenced for PageGenerator.java in  » RSS-RDF » Feedzeo » 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 » RSS RDF » Feedzeo » layout 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:
003:            Feedzeo! 
004:            A free and open source RSS/Atom/RDF feed aggregator
005:
006:            Copyright (C) 2005-2006  Anand Rao (anandrao@users.sourceforge.net)
007:
008:            This library is free software; you can redistribute it and/or
009:            modify it under the terms of the GNU Lesser General Public
010:            License as published by the Free Software Foundation; either
011:            version 2.1 of the License, or (at your option) any later version.
012:
013:            This library is distributed in the hope that it will be useful,
014:            but WITHOUT ANY WARRANTY; without even the implied warranty of
015:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:            Lesser General Public License for more details.
017:
018:            You should have received a copy of the GNU Lesser General Public
019:            License along with this library; if not, write to the Free Software
020:            Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
021:
022:         ************************************************************************************/package layout;
023:
024:        import java.io.*;
025:
026:        import util.*;
027:        import ui.*;
028:        import data.DataElement;
029:        import app.SysObjects;
030:
031:        /**
032:         *
033:         * @author  Anand Rao
034:         */
035:        public class PageGenerator {
036:            private HTMLPage page;
037:            private PageRequest req;
038:            private String TableInfo; /* holds the raw HTML table data for the page */
039:
040:            private void populateCell(TableLayout t, CellElement c, int row,
041:                    int col, int NumCols) {
042:                int index = 0;
043:                String data = null;
044:                if (c.IsTable()) {
045:                    if (t.IsTableListType()) {
046:                        // table is a list of table items
047:                        // sample a cell of the table and depending on its type
048:                        // set the appropriate index
049:                        String CellDataType = c.getTable().getCell(0, 0)
050:                                .getDataType();
051:                        if (DataElement.IsItemData(CellDataType))
052:                            req.ItemIndex = row * NumCols + col;
053:                    }
054:                    boolean cellhasData = populateTable(c.getTable());
055:                    if (cellhasData)
056:                        t.setCellStatus(row, col, true);
057:                } else { // normal cell with datatype given by user
058:                    if (DataElement.IsCategoryData(c.getDataType())) {
059:                        data = SysObjects.getDataManager().getCategoryData(
060:                                c.getDataType(), req.getFeedCategory());
061:                        c.setData(data);
062:                    } else if (DataElement.IsChannelData(c.getDataType())) {
063:                        data = SysObjects.getDataManager().getChannelData(
064:                                c.getDataType(), req.getFeedCategory(),
065:                                req.getFeedSourceURL());
066:                        c.setData(data);
067:                    } else if (DataElement.IsItemData(c.getDataType())) {
068:                        if (t.IsTableListType()) {
069:                            index = row * NumCols + col;
070:                            data = SysObjects.getDataManager().getItemData(
071:                                    c.getDataType(), req.getFeedCategory(),
072:                                    req.getFeedSourceURL(), index);
073:                            c.setData(data);
074:                        } else {
075:                            index = req.ItemIndex;
076:                            data = SysObjects.getDataManager().getItemData(
077:                                    c.getDataType(), req.getFeedCategory(),
078:                                    req.getFeedSourceURL(), index);
079:                            c.setData(data);
080:                        }
081:                    }
082:
083:                    if (data.length() > 0) // cell with non-empty data
084:                        t.setCellStatus(row, col, true);
085:                }
086:            }
087:
088:            /*
089:             * returns true if atleast one of the table's cell contains
090:             * non-empty data; else returns false
091:             */
092:            private boolean populateTable(TableLayout t) {
093:                //System.out.println("POPULATE TABLE "+t.getName());
094:                // set table content to empty 
095:                t.setTableEmpty();
096:                int NumRows = t.getNumRows();
097:                int NumCols = t.getNumCols();
098:                for (int i = 0; i < NumRows; i++)
099:                    for (int j = 0; j < NumCols; j++)
100:                        populateCell(t, t.getCell(i, j), i, j, NumCols);
101:                boolean tableEmpty = t.IsTableEmpty();
102:                if (tableEmpty)
103:                    return false;
104:                return true;
105:            }
106:
107:            private String generateTableInfo() {
108:                String PageName = req.getPageLayoutName();
109:                PageLayout Page = SysObjects.getLayoutManager().getPageLayout(
110:                        PageName);
111:                populateTable(Page.getMainTable());
112:                return Page.getMainTable().toHTML();
113:            }
114:
115:            /** Creates a new instance of PageGenerator */
116:            public PageGenerator(PageRequest req) {
117:                this .req = req;
118:            }
119:
120:            /*
121:             * Sets the link to the HTML page just generated into the appropriate
122:             * Data object; Currently this is only set in ChannelData object
123:             */
124:            private void setHTMLPageLinkInfo() {
125:                SysObjects.getDataManager().setChannelHTMLPageLink(
126:                        req.getFeedCategory(), req.getFeedSourceURL(),
127:                        req.getHTMLFileName());
128:            }
129:
130:            private void setHTMLTableDataLinkInfo() {
131:                SysObjects.getDataManager().setChannelHTMLTableDataPageLink(
132:                        req.getFeedCategory(), req.getFeedSourceURL(),
133:                        req.getHTMLTableDataFileName());
134:            }
135:
136:            /* compiles the HTML tabledata and keeps it ready to be used later 
137:               while generating HTML page
138:             */
139:            public void preparePageInfo() {
140:                TableInfo = generateTableInfo();
141:            }
142:
143:            public void generateHTMLPage() {
144:                if (TableInfo == null) {
145:                    System.out
146:                            .println("TableInfo not found! unable to generate "
147:                                    + req.getFullHTMLFileName());
148:                    return;
149:                }
150:                page = new HTMLPage(req.getFullHTMLFileName());
151:                page.setTableData(TableInfo);
152:                // TODO: set css file in pagelayout object
153:                page.addStyleSheetFile("style.css");
154:                page.writePage();
155:                page.closePage();
156:                // update the datamanager with the link of the page 
157:                // we just generated
158:                setHTMLPageLinkInfo();
159:            }
160:
161:            public void generateHTMLTableDataPage() {
162:                if (TableInfo == null) {
163:                    System.out
164:                            .println("TableInfo not found! unable to generate "
165:                                    + req.getFullHTMLTableDataFileName());
166:                    return;
167:                }
168:                String outputFile = req.getFullHTMLTableDataFileName();
169:                PrintWriter pw = null;
170:                try {
171:                    pw = new PrintWriter(new BufferedWriter(new FileWriter(
172:                            outputFile, false)));
173:                } catch (Exception e) {
174:                    ExceptionUtil.reportException(e);
175:                    return;
176:                }
177:                pw.println(TableInfo);
178:                pw.close();
179:                //update datamanager about this info
180:                setHTMLTableDataLinkInfo();
181:            }
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.