0
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
package com.symbian.smt.gui;
|
|
17 |
|
|
18 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
|
19 |
import org.osgi.service.prefs.BackingStoreException;
|
|
20 |
|
|
21 |
public class PersistentDataStore extends AbstractPersistentDataStore {
|
|
22 |
|
|
23 |
private IEclipsePreferences node;
|
|
24 |
private IEclipsePreferences defaultNode;
|
|
25 |
|
|
26 |
public PersistentDataStore(IEclipsePreferences instanceNode) {
|
|
27 |
this.node = instanceNode;
|
|
28 |
this.defaultNode = null;
|
|
29 |
}
|
|
30 |
|
|
31 |
/**
|
|
32 |
* Creates the PersistentDataStore object, which is used for reading and
|
|
33 |
* writing to a IEclipsePreferences node
|
|
34 |
*
|
|
35 |
* @param IEclipsePreferences
|
|
36 |
* A node
|
|
37 |
*/
|
|
38 |
public PersistentDataStore(IEclipsePreferences instanceNode,
|
|
39 |
IEclipsePreferences defaultNode) {
|
|
40 |
this.node = instanceNode;
|
|
41 |
this.defaultNode = defaultNode;
|
|
42 |
}
|
|
43 |
|
|
44 |
public String read(PersistentSettingsEnums key) {
|
|
45 |
String result = node.get(key.toString(), null);
|
|
46 |
|
|
47 |
if (result == null && defaultNode != null) {
|
|
48 |
result = defaultNode.get(key.toString(), null);
|
|
49 |
}
|
|
50 |
|
|
51 |
return result;
|
|
52 |
}
|
|
53 |
|
|
54 |
public void write(PersistentSettingsEnums key, String value) {
|
|
55 |
node.put(key.toString(), value);
|
|
56 |
try {
|
|
57 |
node.flush();
|
|
58 |
} catch (BackingStoreException e) {
|
|
59 |
Logger.log(e.getMessage(), e);
|
|
60 |
}
|
|
61 |
}
|
|
62 |
}
|