1 |
3032
|
perry
|
/*
|
2 |
|
|
Author: Mike Adair mike.adairATccrs.nrcan.gc.ca
|
3 |
|
|
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
|
4 |
|
|
|
5 |
4307
|
leinfelder
|
$Id: EditContext.js 3881 2008-02-27 15:41:07Z gjvoosten $
|
6 |
3032
|
perry
|
*/
|
7 |
|
|
|
8 |
|
|
// Ensure this object's dependancies are loaded.
|
9 |
|
|
mapbuilder.loadScript(baseDir+"/tool/ToolBase.js");
|
10 |
|
|
|
11 |
|
|
/**
|
12 |
|
|
* Tool which manipulates the Layer list of a Web Map Context document.
|
13 |
|
|
* @constructor
|
14 |
|
|
* @base ToolBase
|
15 |
|
|
* @param toolNode The widget's XML object node from the configuration document.
|
16 |
|
|
* @param model The model object that this widget belongs to.
|
17 |
|
|
*/
|
18 |
|
|
function EditContext(toolNode, model) {
|
19 |
|
|
ToolBase.apply(this, new Array(toolNode, model));
|
20 |
|
|
|
21 |
|
|
var styleUrl = baseDir+"/tool/xsl/wmc_AddResource.xsl"; //TBD figure out a way to set this for other operations
|
22 |
|
|
this.stylesheet = new XslProcessor(styleUrl);
|
23 |
|
|
|
24 |
|
|
// Set stylesheet parameters for all the child nodes from the config file
|
25 |
|
|
for (var j=0;j<toolNode.childNodes.length;j++) {
|
26 |
4307
|
leinfelder
|
if (getNodeValue(toolNode.childNodes[j])) {
|
27 |
|
|
this.stylesheet.setParameter(toolNode.childNodes[j].nodeName,getNodeValue(toolNode.childNodes[j]));
|
28 |
3032
|
perry
|
}
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
/**
|
32 |
|
|
* Adds a new layer to the end of the context document
|
33 |
|
|
* @param featureName the name of the feature to be added
|
34 |
|
|
*/
|
35 |
|
|
this.addNodeToModel = function(featureName) {
|
36 |
|
|
var feature = this.model.getFeatureNode(featureName);
|
37 |
|
|
this.stylesheet.setParameter("version", this.model.getVersion() );
|
38 |
|
|
this.stylesheet.setParameter("serverUrl", this.model.getServerUrl("GetMap","get") );
|
39 |
|
|
this.stylesheet.setParameter("serverTitle", this.model.getServerTitle() );
|
40 |
|
|
this.stylesheet.setParameter("serviceName", "wms");//this.model.getServiceName() );
|
41 |
|
|
this.stylesheet.setParameter("format", this.model.getImageFormat() );
|
42 |
|
|
var newNode = this.stylesheet.transformNodeToObject(feature);
|
43 |
|
|
Sarissa.setXpathNamespaces(newNode, this.targetModel.namespace);
|
44 |
4307
|
leinfelder
|
mbDebugMessage(this, newNode.xml);
|
45 |
3032
|
perry
|
this.targetModel.setParam('addLayer',newNode.documentElement);
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
/**
|
49 |
|
|
* Adds a new layer to the end of the context document
|
50 |
|
|
* @param featureName the name of the feature to be added
|
51 |
|
|
*/
|
52 |
|
|
this.addLayerFromCat = function(featureName) {
|
53 |
|
|
var feature = this.model.getFeatureNode(featureName);
|
54 |
|
|
var newNode = this.stylesheet.transformNodeToObject(feature);
|
55 |
|
|
Sarissa.setXpathNamespaces(newNode, this.targetModel.namespace);
|
56 |
4307
|
leinfelder
|
mbDebugMessage(this, newNode.xml);
|
57 |
3032
|
perry
|
this.targetModel.setParam('addLayer',newNode.documentElement);
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
/**
|
61 |
|
|
* Reorders layers in the context document
|
62 |
|
|
* @param objRef Pointer to this object.
|
63 |
|
|
*/
|
64 |
|
|
this.moveNode = function(objRef, featureName) {
|
65 |
|
|
//TBD
|
66 |
|
|
}
|
67 |
|
|
this.model.addListener("MoveNode", this.addNodeToModel, this);
|
68 |
|
|
|
69 |
|
|
/**
|
70 |
|
|
* Deletes layers from a context doc
|
71 |
|
|
* @param objRef Pointer to this object.
|
72 |
|
|
*/
|
73 |
|
|
this.deleteNode = function(objRef, featureName) {
|
74 |
|
|
//TBD
|
75 |
|
|
}
|
76 |
|
|
this.model.addListener("DeleteNode", this.addNodeToModel, this);
|
77 |
|
|
|
78 |
|
|
}
|