Last change
on this file since 7599 was 5028, checked in by jttt, 12 years ago |
Add possibility to hide side buttons in toggle dialogs permanently, show actions from buttons in popup menu
|
File size:
818 bytes
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.preferences;
|
---|
3 |
|
---|
4 | import org.openstreetmap.josm.Main;
|
---|
5 |
|
---|
6 | public abstract class ParametrizedEnumProperty<T extends Enum<T>> {
|
---|
7 |
|
---|
8 |
|
---|
9 | private final T defaultValue;
|
---|
10 | private final Class<T> enumClass;
|
---|
11 |
|
---|
12 | public ParametrizedEnumProperty(Class<T> enumClass, T defaultValue) {
|
---|
13 | this.defaultValue = defaultValue;
|
---|
14 | this.enumClass = enumClass;
|
---|
15 | }
|
---|
16 |
|
---|
17 | protected abstract String getKey(String... params);
|
---|
18 |
|
---|
19 | public T get(String... params) {
|
---|
20 | return parse(Main.pref.get(getKey(params), defaultValue.name()));
|
---|
21 | }
|
---|
22 |
|
---|
23 | public boolean put(T value, String... params) {
|
---|
24 | return Main.pref.put(getKey(params), value.name());
|
---|
25 | }
|
---|
26 |
|
---|
27 | protected T parse(String s) {
|
---|
28 | return Enum.valueOf(enumClass, s);
|
---|
29 | }
|
---|
30 |
|
---|
31 |
|
---|
32 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.