root / trunk / extensions / extHyperlink / src / org / gvsig / hyperlink / config / LayerLinkConfig.java @ 28132
History | View | Annotate | Download (1.84 KB)
1 |
package org.gvsig.hyperlink.config; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
|
5 |
import com.iver.utiles.IPersistence; |
6 |
import com.iver.utiles.XMLEntity; |
7 |
|
8 |
public class LayerLinkConfig implements IPersistence { |
9 |
protected ArrayList<LinkConfig> linkList; |
10 |
protected boolean enabled; |
11 |
|
12 |
public LayerLinkConfig() {
|
13 |
linkList = new ArrayList<LinkConfig>(); |
14 |
} |
15 |
|
16 |
public void addLink(LinkConfig config) { |
17 |
linkList.add(config); |
18 |
} |
19 |
|
20 |
public void addLink(int position, LinkConfig config) { |
21 |
linkList.add(position, config); |
22 |
} |
23 |
|
24 |
public void addLink(String actionCode, String fieldName) { |
25 |
linkList.add(new LinkConfig(actionCode, fieldName));
|
26 |
} |
27 |
|
28 |
public void addLink(String actionCode, String fieldName, String extension) { |
29 |
linkList.add(new LinkConfig(actionCode, fieldName, extension));
|
30 |
} |
31 |
|
32 |
public LinkConfig removeLink(int linkIndex) { |
33 |
try {
|
34 |
return linkList.remove(linkIndex);
|
35 |
} |
36 |
catch (IndexOutOfBoundsException ex) { |
37 |
return null; |
38 |
} |
39 |
} |
40 |
|
41 |
public LinkConfig getLink(int index) { |
42 |
return linkList.get(index);
|
43 |
} |
44 |
|
45 |
public int linkCount() { |
46 |
return linkList.size();
|
47 |
} |
48 |
|
49 |
public String getClassName() { |
50 |
return this.getClass().getName(); |
51 |
} |
52 |
|
53 |
public boolean isEnabled() { |
54 |
return enabled;
|
55 |
} |
56 |
|
57 |
public void setEnabled(boolean enabled) { |
58 |
this.enabled = enabled;
|
59 |
} |
60 |
|
61 |
public XMLEntity getXMLEntity() {
|
62 |
XMLEntity xmlconfig = new XMLEntity();
|
63 |
xmlconfig.putProperty("className", this.getClassName()); |
64 |
xmlconfig.putProperty("enabled", isEnabled());
|
65 |
for (int i=0; i<linkList.size(); i++) { |
66 |
xmlconfig.addChild(linkList.get(i).getXMLEntity()); |
67 |
} |
68 |
return xmlconfig;
|
69 |
} |
70 |
|
71 |
public void setXMLEntity(XMLEntity xml) { |
72 |
if (xml.contains("enabled")) { |
73 |
setEnabled(xml.getBooleanProperty("enabled"));
|
74 |
} |
75 |
else {
|
76 |
setEnabled(false);
|
77 |
} |
78 |
for (int i=0; i<xml.getChildrenCount(); i++) { |
79 |
LinkConfig link = LinkConfig.createFromXMLEntity(xml.getChild(i)); |
80 |
linkList.add(link); |
81 |
} |
82 |
} |
83 |
|
84 |
} |