Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | 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
 
11
dojo.provide("dojo.widget.TreeRPCController");
12
dojo.require("dojo.event.*");
13
dojo.require("dojo.json");
14
dojo.require("dojo.io.*");
15
dojo.require("dojo.widget.TreeLoadingController");
16
dojo.widget.defineWidget("dojo.widget.TreeRPCController", dojo.widget.TreeLoadingController, {doMove:function (child, newParent, index) {
17
	var params = {child:this.getInfo(child), childTree:this.getInfo(child.tree), newParent:this.getInfo(newParent), newParentTree:this.getInfo(newParent.tree), newIndex:index};
18
	var success;
19
	this.runRPC({url:this.getRPCUrl("move"), load:function (response) {
20
		success = this.doMoveProcessResponse(response, child, newParent, index);
21
	}, sync:true, lock:[child, newParent], params:params});
22
	return success;
23
}, doMoveProcessResponse:function (response, child, newParent, index) {
24
	if (!dojo.lang.isUndefined(response.error)) {
25
		this.RPCErrorHandler("server", response.error);
26
		return false;
27
	}
28
	var args = [child, newParent, index];
29
	return dojo.widget.TreeLoadingController.prototype.doMove.apply(this, args);
30
}, doRemoveNode:function (node, callObj, callFunc) {
31
	var params = {node:this.getInfo(node), tree:this.getInfo(node.tree)};
32
	this.runRPC({url:this.getRPCUrl("removeNode"), load:function (response) {
33
		this.doRemoveNodeProcessResponse(response, node, callObj, callFunc);
34
	}, params:params, lock:[node]});
35
}, doRemoveNodeProcessResponse:function (response, node, callObj, callFunc) {
36
	if (!dojo.lang.isUndefined(response.error)) {
37
		this.RPCErrorHandler("server", response.error);
38
		return false;
39
	}
40
	if (!response) {
41
		return false;
42
	}
43
	if (response == true) {
44
		var args = [node, callObj, callFunc];
45
		dojo.widget.TreeLoadingController.prototype.doRemoveNode.apply(this, args);
46
		return;
47
	} else {
48
		if (dojo.lang.isObject(response)) {
49
			dojo.raise(response.error);
50
		} else {
51
			dojo.raise("Invalid response " + response);
52
		}
53
	}
54
}, doCreateChild:function (parent, index, output, callObj, callFunc) {
55
	var params = {tree:this.getInfo(parent.tree), parent:this.getInfo(parent), index:index, data:output};
56
	this.runRPC({url:this.getRPCUrl("createChild"), load:function (response) {
57
		this.doCreateChildProcessResponse(response, parent, index, callObj, callFunc);
58
	}, params:params, lock:[parent]});
59
}, doCreateChildProcessResponse:function (response, parent, index, callObj, callFunc) {
60
	if (!dojo.lang.isUndefined(response.error)) {
61
		this.RPCErrorHandler("server", response.error);
62
		return false;
63
	}
64
	if (!dojo.lang.isObject(response)) {
65
		dojo.raise("Invalid result " + response);
66
	}
67
	var args = [parent, index, response, callObj, callFunc];
68
	dojo.widget.TreeLoadingController.prototype.doCreateChild.apply(this, args);
69
}});
70