blob: 423faa51ff30f02c587fb4ae10db0dc636d8cd0d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/*
* Copyright (c) 2008, 2011, 2012, 2015 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Eike Stepper - initial API and implementation
*/
package org.eclipse.net4j.util.collection;
import org.eclipse.net4j.util.CheckUtil;
import org.eclipse.net4j.util.om.pref.OMPreference;
/**
* @author Eike Stepper
*/
public class PreferenceHistory extends History<String>
{
private OMPreference<String[]> preference;
public PreferenceHistory(OMPreference<String[]> preference)
{
CheckUtil.checkArg(preference, "preference");
this.preference = preference;
}
public OMPreference<String[]> getPreference()
{
return preference;
}
@Override
protected void load()
{
String[] value = preference.getValue();
if (value != null)
{
for (String data : value)
{
IHistoryElement<String> element = createElement(data);
elements.add(element);
}
}
}
@Override
protected void save()
{
String[] array = getData(new String[size()]);
preference.setValue(array);
}
}
|