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


0001:        //** Copyright Statement ***************************************************
0002:        //The Salmon Open Framework for Internet Applications (SOFIA)
0003:        // Copyright (C) 1999 - 2002, Salmon LLC
0004:        //
0005:        // This program is free software; you can redistribute it and/or
0006:        // modify it under the terms of the GNU General Public License version 2
0007:        // as published by the Free Software Foundation;
0008:        //
0009:        // This program is distributed in the hope that it will be useful,
0010:        // but WITHOUT ANY WARRANTY; without even the implied warranty of
0011:        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012:        // GNU General Public License for more details.
0013:        //
0014:        // You should have received a copy of the GNU General Public License
0015:        // along with this program; if not, write to the Free Software
0016:        // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
0017:        //
0018:        // For more information please visit http://www.salmonllc.com
0019:        //** End Copyright Statement ***************************************************
0020:        package com.salmonllc.ideTools;
0021:
0022:        /////////////////////////
0023:        //$Archive: /SOFIA/SourceCode/com/salmonllc/ideTools/IDETool.java $
0024:        //$Author: Dan $
0025:        //$Revision: 57 $
0026:        //$Modtime: 11/10/04 12:31a $
0027:        /////////////////////////
0028:
0029:        import com.salmonllc.properties.Props;
0030:        import com.salmonllc.sql.DataStore;
0031:        import com.salmonllc.sql.QBEBuilder;
0032:        import com.salmonllc.sql.ValidationRule;
0033:        import com.salmonllc.util.Util;
0034:        import com.salmonllc.win32.Registry;
0035:
0036:        import javax.swing.*;
0037:        import javax.swing.plaf.ColorUIResource;
0038:        import java.io.*;
0039:        import java.lang.reflect.Method;
0040:        import java.net.*;
0041:        import java.awt.*;
0042:        import java.util.*;
0043:
0044:        public class IDETool {
0045:            public static final String SERVER_TOMCAT40 = "Tomcat4.0";
0046:            public static final String SERVER_TOMCAT41 = "Tomcat4.1";
0047:            public static final String SERVER_TOMCAT50 = "Tomcat5.0";
0048:            public static final String SERVER_WEBLOGIC6 = "Weblogic6";
0049:            private static Font DEFAULT_FONT;
0050:            public static final Color DEFAULT_FONT_COLOR = Color.black;
0051:            private static ColorUIResource DEFAULT_SCROLL_BAR_COLOR;
0052:
0053:            private static boolean _redeploy = false;
0054:            private static boolean _restart = false;
0055:            private static boolean _stop = false;
0056:            private static boolean _runBrowser = false;
0057:            private static boolean _runDreamweaver = false;
0058:            private static boolean _genVars = false;
0059:            private static boolean _genController = false;
0060:            private static boolean _siteMap = false;
0061:            private static boolean _setProperties = false;
0062:            private static boolean _setEclipseProperties = false;
0063:            private static boolean _genModel = false;
0064:            private static boolean _makeDefault = false;
0065:            private static boolean _defaultLF = false;
0066:            private static String _modelToGen = null;
0067:            private static String _documentRoot = null;
0068:
0069:            private static boolean _genListForm = false;
0070:            private static boolean _genProject = false;
0071:            private static boolean _dontAppendProject = false;
0072:            private static String _browser = null;
0073:            private static String _defaultWebApp = null;
0074:            private static String _defaultFwApp = null;
0075:            private static String _webPage = null;
0076:            private static String _dreamWeaverFile = null;
0077:            private static String _dreamWeaverPath = null;
0078:            private static String _defaultHost = null;
0079:            private static String _packageName = null;
0080:            private static String _controllerName = null;
0081:            private static String _defaultSourcePath = null;
0082:            private static String _serverType = SERVER_TOMCAT40;
0083:            private static String _xmlFile = null;
0084:            private static String _projectName = null;
0085:            private static String _actualFileName = null;
0086:            private static String _appPropsPath = null;
0087:            private static boolean _useAppProperties = false;
0088:
0089:            private static void append(StringBuffer buf, String line,
0090:                    int indents) {
0091:                for (int i = 0; i < indents; i++)
0092:                    buf.append("     ");
0093:                buf.append(line);
0094:            }
0095:
0096:            private static void appendLn(StringBuffer buf, String line,
0097:                    int indents) {
0098:                append(buf, line, indents);
0099:                buf.append("\r\n");
0100:            }
0101:
0102:            /**
0103:             *  For server invocation, converts a string to base64encoding
0104:             */
0105:            protected static String base64encode(String enc) {
0106:                return new sun.misc.BASE64Encoder().encode(enc.getBytes());
0107:            }
0108:
0109:            /**
0110:             * Pops up a change dialog and saves changes to the System.properties file
0111:             */
0112:            protected static void changeProperties(boolean eclipse) {
0113:                Hashtable changes = null;
0114:                if (eclipse)
0115:                    changes = displayEclipsePropertiesDialog();
0116:                else
0117:                    changes = displayPropertiesDialog();
0118:
0119:                if (changes != null) {
0120:                    try {
0121:                        Props.updateSystemProperties(changes);
0122:                    } catch (Exception e) {
0123:                        displayError(e);
0124:                    }
0125:
0126:                }
0127:                System.exit(0);
0128:
0129:            }
0130:
0131:            private static void makePageDefault() {
0132:                String p = getProjectProperty(Props.IDE_DEFAULT_RUN_URL);
0133:                Hashtable tab = new Hashtable();
0134:                tab.put(p, _webPage);
0135:                try {
0136:                    Props.updateSystemProperties(tab);
0137:                    System.out.println("Made Page:" + _webPage + " default.");
0138:                } catch (Exception e) {
0139:                    displayError(e);
0140:                }
0141:            }
0142:
0143:            /**
0144:             * Copies all the files in sourceDir and subdirectories to outputDir
0145:             */
0146:            public static void copyDirectory(File sourceDir, File outputDir)
0147:                    throws IOException {
0148:                File[] f = sourceDir.listFiles();
0149:                if (f == null)
0150:                    return;
0151:
0152:                for (int i = 0; i < f.length; i++) {
0153:                    if (f[i].isFile()) {
0154:                        File outputFile = new File(outputDir.getPath()
0155:                                + File.separatorChar + f[i].getName());
0156:                        copyFile(f[i], outputFile);
0157:                    } else if (f[i].isDirectory()) {
0158:                        File outputFile = new File(outputDir.getPath()
0159:                                + File.separatorChar + f[i].getName());
0160:                        if (!outputFile.exists())
0161:                            outputFile.mkdir();
0162:                        copyDirectory(f[i], outputFile);
0163:                    }
0164:                }
0165:            }
0166:
0167:            /**
0168:             * Copies input file to output file
0169:             */
0170:
0171:            public static void copyFile(File inputFile, File outputFile)
0172:                    throws IOException {
0173:                BufferedInputStream fr = new BufferedInputStream(
0174:                        new FileInputStream(inputFile));
0175:                BufferedOutputStream fw = new BufferedOutputStream(
0176:                        new FileOutputStream(outputFile));
0177:                byte[] buf = new byte[8192];
0178:                int n;
0179:                while ((n = fr.read(buf)) >= 0)
0180:                    fw.write(buf, 0, n);
0181:                fr.close();
0182:                fw.close();
0183:            }
0184:
0185:            /**
0186:             * Builds all the registry stuff to create a dreamweaver site
0187:             */
0188:
0189:            public static void createDreamweaverProject(String resourcesDir,
0190:                    String projectName, String dreamweaverDir, String host,
0191:                    String projectLocation) throws Exception {
0192:                File fDreamweaverSettings = new File(resourcesDir
0193:                        + File.separator + "Dreamweaver" + File.separator
0194:                        + "Salmon SetProperties.js");
0195:                byte[] baDreamweaverTemplate = new byte[(int) fDreamweaverSettings
0196:                        .length()];
0197:
0198:                if (!fDreamweaverSettings.exists())
0199:                    return;
0200:
0201:                FileInputStream fisDreamweaverSettings = new FileInputStream(
0202:                        fDreamweaverSettings);
0203:                fisDreamweaverSettings.read(baDreamweaverTemplate);
0204:                fisDreamweaverSettings.close();
0205:
0206:                String sDreamweaverSettings = new String(baDreamweaverTemplate);
0207:                sDreamweaverSettings = replace(sDreamweaverSettings,
0208:                        "$PROJECTNAME$", projectName);
0209:                sDreamweaverSettings = replace(sDreamweaverSettings, "$HOST$",
0210:                        host);
0211:
0212:                Properties props = System.getProperties();
0213:                String sUserHome = props.getProperty("user.home");
0214:                File fWriteDreamweaverSettings = new File(sUserHome
0215:                        + File.separator + "Application Data" + File.separator
0216:                        + "Macromedia" + File.separator + "Dreamweaver MX 2004"
0217:                        + File.separator + "Configuration" + File.separator
0218:                        + "Startup" + File.separator
0219:                        + "Salmon SetProperties.js");
0220:                if (!fWriteDreamweaverSettings.exists()) {
0221:                    fWriteDreamweaverSettings = new File(sUserHome
0222:                            + File.separator + "Application Data"
0223:                            + File.separator + "Macromedia" + File.separator
0224:                            + "Dreamweaver MX 2004" + File.separator
0225:                            + "Configuration" + File.separator + "Startup"
0226:                            + File.separator + "SalmonSetProperties.js");
0227:                    if (!fWriteDreamweaverSettings.exists()) {
0228:                        fWriteDreamweaverSettings = new File(sUserHome
0229:                                + File.separator + "Application Data"
0230:                                + File.separator + "Macromedia"
0231:                                + File.separator + "Dreamweaver MX"
0232:                                + File.separator + "Configuration"
0233:                                + File.separator + "Startup" + File.separator
0234:                                + "Salmon SetProperties.js");
0235:                        if (!fWriteDreamweaverSettings.exists()) {
0236:                            fWriteDreamweaverSettings = new File(sUserHome
0237:                                    + File.separator + "Application Data"
0238:                                    + File.separator + "Macromedia"
0239:                                    + File.separator + "Dreamweaver MX"
0240:                                    + File.separator + "Configuration"
0241:                                    + File.separator + "Startup"
0242:                                    + File.separator + "SalmonSetProperties.js");
0243:                            if (!fWriteDreamweaverSettings.exists()) {
0244:                                fWriteDreamweaverSettings = new File(
0245:                                        dreamweaverDir + File.separator
0246:                                                + "Configuration"
0247:                                                + File.separator + "Startup"
0248:                                                + File.separator
0249:                                                + "Salmon SetProperties.js");
0250:                                if (!fWriteDreamweaverSettings.exists()) {
0251:                                    fWriteDreamweaverSettings = new File(
0252:                                            dreamweaverDir + File.separator
0253:                                                    + "Configuration"
0254:                                                    + File.separator
0255:                                                    + "Startup"
0256:                                                    + File.separator
0257:                                                    + "SalmonSetProperties.js");
0258:                                }
0259:                            }
0260:                        }
0261:                    }
0262:                }
0263:
0264:                if (!fWriteDreamweaverSettings.exists())
0265:                    return;
0266:
0267:                String currentAppArray = getDreamweaverArrayInfo(
0268:                        fWriteDreamweaverSettings, "APPARRAY");
0269:                currentAppArray += "APPARRAY[\"" + projectName + "\"]=\""
0270:                        + projectName + "\";";
0271:                sDreamweaverSettings = replace(sDreamweaverSettings,
0272:                        "$APPARRAY$", currentAppArray);
0273:
0274:                String currentURLArray = getDreamweaverArrayInfo(
0275:                        fWriteDreamweaverSettings, "SERVLETARRAY");
0276:                currentURLArray += "SERVLETURLARRAY[\"" + projectName
0277:                        + "\"]=\"http://" + host + "/" + projectName + "\";";
0278:                sDreamweaverSettings = replace(sDreamweaverSettings,
0279:                        "$SERVLETARRAY$", currentURLArray);
0280:
0281:                File fBackup = new File(fWriteDreamweaverSettings
0282:                        .getAbsolutePath()
0283:                        + ".bak");
0284:                if (fBackup.exists())
0285:                    fBackup.delete();
0286:                fWriteDreamweaverSettings.renameTo(new File(
0287:                        fWriteDreamweaverSettings.getAbsolutePath() + ".bak"));
0288:                FileOutputStream fosDreamweaverSettings = new FileOutputStream(
0289:                        fWriteDreamweaverSettings);
0290:                fosDreamweaverSettings.write(sDreamweaverSettings.getBytes());
0291:                fosDreamweaverSettings.close();
0292:
0293:                String sVer = "7";
0294:                Registry rDream = null;
0295:                String sPath = "";
0296:
0297:                try {
0298:                    rDream = new Registry(Registry.HKEY_LOCAL_MACHINE,
0299:                            "SOFTWARE\\Macromedia\\Dreamweaver\\" + sVer
0300:                                    + "\\Installation");
0301:                    sPath = rDream.getStringAttribute("InstallPath");
0302:
0303:                    if (sPath == null || sPath.trim().equals("")) {
0304:                        sVer = "6";
0305:                        rDream = new Registry(Registry.HKEY_LOCAL_MACHINE,
0306:                                "SOFTWARE\\Macromedia\\Dreamweaver\\" + sVer
0307:                                        + "\\Installation");
0308:                        sPath = rDream.getStringAttribute("InstallPath");
0309:
0310:                        if (sPath == null || sPath.trim().equals(""))
0311:                            sVer = "4";
0312:                    }
0313:                } catch (Exception re) {
0314:                    sVer = "4";
0315:                }
0316:
0317:                int iVersion = Integer.parseInt(sVer);
0318:                Registry rSummary = null;
0319:                Registry rSite = null;
0320:                int iNoSites = 0;
0321:
0322:                switch (iVersion) {
0323:                default:
0324:                case 4:
0325:                    rSummary = new Registry(Registry.HKEY_CURRENT_USER,
0326:                            "Software\\Macromedia\\Dreamweaver " + sVer
0327:                                    + "\\Sites\\-Summary");
0328:                    iNoSites = rSummary.getIntAttribute("Number of Sites");
0329:                    rSite = new Registry(Registry.HKEY_CURRENT_USER,
0330:                            "Software\\Macromedia\\Dreamweaver " + sVer
0331:                                    + "\\Sites\\-Site" + iNoSites);
0332:                    break;
0333:
0334:                case 6:
0335:                    rSummary = new Registry(Registry.HKEY_CURRENT_USER,
0336:                            "Software\\Macromedia\\Dreamweaver " + sVer
0337:                                    + "\\Sites\\-Summary");
0338:                    iNoSites = rSummary.getIntAttribute("Number of Sites");
0339:                    rSite = new Registry(Registry.HKEY_CURRENT_USER,
0340:                            "Software\\Macromedia\\Dreamweaver " + sVer
0341:                                    + "\\Sites\\-Site" + iNoSites);
0342:                    break;
0343:
0344:                case 7:
0345:                    rSummary = new Registry(Registry.HKEY_CURRENT_USER,
0346:                            "Software\\Macromedia\\Common\\2004\\Sites\\-Summary");
0347:                    iNoSites = rSummary.getIntAttribute("Number of Sites");
0348:                    rSite = new Registry(Registry.HKEY_CURRENT_USER,
0349:                            "Software\\Macromedia\\Common\\2004\\Sites\\-Site"
0350:                                    + iNoSites);
0351:                    break;
0352:                }
0353:
0354:                // Part common to all versions of Dreamweaver supported here namely DW4, UD4, MX v.6 and MX 2004 v.7
0355:                rSite.setIntAttribute("Access Type", 2);
0356:                rSite.setIntAttribute("Check Out When Opening Files", 1);
0357:                rSite.setIntAttribute("Column Width", 125);
0358:                rSite.setIntAttribute("Column Width Count", 0);
0359:                rSite.setIntAttribute("Dont Show Remote Time Warning", 0);
0360:                rSite.setStringAttribute("Email Address", "");
0361:                rSite.setIntAttribute("Enable Check In/Check Out", 0);
0362:                rSite.setIntAttribute("Firewall", 0);
0363:                rSite.setIntAttribute("Hidden Count", 0);
0364:                rSite.setStringAttribute("Home Page", "");
0365:                rSite.setStringAttribute("Host", "");
0366:                rSite.setStringAttribute("Local Directory", projectLocation
0367:                        + File.separator);
0368:                rSite.setIntAttribute("Local Expanded Dirs", 1);
0369:                rSite.setIntAttribute("Pages Per Row", 200);
0370:                rSite.setIntAttribute("PASV FTP", 1);
0371:                rSite.setIntAttribute("Refresh Local", 1);
0372:                rSite.setIntAttribute("Refresh Remote", 1);
0373:                rSite.setStringAttribute("Remote Directory", "");
0374:                rSite.setIntAttribute("Remote Expanded Dirs", 0);
0375:                rSite.setStringAttribute("Root Dest", "");
0376:                rSite.setIntAttribute("Root Number of Parents", 0);
0377:                rSite.setStringAttribute("Root Source", "");
0378:                rSite.setStringAttribute("Root URL", "http://" + host + "/"
0379:                        + projectName + "/");
0380:                rSite.setIntAttribute("Save PW", 0);
0381:                rSite.setStringAttribute("Server Model", "JSP");
0382:                rSite.setStringAttribute("Server PageExt", ".jsp");
0383:                rSite.setStringAttribute("Server Scripting", "Java");
0384:                rSite.setIntAttribute("Share Columns", 1);
0385:                rSite.setIntAttribute("Show Dependent Files", 0);
0386:                rSite.setIntAttribute("Show Hidden Files", 0);
0387:                rSite.setIntAttribute("Show Page Titles", 0);
0388:                rSite.setStringAttribute("Site Name", projectName);
0389:                rSite.setStringAttribute("Source Control System Type", "");
0390:                rSite.setStringAttribute("Spacer File Path", "");
0391:                rSite.setIntAttribute("Upload Metafile", 1);
0392:                rSite.setStringAttribute("URL Prefix", "http://" + host + "/"
0393:                        + projectName + "/");
0394:                rSite.setIntAttribute("Use Cache", 0);
0395:                rSite.setIntAttribute("Use Metafile", 1);
0396:                rSite.setStringAttribute("User", "");
0397:                rSite.setStringAttribute("User Alias", "");
0398:                rSite.setStringAttribute("User PW", "");
0399:                rSite.setIntAttribute("ZOOM LEVEL", 8);
0400:
0401:                // Part pertaining only to Dreamweaver MX v.6.0
0402:                if (sVer.equals("6")) {
0403:                    rSite.setStringAttribute("LDSSH Address:Port", "");
0404:                    rSite.setStringAttribute("LDSSH Default", "");
0405:                    rSite.setStringAttribute("LDSSH Profile", "");
0406:                    rSite.setIntAttribute("LDUse SSH", 0);
0407:                    rSite.setStringAttribute("SSH Address:Port", "");
0408:                    rSite.setStringAttribute("SSH Default", "");
0409:                    rSite.setStringAttribute("SSH Profile", "");
0410:                    rSite.setStringAttribute("TestSrvBinSSH Address:Port", "");
0411:                    rSite.setStringAttribute("TestSrvBinSSH Default", "");
0412:                    rSite.setStringAttribute("TestSrvBinSSH Profile", "");
0413:                    rSite.setIntAttribute("TestSrvBinSSH Use SSH", 0);
0414:                    rSite.setIntAttribute("Use SSH", 0);
0415:                }
0416:
0417:                // Part common to both Dreamweaver MX v.6.0 and MX 2004 v.7.0
0418:                if ((sVer.equals("6")) || (sVer.equals("7"))) {
0419:                    rSite.setStringAttribute("AdminURL", "");
0420:                    rSite.setIntAttribute("Auto Upload Files", 0);
0421:                    rSite.setIntAttribute("CF DSN List Test Result", 0);
0422:                    rSite.setIntAttribute("Cloak By Pattern", 0);
0423:                    rSite.setIntAttribute("Cloaked Dirs", 0);
0424:                    rSite.setStringAttribute("Cloaked Patterns", "");
0425:                    rSite.setIntAttribute("Cloaking Enabled", 0);
0426:                    rSite.setStringAttribute("Default Document Type", "HTML");
0427:                    rSite.setStringAttribute("Image Directory", "");
0428:                    rSite.setIntAttribute("Live Data Access Type", 1);
0429:                    rSite.setIntAttribute("Live Data Firewall", 0);
0430:                    rSite.setStringAttribute("Live Data Host", "");
0431:                    rSite.setIntAttribute("Live Data PASV FTP", 0);
0432:                    rSite.setIntAttribute("Live Data Refresh Remote", 0);
0433:                    rSite.setStringAttribute("Live Data Remote Directory",
0434:                            projectLocation + File.separator);
0435:                    rSite.setIntAttribute("Live Data Save PW", 0);
0436:                    rSite.setStringAttribute(
0437:                            "Live Data Source Control System Type", "");
0438:                    rSite.setStringAttribute("Live Data User", "");
0439:                    rSite.setStringAttribute("Live Data User PW", "");
0440:                    rSite.setIntAttribute("RDS Login Test Result", 0);
0441:                    rSite.setStringAttribute("RDS Password", "");
0442:                    rSite.setStringAttribute("RDS Username", "");
0443:                    rSite.setIntAttribute("Server Objects Version", 1);
0444:                    rSite.setIntAttribute("Test Srv Bin Access Type", 2);
0445:                    rSite.setIntAttribute("Test Srv Bin Firewall", 0);
0446:                    rSite.setStringAttribute("Test Srv Bin Host", "");
0447:                    rSite.setIntAttribute("Test Srv Bin PASV FTP", 0);
0448:                    rSite.setStringAttribute("Test Srv Bin Remote Directory",
0449:                            "");
0450:                    rSite.setIntAttribute("Test Srv Bin Save PW", 0);
0451:                    rSite.setStringAttribute("Test Srv Bin User", "");
0452:                    rSite.setStringAttribute("Test Srv Bin User PW", "");
0453:                    rSite.setIntAttribute("Test Srv Bin Was Set", 0);
0454:                    rSite.setIntAttribute("UltraDev Connections Migrated", 0);
0455:                    rSite.setIntAttribute("URL Prefix Test Result", 0);
0456:                    rSite.setIntAttribute("Wizard Site Type", 0);
0457:                }
0458:
0459:                // Part pertaining only to Dreamweaver MX 2004 v.7.0
0460:                if (sVer.equals("7")) {
0461:                    rSite.setStringAttribute("Apply Fonts", "font");
0462:                    rSite.setIntAttribute("Contributor Integration Enabled", 0);
0463:                    rSite.setIntAttribute("Controlled", 0);
0464:                    rSite.setStringAttribute("Group Name", "");
0465:                    rSite.setStringAttribute("Group Password", "");
0466:                    rSite
0467:                            .setStringAttribute(
0468:                                    "Live Data Path Name Character Set",
0469:                                    "Windows-1252");
0470:                    rSite.setIntAttribute("Live Data SFTP", 0);
0471:                    rSite.setStringAttribute("Local Expanded Dir0",
0472:                            projectLocation);
0473:                    rSite.setStringAttribute("Path Name Character Set",
0474:                            "Windows-1252");
0475:                    rSite.setIntAttribute("ServerConfiguration", 0);
0476:                    rSite.setIntAttribute("SFTP", 0);
0477:                    rSite.setStringAttribute("Shadow Root", "");
0478:                    rSite.setStringAttribute("Shared File Root", "");
0479:                    rSite.setStringAttribute("Shared Site Root", "");
0480:                    rSite.setStringAttribute("Site Admin", "");
0481:                    rSite.setStringAttribute("Site Admin Email", "");
0482:                    rSite.setIntAttribute("Site Disabled State", 0);
0483:                    rSite.setStringAttribute("Site Disabled State Error Msg",
0484:                            "");
0485:                    rSite.setStringAttribute(
0486:                            "Test Svr Bin Path Name character Set",
0487:                            "Windows-1252");
0488:                    rSite.setIntAttribute("Test Svr Bin SFTP", 0);
0489:                    rSite.setIntAttribute("User Can Change Paragraphs", 1);
0490:                    rSite.setIntAttribute("User Can USe CSS", 1);
0491:                    rSite.setIntAttribute("Workflow", 0);
0492:
0493:                    Registry rAllowedFonts = new Registry(
0494:                            Registry.HKEY_CURRENT_USER,
0495:                            "Software\\Macromedia\\Common\\2004\\Sites\\-Site"
0496:                                    + iNoSites + "\\Allowed Fonts");
0497:                    rAllowedFonts.setIntAttribute("Total", 0);
0498:
0499:                    Registry rCSS = new Registry(Registry.HKEY_CURRENT_USER,
0500:                            "Software\\Macromedia\\Common\\2004\\Sites\\-Site"
0501:                                    + iNoSites + "\\CSS");
0502:                    rCSS.setStringAttribute("LastSamplePath", "");
0503:
0504:                    Registry rDropFolders = new Registry(
0505:                            Registry.HKEY_CURRENT_USER,
0506:                            "Software\\Macromedia\\Common\\2004\\Sites\\-Site"
0507:                                    + iNoSites + "\\Drop Folders");
0508:                    rDropFolders.setIntAttribute("Total", 0);
0509:
0510:                    Registry rReviewers = new Registry(
0511:                            Registry.HKEY_CURRENT_USER,
0512:                            "Software\\Macromedia\\Common\\2004\\Sites\\-Site"
0513:                                    + iNoSites + "\\Reviewers");
0514:                    rReviewers.setIntAttribute("Total", 0);
0515:
0516:                    // ------------------------------------------
0517:                    // We also have to populate the site backup |
0518:                    // ------------------------------------------
0519:                    Registry rSiteBackup = new Registry(
0520:                            Registry.HKEY_CURRENT_USER,
0521:                            "Software\\Macromedia\\Common\\2004\\Sites_Backup\\-Site"
0522:                                    + iNoSites);
0523:
0524:                    // Part common to all versions of Dreamweaver supported here namely DW4, UD4, MX v.6 and MX 2004 v.7
0525:                    rSiteBackup.setIntAttribute("Access Type", 2);
0526:                    rSiteBackup.setIntAttribute("Check Out When Opening Files",
0527:                            1);
0528:                    rSiteBackup.setIntAttribute("Column Width", 125);
0529:                    rSiteBackup.setIntAttribute("Column Width Count", 0);
0530:                    rSiteBackup.setIntAttribute(
0531:                            "Dont Show Remote Time Warning", 0);
0532:                    rSiteBackup.setStringAttribute("Email Address", "");
0533:                    rSiteBackup.setIntAttribute("Enable Check In/Check Out", 0);
0534:                    rSiteBackup.setIntAttribute("Firewall", 0);
0535:                    rSiteBackup.setIntAttribute("Hidden Count", 0);
0536:                    rSiteBackup.setStringAttribute("Home Page", "");
0537:                    rSiteBackup.setStringAttribute("Host", "");
0538:                    rSiteBackup.setStringAttribute("Local Directory",
0539:                            projectLocation + File.separator);
0540:                    rSiteBackup.setIntAttribute("Local Expanded Dirs", 1);
0541:                    rSiteBackup.setIntAttribute("Pages Per Row", 200);
0542:                    rSiteBackup.setIntAttribute("PASV FTP", 1);
0543:                    rSiteBackup.setIntAttribute("Refresh Local", 1);
0544:                    rSiteBackup.setIntAttribute("Refresh Remote", 1);
0545:                    rSiteBackup.setStringAttribute("Remote Directory", "");
0546:                    rSiteBackup.setIntAttribute("Remote Expanded Dirs", 0);
0547:                    rSiteBackup.setStringAttribute("Root Dest", "");
0548:                    rSiteBackup.setIntAttribute("Root Number of Parents", 0);
0549:                    rSiteBackup.setStringAttribute("Root Source", "");
0550:                    rSiteBackup.setStringAttribute("Root URL", "http://" + host
0551:                            + "/" + projectName + "/");
0552:                    rSiteBackup.setIntAttribute("Save PW", 0);
0553:                    rSiteBackup.setStringAttribute("Server Model", "JSP");
0554:                    rSiteBackup.setStringAttribute("Server PageExt", ".jsp");
0555:                    rSiteBackup.setStringAttribute("Server Scripting", "Java");
0556:                    rSiteBackup.setIntAttribute("Share Columns", 1);
0557:                    rSiteBackup.setIntAttribute("Show Dependent Files", 0);
0558:                    rSiteBackup.setIntAttribute("Show Hidden Files", 0);
0559:                    rSiteBackup.setIntAttribute("Show Page Titles", 0);
0560:                    rSiteBackup.setStringAttribute("Site Name", projectName);
0561:                    rSiteBackup.setStringAttribute(
0562:                            "Source Control System Type", "");
0563:                    rSiteBackup.setStringAttribute("Spacer File Path", "");
0564:                    rSiteBackup.setIntAttribute("Upload Metafile", 1);
0565:                    rSiteBackup.setStringAttribute("URL Prefix", "http://"
0566:                            + host + "/" + projectName + "/");
0567:                    rSiteBackup.setIntAttribute("Use Cache", 0);
0568:                    rSiteBackup.setIntAttribute("Use Metafile", 1);
0569:                    rSiteBackup.setStringAttribute("User", "");
0570:                    rSiteBackup.setStringAttribute("User Alias", "");
0571:                    rSiteBackup.setStringAttribute("User PW", "");
0572:                    rSiteBackup.setIntAttribute("ZOOM LEVEL", 8);
0573:
0574:                    // Part common to both Dreamweaver MX v.6.0 and MX 2004 v.7.0
0575:                    rSiteBackup.setStringAttribute("AdminURL", "");
0576:                    rSiteBackup.setIntAttribute("Auto Upload Files", 0);
0577:                    rSiteBackup.setIntAttribute("CF DSN List Test Result", 0);
0578:                    rSiteBackup.setIntAttribute("Cloak By Pattern", 0);
0579:                    rSiteBackup.setIntAttribute("Cloaked Dirs", 0);
0580:                    rSiteBackup.setStringAttribute("Cloaked Patterns", "");
0581:                    rSiteBackup.setIntAttribute("Cloaking Enabled", 0);
0582:                    rSiteBackup.setStringAttribute("Default Document Type",
0583:                            "HTML");
0584:                    rSiteBackup.setStringAttribute("Image Directory", "");
0585:                    rSiteBackup.setIntAttribute("Live Data Access Type", 1);
0586:                    rSiteBackup.setIntAttribute("Live Data Firewall", 0);
0587:                    rSiteBackup.setStringAttribute("Live Data Host", "");
0588:                    rSiteBackup.setIntAttribute("Live Data PASV FTP", 0);
0589:                    rSiteBackup.setIntAttribute("Live Data Refresh Remote", 0);
0590:                    rSiteBackup.setStringAttribute(
0591:                            "Live Data Remote Directory", projectLocation
0592:                                    + File.separator);
0593:                    rSiteBackup.setIntAttribute("Live Data Save PW", 0);
0594:                    rSiteBackup.setStringAttribute(
0595:                            "Live Data Source Control System Type", "");
0596:                    rSiteBackup.setStringAttribute("Live Data User", "");
0597:                    rSiteBackup.setStringAttribute("Live Data User PW", "");
0598:                    rSiteBackup.setIntAttribute("RDS Login Test Result", 0);
0599:                    rSiteBackup.setStringAttribute("RDS Password", "");
0600:                    rSiteBackup.setStringAttribute("RDS Username", "");
0601:                    rSiteBackup.setIntAttribute("Server Objects Version", 1);
0602:                    rSiteBackup.setIntAttribute("Test Srv Bin Access Type", 2);
0603:                    rSiteBackup.setIntAttribute("Test Srv Bin Firewall", 0);
0604:                    rSiteBackup.setStringAttribute("Test Srv Bin Host", "");
0605:                    rSiteBackup.setIntAttribute("Test Srv Bin PASV FTP", 0);
0606:                    rSiteBackup.setStringAttribute(
0607:                            "Test Srv Bin Remote Directory", "");
0608:                    rSiteBackup.setIntAttribute("Test Srv Bin Save PW", 0);
0609:                    rSiteBackup.setStringAttribute("Test Srv Bin User", "");
0610:                    rSiteBackup.setStringAttribute("Test Srv Bin User PW", "");
0611:                    rSiteBackup.setIntAttribute("Test Srv Bin Was Set", 0);
0612:                    rSiteBackup.setIntAttribute(
0613:                            "UltraDev Connections Migrated", 0);
0614:                    rSiteBackup.setIntAttribute("URL Prefix Test Result", 0);
0615:                    rSiteBackup.setIntAttribute("Wizard Site Type", 0);
0616:
0617:                    // Part pertaining only to Dreamweaver MX 2004 v.7.0
0618:                    rSiteBackup.setStringAttribute("Apply Fonts", "font");
0619:                    rSiteBackup.setIntAttribute(
0620:                            "Contributor Integration Enabled", 0);
0621:                    rSiteBackup.setIntAttribute("Controlled", 0);
0622:                    rSiteBackup.setStringAttribute("Group Name", "");
0623:                    rSiteBackup.setStringAttribute("Group Password", "");
0624:                    rSiteBackup
0625:                            .setStringAttribute(
0626:                                    "Live Data Path Name Character Set",
0627:                                    "Windows-1252");
0628:                    rSiteBackup.setIntAttribute("Live Data SFTP", 0);
0629:                    rSiteBackup.setStringAttribute("Local Expanded Dir0",
0630:                            projectLocation);
0631:                    rSiteBackup.setStringAttribute("Path Name Character Set",
0632:                            "Windows-1252");
0633:                    rSiteBackup.setIntAttribute("ServerConfiguration", 0);
0634:                    rSiteBackup.setIntAttribute("SFTP", 0);
0635:                    rSiteBackup.setStringAttribute("Shadow Root", "");
0636:                    rSiteBackup.setStringAttribute("Shared File Root", "");
0637:                    rSiteBackup.setStringAttribute("Shared Site Root", "");
0638:                    rSiteBackup.setStringAttribute("Site Admin", "");
0639:                    rSiteBackup.setStringAttribute("Site Admin Email", "");
0640:                    rSiteBackup.setIntAttribute("Site Disabled State", 0);
0641:                    rSiteBackup.setStringAttribute(
0642:                            "Site Disabled State Error Msg", "");
0643:                    rSiteBackup.setStringAttribute(
0644:                            "Test Svr Bin Path Name character Set",
0645:                            "Windows-1252");
0646:                    rSiteBackup.setIntAttribute("Test Svr Bin SFTP", 0);
0647:                    rSiteBackup
0648:                            .setIntAttribute("User Can Change Paragraphs", 1);
0649:                    rSiteBackup.setIntAttribute("User Can USe CSS", 1);
0650:                    rSiteBackup.setIntAttribute("Workflow", 0);
0651:
0652:                    Registry rAllowedFontsBackup = new Registry(
0653:                            Registry.HKEY_CURRENT_USER,
0654:                            "Software\\Macromedia\\Common\\2004\\Sites_Backup\\-Site"
0655:                                    + iNoSites + "\\Allowed Fonts");
0656:                    rAllowedFontsBackup.setIntAttribute("Total", 0);
0657:
0658:                    Registry rCSSBackup = new Registry(
0659:                            Registry.HKEY_CURRENT_USER,
0660:                            "Software\\Macromedia\\Common\\2004\\Sites_Backup\\-Site"
0661:                                    + iNoSites + "\\CSS");
0662:                    rCSSBackup.setStringAttribute("LastSamplePath", "");
0663:
0664:                    Registry rDropFoldersBackup = new Registry(
0665:                            Registry.HKEY_CURRENT_USER,
0666:                            "Software\\Macromedia\\Common\\2004\\Sites_Backup\\-Site"
0667:                                    + iNoSites + "\\Drop Folders");
0668:                    rDropFoldersBackup.setIntAttribute("Total", 0);
0669:
0670:                    Registry rReviewersBackup = new Registry(
0671:                            Registry.HKEY_CURRENT_USER,
0672:                            "Software\\Macromedia\\Common\\2004\\Sites_Backup\\-Site"
0673:                                    + iNoSites + "\\Reviewers");
0674:                    rReviewersBackup.setIntAttribute("Total", 0);
0675:                }
0676:
0677:                // Set the relevant variables in the Summary key
0678:                rSummary.setIntAttribute("Current Site", iNoSites);
0679:                rSummary.setIntAttribute("Number of Sites", iNoSites + 1);
0680:
0681:                // Part pertaining only to Dreamweaver MX 2004 v.7.0
0682:                if (sVer.equals("7")) {
0683:                    int iNbrRecentSites = rSummary
0684:                            .getIntAttribute("Number of Recent Sites");
0685:                    if (iNbrRecentSites == 0) {
0686:                        rSummary.setIntAttribute("Number of Recent Sites", 1);
0687:                        rSummary.setStringAttribute("RecentSite0", projectName);
0688:                    } else {
0689:                        // Arbitrary #recent sites: 5
0690:                        if (iNbrRecentSites > 5) {
0691:                            // We are losing the least recent site
0692:                            for (int iSiteNbr = iNbrRecentSites - 1; iSiteNbr > 0; iSiteNbr--)
0693:                                rSummary.setStringAttribute("RecentSite"
0694:                                        + iSiteNbr, rSummary
0695:                                        .getStringAttribute("RecentSite"
0696:                                                + (iSiteNbr - 1)));
0697:
0698:                            rSummary.setStringAttribute("RecentSite0",
0699:                                    projectName);
0700:                        } else {
0701:                            // We are shifting down all sites to make room for SofiaExamples
0702:                            for (int iSiteNbr = iNbrRecentSites; iSiteNbr > 0; iSiteNbr--)
0703:                                rSummary.setStringAttribute("RecentSite"
0704:                                        + iSiteNbr, rSummary
0705:                                        .getStringAttribute("RecentSite"
0706:                                                + (iSiteNbr - 1)));
0707:
0708:                            rSummary.setStringAttribute("RecentSite0",
0709:                                    projectName);
0710:                        }
0711:                    }
0712:                }
0713:
0714:                // Set the last directory depending on the version
0715:                Registry rSettings = null;
0716:                if ((sVer.equals("4")) || (sVer.equals("6"))) {
0717:                    rSettings = new Registry(Registry.HKEY_CURRENT_USER,
0718:                            "Software\\Macromedia\\Dreamweaver " + sVer
0719:                                    + "\\Settings");
0720:                } else if (sVer.equals("7")) {
0721:                    rSettings = new Registry(Registry.HKEY_CURRENT_USER,
0722:                            "Software\\Macromedia\\Dreamweaver MX 2004\\Settings");
0723:                }
0724:
0725:                if (rSettings != null)
0726:                    rSettings.setStringAttribute("LastDirectory",
0727:                            projectLocation + File.separator + "Jsp");
0728:            }
0729:
0730:            private static String getDreamweaverArrayInfo(File configFile,
0731:                    String token) {
0732:                String ret = "";
0733:                try {
0734:                    String startToken = "//$" + token + "START$";
0735:                    String endToken = "//$" + token + "END$";
0736:                    BufferedReader reader = new BufferedReader(
0737:                            new InputStreamReader(new FileInputStream(
0738:                                    configFile)));
0739:                    String st = reader.readLine();
0740:                    boolean started = false;
0741:                    while (st != null) {
0742:                        if (st.equals(endToken))
0743:                            break;
0744:
0745:                        if (started)
0746:                            ret += st + "\r\n";
0747:
0748:                        if (st.equals(startToken))
0749:                            started = true;
0750:
0751:                        st = reader.readLine();
0752:                    }
0753:                    reader.close();
0754:                } catch (Exception e) {
0755:                    displayError(e);
0756:                }
0757:
0758:                return ret;
0759:            }
0760:
0761:            /**
0762:             * Pops up a create project dialog and saves changes to the System.properties file
0763:             */
0764:            protected static void createProject() {
0765:                String sSourceDir = displayProjectDialog();
0766:                if (sSourceDir != null) {
0767:                    Hashtable changes = new Hashtable();
0768:                    changes.put(Props.IDE_DEFAULT_SOURCE_PATH, sSourceDir
0769:                            .replace('/', File.separatorChar));
0770:                    try {
0771:                        File outFile = new File(Props.getPropsPath()
0772:                                + File.separator + "System$temp.properties");
0773:                        File inFile = new File(Props.getPropsPath()
0774:                                + File.separator + "System.properties");
0775:                        PrintWriter out = new PrintWriter(new FileOutputStream(
0776:                                outFile));
0777:                        BufferedReader in = new BufferedReader(
0778:                                new InputStreamReader(new FileInputStream(
0779:                                        inFile)));
0780:                        String s = in.readLine();
0781:                        while (s != null) {
0782:                            int ndx = s.indexOf('=');
0783:                            if (ndx == -1)
0784:                                out.println(s);
0785:                            else {
0786:                                String key = s.substring(0, ndx).trim();
0787:                                if (changes.containsKey(key)) {
0788:                                    out.println(key
0789:                                            + "="
0790:                                            + fixSlashes((String) changes
0791:                                                    .get(key)));
0792:                                    changes.remove(key);
0793:                                } else
0794:                                    out.println(s);
0795:                            }
0796:                            s = in.readLine();
0797:                        }
0798:
0799:                        Enumeration e = changes.keys();
0800:                        while (e.hasMoreElements()) {
0801:                            String key = (String) e.nextElement();
0802:                            String val = (String) changes.get(key);
0803:                            out.println(key + "=" + fixSlashes(val));
0804:                        }
0805:
0806:                        in.close();
0807:                        out.close();
0808:                        inFile.delete();
0809:                        outFile.renameTo(inFile);
0810:                    } catch (Exception e) {
0811:                        displayError(e);
0812:                    }
0813:
0814:                }
0815:                System.exit(0);
0816:
0817:            }
0818:
0819:            /**
0820:             *  Displays a cut paste dialog box with the contents of the text
0821:             */
0822:            public static void displayCutPasteDialog(String fileText) {
0823:                JFrame f = new JFrame();
0824:                new CutPasteDialog(f, fileText);
0825:                f.dispose();
0826:            }
0827:
0828:            /**
0829:             * Displays a dialog for editing the system.properties file Eclipse IDE based properties. It returns a Hashtable of changes or null if nothing was changed
0830:             */
0831:            protected static Hashtable displayEclipsePropertiesDialog() {
0832:                JFrame f = new JFrame();
0833:                EclipsePropertiesDialog d = new EclipsePropertiesDialog(f,
0834:                        Props.getSystemProps());
0835:                if (d.getCancel())
0836:                    return null;
0837:                else {
0838:                    Hashtable ret = d.getChangedValues();
0839:                    if (ret.size() == 0)
0840:                        return null;
0841:                    else
0842:                        return ret;
0843:                }
0844:            }
0845:
0846:            protected static void displayError(Exception e) {
0847:                if (e instanceof  ConnectException)
0848:                    displayError("Error connecting to the test server.\nMake sure that the server is running and that property IDEDefaulttHost in the System.properties file is pointing to the correct host and port.");
0849:                else
0850:                    displayError(e.getMessage() == null ? e.toString() : e
0851:                            .getMessage());
0852:                e.printStackTrace();
0853:            }
0854:
0855:            /**
0856:             * Displays an Error Message dialog and terminates the program
0857:             */
0858:            protected static void displayError(String error) {
0859:                displayError(error, true);
0860:            }
0861:
0862:            /**
0863:             * Displays an Error Message dialog and allows a parameter to decided whether to terminate the program immediately after
0864:             */
0865:            protected static void displayError(String error, boolean exit) {
0866:                System.out.println("Error Display:" + error);
0867:                JFrame f = new JFrame();
0868:                JOptionPane.showMessageDialog(f, error, "Error",
0869:                        JOptionPane.ERROR_MESSAGE);
0870:                f.dispose();
0871:                if (exit)
0872:                    System.exit(-1);
0873:            }
0874:
0875:            /**
0876:             * Displays an Error Message dialog and allows a parameter to decided whether to terminate the program immediately after
0877:             */
0878:            protected static void displayInfo(String info) {
0879:                System.out.println("Info Display:" + info);
0880:                JFrame f = new JFrame();
0881:                JOptionPane.showMessageDialog(f, info, "Information",
0882:                        JOptionPane.INFORMATION_MESSAGE);
0883:                f.dispose();
0884:            }
0885:
0886:            /**
0887:             * Displays a dialog for creating a ListForm
0888:             */
0889:            protected static void displayListFormDialog() {
0890:                JFrame f = new JFrame();
0891:                new ListFormDialog(f);
0892:                /*       while (cont) {
0893:                           if (d.getCancelClicked()) {
0894:                               d.dispose();
0895:                               cont = false;
0896:                           }
0897:                           else {
0898:                               String className = d.getClassName();
0899:                               String packageName = null;
0900:                               int ndx = className.lastIndexOf(".");
0901:                               if (ndx > -1) {
0902:                                   packageName = className.substring(0,ndx);
0903:                                   className = className.substring(ndx + 1);
0904:                               }
0905:                
0906:                               String fileName = genClassFileName(packageName,className,_defaultSourcePath,_defaultFwApp);
0907:                               String text = generateModel(packageName,className,d);
0908:                              //*****Delete Me*****
0909:                              // displayCutPasteDialog(text);
0910:                              // d.setVisible(true);
0911:                               //*****Delete Me*****
0912:                               if (saveClass(fileName,text)) {
0913:                                   d.dispose();
0914:                                   cont = false;
0915:                               }
0916:                               else {
0917:                                   d.setVisible(true);
0918:                               }
0919:                           }
0920:                       }*/
0921:            }
0922:
0923:            /**
0924:             * Displays a dialog for creating a model and returns the text for the model
0925:             */
0926:            protected static void displayModelDialog() {
0927:                JFrame f = new JFrame();
0928:                boolean cont = true;
0929:                ModelDialog d = new ModelDialog(f, _modelToGen, _defaultLF ? -1
0930:                        : 28);
0931:                while (cont) {
0932:                    if (d.getCancelClicked()) {
0933:                        d.dispose();
0934:                        cont = false;
0935:                    } else {
0936:                        String className = d.getClassName();
0937:                        String packageName = null;
0938:                        int ndx = className.lastIndexOf(".");
0939:                        if (ndx > -1) {
0940:                            packageName = className.substring(0, ndx);
0941:                            className = className.substring(ndx + 1);
0942:                        }
0943:                        if (_defaultSourcePath == null) {
0944:                            _defaultSourcePath = "c:/";
0945:                        }
0946:                        String fileName = genClassFileName(packageName,
0947:                                className, _defaultSourcePath, _defaultFwApp,
0948:                                _dontAppendProject);
0949:                        String text = generateModel(packageName, className, d);
0950:                        text = mergeModels(text, fileName);
0951:                        if (saveClass(fileName, text)) {
0952:                            d.dispose();
0953:                            cont = false;
0954:                        } else {
0955:                            d.setVisible(true);
0956:                        }
0957:                    }
0958:                }
0959:            }
0960:
0961:            /**
0962:             * Displays a SiteMap dialog
0963:             */
0964:            protected static void displaySiteMapDialog() {
0965:                JFrame f = new JFrame();
0966:                SiteMapDialog d = new SiteMapDialog(f);
0967:                d.setVisible(true);
0968:            }
0969:
0970:            /**
0971:             * Displays a dialog for creating a new project. It returns a String of the new Default Source Directory
0972:             */
0973:            protected static String displayProjectDialog() {
0974:                JFrame f = new JFrame();
0975:                ProjectDialog d = new ProjectDialog(f, Props.getSystemProps());
0976:                if (d.getCancel())
0977:                    return null;
0978:                else {
0979:                    String ret = d.getSourceDir();
0980:                    return ret;
0981:                }
0982:            }
0983:
0984:            /**
0985:             * Displays a dialog for editing the system.properties file IDE based properties. It returns a Hashtable of changes or null if nothing was changed
0986:             */
0987:            protected static Hashtable displayPropertiesDialog() {
0988:                JFrame f = new JFrame();
0989:                PropertiesDialog d = new PropertiesDialog(f, Props
0990:                        .getSystemProps());
0991:                if (d.getCancel())
0992:                    return null;
0993:                else {
0994:                    Hashtable ret = d.getChangedValues();
0995:                    if (ret.size() == 0)
0996:                        return null;
0997:                    else
0998:                        return ret;
0999:                }
1000:            }
1001:
1002:            /**
1003:             * Displays a OK, Cancel Question dialog with the string passed. Returns true if the user clicks OK and false if CANCEL
1004:             */
1005:            protected static boolean displayQuestion(String question) {
1006:                System.out.println("Question:" + question);
1007:                JFrame f = new JFrame();
1008:                int dialogRet = JOptionPane.showOptionDialog(f, question,
1009:                        "Question", JOptionPane.YES_NO_OPTION,
1010:                        JOptionPane.QUESTION_MESSAGE, null, null, null);
1011:                f.dispose();
1012:                return dialogRet == JOptionPane.OK_OPTION;
1013:            }
1014:
1015:            /**
1016:             * Displays a file save dialog for a generated controller. Pass the default filename and the text for the controller
1017:             */
1018:            protected static String displaySaveDialog(String fileName,
1019:                    String text) {
1020:                JFrame f = new JFrame();
1021:                SaveDialog d = new SaveDialog(f, fileName, text);
1022:                if (d.getCancel()) {
1023:                    f.dispose();
1024:                    return null;
1025:                } else {
1026:                    f.dispose();
1027:                    return d.getFileName();
1028:                }
1029:
1030:            }
1031:
1032:            private static String fixColName(String name) {
1033:                StringBuffer sb = new StringBuffer(name.length());
1034:                for (int i = 0; i < name.length(); i++) {
1035:                    char c = name.charAt(i);
1036:                    if (c == '.' || c == '-') {
1037:                        c = '_';
1038:                    } else {
1039:                        c = Character.toUpperCase(c);
1040:                    }
1041:
1042:                    sb.append(c);
1043:                }
1044:                return sb.toString();
1045:            }
1046:
1047:            /**
1048:             * Fixes HTML characters in controller code and converts then to regular ASCII.
1049:             * It will convert &nbsp; &quot; and <BR>
1050:             */
1051:            protected static String fixHtml(String line) {
1052:                StringBuffer ret = new StringBuffer(line.length());
1053:                for (int i = 0; i < line.length(); i++) {
1054:                    char c = line.charAt(i);
1055:                    if (c == '&') {
1056:                        int ndx = line.indexOf(';', i);
1057:                        String text = line.substring(i, ndx + 1);
1058:                        if (text.equals("&nbsp;")) {
1059:                            ret.append(' ');
1060:                            i = ndx;
1061:                        } else if (text.equals("&quot;")) {
1062:                            ret.append('"');
1063:                            i = ndx;
1064:                        }
1065:                    } else if (c == '<') {
1066:                        int ndx = line.indexOf('>', i);
1067:                        String text = line.substring(i, ndx + 1);
1068:                        if (text.equals("<BR>"))
1069:                            ret.append("\n");
1070:                        i = ndx;
1071:                    } else
1072:                        ret.append(c);
1073:                }
1074:                return ret.toString();
1075:            }
1076:
1077:            private static String fixSlashes(String in) {
1078:                StringBuffer ret = new StringBuffer(in.length());
1079:                for (int i = 0; i < in.length(); i++) {
1080:                    char c = in.charAt(i);
1081:                    if (c == '\\')
1082:                        ret.append("\\\\");
1083:                    else
1084:                        ret.append(c);
1085:                }
1086:                return ret.toString();
1087:            }
1088:
1089:            private static String fixSlashesAndQuotes(String in) {
1090:                StringBuffer ret = new StringBuffer(in.length());
1091:                for (int i = 0; i < in.length(); i++) {
1092:                    char c = in.charAt(i);
1093:                    if (c == '\\')
1094:                        ret.append("\\\\");
1095:                    else if (c == '"')
1096:                        ret.append("\\\"");
1097:                    else
1098:                        ret.append(c);
1099:                }
1100:                return ret.toString();
1101:            }
1102:
1103:            /**
1104:             * generates a file name for a controller given the package and the controller class name
1105:             */
1106:            public static String genClassFileName(String packageName,
1107:                    String controllerName, String defaultPath,
1108:                    String defaultApp, boolean dontAppendApp) {
1109:                StringBuffer b = new StringBuffer(defaultPath);
1110:                if (!dontAppendApp) {
1111:                    b.append(File.separatorChar);
1112:                    b.append(defaultApp);
1113:                }
1114:                if (packageName != null && packageName.length() > 0) {
1115:                    b.append(File.separatorChar);
1116:                    for (int i = 0; i < packageName.length(); i++) {
1117:                        char c = packageName.charAt(i);
1118:                        if (c == '.')
1119:                            b.append(File.separatorChar);
1120:                        else
1121:                            b.append(c);
1122:                    }
1123:                }
1124:                b.append(File.separatorChar);
1125:                b.append(controllerName);
1126:                b.append(".java");
1127:                return b.toString();
1128:            }
1129:
1130:            /**
1131:             * Invokes a command to generate either a controller or vars. Pass the url of the page, the command (vars or genController)
1132:             * and the prefix that indicates that the generated code is about to start. The method
1133:             * returns the generated code.
1134:             */
1135:
1136:            protected static String genCommand(String url, String command,
1137:                    String prefix) throws Exception {
1138:                if (command != null)
1139:                    command = url + "?" + command + "=true";
1140:                else
1141:                    command = url;
1142:                URL u = new URL(command);
1143:                HttpURLConnection.setFollowRedirects(false);
1144:                HttpURLConnection conn = (HttpURLConnection) u.openConnection();
1145:
1146:                if (conn.getResponseCode() == HttpURLConnection.HTTP_MOVED_TEMP) {
1147:                    String newLocation = conn.getHeaderField("Location");
1148:                    String cookie = conn.getHeaderField("Set-Cookie");
1149:                    int ndx = cookie.indexOf(";");
1150:                    if (ndx > -1)
1151:                        cookie = cookie.substring(0, ndx);
1152:                    InputStream in = conn.getInputStream();
1153:                    in.close();
1154:                    u = new URL(newLocation);
1155:                    conn = (HttpURLConnection) u.openConnection();
1156:                    conn.setRequestProperty("Cookie", cookie);
1157:                }
1158:
1159:                InputStream in = conn.getInputStream();
1160:                BufferedReader reader = new BufferedReader(
1161:                        new InputStreamReader(in));
1162:                StringBuffer b = new StringBuffer();
1163:                boolean started = (prefix == null);
1164:
1165:                String l = reader.readLine();
1166:                while (l != null) {
1167:                    if (!started && l.equals(prefix))
1168:                        started = true;
1169:                    if (started) {
1170:                        if (l.startsWith("package"))
1171:                            _packageName = l.substring(8, l.length() - 1);
1172:                        else if (l.startsWith("public class")) {
1173:                            _controllerName = l.substring(13);
1174:                            int ndx = _controllerName.indexOf(" ");
1175:                            _controllerName = _controllerName.substring(0, ndx);
1176:                        }
1177:
1178:                        l = fixHtml(l);
1179:                        b.append(l);
1180:                    }
1181:                    l = reader.readLine();
1182:                }
1183:
1184:                reader.close();
1185:                in.close();
1186:                return b.toString();
1187:            }
1188:
1189:            private static String generateModel(String packageName,
1190:                    String className, ModelDialog d) {
1191:                ModelDialog.ColumnDef[] cols = d.getColumns();
1192:                ModelDialog.BucketDef[] buckets = d.getBuckets();
1193:                ModelDialog.SortDef[] sort = d.getSortColumns();
1194:                ModelDialog.JoinDef[] joins = d.getJoins();
1195:                ModelDialog.AliasDef[] alias = d.getAliases();
1196:                ModelDialog.QBECriteriaDef[] qbe = d.getQBECriteria();
1197:                ValidationRuleDefinition[] validations = d.getValidationRules();
1198:                boolean isQBE = d.isQBE();
1199:
1200:                StringBuffer sb = new StringBuffer();
1201:                //package
1202:                append(sb, "package ", 0);
1203:                append(sb, packageName, 0);
1204:                appendLn(sb, ";", 0);
1205:                appendLn(sb, "", 0);
1206:
1207:                //imports
1208:                appendLn(sb, "import com.salmonllc.sql.*;", 0);
1209:                // comments for custom imports
1210:                appendLn(sb, "", 0);
1211:                appendLn(sb, "//$CUSTOMIMPORTS$", 0);
1212:                appendLn(
1213:                        sb,
1214:                        "//Put custom imports between these comments, otherwise they will be overwritten if the model is regenerated",
1215:                        0);
1216:                appendLn(sb, "", 0);
1217:                appendLn(sb, "//$ENDCUSTOMIMPORTS$", 0);
1218:                appendLn(sb, "", 0);
1219:
1220:                //class name
1221:                appendLn(sb, "/**", 0);
1222:                appendLn(sb, " * " + className + ": A SOFIA generated model", 0);
1223:                appendLn(sb, " */", 0);
1224:                append(sb, "public class ", 0);
1225:                append(sb, className, 0);
1226:                if (isQBE)
1227:                    append(sb, " extends QBEBuilder ", 0);
1228:                else
1229:                    append(sb, " extends DataStore ", 0);
1230:                if (d.isRemotable())
1231:                    append(sb, "implements Remotable ", 0);
1232:
1233:                appendLn(sb, "{", 0);
1234:                appendLn(sb, "", 0);
1235:
1236:                if (!isQBE) {
1237:                    //table column constants
1238:                    if (cols.length > 0) {
1239:                        appendLn(sb, "//constants for columns", 1);
1240:                        for (int i = 0; i < cols.length; i++) {
1241:                            String name = cols[i].getName();
1242:                            append(sb, "public static final String ", 1);
1243:                            append(sb, fixColName(name), 0);
1244:                            append(sb, "=\"", 0);
1245:                            append(sb, name, 0);
1246:                            appendLn(sb, "\";", 0);
1247:                        }
1248:                        appendLn(sb, "", 0);
1249:                    }
1250:
1251:                    //bucket column constants
1252:                    if (buckets.length > 0) {
1253:                        appendLn(sb, "//constants for buckets", 1);
1254:                        for (int i = 0; i < buckets.length; i++) {
1255:                            String name = buckets[i].name;
1256:                            append(sb, "public static final String ", 1);
1257:                            append(sb, fixColName(name), 0);
1258:                            append(sb, "=\"", 0);
1259:                            append(sb, name, 0);
1260:                            appendLn(sb, "\";", 0);
1261:                        }
1262:                        appendLn(sb, "", 0);
1263:                    }
1264:                } else {
1265:                    //qbe column constants	
1266:                    if (qbe.length > 0) {
1267:                        appendLn(sb, "//constants for qbe criteria", 1);
1268:                        for (int i = 0; i < qbe.length; i++) {
1269:                            String name = qbe[i].name;
1270:                            append(sb, "public static final String ", 1);
1271:                            append(sb, fixColName(name), 0);
1272:                            append(sb, "=\"", 0);
1273:                            append(sb, name, 0);
1274:                            appendLn(sb, "\";", 0);
1275:                        }
1276:                        appendLn(sb, "", 0);
1277:                    }
1278:                }
1279:
1280:                // comments for custom code
1281:                appendLn(sb, "//$CUSTOMVARS$", 1);
1282:                appendLn(
1283:                        sb,
1284:                        "//Put custom instance variables between these comments, otherwise they will be overwritten if the model is regenerated",
1285:                        1);
1286:                appendLn(sb, "", 1);
1287:                appendLn(sb, "//$ENDCUSTOMVARS$", 1);
1288:                appendLn(sb, "", 1);
1289:
1290:                //constructor
1291:                appendLn(sb, "/**", 1);
1292:                appendLn(sb, " * Create a new " + className + " object.", 1);
1293:                if (!isQBE)
1294:                    appendLn(sb,
1295:                            " * @param appName The SOFIA application name", 1);
1296:                appendLn(sb, " */", 1);
1297:                append(sb, "public ", 1);
1298:                append(sb, className, 0);
1299:
1300:                if (!isQBE) {
1301:                    appendLn(sb, " (String appName) { ", 0);
1302:                    appendLn(sb, "this(appName, null);", 2);
1303:                    appendLn(sb, "}", 1);
1304:                    appendLn(sb, "", 0);
1305:
1306:                    appendLn(sb, "/**", 1);
1307:                    appendLn(sb, " * Create a new " + className + " object.", 1);
1308:                    appendLn(sb,
1309:                            " * @param appName The SOFIA application name", 1);
1310:                    appendLn(sb,
1311:                            " * @param profile The database profile to use", 1);
1312:                    appendLn(sb, " */", 1);
1313:                    append(sb, "public ", 1);
1314:                    append(sb, className, 0);
1315:                    appendLn(sb, " (String appName, String profile) { ", 0);
1316:                    appendLn(sb, "super(appName, profile);", 2);
1317:                } else {
1318:                    appendLn(sb, " () { ", 0);
1319:                }
1320:
1321:                //put everything in a try catch if there are any formats in the buckets or columns or validation rules
1322:                int indent = 2;
1323:
1324:                if (validations.length > 0)
1325:                    indent = 3;
1326:                else if (!isQBE) {
1327:                    for (int i = 0; i < cols.length; i++) {
1328:                        if (cols[i].format != null) {
1329:                            indent = 3;
1330:                            break;
1331:                        }
1332:                    }
1333:                    if (indent == 2) {
1334:                        for (int i = 0; i < buckets.length; i++) {
1335:                            if (buckets[i].format != null) {
1336:                                indent = 3;
1337:                                break;
1338:                            }
1339:                        }
1340:                    }
1341:                }
1342:
1343:                if (indent == 3) {
1344:                    appendLn(sb, "", 0);
1345:                    appendLn(sb, "try {", 2);
1346:                }
1347:
1348:                if (!isQBE) {
1349:                    //add aliases
1350:                    if (alias.length > 0) {
1351:                        appendLn(sb, "", 0);
1352:                        appendLn(sb, "//add aliases", indent);
1353:                        for (int i = 0; i < alias.length; i++) {
1354:                            append(sb, "addTableAlias(computeTableName(\"",
1355:                                    indent);
1356:                            append(sb, alias[i].table, 0);
1357:                            if (alias[i].alias == null)
1358:                                appendLn(sb, "\"),null);", 0);
1359:                            else {
1360:                                append(sb, "\"),\"", 0);
1361:                                append(sb, alias[i].alias, 0);
1362:                                appendLn(sb, "\");", 0);
1363:                            }
1364:                        }
1365:                    }
1366:
1367:                    //add columns
1368:                    if (cols.length > 0) {
1369:                        appendLn(sb, "", 0);
1370:                        appendLn(sb, "//add columns", indent);
1371:                        for (int i = 0; i < cols.length; i++) {
1372:                            String name = fixColName(cols[i].getName());
1373:                            append(sb, "addColumn(computeTableName(\"", indent);
1374:                            if (cols[i].alias != null)
1375:                                append(sb, cols[i].alias, 0);
1376:                            else
1377:                                append(sb, cols[i].def.getTableName(), 0);
1378:                            append(sb, "\"),\"", 0);
1379:                            append(sb, cols[i].def.getColumnName(), 0);
1380:                            append(sb, "\",", 0);
1381:                            append(sb, translateDSType(cols[i].def
1382:                                    .getDSDataType()), 0);
1383:                            append(sb, ",", 0);
1384:                            append(sb, cols[i].def.isPkey() ? "true" : "false",
1385:                                    0);
1386:                            append(sb, ",", 0);
1387:                            append(sb, cols[i].updateable ? "true" : "false", 0);
1388:                            append(sb, ",", 0);
1389:                            append(sb, name, 0);
1390:                            appendLn(sb, ");", 0);
1391:                            if (cols[i].format != null) {
1392:                                append(sb, "setFormat(", indent);
1393:                                append(sb, name.toUpperCase(), 0);
1394:                                append(sb, ",\"", 0);
1395:                                append(sb, cols[i].format, 0);
1396:                                appendLn(sb, "\");", 0);
1397:                            }
1398:                        }
1399:                    }
1400:
1401:                    //add buckets
1402:                    if (buckets.length > 0) {
1403:                        appendLn(sb, "", 0);
1404:                        appendLn(sb, "//add buckets", indent);
1405:                        for (int i = 0; i < buckets.length; i++) {
1406:                            String name = buckets[i].name;
1407:                            append(sb, "addBucket(", indent);
1408:                            append(sb, fixColName(name), 0);
1409:                            append(sb, ",", 0);
1410:                            append(sb,
1411:                                    translateDSType(buckets[i].datatype.type),
1412:                                    0);
1413:                            appendLn(sb, ");", 0);
1414:                            if (buckets[i].format != null) {
1415:                                append(sb, "setFormat(", indent);
1416:                                append(sb, name.toUpperCase(), 0);
1417:                                append(sb, ",\"", 0);
1418:                                append(sb, buckets[i].format, 0);
1419:                                appendLn(sb, "\");", 0);
1420:                            }
1421:                        }
1422:                    }
1423:
1424:                    //joins
1425:                    if (joins.length > 0) {
1426:                        appendLn(sb, "", 0);
1427:                        appendLn(sb, "//add joins", indent);
1428:                        for (int i = 0; i < joins.length; i++) {
1429:                            append(sb, "addJoin(", indent);
1430:                            append(sb, genJoin(joins[i].leftSide), 0);
1431:                            append(sb, ",", 0);
1432:                            append(sb, genJoin(joins[i].rightSide), 0);
1433:                            append(sb, ",", 0);
1434:                            append(sb, joins[i].outer ? "true" : "false", 0);
1435:                            appendLn(sb, ");", 0);
1436:                        }
1437:                    }
1438:
1439:                    //Order by
1440:                    if (sort.length > 0) {
1441:                        appendLn(sb, "", 0);
1442:                        appendLn(sb, "//set order by", indent);
1443:                        append(sb, "setOrderBy(", indent);
1444:                        for (int i = 0; i < sort.length; i++) {
1445:                            String col = "";
1446:                            if (sort[i].alias != null)
1447:                                col = sort[i].alias + "."
1448:                                        + sort[i].def.getColumnName();
1449:                            else
1450:                                col = sort[i].def.getTableName() + "."
1451:                                        + sort[i].def.getColumnName();
1452:
1453:                            append(sb, "computeTableAndFieldName(\"", 0);
1454:                            append(sb, col, 0);
1455:                            append(sb, "\") + \" ", 0);
1456:                            append(sb, sort[i].getDir(), 0);
1457:                            append(sb, ",\" + ", 0);
1458:                        }
1459:                        sb.setLength(sb.length() - 5);
1460:                        append(sb, "\"", 0);
1461:                        appendLn(sb, ");", 0);
1462:                    }
1463:                } else {
1464:                    //QBECriteria
1465:                    //add buckets
1466:                    if (qbe.length > 0) {
1467:                        appendLn(sb, "", 0);
1468:                        appendLn(sb, "//add qbe criteria", indent);
1469:                        for (int i = 0; i < qbe.length; i++) {
1470:                            String name = qbe[i].name;
1471:                            append(sb, "addCriteria(", indent);
1472:                            append(sb, fixColName(name), 0);
1473:                            append(sb, ",", 0);
1474:                            append(sb, translateQBEType(qbe[i].type.type), 0);
1475:                            append(sb, ",\"", 0);
1476:                            append(sb, qbe[i].colList, 0);
1477:                            appendLn(sb, "\");", 0);
1478:                        }
1479:                    }
1480:                }
1481:                if (validations.length > 0) {
1482:                    appendLn(sb, "", 0);
1483:                    appendLn(sb, "//add validations", indent);
1484:                    for (int i = 0; i < validations.length; i++) {
1485:                        String name = fixColName(validations[i].columnName);
1486:                        ValidationRule rule = validations[i].rule;
1487:                        String errorMessage = rule.getErrorMessage();
1488:                        if (errorMessage == null)
1489:                            errorMessage = "null";
1490:                        else
1491:                            errorMessage = "\""
1492:                                    + fixSlashesAndQuotes(rule
1493:                                            .getErrorMessage()) + "\"";
1494:
1495:                        if (rule.getRuleType() == ValidationRule.TYPE_REQUIRED) {
1496:                            append(sb, "addRequiredRule(", indent);
1497:                            append(sb, name, 0);
1498:                            append(sb, ",", 0);
1499:                            append(sb, errorMessage, 0);
1500:                            appendLn(sb, ");", 0);
1501:                        } else if (rule.getRuleType() == ValidationRule.TYPE_TYPE_CHECK) {
1502:                            append(sb, "addTypeCheckRule(", indent);
1503:                            append(sb, name, 0);
1504:                            append(sb, ",", 0);
1505:                            append(sb, errorMessage, 0);
1506:                            appendLn(sb, ");", 0);
1507:                        } else if (rule.getRuleType() == ValidationRule.TYPE_RANGE) {
1508:                            append(sb, "addRangeRule(", indent);
1509:                            append(sb, name, 0);
1510:                            if (rule.getMinValue() == null)
1511:                                append(sb, ",null", 0);
1512:                            else {
1513:                                append(sb, ",convertValue(\"", 0);
1514:                                append(sb, fixSlashesAndQuotes((String) rule
1515:                                        .getMinValue()), 0);
1516:                                append(sb, "\",", 0);
1517:                                append(sb, name, 0);
1518:                                append(sb, ")", 0);
1519:                            }
1520:                            if (rule.getMaxValue() == null)
1521:                                append(sb, ",null", 0);
1522:                            else {
1523:                                append(sb, ",convertValue(\"", 0);
1524:                                append(sb, fixSlashesAndQuotes((String) rule
1525:                                        .getMaxValue()), 0);
1526:                                append(sb, "\",", 0);
1527:                                append(sb, name, 0);
1528:                                append(sb, ")", 0);
1529:                            }
1530:                            append(sb, ",", 0);
1531:                            append(sb, errorMessage, 0);
1532:                            appendLn(sb, ");", 0);
1533:                        } else if (rule.getRuleType() == ValidationRule.TYPE_EXPRESSION) {
1534:                            append(sb, "addExpressionRule(", indent);
1535:                            append(sb, name, 0);
1536:                            if (rule.getExpression() == null)
1537:                                append(sb, ",null", 0);
1538:                            else {
1539:                                append(sb, ",\"", 0);
1540:                                append(sb, fixSlashesAndQuotes((String) rule
1541:                                        .getExpression()), 0);
1542:                                append(sb, "\"", 0);
1543:                            }
1544:                            append(sb, ",", 0);
1545:                            append(sb, errorMessage, 0);
1546:                            appendLn(sb, ");", 0);
1547:                        } else if (rule.getRuleType() == ValidationRule.TYPE_JAVASCRIPT) {
1548:                            append(sb, "addJavaScriptRule(", indent);
1549:                            append(sb, name, 0);
1550:                            if (rule.getExpression() == null)
1551:                                append(sb, ",null", 0);
1552:                            else {
1553:                                append(sb, ",\"", 0);
1554:                                append(sb, fixSlashesAndQuotes((String) rule
1555:                                        .getExpression()), 0);
1556:                                append(sb, "\"", 0);
1557:                            }
1558:                            append(sb, ",", 0);
1559:                            append(sb, errorMessage, 0);
1560:                            appendLn(sb, ");", 0);
1561:
1562:                        } else if (rule.getRuleType() == ValidationRule.TYPE_REGULAR_EXPRESSION) {
1563:                            append(sb, "addReqularExpressionRule(", indent);
1564:                            append(sb, name, 0);
1565:                            if (rule.getExpression() == null)
1566:                                append(sb, ",null", 0);
1567:                            else {
1568:                                append(sb, ",\"", 0);
1569:                                append(sb, fixSlashesAndQuotes((String) rule
1570:                                        .getExpression()), 0);
1571:                                append(sb, "\"", 0);
1572:                            }
1573:                            append(sb, ",", 0);
1574:                            append(sb, errorMessage, 0);
1575:                            appendLn(sb, ");", 0);
1576:
1577:                        } else if (rule.getRuleType() == ValidationRule.TYPE_LOOKUP) {
1578:                            append(sb, "addLookupRule(", indent);
1579:                            append(sb, name, 0);
1580:                            if (rule.getLookupTable() == null)
1581:                                append(sb, ",null", 0);
1582:                            else {
1583:                                append(sb, ",\"", 0);
1584:                                append(sb, fixSlashesAndQuotes((String) rule
1585:                                        .getLookupTable()), 0);
1586:                                append(sb, "\"", 0);
1587:                            }
1588:                            if (rule.getLookupExpression() == null)
1589:                                append(sb, ",null", 0);
1590:                            else {
1591:                                append(sb, ",\"", 0);
1592:                                append(sb, fixSlashesAndQuotes((String) rule
1593:                                        .getLookupExpression()), 0);
1594:                                append(sb, "\"", 0);
1595:                            }
1596:                            if (rule.getDesciptionColumn() == null)
1597:                                append(sb, ",null", 0);
1598:                            else {
1599:                                append(sb, ",\"", 0);
1600:                                append(sb, fixSlashesAndQuotes((String) rule
1601:                                        .getDesciptionColumn()), 0);
1602:                                append(sb, "\"", 0);
1603:                            }
1604:                            if (rule.getDescriptionBucket() == null)
1605:                                append(sb, ",null", 0);
1606:                            else {
1607:                                append(sb, ",\"", 0);
1608:                                append(sb, fixSlashesAndQuotes((String) rule
1609:                                        .getDescriptionBucket()), 0);
1610:                                append(sb, "\"", 0);
1611:                            }
1612:                            append(sb, ",", 0);
1613:                            append(sb, errorMessage, 0);
1614:                            appendLn(sb, ");", 0);
1615:                        }
1616:
1617:                    }
1618:
1619:                }
1620:                //end try catch
1621:                if (indent == 3) {
1622:                    appendLn(sb, "}", 2);
1623:                    appendLn(sb, "catch (DataStoreException e) {", 2);
1624:                    appendLn(
1625:                            sb,
1626:                            "com.salmonllc.util.MessageLog.writeErrorMessage(e,this);",
1627:                            3);
1628:                    appendLn(sb, "}", 2);
1629:                }
1630:
1631:                // comments for custom code
1632:                appendLn(sb, "", 0);
1633:                appendLn(sb, "//$CUSTOMCONSTRUCTOR$", 2);
1634:                appendLn(
1635:                        sb,
1636:                        "//Put custom constructor code between these comments, otherwise it be overwritten if the model is regenerated",
1637:                        2);
1638:                appendLn(sb, "", 0);
1639:                appendLn(sb, "//$ENDCUSTOMCONSTRUCTOR$", 2);
1640:                appendLn(sb, "", 0);
1641:
1642:                //end of constructor
1643:                appendLn(sb, "}", 1);
1644:
1645:                if (!isQBE) {
1646:                    //get and set methods for columns
1647:                    for (int i = 0; i < cols.length; i++) {
1648:                        String name = fixColName(cols[i].getName());
1649:                        genGetSetMethods(cols[i].getName(), "column", name,
1650:                                cols[i].def.getDSDataType(), true, sb, 1);
1651:                    }
1652:
1653:                    //get and set methods for buckets
1654:                    for (int i = 0; i < buckets.length; i++) {
1655:                        genGetSetMethods(buckets[i].name, "bucket",
1656:                                buckets[i].name, buckets[i].datatype.type,
1657:                                false, sb, 1);
1658:                    }
1659:                }
1660:
1661:                // comments for custom code
1662:                appendLn(sb, "", 1);
1663:                appendLn(sb, "//$CUSTOMMETHODS$", 1);
1664:                appendLn(
1665:                        sb,
1666:                        "//Put custom methods between these comments, otherwise they will be overwritten if the model is regenerated",
1667:                        1);
1668:                appendLn(sb, "", 1);
1669:                appendLn(sb, "//$ENDCUSTOMMETHODS$", 1);
1670:                appendLn(sb, "", 1);
1671:
1672:                //end of class
1673:                appendLn(sb, "}", 0);
1674:
1675:                return sb.toString();
1676:
1677:            }
1678:
1679:            private static void genGetSetMethods(String name,
1680:                    String colOrBucket, String constant, int type,
1681:                    boolean changeCase, StringBuffer sb, int indent) {
1682:                Class test = null;
1683:                try {
1684:                    test = Class.forName("com.salmonllc.sql.DataStore");
1685:                } catch (ClassNotFoundException e) {
1686:                }
1687:
1688:                String methName = translateConstantToMethod(constant,
1689:                        changeCase);
1690:                String methType = translateDSTypeToJavaType(type);
1691:                Class methClass = translateDSTypeToJavaClass(type);
1692:
1693:                if (!doesMethodExist(test, "get" + methName, null, null)) {
1694:                    appendLn(sb, "", 0);
1695:                    appendLn(sb, "/**", indent);
1696:                    appendLn(sb, " * Retrieve the value of the " + name + " "
1697:                            + colOrBucket + " for the current row.", indent);
1698:                    appendLn(sb, " * @return " + methType, indent);
1699:                    appendLn(sb, " * @throws DataStoreException", indent);
1700:                    appendLn(sb, " */ ", indent);
1701:                    append(sb, "public ", indent);
1702:                    append(sb, methType, 0);
1703:                    append(sb, " get", 0);
1704:                    append(sb, methName, 0);
1705:                    appendLn(sb, "() throws DataStoreException {", 0);
1706:                    append(sb, "return ", indent + 1);
1707:                    append(sb, " get", 0);
1708:                    append(sb, translateDSTypeToMethod(type), 0);
1709:                    append(sb, "(", 0);
1710:                    append(sb, constant.toUpperCase(), 0);
1711:                    appendLn(sb, ");", 0);
1712:                    appendLn(sb, "}", indent);
1713:                }
1714:
1715:                if (!doesMethodExist(test, "get" + methName, Integer.TYPE, null)) {
1716:                    appendLn(sb, "", 0);
1717:                    appendLn(sb, "/**", indent);
1718:                    appendLn(sb, " * Retrieve the value of the " + name + " "
1719:                            + colOrBucket + " for the specified row.", indent);
1720:                    appendLn(sb, " * @param row which row in the table", indent);
1721:                    appendLn(sb, " * @return " + methType, indent);
1722:                    appendLn(sb, " * @throws DataStoreException", indent);
1723:                    appendLn(sb, " */ ", indent);
1724:                    append(sb, "public ", indent);
1725:                    append(sb, methType, 0);
1726:                    append(sb, " get", 0);
1727:                    append(sb, methName, 0);
1728:                    appendLn(sb, "(int row) throws DataStoreException {", 0);
1729:                    append(sb, "return ", indent + 1);
1730:                    append(sb, " get", 0);
1731:                    append(sb, translateDSTypeToMethod(type), 0);
1732:                    append(sb, "(row,", 0);
1733:                    append(sb, constant.toUpperCase(), 0);
1734:                    appendLn(sb, ");", 0);
1735:                    appendLn(sb, "}", indent);
1736:                }
1737:
1738:                if (!doesMethodExist(test, "set" + methName, methClass, null)) {
1739:                    appendLn(sb, "", 0);
1740:                    appendLn(sb, "/**", indent);
1741:                    appendLn(sb, " * Set the value of the " + name + " "
1742:                            + colOrBucket + " for the current row.", indent);
1743:                    appendLn(sb, " * @param newValue the new item value",
1744:                            indent);
1745:                    appendLn(sb, " * @throws DataStoreException", indent);
1746:                    appendLn(sb, " */ ", indent);
1747:                    append(sb, "public void", indent);
1748:                    append(sb, " set", 0);
1749:                    append(sb, methName, 0);
1750:                    append(sb, "(", 0);
1751:                    append(sb, methType, 0);
1752:                    appendLn(sb, " newValue) throws DataStoreException {", 0);
1753:                    append(sb, "set", indent + 1);
1754:                    append(sb, translateDSTypeToMethod(type), 0);
1755:                    append(sb, "(", 0);
1756:                    append(sb, constant.toUpperCase(), 0);
1757:                    appendLn(sb, ", newValue);", 0);
1758:                    appendLn(sb, "}", indent);
1759:                }
1760:
1761:                if (!doesMethodExist(test, "set" + methName, Integer.TYPE,
1762:                        methClass)) {
1763:                    appendLn(sb, "", 0);
1764:                    appendLn(sb, "/**", indent);
1765:                    appendLn(sb, " * Set the value of the " + name + " "
1766:                            + colOrBucket + " for the specified row.", indent);
1767:                    appendLn(sb, " * @param row which row in the table", indent);
1768:                    appendLn(sb, " * @param newValue the new item value",
1769:                            indent);
1770:                    appendLn(sb, " * @throws DataStoreException", indent);
1771:                    appendLn(sb, " */ ", indent);
1772:                    append(sb, "public void", indent);
1773:                    append(sb, " set", 0);
1774:                    append(sb, methName, 0);
1775:                    append(sb, "(int row,", 0);
1776:                    append(sb, methType, 0);
1777:                    appendLn(sb, " newValue) throws DataStoreException {", 0);
1778:                    append(sb, "set", indent + 1);
1779:                    append(sb, translateDSTypeToMethod(type), 0);
1780:                    append(sb, "(row,", 0);
1781:                    append(sb, constant.toUpperCase(), 0);
1782:                    appendLn(sb, ", newValue);", 0);
1783:                    appendLn(sb, "}", indent);
1784:                }
1785:            }
1786:
1787:            private static boolean doesMethodExist(Class test, String methName,
1788:                    Class parm1, Class parm2) {
1789:                Class parms[];
1790:                if (parm1 == null)
1791:                    parms = new Class[0];
1792:                else if (parm2 == null) {
1793:                    parms = new Class[1];
1794:                    parms[0] = parm1;
1795:                } else {
1796:                    parms = new Class[2];
1797:                    parms[0] = parm1;
1798:                    parms[1] = parm2;
1799:                }
1800:
1801:                boolean exists = false;
1802:                if (test != null) {
1803:                    try {
1804:                        Method m = test.getMethod(methName, parms);
1805:                        exists = true;
1806:                    } catch (Exception e1) {
1807:
1808:                    }
1809:                }
1810:                return exists;
1811:            }
1812:
1813:            private static String genJoin(String join) {
1814:                StringBuffer sb = new StringBuffer();
1815:                StringTokenizer st = new StringTokenizer(join, ",");
1816:                while (st.hasMoreTokens()) {
1817:                    sb.append("computeTableAndFieldName(\"");
1818:                    sb.append(st.nextToken());
1819:                    sb.append("\") + \",\" +");
1820:                }
1821:                if (sb.length() > 0)
1822:                    sb.setLength(sb.length() - 8);
1823:                return sb.toString();
1824:
1825:            }
1826:
1827:            public static String getProject() {
1828:                return _projectName;
1829:            }
1830:
1831:            public static String getProjectProperty(String property) {
1832:                if (_projectName == null)
1833:                    return property;
1834:                Props p = Props.getSystemProps();
1835:                if (p.getProperty(_projectName + "." + property) != null)
1836:                    return _projectName + "." + property;
1837:                else
1838:                    return property;
1839:            }
1840:
1841:            /**
1842:             *  Figures out what the url would be for a given JSP on the file system.
1843:             */
1844:            protected static String getURLFromFile(String host, String webPage,
1845:                    String defaultWebApp, String defaultFWApp, String command) {
1846:                int ndx = -1;
1847:                if ((defaultWebApp == null || defaultWebApp.trim().length() == 0)
1848:                        && _serverType == SERVER_WEBLOGIC6) {
1849:                    ndx = webPage.indexOf("DefaultWebApp" + File.separator);
1850:                    defaultWebApp = null;
1851:                } else if ((defaultWebApp == null || defaultWebApp.trim()
1852:                        .length() == 0)
1853:                        && (defaultFWApp != null)) {
1854:                    ndx = webPage.indexOf(defaultFWApp);
1855:                    defaultWebApp = "";
1856:                } else
1857:                    ndx = webPage.indexOf(defaultWebApp + File.separator);
1858:                if (ndx != -1) {
1859:                    StringBuffer b = new StringBuffer(webPage.length());
1860:                    b.append("http://");
1861:                    b.append(host);
1862:
1863:                    if (defaultWebApp != null && defaultWebApp.length() > 0) {
1864:                        b.append("/");
1865:                        int pos = defaultWebApp.indexOf(File.separator);
1866:                        if (pos > -1)
1867:                            b.append(defaultWebApp.substring(0, pos));
1868:                        else
1869:                            b.append(defaultWebApp);
1870:                    } else if (_serverType == SERVER_WEBLOGIC6)
1871:                        defaultWebApp = "DefaultWebApp";
1872:                    else
1873:                        defaultWebApp = defaultFWApp;
1874:
1875:                    b.append("/");
1876:                    for (int j = ndx + defaultWebApp.length() + 1; j < webPage
1877:                            .length(); j++) {
1878:                        char c = webPage.charAt(j);
1879:                        if (c == File.separatorChar)
1880:                            b.append("/");
1881:                        else
1882:                            b.append(c);
1883:                    }
1884:                    if (command != null) {
1885:                        b.append("?");
1886:                        b.append(command);
1887:                        b.append("=true");
1888:                    }
1889:                    return b.toString();
1890:                }
1891:                return null;
1892:            }
1893:
1894:            public static String getXmlFile() {
1895:                return _xmlFile;
1896:            }
1897:
1898:            /**
1899:             * Returns true if a class name is valid
1900:             */
1901:            public static boolean isClassNameValid(String name,
1902:                    boolean incPackage) {
1903:                if (name == null)
1904:                    return false;
1905:                name = name.trim();
1906:                if (name.length() == 0)
1907:                    return false;
1908:                if (name.startsWith(".") || name.endsWith("."))
1909:                    return false;
1910:                if (name.indexOf(".") == -1 && incPackage)
1911:                    return false;
1912:                if (name.indexOf(" ") > -1)
1913:                    return false;
1914:                return true;
1915:            }
1916:
1917:            /**
1918:             * Returns true if a class name is valid
1919:             */
1920:            public static boolean isXMLNameValid(String name) {
1921:                if (name == null)
1922:                    return false;
1923:                name = name.trim();
1924:                if (name.length() == 0)
1925:                    return false;
1926:                if (!name.toLowerCase().endsWith(".xml"))
1927:                    return false;
1928:                return true;
1929:            }
1930:
1931:            public static void main(String args[]) {
1932:                Props p = null;
1933:                try {
1934:                    p = parseArgs(args);
1935:                } catch (Exception e) {
1936:                    displayError(e.toString());
1937:                    System.exit(-1);
1938:                }
1939:
1940:                try {
1941:                    if (_defaultLF)
1942:                        UIManager.setLookAndFeel(UIManager
1943:                                .getSystemLookAndFeelClassName());
1944:                    if (_redeploy
1945:                            && (_serverType == SERVER_TOMCAT40
1946:                                    || _serverType == SERVER_TOMCAT41 || _serverType == SERVER_TOMCAT50)) {
1947:                        String tomcatManagerApp = p.getProperty(
1948:                                Props.IDE_TOMCAT_MANAGER_APP, "manager");
1949:                        String tomcatManagerUID = p
1950:                                .getProperty(Props.IDE_SERVER_MANAGER_ID);
1951:                        String tomcatManagerPW = p
1952:                                .getProperty(Props.IDE_SERVER_MANAGER_PW);
1953:                        System.out.println("Redploying web appliction:"
1954:                                + _defaultWebApp);
1955:                        System.out.println(tomcat4Command(_defaultHost,
1956:                                tomcatManagerApp, _defaultWebApp, "reload",
1957:                                tomcatManagerUID, tomcatManagerPW));
1958:                    } else if (_redeploy && _serverType == SERVER_WEBLOGIC6) {
1959:                        String webLogicPath = p
1960:                                .getProperty(Props.IDE_WEBLOGIC_APPLICATION_PATH);
1961:                        redeployWeblogicApplication(webLogicPath,
1962:                                _defaultWebApp);
1963:                    } else if (_restart
1964:                            && (_serverType == SERVER_TOMCAT40
1965:                                    || _serverType == SERVER_TOMCAT41 || _serverType == SERVER_TOMCAT50)) {
1966:                        if (_useAppProperties)
1967:                            setPropsPath(null);
1968:                        if (_runBrowser)
1969:                            TomcatBootstrap.execute(TomcatBootstrap.RESTART,
1970:                                    _browser, _webPage, _serverType);
1971:                        else
1972:                            TomcatBootstrap.execute(TomcatBootstrap.RESTART,
1973:                                    null, null, _serverType);
1974:                        System.exit(0);
1975:                    } else if (_stop
1976:                            && (_serverType == SERVER_TOMCAT40
1977:                                    || _serverType == SERVER_TOMCAT41 || _serverType == SERVER_TOMCAT50)) {
1978:                        System.out.println("Stopping Tomcat");
1979:                        TomcatBootstrap.execute(TomcatBootstrap.STOP, null,
1980:                                null, _serverType);
1981:                        System.out.println("Tomcat Stopped");
1982:
1983:                    }
1984:                } catch (Exception e) {
1985:                    displayError(e);
1986:                }
1987:
1988:                if (_runDreamweaver) {
1989:                    System.out
1990:                            .println("Running Dreamweaver" + _dreamWeaverPath);
1991:                    runDreamweaver(_dreamWeaverPath, _dreamWeaverFile);
1992:                } else if (_genController) {
1993:                    setPropsPath();
1994:                    try {
1995:                        System.out.println("Generating Controller:" + _webPage);
1996:                        String controller = genCommand(_webPage,
1997:                                "generateCode", "//package statement");
1998:                        if (_controllerName.equals("GeneratedController"))
1999:                            displayError("Please specify the controller attribute in this jsp's framework\npage tag before running this command.");
2000:                        else if (!isClassNameValid(_controllerName, false))
2001:                            displayError("The specified controller name in the page tag is invalid\nThe controller must have a valid Java class name.");
2002:                        else if (_packageName == null
2003:                                || _packageName.trim().length() == 0)
2004:                            displayError("The specified controller name in the page tag must contain a package name.");
2005:                        saveClass(genClassFileName(_packageName,
2006:                                _controllerName, _defaultSourcePath,
2007:                                _defaultFwApp, _dontAppendProject), controller);
2008:                        System.exit(0);
2009:                    } catch (Exception e) {
2010:                        if (!_webPage.startsWith("http")) {
2011:                            displayError("Could not translate the filename for the JSP into a valid URL on the server. A likely cause is:\nThe web application name in the Salmon properties does not match the web application name you are using (make sure it matches exactly including case).\nYou can change the setting in the Salmon Properties dialog.");
2012:                        } else if (e instanceof  IOException) {
2013:                            displayError("An error occured on the server generating the controller from the JSP:\n("
2014:                                    + e.toString()
2015:                                    + ").\nMake sure the JSP is valid and can be compiled into a servlet and executed.\nA few ways test if the page is valid are: Opening the page in Dreamweaver and running the URL in a browser.\nIn both cases look for errors in either Dreamweaver or the browser and on the server console in the IDE.");
2016:                        } else
2017:                            displayError(e);
2018:                    }
2019:                } else if (_genVars) {
2020:                    setPropsPath();
2021:                    try {
2022:                        System.out.println("Generating Variables:"
2023:                                + _actualFileName);
2024:                        String webApp = _defaultWebApp;
2025:                        if (webApp != null) {
2026:                            int pos = webApp.indexOf(File.separator);
2027:                            if (pos > -1)
2028:                                webApp = webApp.substring(0, pos);
2029:
2030:                        }
2031:                        String url = "http://" + _defaultHost + "/" + webApp
2032:                                + "/" + "Translator" + "?HeaderLine=*"
2033:                                + _defaultFwApp + "*&InputFile="
2034:                                + Util.urlEncode(_actualFileName);
2035:                        displayCutPasteDialog(genCommand(url, null, null));
2036:                    } catch (Exception e) {
2037:                        if (!_webPage.startsWith("http")) {
2038:                            displayError("Could not translate the filename for the JSP into a valid URL on the server. A likely cause is:\nThe web application name in the Salmon properties does not match the web application name you are using (make sure it matches exactly including case).\nYou can change the setting in the Salmon Properties dialog.");
2039:                        } else if (e instanceof  IOException) {
2040:                            displayError("An error occured on the server generating instance variables from the JSP:\n("
2041:                                    + e.toString()
2042:                                    + ").\nMake sure the JSP is valid and can be compiled into a servlet and executed.\nA few ways test if the page is valid are: Opening the page in Dreamweaver and running the URL in a browser.\nIn both cases look for errors in either Dreamweaver or the browser and on the server console in the IDE.");
2043:                        } else
2044:                            displayError(e);
2045:                    }
2046:                } else if (_runBrowser) {
2047:                    System.out.println("Launching Browser:" + _browser);
2048:                    System.out.println(runExe(_browser, _webPage));
2049:                } else if (_setProperties) {
2050:                    changeProperties(_setEclipseProperties);
2051:                } else if (_genModel) {
2052:                    displayModelDialog();
2053:                } else if (_genListForm) {
2054:                    setPropsPath();
2055:                    displayListFormDialog();
2056:                } else if (_genProject) {
2057:                    createProject();
2058:                } else if (_makeDefault) {
2059:                    makePageDefault();
2060:                } else if (_siteMap) {
2061:                    displaySiteMapDialog();
2062:                }
2063:
2064:                System.exit(0);
2065:            }
2066:
2067:            public static void setPropsPath() {
2068:                if (_useAppProperties)
2069:                    setPropsPath(_appPropsPath);
2070:            }
2071:
2072:            private static void setPropsPath(String path) {
2073:                if (path == null)
2074:                    path = "";
2075:                System.setProperty("salmon.props.path", path);
2076:                Props.setPropsPath(path, false);
2077:            }
2078:
2079:            /**
2080:             *  Parses the arguments passed to the main method.
2081:             *  Valid ARGS are
2082:             *      -RUNDREAMWEAVER - Run Dreamweaver and opens a file if specified
2083:             *      -REDEPLOY - Redeploys the default web application
2084:             *      -RUNBROWSER - Runs a browser. This should be followed by a browser name from the System.properties file (IE,Netscape4,etc). Used in conjunction with the -URL arg
2085:             *      -GENCONTROLLER - Generates a controller for a JSP, Used in conjunction with the -URL arg
2086:             *      -GENVARS - Generates the instance variables for a JSP, Used in conjunction with the -URL arg
2087:             *      -URL - Specify the URL or file for a browser to run or code to be generated from
2088:             *      -SETPROPS - Edit the property file settings for the IDE
2089:             *      -GENMODEL - Open a dialog that generates a datastore model
2090:             */
2091:            protected static Props parseArgs(String args[]) throws Exception {
2092:
2093:                Props p = Props.getSystemProps();
2094:                _useAppProperties = p.getBooleanProperty(
2095:                        Props.IDE_USE_APP_PROPERTIES, false);
2096:                _defaultWebApp = p.getProperty(Props.IDE_WEB_APP);
2097:                _defaultFwApp = p.getProperty(Props.IDE_DEFAULT_FRAMEWORK_APP);
2098:                _defaultHost = p.getProperty(Props.IDE_DEFAULT_HOST,
2099:                        "127.0.0.1:8080");
2100:                _dreamWeaverPath = p.getProperty(Props.IDE_DREAMWEAVER_PATH);
2101:                _defaultSourcePath = p
2102:                        .getProperty(Props.IDE_DEFAULT_SOURCE_PATH);
2103:                _serverType = p.getProperty(Props.IDE_SERVER_TYPE);
2104:                if (_serverType == null)
2105:                    _serverType = SERVER_TOMCAT40;
2106:                else if (_serverType.equals(SERVER_WEBLOGIC6))
2107:                    _serverType = SERVER_WEBLOGIC6;
2108:                else if (_serverType.equals(SERVER_TOMCAT41))
2109:                    _serverType = SERVER_TOMCAT41;
2110:                else if (_serverType.equals(SERVER_TOMCAT50))
2111:                    _serverType = SERVER_TOMCAT50;
2112:                else
2113:                    _serverType = SERVER_TOMCAT40;
2114:                _webPage = p.getProperty(Props.IDE_DEFAULT_RUN_URL);
2115:
2116:                //If there is a project, some of the args may change based on the project name
2117:                for (int i = 0; i < args.length; i++) {
2118:                    if (args[i].equalsIgnoreCase("-PROJECT")) {
2119:                        if (i < (args.length - 1)) {
2120:                            int next = i + 1;
2121:                            if (!args[next].startsWith("-")) {
2122:                                _projectName = args[next];
2123:
2124:                                String defaultWebApp = p
2125:                                        .getProperty(_projectName + "."
2126:                                                + Props.IDE_WEB_APP);
2127:                                if (defaultWebApp != null)
2128:                                    _defaultWebApp = defaultWebApp;
2129:
2130:                                String defaultFwApp = p
2131:                                        .getProperty(_projectName
2132:                                                + "."
2133:                                                + Props.IDE_DEFAULT_FRAMEWORK_APP);
2134:                                if (defaultFwApp != null)
2135:                                    _defaultFwApp = defaultFwApp;
2136:
2137:                                String defaultSourcePath = p
2138:                                        .getProperty(_projectName + "."
2139:                                                + Props.IDE_DEFAULT_SOURCE_PATH);
2140:                                if (defaultSourcePath != null)
2141:                                    _defaultSourcePath = defaultSourcePath;
2142:
2143:                                String webPage = p.getProperty(_projectName
2144:                                        + "." + Props.IDE_DEFAULT_RUN_URL);
2145:                                if (webPage != null)
2146:                                    _webPage = webPage;
2147:                            }
2148:                        }
2149:                    }
2150:                }
2151:
2152:                //compute the http version of the web page if it is a file system path
2153:                if (_webPage != null && !_webPage.startsWith("http")) {
2154:                    String temp = getURLFromFile(_defaultHost, _webPage,
2155:                            _defaultWebApp, _defaultFwApp, null);
2156:                    if (temp != null)
2157:                        _webPage = temp;
2158:                }
2159:
2160:                //Go through the rest of the args
2161:                for (int i = 0; i < args.length; i++) {
2162:                    if (args[i].equalsIgnoreCase("-RUNDREAMWEAVER")) {
2163:                        _runDreamweaver = true;
2164:                        if (i < (args.length - 1)) {
2165:                            int next = i + 1;
2166:                            if (!args[next].startsWith("-"))
2167:                                _dreamWeaverFile = args[next];
2168:                            if (_dreamWeaverFile != null
2169:                                    && !_dreamWeaverFile.endsWith(".jsp")
2170:                                    && !_dreamWeaverFile.endsWith(".htm")
2171:                                    && !_dreamWeaverFile.endsWith(".html")
2172:                                    && !_dreamWeaverFile.endsWith(".xml")
2173:                                    && !_dreamWeaverFile.endsWith(".tld")) {
2174:                                throw new Exception(
2175:                                        "A file must be a jsp, html, xml or tld file to edit with Dreamweaver. \n Please select a file of the correct type and try again.");
2176:                            }
2177:                        }
2178:                    } else if (args[i].equalsIgnoreCase("-GENCONTROLLER"))
2179:                        _genController = true;
2180:                    else if (args[i].equalsIgnoreCase("-GENVARS"))
2181:                        _genVars = true;
2182:                    else if (args[i].equalsIgnoreCase("-SITEMAP"))
2183:                        _siteMap = true;
2184:                    else if (args[i].equalsIgnoreCase("-GENMODEL")) {
2185:                        _genModel = true;
2186:                        if (i < (args.length - 1)) {
2187:                            int next = i + 1;
2188:                            if (!args[next].startsWith("-")) {
2189:                                _modelToGen = args[next];
2190:                            }
2191:                        }
2192:                    } else if (args[i].equalsIgnoreCase("-GENLISTFORM")) {
2193:                        _genListForm = true;
2194:                        if (i < (args.length - 1)) {
2195:                            int next = i + 1;
2196:                            if (!args[next].startsWith("-"))
2197:                                _xmlFile = args[next];
2198:                            if (_xmlFile != null && !_xmlFile.endsWith(".xml")) {
2199:                                throw new Exception(
2200:                                        "A file must be a .xml file to import into Generate Listform. \n Please select a file .xml type and try again.");
2201:                            }
2202:                        }
2203:                    } else if (args[i].equalsIgnoreCase("-SETPROPS"))
2204:                        _setProperties = true;
2205:                    else if (args[i].equalsIgnoreCase("-SETECLIPSEPROPS")) {
2206:                        _setProperties = true;
2207:                        _setEclipseProperties = true;
2208:                    } else if (args[i].equalsIgnoreCase("-GENPROJECT"))
2209:                        _genProject = true;
2210:                    else if (args[i].equalsIgnoreCase("-REDEPLOY"))
2211:                        _redeploy = true;
2212:                    else if (args[i].equalsIgnoreCase("-RESTART")
2213:                            || args[i].equalsIgnoreCase("-START"))
2214:                        _restart = true;
2215:                    else if (args[i].equalsIgnoreCase("-STOP"))
2216:                        _stop = true;
2217:                    else if (args[i].equalsIgnoreCase("-DONTAPPENDPROJECT"))
2218:                        _dontAppendProject = true;
2219:                    else if (args[i].equalsIgnoreCase("-MAKEDEFAULT"))
2220:                        _makeDefault = true;
2221:                    else if (args[i].equalsIgnoreCase("-OSLOOKANDFEEL")) {
2222:                        _defaultLF = true;
2223:                        setDefaultScrollBarColor(new ColorUIResource(0, 0, 0));
2224:                    } else if (args[i].equalsIgnoreCase("-RUNBROWSER")) {
2225:                        _runBrowser = true;
2226:                        _browser = p.getProperty(Props.IDE_BROWSER_PATH);
2227:                        if (i < (args.length - 1)) {
2228:                            int next = i + 1;
2229:                            if (!args[next].startsWith("-"))
2230:                                _browser = p.getProperty(Props.IDE_BROWSER_PATH
2231:                                        + "." + args[next]);
2232:                        }
2233:                    } else if (args[i].equalsIgnoreCase("-URL")) {
2234:                        if (i < (args.length - 1)) {
2235:                            int next = i + 1;
2236:                            if (!args[next].startsWith("-")) {
2237:                                _webPage = args[next];
2238:                                if (!_webPage.startsWith("http")) {
2239:                                    String temp = getURLFromFile(_defaultHost,
2240:                                            _webPage, _defaultWebApp,
2241:                                            _defaultFwApp, null);
2242:                                    if (temp != null) {
2243:                                        _actualFileName = _webPage;
2244:                                        _webPage = temp;
2245:                                    }
2246:                                }
2247:                            }
2248:                        }
2249:                    } else if (args[i].equalsIgnoreCase("-DOCUMENTROOT")) {
2250:                        if (i < (args.length - 1)) {
2251:                            int next = i + 1;
2252:                            if (!args[next].startsWith("-"))
2253:                                _documentRoot = args[next];
2254:                        }
2255:                    }
2256:                }
2257:
2258:                if (_runBrowser) {
2259:                    String page = _webPage;
2260:                    int pos = page.indexOf("?");
2261:                    if (pos != -1)
2262:                        page = page.substring(0, pos);
2263:                    pos = page.indexOf("#");
2264:                    if (pos != -1)
2265:                        page = page.substring(0, pos);
2266:
2267:                    //if (!page.endsWith(".html") && !page.endsWith(".htm") && !page.endsWith(".jsp")) {
2268:                    //	throw new Exception("A file must be a jsp or html file to run in a browser. \n Please select a file of the correct type and try again.");
2269:                    //}
2270:                } else if (_genVars) {
2271:                    if (!_webPage.endsWith(".jsp"))
2272:                        throw new Exception(
2273:                                "A file must be a jsp to generate instance variables for it. \n Please select a file of the correct type and try again.");
2274:                } else if (_genController) {
2275:                    if (!_webPage.endsWith(".jsp"))
2276:                        throw new Exception(
2277:                                "A file must be a jsp to generate a controller for it. \n Please select a file of the correct type and try again.");
2278:                }
2279:
2280:                if (_useAppProperties)
2281:                    _appPropsPath = p
2282:                            .getProperty(getProjectProperty(Props.IDE_APP_PROPS_PATH));
2283:                return p;
2284:            }
2285:
2286:            /**
2287:             * Reads input file into a String
2288:             */
2289:            public static String readFile(File inputFile) throws IOException {
2290:                FileInputStream in = (new FileInputStream(inputFile));
2291:                ByteArrayOutputStream out = new ByteArrayOutputStream();
2292:                byte[] buf = new byte[8192];
2293:                int n;
2294:                while ((n = in.read(buf)) >= 0)
2295:                    out.write(buf, 0, n);
2296:                in.close();
2297:                out.close();
2298:                return new String(out.toByteArray());
2299:            }
2300:
2301:            /**
2302:             * Redeploy a weblogic application
2303:             */
2304:            public static void redeployWeblogicApplication(String webLogicRoot,
2305:                    String webApp) throws Exception {
2306:                if (webApp == null || webApp.length() == 0)
2307:                    webApp = "DefaultWebApp";
2308:                File f = new File(webLogicRoot + "\\" + webApp
2309:                        + "\\META-INF\\redeploy");
2310:                if (f.exists())
2311:                    f.setLastModified(System.currentTimeMillis());
2312:            }
2313:
2314:            private static String replace(String sString, String sOldString,
2315:                    String sNewString) {
2316:                StringBuffer sbString = new StringBuffer(sString);
2317:                while (true) {
2318:                    int iIndex = sbString.toString().indexOf(sOldString);
2319:                    if (iIndex < 0)
2320:                        break;
2321:                    sbString.replace(iIndex, iIndex + sOldString.length(),
2322:                            sNewString);
2323:                }
2324:                return sbString.toString();
2325:            }
2326:
2327:            /**
2328:             * Runs Dreamweaver, but first sets the path so everything works OK
2329:             */
2330:            public static String runDreamweaver(String command, String parms) {
2331:                return runExe(command, parms);
2332:
2333:                //        This was added because without setting up the path properly, the
2334:                //        Dreamweaver extnesion manager couldn't run. Adding this code causes Dreamweaver
2335:                //        to not call the translator so it was removed
2336:                //
2337:                //            try {
2338:                //                String runCom = command + (parms == null ? "" : (" " + parms));
2339:                //                String environmentArgs[]=new String[1];
2340:                //                Registry reg=new Registry(Registry.HKEY_LOCAL_MACHINE,"SOFTWARE\\Macromedia\\Common Files");
2341:                //                String extensionsDll=reg.getStringAttribute("extensions.dll");
2342:                //                extensionsDll=extensionsDll.substring(0,extensionsDll.length()-15);
2343:                //                String path=command.substring(0,command.length()-15);
2344:                //                environmentArgs[0] = "";
2345:                //                environmentArgs[0]="PATH=%PATH%;"+path + ";" + extensionsDll + ";";
2346:                //                Process process=Runtime.getRuntime().exec(runCom, environmentArgs);
2347:                //
2348:                //                slurpProcessOutput(process);
2349:                //                return "OK";
2350:                //			}
2351:                //            catch (Exception e) {
2352:                //                return runExe(command,parms);
2353:                //            }
2354:            }
2355:
2356:            /**
2357:             * Runs a program
2358:             */
2359:            public static String runExe(String command, String parms) {
2360:                Runtime r = Runtime.getRuntime();
2361:
2362:                try {
2363:                    Process p = r.exec(command
2364:                            + (parms == null ? "" : (" " + parms)));
2365:                    slurpProcessOutput(p);
2366:                } catch (IOException e) {
2367:                    return e.toString();
2368:                }
2369:
2370:                return "OK";
2371:            }
2372:
2373:            /**
2374:             *  Displays a dialog and saves a generated controller
2375:             */
2376:            public static boolean saveClass(String defaultFileName,
2377:                    String fileText) {
2378:                boolean isValid = false;
2379:                String fileName = defaultFileName;
2380:                while (!isValid) {
2381:                    fileName = displaySaveDialog(fileName, fileText);
2382:                    if (fileName == null)
2383:                        return false;
2384:                    File f = new File(fileName);
2385:                    File parent = f.getParentFile();
2386:                    try {
2387:                        if (f.exists()) {
2388:                            if (!displayQuestion("The file "
2389:                                    + f.getAbsolutePath()
2390:                                    + " exists. Overwrite It?"))
2391:                                continue;
2392:                        }
2393:                        if (!parent.exists()) {
2394:                            if (!displayQuestion("The directory "
2395:                                    + parent.getAbsolutePath()
2396:                                    + " doesn't exist. Create It?"))
2397:                                continue;
2398:                            parent.mkdirs();
2399:                        }
2400:                        FileOutputStream out = new FileOutputStream(f);
2401:                        PrintWriter w = new PrintWriter(out);
2402:                        w.print(fileText);
2403:                        w.close();
2404:                        out.close();
2405:                    } catch (Exception e) {
2406:                        displayError(e.toString(), false);
2407:                        continue;
2408:                    }
2409:                    System.out.println("$genclass$" + fileName
2410:                            + "$genclassend$");
2411:                    isValid = true;
2412:                }
2413:                return true;
2414:            }
2415:
2416:            public static void slurpProcessOutput(Process p) throws IOException {
2417:                BufferedReader br = new BufferedReader(new InputStreamReader(p
2418:                        .getInputStream()));
2419:                if (br.ready()) {
2420:                    String line = br.readLine();
2421:                    while (line != null) {
2422:                        if (br.ready())
2423:                            line = br.readLine();
2424:                        else
2425:                            line = null;
2426:                    }
2427:                }
2428:                br.close();
2429:            }
2430:
2431:            /**
2432:             * Tomcat 4 command Controller
2433:             */
2434:            public static String tomcat4Command(String host, String managerApp,
2435:                    String webapp, String command, String userID, String pw)
2436:                    throws Exception {
2437:                URL u = new URL("http://" + host + "/" + managerApp + "/"
2438:                        + command + "?path=/" + webapp);
2439:                URLConnection conn = u.openConnection();
2440:
2441:                String authString = userID + ":" + pw;
2442:                String auth = "Basic " + base64encode(authString);
2443:                conn.setRequestProperty("Authorization", auth);
2444:
2445:                InputStream in = conn.getInputStream();
2446:                StringBuffer b = new StringBuffer();
2447:                int i = in.read();
2448:                while (i != -1) {
2449:                    b.append((char) i);
2450:                    i = in.read();
2451:                }
2452:                in.close();
2453:                return b.toString();
2454:            }
2455:
2456:            private static String translateConstantToMethod(String constant,
2457:                    boolean changeCase) {
2458:                StringBuffer sb = new StringBuffer(constant.length());
2459:                boolean uCase = true;
2460:                for (int i = 0; i < constant.length(); i++) {
2461:                    char c = constant.charAt(i);
2462:                    if (c == '_')
2463:                        uCase = true;
2464:                    else {
2465:                        if (uCase) {
2466:                            c = Character.toUpperCase(c);
2467:                            uCase = false;
2468:                        } else if (changeCase)
2469:                            c = Character.toLowerCase(c);
2470:                        sb.append(c);
2471:                    }
2472:                }
2473:                return sb.toString();
2474:            }
2475:
2476:            private static String translateDSType(int type) {
2477:                if (type == DataStore.DATATYPE_BYTEARRAY)
2478:                    return "DataStore.DATATYPE_BYTEARRAY";
2479:                else if (type == DataStore.DATATYPE_DATE)
2480:                    return "DataStore.DATATYPE_DATE";
2481:                else if (type == DataStore.DATATYPE_DATETIME)
2482:                    return "DataStore.DATATYPE_DATETIME";
2483:                else if (type == DataStore.DATATYPE_DOUBLE)
2484:                    return "DataStore.DATATYPE_DOUBLE";
2485:                else if (type == DataStore.DATATYPE_FLOAT)
2486:                    return "DataStore.DATATYPE_FLOAT";
2487:                else if (type == DataStore.DATATYPE_INT)
2488:                    return "DataStore.DATATYPE_INT";
2489:                else if (type == DataStore.DATATYPE_LONG)
2490:                    return "DataStore.DATATYPE_LONG";
2491:                else if (type == DataStore.DATATYPE_SHORT)
2492:                    return "DataStore.DATATYPE_SHORT";
2493:                else if (type == DataStore.DATATYPE_STRING)
2494:                    return "DataStore.DATATYPE_STRING";
2495:                else if (type == DataStore.DATATYPE_TIME)
2496:                    return "DataStore.DATATYPE_TIME";
2497:                else
2498:                    return "";
2499:            }
2500:
2501:            private static String translateQBEType(int type) {
2502:                if (type == QBEBuilder.CRITERIA_TYPE_COMPLEX)
2503:                    return "QBEBuilder.CRITERIA_TYPE_COMPLEX";
2504:                else if (type == QBEBuilder.CRITERIA_TYPE_CONTAINS)
2505:                    return "QBEBuilder.CRITERIA_TYPE_CONTAINS";
2506:                else if (type == QBEBuilder.CRITERIA_TYPE_CONTAINS_IGNORE_CASE)
2507:                    return "QBEBuilder.CRITERIA_TYPE_CONTAINS_IGNORE_CASE";
2508:                else if (type == QBEBuilder.CRITERIA_TYPE_EQUALS)
2509:                    return "QBEBuilder.CRITERIA_TYPE_EQUALS";
2510:                else if (type == QBEBuilder.CRITERIA_TYPE_EQUALS_IGNORE_CASE)
2511:                    return "QBEBuilder.CRITERIA_TYPE_EQUALS_IGNORE_CASE";
2512:                else if (type == QBEBuilder.CRITERIA_TYPE_GT)
2513:                    return "QBEBuilder.CRITERIA_TYPE_GT";
2514:                else if (type == QBEBuilder.CRITERIA_TYPE_GTE)
2515:                    return "QBEBuilder.CRITERIA_TYPE_GTE";
2516:                else if (type == QBEBuilder.CRITERIA_TYPE_LT)
2517:                    return "QBEBuilder.CRITERIA_TYPE_LT";
2518:                else if (type == QBEBuilder.CRITERIA_TYPE_LTE)
2519:                    return "QBEBuilder.CRITERIA_TYPE_LTE";
2520:                else if (type == QBEBuilder.CRITERIA_TYPE_NOT_EQUALS)
2521:                    return "QBEBuilder.CRITERIA_TYPE_NOT_EQUALS";
2522:                else if (type == QBEBuilder.CRITERIA_TYPE_STARTS_WITH)
2523:                    return "QBEBuilder.CRITERIA_TYPE_STARTS_WITH";
2524:                else if (type == QBEBuilder.CRITERIA_TYPE_STARTS_WITH_IGNORE_CASE)
2525:                    return "QBEBuilder.CRITERIA_TYPE_STARTS_WITH_WITH_IGNORE_CASE";
2526:                else if (type == QBEBuilder.CRITERIA_TYPE_IN)
2527:                    return "QBEBuilder.CRITERIA_TYPE_IN";
2528:                else if (type == QBEBuilder.CRITERIA_TYPE_CUSTOM)
2529:                    return "QBEBuilder.CRITERIA_TYPE_CUSTOM";
2530:                else
2531:                    return "";
2532:            }
2533:
2534:            private static String translateDSTypeToJavaType(int type) {
2535:                if (type == DataStore.DATATYPE_BYTEARRAY)
2536:                    return "byte[]";
2537:                else if (type == DataStore.DATATYPE_DATE)
2538:                    return "java.sql.Date";
2539:                else if (type == DataStore.DATATYPE_DATETIME)
2540:                    return "java.sql.Timestamp";
2541:                else if (type == DataStore.DATATYPE_DOUBLE)
2542:                    return "double";
2543:                else if (type == DataStore.DATATYPE_FLOAT)
2544:                    return "float";
2545:                else if (type == DataStore.DATATYPE_INT)
2546:                    return "int";
2547:                else if (type == DataStore.DATATYPE_LONG)
2548:                    return "long";
2549:                else if (type == DataStore.DATATYPE_SHORT)
2550:                    return "short";
2551:                else if (type == DataStore.DATATYPE_STRING)
2552:                    return "String";
2553:                else if (type == DataStore.DATATYPE_TIME)
2554:                    return "java.sql.Time";
2555:                else
2556:                    return "";
2557:            }
2558:
2559:            private static Class translateDSTypeToJavaClass(int type) {
2560:                if (type == DataStore.DATATYPE_BYTEARRAY)
2561:                    return byte[].class;
2562:                else if (type == DataStore.DATATYPE_DATE)
2563:                    return java.sql.Date.class;
2564:                else if (type == DataStore.DATATYPE_DATETIME)
2565:                    return java.sql.Timestamp.class;
2566:                else if (type == DataStore.DATATYPE_DOUBLE)
2567:                    return Double.TYPE;
2568:                else if (type == DataStore.DATATYPE_FLOAT)
2569:                    return Float.TYPE;
2570:                else if (type == DataStore.DATATYPE_INT)
2571:                    return Integer.TYPE;
2572:                else if (type == DataStore.DATATYPE_LONG)
2573:                    return Long.TYPE;
2574:                else if (type == DataStore.DATATYPE_SHORT)
2575:                    return Short.TYPE;
2576:                else if (type == DataStore.DATATYPE_STRING)
2577:                    return String.class;
2578:                else if (type == DataStore.DATATYPE_TIME)
2579:                    return java.sql.Time.class;
2580:                else
2581:                    return null;
2582:            }
2583:
2584:            private static String translateDSTypeToMethod(int type) {
2585:                if (type == DataStore.DATATYPE_BYTEARRAY)
2586:                    return "ByteArray";
2587:                else if (type == DataStore.DATATYPE_DATE)
2588:                    return "Date";
2589:                else if (type == DataStore.DATATYPE_DATETIME)
2590:                    return "DateTime";
2591:                else if (type == DataStore.DATATYPE_DOUBLE)
2592:                    return "Double";
2593:                else if (type == DataStore.DATATYPE_FLOAT)
2594:                    return "Float";
2595:                else if (type == DataStore.DATATYPE_INT)
2596:                    return "Int";
2597:                else if (type == DataStore.DATATYPE_LONG)
2598:                    return "Long";
2599:                else if (type == DataStore.DATATYPE_SHORT)
2600:                    return "Short";
2601:                else if (type == DataStore.DATATYPE_STRING)
2602:                    return "String";
2603:                else if (type == DataStore.DATATYPE_TIME)
2604:                    return "Time";
2605:                else
2606:                    return "";
2607:            }
2608:
2609:            private static String mergeModels(String newText, String origFile) {
2610:                try {
2611:                    if (!new File(origFile).exists())
2612:                        return newText;
2613:                    BufferedReader in = new BufferedReader(new FileReader(
2614:                            origFile));
2615:                    StringBuffer sb = new StringBuffer();
2616:                    String line = in.readLine();
2617:                    while (line != null) {
2618:                        sb.append(line);
2619:                        sb.append("\r\n");
2620:                        line = in.readLine();
2621:                    }
2622:                    in.close();
2623:                    String oldText = sb.toString();
2624:
2625:                    //Find the custom code in the existing model
2626:                    String customVars = "\r\n";
2627:                    String customCode = "\r\n";
2628:                    String customImports = "\r\n";
2629:                    String customConstructor = "\r\n";
2630:
2631:                    int st = oldText.indexOf("//$CUSTOMIMPORTS$");
2632:                    int end = oldText.indexOf("//$ENDCUSTOMIMPORTS$");
2633:                    if (st > -1 && end > -1)
2634:                        customImports = oldText.substring(st + 19, end);
2635:
2636:                    st = oldText.indexOf("//$CUSTOMVARS$");
2637:                    end = oldText.indexOf("//$ENDCUSTOMVARS$");
2638:                    if (st > -1 && end > -1)
2639:                        customVars = oldText.substring(st + 16, end);
2640:
2641:                    st = oldText.indexOf("//$CUSTOMCONSTRUCTOR$");
2642:                    end = oldText.indexOf("//$ENDCUSTOMCONSTRUCTOR$");
2643:                    if (st > -1 && end > -1)
2644:                        customConstructor = oldText.substring(st + 23, end);
2645:
2646:                    st = oldText.indexOf("//$CUSTOMMETHODS$");
2647:                    end = oldText.indexOf("//$ENDCUSTOMMETHODS$");
2648:                    if (st > -1 && end > -1)
2649:                        customCode = oldText.substring(st + 19, end);
2650:
2651:                    //update the custom code in the new Text
2652:                    StringBuffer work = new StringBuffer(newText);
2653:
2654:                    st = newText.indexOf("//$CUSTOMIMPORTS$");
2655:                    end = newText.indexOf("//$ENDCUSTOMIMPORTS$");
2656:                    work.replace(st + 19, end, customImports);
2657:                    newText = work.toString();
2658:
2659:                    st = newText.indexOf("//$CUSTOMVARS$");
2660:                    end = newText.indexOf("//$ENDCUSTOMVARS$");
2661:                    work.replace(st + 16, end, customVars);
2662:                    newText = work.toString();
2663:
2664:                    st = newText.indexOf("//$CUSTOMCONSTRUCTOR$");
2665:                    end = newText.indexOf("//$ENDCUSTOMCONSTRUCTOR$");
2666:                    work.replace(st + 23, end, customConstructor);
2667:                    newText = work.toString();
2668:
2669:                    st = newText.indexOf("//$CUSTOMMETHODS$");
2670:                    end = newText.indexOf("//$ENDCUSTOMMETHODS$");
2671:                    work.replace(st + 19, end, customCode);
2672:
2673:                    return work.toString();
2674:                } catch (Exception e) {
2675:                    return newText;
2676:                }
2677:
2678:            }
2679:
2680:            /**
2681:             * Returns true if the Operating System default look and feel is being used
2682:             */
2683:            public static boolean useDefaultOSLookAndFeel() {
2684:                return _defaultLF;
2685:            }
2686:
2687:            /**
2688:             * @return the document root for the web application
2689:             */
2690:            public static String getDocumentRoot() {
2691:                return _documentRoot;
2692:            }
2693:
2694:            /**
2695:             * @return the default framework application
2696:             */
2697:            public static String getDefaultFwApp() {
2698:                return _defaultFwApp;
2699:            }
2700:
2701:            /**
2702:             * @return the default source path
2703:             */
2704:            public static String getDefaultSourcePath() {
2705:                return _defaultSourcePath;
2706:            }
2707:
2708:            /**
2709:             * @return the dont append project flag
2710:             */
2711:            public static boolean getDontAppendProject() {
2712:                return _dontAppendProject;
2713:            }
2714:
2715:            public static void setDefaultScrollBarColor(
2716:                    ColorUIResource dEFAULT_SCROLL_BAR_COLOR) {
2717:                DEFAULT_SCROLL_BAR_COLOR = dEFAULT_SCROLL_BAR_COLOR;
2718:            }
2719:
2720:            public static ColorUIResource getDefaultScrollBarColor() {
2721:                if (DEFAULT_SCROLL_BAR_COLOR == null) {
2722:                    DEFAULT_SCROLL_BAR_COLOR = new ColorUIResource(91, 135, 206);
2723:                }
2724:                if (DEFAULT_SCROLL_BAR_COLOR.getRed() == 0
2725:                        && DEFAULT_SCROLL_BAR_COLOR.getBlue() == 0
2726:                        && DEFAULT_SCROLL_BAR_COLOR.getGreen() == 0)
2727:                    return null;
2728:                else
2729:                    return DEFAULT_SCROLL_BAR_COLOR;
2730:            }
2731:
2732:            public static Font getDefaultFont() {
2733:                if (DEFAULT_FONT == null) {
2734:                    DEFAULT_FONT = new Font("Dialog", Font.PLAIN, 12);
2735:                }
2736:                return DEFAULT_FONT;
2737:            }
2738:
2739:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.