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 @ 44259
History | View | Annotate | Download (3.25 KB)
1 | 41491 | jjdelcerro | /*
|
---|---|---|---|
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 | public String getName() { |
||
41 | return this.name; |
||
42 | } |
||
43 | |||
44 | public void copyTo(DataServerExplorerPoolEntry target) { |
||
45 | DefaultDataServerExplorerPoolEntry other = (DefaultDataServerExplorerPoolEntry)target; |
||
46 | other.name = this.name;
|
||
47 | other.description = this.description;
|
||
48 | other.explorer = this.explorer;
|
||
49 | } |
||
50 | |||
51 | public DataServerExplorerParameters getExplorerParameters() {
|
||
52 | return this.explorer; |
||
53 | } |
||
54 | |||
55 | public String getDescription() { |
||
56 | return this.description; |
||
57 | } |
||
58 | |||
59 | public void saveToState(PersistentState state) throws PersistenceException { |
||
60 | state.set("name", this.name); |
||
61 | state.set("description", this.description); |
||
62 | state.set("explorer", this.explorer); |
||
63 | } |
||
64 | |||
65 | public void loadFromState(PersistentState state) throws PersistenceException { |
||
66 | this.description = state.getString("description"); |
||
67 | this.name = state.getString("name"); |
||
68 | this.explorer = (DataServerExplorerParameters) state.get("explorer"); |
||
69 | } |
||
70 | |||
71 | public static void registerPersistenceDefinition() { |
||
72 | PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
||
73 | if ( manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null ) { |
||
74 | DynStruct definition |
||
75 | = manager.addDefinition(DefaultDataServerExplorerPoolEntry.class, |
||
76 | PERSISTENCE_DEFINITION_NAME, PERSISTENCE_DEFINITION_NAME |
||
77 | + " Persistent definition", null, null); |
||
78 | |||
79 | definition.addDynFieldString("name")
|
||
80 | .setMandatory(true)
|
||
81 | .setPersistent(true);
|
||
82 | |||
83 | definition.addDynFieldString("description")
|
||
84 | .setMandatory(false)
|
||
85 | .setPersistent(true);
|
||
86 | |||
87 | definition.addDynFieldObject("explorer")
|
||
88 | .setClassOfValue(DataServerExplorerParameters.class) |
||
89 | .setMandatory(true)
|
||
90 | .setPersistent(true);
|
||
91 | } |
||
92 | } |
||
93 | |||
94 | } |