]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.project/src/org/simantics/project/management/WorkspaceUtil.java
Support ontology install option trueWhenDeployed also during development
[simantics/platform.git] / bundles / org.simantics.project / src / org / simantics / project / management / WorkspaceUtil.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.project.management;
13
14 import java.io.File;
15 import java.io.FileReader;
16 import java.io.FileWriter;
17 import java.io.IOException;
18 import java.util.Properties;
19
20 /**
21  * Workspace management utils
22  *
23  * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
24  */
25 public class WorkspaceUtil {
26
27         /**
28          * Write project properties 
29          * 
30          * Project URI is in a text file simantics.cfg 
31          * 
32          * @param propertyFile
33          * @param props
34          * @throws IOException 
35          */
36         public static void writeProperties(File propertyFile, Properties props) throws IOException {
37             FileWriter fw = null;
38             try {
39                 fw = new FileWriter( propertyFile );
40                 props.store(fw, "Project configuration");
41             } finally {
42                 if (fw!=null) fw.close();
43             }                           
44         }
45         
46         /**
47          * Read project properties in a workspace
48          * 
49          * @param workspace
50          * @return
51          * @throws IOException
52          */
53         public static Properties readProperties(File propertyFile) throws IOException {
54             FileReader fr = null;
55             try {
56                 fr = new FileReader(propertyFile);              
57                         Properties props = new Properties();
58                     props.load(fr);
59                         return props;
60             } finally {
61                 if (fr!=null) fr.close();
62             }
63                 
64         }
65
66         
67 }
68