1
|
/*
|
2
|
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
|
3
|
$Id$
|
4
|
*/
|
5
|
|
6
|
// Ensure this object's dependancies are loaded.
|
7
|
mapbuilder.loadScript(baseDir+"/widget/ButtonBase.js");
|
8
|
|
9
|
/**
|
10
|
* When this button is selected, clicks on the MapPane will add a
|
11
|
* new point to a model.
|
12
|
* Requires an enclosing GML model.
|
13
|
* @constructor
|
14
|
* @base EditButtonBase
|
15
|
* @author Cameron Shorter cameronATshorter.net
|
16
|
* @param widgetNode The node from the Config XML file.
|
17
|
* @param model The ButtonBar widget.
|
18
|
*/
|
19
|
function EditPoint_1(widgetNode, model) {
|
20
|
// Extend EditButtonBase
|
21
|
var base = new ButtonBase(this, widgetNode, model);
|
22
|
|
23
|
/**
|
24
|
* Add a point to the enclosing GML model.
|
25
|
* @param objRef Pointer to this object.
|
26
|
* @param targetNode The node for the enclosing HTML tag for this widget.
|
27
|
*/
|
28
|
this.doAction = function(objRef,targetNode) {
|
29
|
if (objRef.enabled) {
|
30
|
point=objRef.targetModel.containerModel.extent.getXY(targetNode.evpl);
|
31
|
sucess=objRef.targetModel.setXpathValue(
|
32
|
objRef.targetModel,
|
33
|
objRef.targetModel.nodeSelectXpath,point[0]+","+point[1]);
|
34
|
if(!sucess){
|
35
|
alert("EditPoint: invalid featureXpath in config: "+objRef.targetModel.nodeSelectXpath);
|
36
|
}
|
37
|
}
|
38
|
}
|
39
|
|
40
|
/**
|
41
|
* Register for mouseUp events.
|
42
|
* @param objRef Pointer to this object.
|
43
|
*/
|
44
|
this.setMouseListener = function(objRef) {
|
45
|
if (objRef.targetModel.containerModel) {
|
46
|
objRef.targetModel.containerModel.addListener('mouseup',objRef.doAction,objRef);
|
47
|
}
|
48
|
}
|
49
|
config.addListener( "loadModel", this.setMouseListener, this );
|
50
|
|
51
|
}
|