svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.mapcontext / org.gvsig.fmap.mapcontext.api / src / main / java / org / gvsig / fmap / mapcontext / layers / ExtendedPropertiesHelper.java @ 44455
History | View | Annotate | Download (3.56 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.fmap.mapcontext.layers; |
25 |
|
26 |
import java.util.HashMap; |
27 |
import java.util.Map; |
28 |
import org.gvsig.tools.ToolsLocator; |
29 |
import org.gvsig.tools.dynobject.DynStruct; |
30 |
import org.gvsig.tools.persistence.PersistenceManager; |
31 |
|
32 |
import org.slf4j.Logger; |
33 |
import org.slf4j.LoggerFactory; |
34 |
|
35 |
import org.gvsig.tools.persistence.Persistent; |
36 |
import org.gvsig.tools.util.Callable; |
37 |
import org.gvsig.tools.util.PropertiesSupportHelper; |
38 |
|
39 |
public class ExtendedPropertiesHelper extends PropertiesSupportHelper implements ExtendedPropertiesSupport, Persistent { |
40 |
|
41 |
private static final Logger logger = LoggerFactory.getLogger(ExtendedPropertiesHelper.class); |
42 |
|
43 |
/*
|
44 |
Add this to class that implements ExtendedPropertiesSupport
|
45 |
|
46 |
private ExtendedPropertiesHelper propertiesHelper = new ExtendedPropertiesHelper();
|
47 |
|
48 |
This methods
|
49 |
|
50 |
public Object getProperty(Object key) {
|
51 |
return this.propertiesHelper.getProperty(key);
|
52 |
}
|
53 |
|
54 |
public void setProperty(Object key, Object obj) {
|
55 |
this.propertiesHelper.setProperty(key, obj);
|
56 |
}
|
57 |
|
58 |
public Map getExtendedProperties() {
|
59 |
return this.propertiesHelper.getExtendedProperties();
|
60 |
}
|
61 |
|
62 |
To the persistence defnition
|
63 |
|
64 |
definition.addDynFieldObject("propertiesHelper").setClassOfValue(ExtendedPropertiesHelper.class)
|
65 |
.setMandatory(false);
|
66 |
|
67 |
To the loadFromState
|
68 |
|
69 |
this.propertiesHelper = (ExtendedPropertiesHelper) state.get("propertiesHelper");
|
70 |
|
71 |
And to the saveToState
|
72 |
|
73 |
state.set("propertiesHelper",propertiesHelper);
|
74 |
|
75 |
*/
|
76 |
@Override
|
77 |
public Object getProperty(Object key) { |
78 |
return this.getProperty((String) key); |
79 |
} |
80 |
|
81 |
@Override
|
82 |
public void setProperty(Object key, Object val) { |
83 |
this.setProperty((String) key, val); |
84 |
} |
85 |
|
86 |
@Override
|
87 |
public Map getExtendedProperties() { |
88 |
return this.getProperties(); |
89 |
} |
90 |
|
91 |
public void setExtendedProperties(Map properties) { |
92 |
this.setProperties(properties);
|
93 |
} |
94 |
|
95 |
public static class RegisterPersistence implements Callable { |
96 |
|
97 |
@Override
|
98 |
public Object call() { |
99 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
100 |
DynStruct definition = manager.addDefinition( |
101 |
ExtendedPropertiesHelper.class, |
102 |
"ExtendedPropertiesHelper",
|
103 |
"ExtendedPropertiesHelper Persistence definition",
|
104 |
null,
|
105 |
null
|
106 |
); |
107 |
definition.addDynFieldMap("properties").setClassOfItems(Object.class) |
108 |
.setMandatory(true);
|
109 |
|
110 |
return Boolean.TRUE; |
111 |
} |
112 |
} |
113 |
|
114 |
} |