Subversion Repositories Applications.papyrus

Rev

Rev 1422 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.widget.TreeRPCController");
14
dojo.require("dojo.event.*");
15
dojo.require("dojo.json");
16
dojo.require("dojo.io.*");
17
dojo.require("dojo.widget.TreeLoadingController");
18
dojo.widget.defineWidget("dojo.widget.TreeRPCController", dojo.widget.TreeLoadingController, {doMove:function (child, newParent, index) {
19
	var params = {child:this.getInfo(child), childTree:this.getInfo(child.tree), newParent:this.getInfo(newParent), newParentTree:this.getInfo(newParent.tree), newIndex:index};
20
	var success;
21
	this.runRPC({url:this.getRPCUrl("move"), load:function (response) {
22
		success = this.doMoveProcessResponse(response, child, newParent, index);
23
	}, sync:true, lock:[child, newParent], params:params});
24
	return success;
25
}, doMoveProcessResponse:function (response, child, newParent, index) {
26
	if (!dojo.lang.isUndefined(response.error)) {
27
		this.RPCErrorHandler("server", response.error);
28
		return false;
29
	}
30
	var args = [child, newParent, index];
31
	return dojo.widget.TreeLoadingController.prototype.doMove.apply(this, args);
32
}, doRemoveNode:function (node, callObj, callFunc) {
33
	var params = {node:this.getInfo(node), tree:this.getInfo(node.tree)};
34
	this.runRPC({url:this.getRPCUrl("removeNode"), load:function (response) {
35
		this.doRemoveNodeProcessResponse(response, node, callObj, callFunc);
36
	}, params:params, lock:[node]});
37
}, doRemoveNodeProcessResponse:function (response, node, callObj, callFunc) {
38
	if (!dojo.lang.isUndefined(response.error)) {
39
		this.RPCErrorHandler("server", response.error);
40
		return false;
41
	}
42
	if (!response) {
43
		return false;
44
	}
45
	if (response == true) {
46
		var args = [node, callObj, callFunc];
47
		dojo.widget.TreeLoadingController.prototype.doRemoveNode.apply(this, args);
48
		return;
49
	} else {
50
		if (dojo.lang.isObject(response)) {
51
			dojo.raise(response.error);
52
		} else {
53
			dojo.raise("Invalid response " + response);
54
		}
55
	}
56
}, doCreateChild:function (parent, index, output, callObj, callFunc) {
57
	var params = {tree:this.getInfo(parent.tree), parent:this.getInfo(parent), index:index, data:output};
58
	this.runRPC({url:this.getRPCUrl("createChild"), load:function (response) {
59
		this.doCreateChildProcessResponse(response, parent, index, callObj, callFunc);
60
	}, params:params, lock:[parent]});
61
}, doCreateChildProcessResponse:function (response, parent, index, callObj, callFunc) {
62
	if (!dojo.lang.isUndefined(response.error)) {
63
		this.RPCErrorHandler("server", response.error);
64
		return false;
65
	}
66
	if (!dojo.lang.isObject(response)) {
67
		dojo.raise("Invalid result " + response);
68
	}
69
	var args = [parent, index, response, callObj, callFunc];
70
	dojo.widget.TreeLoadingController.prototype.doCreateChild.apply(this, args);
71
}});
72