01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08: *
09: * When distributing Covered Code, include this CDDL Header Notice in each file
10: * and include the License file at http://www.netbeans.org/cddl.txt.
11: * If applicable, add the following below the CDDL Header, with the fields
12: * enclosed by brackets [] replaced by your own identifying information:
13: * "Portions Copyrighted [year] [name of copyright owner]"
14: *
15: * The Original Software is NetBeans. The Initial Developer of the Original
16: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17: * Microsystems, Inc. All Rights Reserved.
18: */
19:
20: package org.netbeans.modules.sql.project;
21:
22: import java.io.IOException;
23:
24: import org.netbeans.api.project.Project;
25: import org.netbeans.api.project.ProjectManager;
26: import org.netbeans.spi.project.support.ant.AntProjectHelper;
27: import org.netbeans.spi.project.support.ant.EditableProperties;
28:
29: /**
30: *
31: * @author sgenipudi
32: */
33: public class SQLproProjectHelper {
34:
35: private SQLproProject mProject = null;
36: private static SQLproProjectHelper mInstance = null;
37:
38: /** Creates a new instance of SQLProjectHelper */
39: public void setProject(SQLproProject project) {
40: mProject = project;
41: }
42:
43: public static SQLproProjectHelper getInstance() {
44: if (mInstance == null) {
45: mInstance = new SQLproProjectHelper();
46: }
47: return mInstance;
48: }
49:
50: public void setProjectProperty(String propertyName, String value,
51: boolean save) {
52: AntProjectHelper helper = mProject.getAntProjectHelper();
53: EditableProperties ep = helper
54: .getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
55: ep.setProperty(propertyName, value);
56: helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,
57: ep);
58: if (save) {
59: try {
60: Project p = ProjectManager.getDefault().findProject(
61: mProject.getAntProjectHelper()
62: .getProjectDirectory());
63: ProjectManager.getDefault().saveProject(p);
64: } catch (IOException ie) {
65: ie.printStackTrace();
66: }
67: }
68: }
69:
70: public String getProjectProperty(String propertyName) {
71: AntProjectHelper helper = mProject.getAntProjectHelper();
72: EditableProperties ep = helper
73: .getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
74: return ep.getProperty(propertyName);
75: }
76: }
|