Source Code Cross Referenced for KelpInfo.java in  » J2EE » enhydra-IDE-plugin » org » enhydra » kelp » 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 » enhydra IDE plugin » org.enhydra.kelp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Enhydra Java Application Server Project
003:         *
004:         * The contents of this file are subject to the Enhydra Public License
005:         * Version 1.1 (the "License"); you may not use this file except in
006:         * compliance with the License. You may obtain a copy of the License on
007:         * the Enhydra web site ( http://www.enhydra.org/ ).
008:         *
009:         * Software distributed under the License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011:         * the License for the specific terms governing rights and limitations
012:         * under the License.
013:         *
014:         * The Initial Developer of the Enhydra Application Server is Lutris
015:         * Technologies, Inc. The Enhydra Application Server and portions created
016:         * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017:         * All Rights Reserved.
018:         *
019:         * Contributor(s):
020:         * Paul Mahar
021:         *
022:         */
023:        package org.enhydra.kelp;
024:
025:        // ToolBox
026:        import org.enhydra.tool.ToolBoxInfo;
027:        import org.enhydra.tool.common.FilenameFilter;
028:        import org.enhydra.tool.common.FileUtil;
029:        import org.enhydra.tool.common.PathHandle;
030:        import org.enhydra.tool.common.ToolException;
031:
032:        // AddinCore
033:        import org.enhydra.kelp.common.Constants;
034:        import org.enhydra.kelp.common.ResUtil;
035:
036:        // JDK
037:        import java.io.File;
038:        import java.net.MalformedURLException;
039:        import java.util.ArrayList;
040:        import java.util.Arrays;
041:        import java.util.ResourceBundle;
042:        import java.util.Properties;
043:
044:        /**
045:         * Class containing the version information
046:         */
047:        public class KelpInfo {
048:            public static final String ADDIN_ROOT = "addin.root";
049:            public static final String ADDIN_HELP = "using_kelp.html";
050:
051:            // not to be resourced
052:            static ResourceBundle res = ResourceBundle
053:                    .getBundle("org.enhydra.kelp.common.Res"); // nores
054:            private static final String VERSION = "6"; // nores
055:            private static final String TOOLBOX_CLASS = "org.enhydra.tool.ToolBoxInfo"; // nores
056:
057:            //
058:            public static String getKelpVersion() {
059:                return KelpInfo.VERSION;
060:            }
061:
062:            public static void verifyIDEClassPath() throws Exception {
063:                boolean valid = true;
064:
065:                valid = KelpInfo.isClassPathComplete();
066:                StringBuffer message = new StringBuffer();
067:
068:                if (!valid) {
069:                    message.append(res.getString("MissingJars1"));
070:                    message.append(res.getString("MissingJars2"));
071:                    if (KelpInfo.isToolBoxInClassPath()) {
072:                        if (!KelpInfo.isToolBoxVersionInSynch()) {
073:                            message.setLength(0);
074:                            message.append(res.getString("OutOfSync"));
075:                            message.append(ResUtil.format(res
076:                                    .getString("Kelp_version_0"), KelpInfo
077:                                    .getKelpVersion()));
078:                            message.append('\n');
079:                            message.append(ResUtil.format(res
080:                                    .getString("ToolBox_version_0"),
081:                                    ToolBoxInfo.getToolBoxVersion()));
082:                        } else if (!ToolBoxInfo.isEnhydraInClassPath()) {
083:                            message.append(Constants.FILE_ENHYDRA_JAR);
084:                            message.append('\n');
085:                        } else if (!ToolBoxInfo.isXMLCInClassPath()) {
086:                            message.append(Constants.FILE_XMLC_JAR);
087:                            message.append('\n');
088:                        }
089:                    } else {
090:                        message.append(Constants.FILE_TOOLBOX_JAR);
091:                        message.append('\n');
092:                    }
093:                    throw new Exception(message.toString());
094:                }
095:            }
096:
097:            public static String getMessageBoxTitle() {
098:                StringBuffer buf = new StringBuffer();
099:
100:                buf.append(Constants.KELP);
101:                buf.append(Constants.TAB1);
102:                buf.append(KelpInfo.VERSION);
103:                return buf.toString();
104:            }
105:
106:            public static boolean isToolBoxInClassPath() {
107:                boolean inPath = true;
108:
109:                try {
110:                    Class testClass = Class.forName(TOOLBOX_CLASS);
111:                } catch (java.lang.ClassNotFoundException e) {
112:                    inPath = false;
113:                }
114:                return inPath;
115:            }
116:
117:            public static boolean isToolBoxVersionInSynch() {
118:                boolean inSynch = false;
119:
120:                if (KelpInfo.isToolBoxInClassPath()) {
121:                    if (ToolBoxInfo.getToolBoxVersion().equalsIgnoreCase(
122:                            KelpInfo.getKelpVersion())) {
123:                        inSynch = true;
124:                    }
125:                }
126:                return inSynch;
127:            }
128:
129:            public static boolean isClassPathComplete() {
130:                boolean complete = false;
131:
132:                if (KelpInfo.isToolBoxInClassPath()) {
133:                    if (ToolBoxInfo.isXMLCInClassPath()
134:                            && KelpInfo.isToolBoxVersionInSynch()) {
135:                        complete = true;
136:                    }
137:                }
138:                return complete;
139:            }
140:
141:            public static String getAddinHelpURL() {
142:                String[] search = new String[0];
143:
144:                return KelpInfo.getAddinHelpURL(search);
145:            }
146:
147:            public static String getAddinHelpURL(String s) {
148:                String[] search = new String[1];
149:
150:                if (s == null) {
151:                    search = new String[0];
152:                } else {
153:                    search[0] = s;
154:                }
155:                return KelpInfo.getAddinHelpURL(search);
156:            }
157:
158:            public static String getAddinHelpURL(String[] search) {
159:                StringBuffer buf = new StringBuffer();
160:                File file = null;
161:
162:                buf.append(KelpInfo.getAddinRoot(search));
163:                buf.append("/doc/");
164:                buf.append(KelpInfo.ADDIN_HELP);
165:                file = new File(buf.toString());
166:                buf.setLength(0);
167:                try {
168:                    buf.append(file.toURL().toExternalForm());
169:                } catch (MalformedURLException e) {
170:                    e.printStackTrace(System.err);
171:                }
172:                return buf.toString();
173:            }
174:
175:            private static String getAddinRoot(String[] search) {
176:                final String FILE_ADDIN_JAR = "KelpAddinJBuilder7.jar";
177:                ArrayList list = null;
178:                Properties props = null;
179:                String root = null;
180:                String[] paths = new String[0];
181:                ClassLoader loader = null;
182:                FilenameFilter filter = null;
183:                PathHandle ph = null;
184:                KelpInfo info = null;
185:
186:                // find by class loader - will fail for forte
187:                info = new KelpInfo();
188:                loader = info.getClass().getClassLoader();
189:                paths = FileUtil.findJarPaths(FILE_ADDIN_JAR, loader);
190:                for (int i = 0; i < paths.length; i++) {
191:                    ph = PathHandle.createPathHandle(paths[i]);
192:                    ph = ph.getParent();
193:                    if (ph.getParent() == null) {
194:                        root = ph.getPath();
195:                    } else {
196:                        root = ph.getParent().getPath();
197:                    }
198:                    break;
199:                }
200:
201:                // search
202:                if (root == null) {
203:                    ph = PathHandle.createPathHandle(ToolBoxInfo
204:                            .getEnhydraRoot());
205:                    if (ph.getParent() != null) {
206:                        list = new ArrayList(Arrays.asList(search));
207:                        list.add(ph.getParent().getPath() + "/kelp5");
208:                        list.trimToSize();
209:                        search = new String[list.size()];
210:                        search = (String[]) list.toArray(search);
211:                        list.clear();
212:                    }
213:                    filter = new FilenameFilter();
214:                    filter.setIncludeName(KelpInfo.ADDIN_HELP);
215:                    filter.setDirectoryValid(false);
216:                    for (int i = 0; i < search.length; i++) {
217:                        ph = PathHandle.createPathHandle(FileUtil.findFirst(
218:                                filter, search[i]));
219:                        if (ph.isFile()) {
220:                            ph = ph.getParent();
221:                            if (ph.getParent() != null) {
222:                                ph = ph.getParent();
223:                            }
224:                            root = ph.getPath();
225:                            break;
226:                        }
227:                    }
228:                }
229:                try {
230:
231:                    // if can't find root load prop, otherwise save
232:                    props = ToolBoxInfo.loadProperties();
233:                    if (root == null) {
234:                        root = props.getProperty(ADDIN_ROOT);
235:                    } else {
236:                        props.setProperty(KelpInfo.ADDIN_ROOT, root);
237:                        ToolBoxInfo.storeProperties(props);
238:                    }
239:                } catch (ToolException e) {
240:                    e.printStackTrace(System.err);
241:                    root = null;
242:                }
243:                if (root == null) {
244:                    root = "../kelp5";
245:                }
246:                return root;
247:            }
248:
249:            /**
250:             * Prevent instantiation.
251:             */
252:            private KelpInfo() {
253:            }
254:
255:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.