Source Code Cross Referenced for ProjectManager.java in  » Web-Framework » roma-webwizard » org » romaframework » wizard » 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 » Web Framework » roma webwizard » org.romaframework.wizard 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006 Luca Garulli (luca.garulli@assetdata.it)
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.romaframework.wizard;
018:
019:        import java.io.FileInputStream;
020:        import java.io.FileOutputStream;
021:        import java.util.Properties;
022:
023:        import org.romaframework.wizard.properties.ProjectProperties;
024:        import org.romaframework.wizard.schema.NoDTDProperties;
025:
026:        /**
027:         * Handle ROMA projects. It load and save configuration to ROMA_HOME/config/projects.properties.
028:         * 
029:         * @author Luca Garulli (luca.garulli@assetdata.it)
030:         */
031:        public class ProjectManager {
032:            private Properties properties = null;
033:            private String fileName;
034:
035:            private static final ProjectManager instance = new ProjectManager();
036:
037:            public static final String ROMA_FILE_NAME = "projects.xml";
038:            public static final String LAST_PROJECT_VAR = "lastProject";
039:            public static final String PROJECT_PATH_EXT_VAR = ".path";
040:
041:            private static final String COMMENTS = "ROMA Framework configuration file";
042:
043:            protected ProjectManager() {
044:            }
045:
046:            public synchronized String getCurrentProjectName() {
047:                if (!loadFromFile())
048:                    return null;
049:                return properties.getProperty(LAST_PROJECT_VAR);
050:            }
051:
052:            public synchronized void switchCurrentProject(String iProjectName,
053:                    String iProjectLocation) {
054:                if (!loadFromFile())
055:                    return;
056:
057:                //		MainWizard.getIO().getOutput().println("\n[ROMA] Current project is: " + iProjectName);
058:                //		MainWizard.getIO().getOutput().println("\n[ROMA] Note: To switch project use the 'switch' command");
059:
060:                properties.setProperty(LAST_PROJECT_VAR, iProjectName);
061:
062:                if (iProjectLocation != null)
063:                    // UPDATE ALSO PROJECT PATH
064:                    properties.setProperty(iProjectName + PROJECT_PATH_EXT_VAR,
065:                            iProjectLocation);
066:
067:                saveToFile();
068:            }
069:
070:            /**
071:             * Update project information overwriting previous info.
072:             * 
073:             * @param iProjectName
074:             *          Project Name
075:             * @param iInfo
076:             *          Map<String,String> containing all info to store
077:             */
078:            public synchronized void setProjectPath(String iProjectName,
079:                    String iProjectLocation) {
080:                if (!loadFromFile())
081:                    return;
082:
083:                properties.setProperty(iProjectName + PROJECT_PATH_EXT_VAR,
084:                        iProjectLocation);
085:
086:                saveToFile();
087:            }
088:
089:            /**
090:             * Return the project path required
091:             * 
092:             * @param iProjectName
093:             * @return
094:             */
095:            public String getProjectPath(String iProjectName) {
096:                if (!loadFromFile())
097:                    return null;
098:
099:                return properties.getProperty(iProjectName
100:                        + PROJECT_PATH_EXT_VAR);
101:            }
102:
103:            /**
104:             * Return the project information required.
105:             * 
106:             * @param iProjectName
107:             *          Project Name
108:             * @param iVarName
109:             *          Name of variable to get
110:             * @return
111:             */
112:            public synchronized ProjectProperties getProjectInfo(
113:                    String iProjectName) throws WizardException {
114:                String path = getProjectPath(iProjectName);
115:                if (path == null)
116:                    throw new WizardException("No path found for the project "
117:                            + iProjectName);
118:
119:                ProjectProperties prj;
120:                try {
121:                    prj = new ProjectProperties(path);
122:                    return prj;
123:                } catch (Exception e) {
124:                    MainWizard.getIO().getError().println(
125:                            "Error on loading project properties from project path: "
126:                                    + path);
127:                    MainWizard.getIO().getError().println(
128:                            "Check if the project path exists.\n");
129:                    MainWizard.getIO().getError().println(e);
130:                    throw new WizardException(
131:                            "Error on loading project properties from project path: "
132:                                    + path, e);
133:                }
134:            }
135:
136:            private void saveToFile() {
137:                try {
138:                    properties.storeToXML(new FileOutputStream(fileName),
139:                            COMMENTS);
140:                } catch (Exception e) {
141:                    e.printStackTrace();
142:                }
143:            }
144:
145:            private boolean loadFromFile() {
146:                if (properties != null)
147:                    return true;
148:
149:                properties = new NoDTDProperties();
150:                fileName = MainWizard.getRomaHome() + "config/"
151:                        + ROMA_FILE_NAME;
152:                try {
153:                    properties.loadFromXML(new FileInputStream(fileName));
154:                } catch (Exception e) {
155:                    e.printStackTrace();
156:                    return false;
157:                }
158:                return true;
159:            }
160:
161:            public static ProjectManager getInstance() {
162:                return instance;
163:            }
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.