Source Code Cross Referenced for ExamplesModel.java in  » J2EE » Sofia » com » salmonllc » examples » example7 » 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 » J2EE » Sofia » com.salmonllc.examples.example7 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.salmonllc.examples.example7;
002:
003:        //The Salmon Open Framework for Internet Applications (SOFIA)
004:        //Copyright (C) 1999 - 2002, Salmon LLC
005:        //
006:        //This program is free software; you can redistribute it and/or
007:        //modify it under the terms of the GNU General Public License version 2
008:        //as published by the Free Software Foundation; 
009:        //
010:        //This program is distributed in the hope that it will be useful,
011:        //but WITHOUT ANY WARRANTY; without even the implied warranty of
012:        //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013:        //GNU General Public License for more details.
014:        //
015:        //You should have received a copy of the GNU General Public License
016:        //along with this program; if not, write to the Free Software
017:        //Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
018:        //
019:        //For more information please visit http://www.salmonllc.com
020:
021:        import com.salmonllc.properties.Props;
022:        import com.salmonllc.sql.*;
023:        import com.salmonllc.jsp.JspNavBar;
024:
025:        import java.sql.SQLException;
026:
027:        /**
028:         * Most of this model was generated by the IDE Tool Utility. One method was hand code: populateNavBar which takes the tata from the model and fills in a navbar gui component.
029:         */
030:        public class ExamplesModel extends DataStore {
031:
032:            //constants for columns
033:            public static final String EXAMPLES_NAME = "examples.name";
034:            public static final String EXAMPLES_PAGE_URL = "examples.page_url";
035:            public static final String SOURCE_CODE_FILENAME = "source_code.filename";
036:            public static final String SOURCE_CODE_EXAMPLE_ID = "source_code.example_id";
037:
038:            public ExamplesModel(String appName) {
039:                super (appName);
040:
041:                //add columns
042:                addColumn(computeTableName("examples"), "name",
043:                        DataStore.DATATYPE_STRING, false, true, EXAMPLES_NAME);
044:                addColumn(computeTableName("examples"), "page_url",
045:                        DataStore.DATATYPE_STRING, false, true,
046:                        EXAMPLES_PAGE_URL);
047:                addColumn(computeTableName("source_code"), "filename",
048:                        DataStore.DATATYPE_STRING, true, true,
049:                        SOURCE_CODE_FILENAME);
050:                addColumn(computeTableName("source_code"), "example_id",
051:                        DataStore.DATATYPE_INT, true, true,
052:                        SOURCE_CODE_EXAMPLE_ID);
053:
054:                //add joins
055:                addJoin(computeTableAndFieldName("examples.example_id"),
056:                        computeTableAndFieldName("source_code.example_id"),
057:                        false);
058:
059:                //set order by
060:                setOrderBy(computeTableAndFieldName("source_code.example_id")
061:                        + " ASC");
062:            }
063:
064:            /**
065:             * Populates a navigation component with the contents of the model
066:             */
067:            public void populateNavBar(JspNavBar nav, int groupNo)
068:                    throws SQLException, DataStoreException {
069:                retrieve();
070:                //Each row has one sub menu item with a source code file.
071:                //The examples are repeated if an example only has more that one source file associated with it.
072:                //So each row should have a sub item, but only add an item if the example changes.
073:                int lastExampleID = -1;
074:                for (int i = 0; i < getRowCount(); i++) {
075:                    if (lastExampleID != getSourceCodeExampleId(i)) {
076:                        //add a group item if the example id changes
077:                        lastExampleID = getSourceCodeExampleId(i);
078:                        String name = "example" + lastExampleID; //unique name for the group
079:                        String url = getExamplesPageUrl(i); //url to go to when user click the group
080:                        String subName = "subMenu" + lastExampleID; //unique name of submenu for this group
081:                        nav.addGroupItem(name, groupNo, getExamplesName(i),
082:                                url, null, 0, subName);
083:                    }
084:                    //add a sub item for each row
085:                    addSubItem(nav, lastExampleID, i);
086:                }
087:            }
088:
089:            /**
090:             * Adds a sub item to a navigation bar group
091:             */
092:            private void addSubItem(JspNavBar nav, int lastExampleID, int row)
093:                    throws DataStoreException {
094:                //compute the name of this sub item, each sub item must have a unique name
095:                String name = "sub" + row;
096:
097:                //compute the description for the sub item
098:                String description = getSourceCodeFilename(row);
099:                int pos = description.lastIndexOf("/");
100:                if (pos > -1)
101:                    description = description.substring(pos + 1);
102:
103:                //compute the url that will be invoked when the the user clicks on the item
104:                String url = "%SourceView?file=" + getSourceCodeFilename(row);
105:
106:                //compute the parent menu name. This is the name of the item that this group will fall under.
107:                String parentMenuName = "example" + lastExampleID;
108:
109:                //Color for sub items
110:                String bgColor = nav.getPage().getPageProperties().getProperty(
111:                        Props.NAVBAR_SHOW_POPUP_BG_COLOR);
112:
113:                //add the item to the group
114:                nav.addSubItem(name, description, url, null, 0, parentMenuName,
115:                        null, bgColor);
116:            }
117:
118:            public String getExamplesName() throws DataStoreException {
119:                return getString(EXAMPLES_NAME);
120:            }
121:
122:            public String getExamplesName(int row) throws DataStoreException {
123:                return getString(row, EXAMPLES_NAME);
124:            }
125:
126:            public void setExamplesName(String newValue)
127:                    throws DataStoreException {
128:                setString(EXAMPLES_NAME, newValue);
129:            }
130:
131:            public void setExamplesName(int row, String newValue)
132:                    throws DataStoreException {
133:                setString(row, EXAMPLES_NAME, newValue);
134:            }
135:
136:            public String getExamplesPageUrl() throws DataStoreException {
137:                return getString(EXAMPLES_PAGE_URL);
138:            }
139:
140:            public String getExamplesPageUrl(int row) throws DataStoreException {
141:                return getString(row, EXAMPLES_PAGE_URL);
142:            }
143:
144:            public void setExamplesPageUrl(String newValue)
145:                    throws DataStoreException {
146:                setString(EXAMPLES_PAGE_URL, newValue);
147:            }
148:
149:            public void setExamplesPageUrl(int row, String newValue)
150:                    throws DataStoreException {
151:                setString(row, EXAMPLES_PAGE_URL, newValue);
152:            }
153:
154:            public String getSourceCodeFilename() throws DataStoreException {
155:                return getString(SOURCE_CODE_FILENAME);
156:            }
157:
158:            public String getSourceCodeFilename(int row)
159:                    throws DataStoreException {
160:                return getString(row, SOURCE_CODE_FILENAME);
161:            }
162:
163:            public void setSourceCodeFilename(String newValue)
164:                    throws DataStoreException {
165:                setString(SOURCE_CODE_FILENAME, newValue);
166:            }
167:
168:            public void setSourceCodeFilename(int row, String newValue)
169:                    throws DataStoreException {
170:                setString(row, SOURCE_CODE_FILENAME, newValue);
171:            }
172:
173:            public int getSourceCodeExampleId() throws DataStoreException {
174:                return getInt(SOURCE_CODE_EXAMPLE_ID);
175:            }
176:
177:            public int getSourceCodeExampleId(int row)
178:                    throws DataStoreException {
179:                return getInt(row, SOURCE_CODE_EXAMPLE_ID);
180:            }
181:
182:            public void setSourceCodeExampleId(int newValue)
183:                    throws DataStoreException {
184:                setInt(SOURCE_CODE_EXAMPLE_ID, newValue);
185:            }
186:
187:            public void setSourceCodeExampleId(int row, int newValue)
188:                    throws DataStoreException {
189:                setInt(row, SOURCE_CODE_EXAMPLE_ID, newValue);
190:            }
191:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.