1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package pl.edu.agh.cast.resources;
19
20 import org.apache.log4j.Logger;
21 import org.eclipse.core.resources.IProject;
22 import org.eclipse.core.resources.ProjectScope;
23 import org.eclipse.core.runtime.preferences.IEclipsePreferences;
24 import org.osgi.service.prefs.BackingStoreException;
25
26 import pl.edu.agh.cast.model.base.BasePlugin;
27
28
29
30
31
32
33 public class BaseProjectUtil {
34
35
36
37
38 public static final String PROJECT_DISPLAY_NAME_PROPERTY = "project.displayName";
39
40
41
42
43 public static final String PROJECT_ID_PROPERTY = "project.id";
44
45
46
47
48
49
50
51
52
53
54 public static String getProperty(IProject project, String propertyId) {
55 ProjectScope ps = new ProjectScope(project);
56 return ps.getNode(BasePlugin.PLUGIN_ID).get(propertyId, null);
57 }
58
59
60
61
62
63
64
65
66
67
68
69 public static void setProperty(IProject project, String propertyId, String value) {
70 ProjectScope ps = new ProjectScope(project);
71 IEclipsePreferences node = ps.getNode(BasePlugin.PLUGIN_ID);
72 node.put(propertyId, value);
73 try {
74 node.flush();
75 } catch (BackingStoreException e) {
76 Logger.getLogger(BaseProjectUtil.class).error("Failed to save property " + propertyId, e);
77 }
78 }
79
80 }