svn-gvsig-desktop / branches / org.gvsig.desktop-cvsgis1 / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.spi / src / main / java / org / gvsig / fmap / dal / spi / DataServerExplorerPoolEntryImpl.java @ 45393
History | View | Annotate | Download (3.45 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.spi; |
7 |
|
8 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
9 |
import org.gvsig.fmap.dal.DataServerExplorerPoolEntry; |
10 |
import org.gvsig.tools.ToolsLocator; |
11 |
import org.gvsig.tools.dynobject.DynStruct; |
12 |
import org.gvsig.tools.persistence.PersistenceManager; |
13 |
import org.gvsig.tools.persistence.PersistentState; |
14 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
15 |
|
16 |
/**
|
17 |
*
|
18 |
* @author gvSIG Team
|
19 |
*/
|
20 |
public class DataServerExplorerPoolEntryImpl implements DataServerExplorerPoolEntry { |
21 |
|
22 |
private static final String PERSISTENCE_DEFINITION_NAME = "DataServerExplorerPoolEntry"; |
23 |
|
24 |
protected String name; |
25 |
protected String description; |
26 |
protected DataServerExplorerParameters explorer;
|
27 |
|
28 |
public DataServerExplorerPoolEntryImpl() {
|
29 |
// Required by Persistent
|
30 |
} |
31 |
|
32 |
public DataServerExplorerPoolEntryImpl(String name, String description, DataServerExplorerParameters explorer) { |
33 |
this.name = name;
|
34 |
this.description = description;
|
35 |
this.explorer = explorer;
|
36 |
|
37 |
} |
38 |
|
39 |
@Override
|
40 |
public String getName() { |
41 |
return this.name; |
42 |
} |
43 |
|
44 |
@Override
|
45 |
public void copyTo(DataServerExplorerPoolEntry target) { |
46 |
DataServerExplorerPoolEntryImpl other = (DataServerExplorerPoolEntryImpl)target; |
47 |
other.name = this.name;
|
48 |
other.description = this.description;
|
49 |
other.explorer = this.explorer;
|
50 |
} |
51 |
|
52 |
@Override
|
53 |
public DataServerExplorerParameters getExplorerParameters() {
|
54 |
return this.explorer; |
55 |
} |
56 |
|
57 |
@Override
|
58 |
public String getDescription() { |
59 |
return this.description; |
60 |
} |
61 |
|
62 |
@Override
|
63 |
public void saveToState(PersistentState state) throws PersistenceException { |
64 |
state.set("name", this.name); |
65 |
state.set("description", this.description); |
66 |
state.set("explorer", this.explorer); |
67 |
} |
68 |
|
69 |
@Override
|
70 |
public void loadFromState(PersistentState state) throws PersistenceException { |
71 |
this.description = state.getString("description"); |
72 |
this.name = state.getString("name"); |
73 |
this.explorer = (DataServerExplorerParameters) state.get("explorer"); |
74 |
} |
75 |
|
76 |
public static void registerPersistenceDefinition() { |
77 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
78 |
if ( manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null ) { |
79 |
DynStruct definition |
80 |
= manager.addDefinition(DataServerExplorerPoolEntryImpl.class, |
81 |
PERSISTENCE_DEFINITION_NAME, PERSISTENCE_DEFINITION_NAME |
82 |
+ " Persistent definition", null, null); |
83 |
|
84 |
definition.addDynFieldString("name")
|
85 |
.setMandatory(true)
|
86 |
.setPersistent(true);
|
87 |
|
88 |
definition.addDynFieldString("description")
|
89 |
.setMandatory(false)
|
90 |
.setPersistent(true);
|
91 |
|
92 |
definition.addDynFieldObject("explorer")
|
93 |
.setClassOfValue(DataServerExplorerParameters.class) |
94 |
.setMandatory(true)
|
95 |
.setPersistent(true);
|
96 |
} |
97 |
} |
98 |
|
99 |
@Override
|
100 |
public String getLabel() { |
101 |
return this.getName(); |
102 |
} |
103 |
|
104 |
@Override
|
105 |
public DataServerExplorerPoolEntry getValue() {
|
106 |
return this; |
107 |
} |
108 |
|
109 |
} |