svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.impl / src / main / java / org / gvsig / fmap / dal / impl / DefaultDataServerExplorerPoolEntry.java @ 44419
History | View | Annotate | Download (3.33 KB)
1 |
/*
|
---|---|
2 |
* To change this license header, choose License Headers in Project Properties.
|
3 |
* To change this template file, choose Tools | Templates
|
4 |
* and open the template in the editor.
|
5 |
*/
|
6 |
package org.gvsig.fmap.dal.impl; |
7 |
|
8 |
import org.gvsig.fmap.dal.DataServerExplorer; |
9 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
10 |
import org.gvsig.fmap.dal.DataServerExplorerPoolEntry; |
11 |
import org.gvsig.tools.ToolsLocator; |
12 |
import org.gvsig.tools.dynobject.DynStruct; |
13 |
import org.gvsig.tools.persistence.PersistenceManager; |
14 |
import org.gvsig.tools.persistence.PersistentState; |
15 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
16 |
|
17 |
/**
|
18 |
*
|
19 |
* @author usuario
|
20 |
*/
|
21 |
public class DefaultDataServerExplorerPoolEntry implements DataServerExplorerPoolEntry { |
22 |
|
23 |
private static final String PERSISTENCE_DEFINITION_NAME = "DataServerExplorerPoolEntry"; |
24 |
|
25 |
protected String name; |
26 |
protected String description; |
27 |
protected DataServerExplorerParameters explorer;
|
28 |
|
29 |
public DefaultDataServerExplorerPoolEntry() {
|
30 |
// Required by Persistent
|
31 |
} |
32 |
|
33 |
public DefaultDataServerExplorerPoolEntry(String name, String description, DataServerExplorerParameters explorer) { |
34 |
this.name = name;
|
35 |
this.description = description;
|
36 |
this.explorer = explorer;
|
37 |
|
38 |
} |
39 |
|
40 |
@Override
|
41 |
public String getName() { |
42 |
return this.name; |
43 |
} |
44 |
|
45 |
@Override
|
46 |
public void copyTo(DataServerExplorerPoolEntry target) { |
47 |
DefaultDataServerExplorerPoolEntry other = (DefaultDataServerExplorerPoolEntry)target; |
48 |
other.name = this.name;
|
49 |
other.description = this.description;
|
50 |
other.explorer = this.explorer;
|
51 |
} |
52 |
|
53 |
@Override
|
54 |
public DataServerExplorerParameters getExplorerParameters() {
|
55 |
return this.explorer; |
56 |
} |
57 |
|
58 |
@Override
|
59 |
public String getDescription() { |
60 |
return this.description; |
61 |
} |
62 |
|
63 |
@Override
|
64 |
public void saveToState(PersistentState state) throws PersistenceException { |
65 |
state.set("name", this.name); |
66 |
state.set("description", this.description); |
67 |
state.set("explorer", this.explorer); |
68 |
} |
69 |
|
70 |
@Override
|
71 |
public void loadFromState(PersistentState state) throws PersistenceException { |
72 |
this.description = state.getString("description"); |
73 |
this.name = state.getString("name"); |
74 |
this.explorer = (DataServerExplorerParameters) state.get("explorer"); |
75 |
} |
76 |
|
77 |
public static void registerPersistenceDefinition() { |
78 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
79 |
if ( manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null ) { |
80 |
DynStruct definition |
81 |
= manager.addDefinition(DefaultDataServerExplorerPoolEntry.class, |
82 |
PERSISTENCE_DEFINITION_NAME, PERSISTENCE_DEFINITION_NAME |
83 |
+ " Persistent definition", null, null); |
84 |
|
85 |
definition.addDynFieldString("name")
|
86 |
.setMandatory(true)
|
87 |
.setPersistent(true);
|
88 |
|
89 |
definition.addDynFieldString("description")
|
90 |
.setMandatory(false)
|
91 |
.setPersistent(true);
|
92 |
|
93 |
definition.addDynFieldObject("explorer")
|
94 |
.setClassOfValue(DataServerExplorerParameters.class) |
95 |
.setMandatory(true)
|
96 |
.setPersistent(true);
|
97 |
} |
98 |
} |
99 |
|
100 |
} |