svn-gvsig-desktop / tags / v2_0_0_Build_2020 / extensions / org.gvsig.hyperlink.app / org.gvsig.hyperlink.app.extension / src / main / java / org / gvsig / hyperlink / app / extension / config / LinkConfig.java @ 33915
History | View | Annotate | Download (3.81 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
|
23 |
package org.gvsig.hyperlink.app.extension.config; |
24 |
|
25 |
import org.gvsig.tools.ToolsLocator; |
26 |
import org.gvsig.tools.dynobject.DynStruct; |
27 |
import org.gvsig.tools.persistence.PersistenceManager; |
28 |
import org.gvsig.tools.persistence.Persistent; |
29 |
import org.gvsig.tools.persistence.PersistentState; |
30 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
31 |
import org.gvsig.tools.util.Callable; |
32 |
|
33 |
public class LinkConfig implements Persistent { |
34 |
|
35 |
private String fieldName; |
36 |
private String extension = ""; |
37 |
private String actionCode; |
38 |
public static final String LINKCONFIG_PERSISTENCE_DEFINITION_NAME = "LinkConfig"; |
39 |
|
40 |
public LinkConfig() {
|
41 |
} |
42 |
|
43 |
public LinkConfig(String actionCode, String fieldName) { |
44 |
this.actionCode = actionCode;
|
45 |
this.fieldName = fieldName;
|
46 |
} |
47 |
|
48 |
public LinkConfig(String actionCode, String fieldName, String extension) { |
49 |
this.actionCode = actionCode;
|
50 |
this.fieldName = fieldName;
|
51 |
this.extension = extension;
|
52 |
} |
53 |
|
54 |
public String getFieldName() { |
55 |
return fieldName;
|
56 |
} |
57 |
|
58 |
public String getActionCode() { |
59 |
return actionCode;
|
60 |
} |
61 |
|
62 |
public void setFieldName(String fieldName) { |
63 |
this.fieldName = fieldName;
|
64 |
} |
65 |
|
66 |
public void setActionCode(String actionCode) { |
67 |
this.actionCode = actionCode;
|
68 |
} |
69 |
|
70 |
public void setExtension(String extension) { |
71 |
this.extension = extension;
|
72 |
} |
73 |
|
74 |
public String getExtension() { |
75 |
return extension;
|
76 |
} |
77 |
|
78 |
public String getClassName() { |
79 |
return this.getClass().getName(); |
80 |
} |
81 |
|
82 |
public void saveToState(PersistentState state) throws PersistenceException { |
83 |
state.set("fieldName", this.fieldName); |
84 |
state.set("extension", this.extension); |
85 |
state.set("actionCode", this.actionCode); |
86 |
} |
87 |
|
88 |
public void loadFromState(PersistentState state) throws PersistenceException { |
89 |
this.fieldName = state.getString("fieldName"); |
90 |
this.extension = state.getString("extension"); |
91 |
this.actionCode = state.getString("actionCode"); |
92 |
} |
93 |
|
94 |
public static class RegisterPersistence implements Callable { |
95 |
|
96 |
public Object call() throws Exception { |
97 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
98 |
if( manager.getDefinition(LINKCONFIG_PERSISTENCE_DEFINITION_NAME)==null ) { |
99 |
DynStruct definition = manager.addDefinition( |
100 |
LinkConfig.class, |
101 |
LINKCONFIG_PERSISTENCE_DEFINITION_NAME, |
102 |
LINKCONFIG_PERSISTENCE_DEFINITION_NAME+" Persistence definition",
|
103 |
null,
|
104 |
null
|
105 |
); |
106 |
|
107 |
definition.addDynFieldString("fieldName").setMandatory(true); |
108 |
definition.addDynFieldString("extension").setMandatory(false); |
109 |
definition.addDynFieldString("actionCode").setMandatory(true); |
110 |
} |
111 |
return Boolean.TRUE; |
112 |
} |
113 |
|
114 |
} |
115 |
|
116 |
} |