]> git.argeo.org Git - gpl/argeo-slc.git/blob - ContextNodeInputView.js
5b94762c17ca7a5e2ca27a104adb741f7c0e38ed
[gpl/argeo-slc.git] / ContextNodeInputView.js
1 qx.Class.define("org.argeo.jcr.ria.views.ContextNodeInputView", {
2 extend : qx.ui.container.Composite,
3 implement : [org.argeo.ria.components.IView],
4
5 properties : {
6 /**
7 * The commands definition Map that will be automatically added and wired to the menubar and toolbar.
8 * See {@link org.argeo.ria.event.CommandsManager#definitions} for the keys to use for defining commands.
9 */
10 commands : {
11 init : {}
12 },
13 viewSelection : {
14 nullable:false,
15 check:"org.argeo.ria.components.ViewSelection"
16 },
17 instanceId : {
18 init:"inputViewer",
19 event : "changeInstanceId"
20 },
21 instanceLabel : {
22 init:"Xml Editor",
23 event : "changeInstanceLabel"
24 },
25 dataModel : {
26
27 }
28 },
29
30 construct : function(){
31 this.base(arguments);
32 },
33
34 members : {
35 /**
36 * The implementation should contain the GUI initialisation.
37 * This is the role of the manager to actually add the graphical component to the pane,
38 * so it's not necessary to do it here.
39 * @param viewPane {org.argeo.ria.components.ViewPane} The pane manager
40 * @param data {Mixed} Any object or data passed by the initiator of the view
41 * @return {Boolean}
42 */
43 init : function(viewPane, dataModel){
44 this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId()));
45 this.set({
46 layout : new qx.ui.layout.HBox(),
47 dataModel : dataModel,
48 padding: 10,
49 decorator : 'toolbar'
50 });
51
52 this.contextInput = new qx.ui.form.TextField();
53 this.contextInput.setWidth(100);
54 this.contextInput.setTextAlign("right");
55 this.add(this.contextInput);
56
57 var sep = new qx.ui.basic.Label(":");
58 sep.set({paddingTop:3, paddingLeft:2,paddingRight:2});
59 this.add(sep);
60
61 this.selectionInput = new qx.ui.form.TextField();
62 this.selectionInput.setWidth(300);
63 this.add(this.selectionInput);
64
65 this._attachInputsToDM();
66 },
67 /**
68 * The implementation should contain the real data loading (i.o. query...)
69 * @return {Boolean}
70 */
71 load : function(){
72 },
73
74 _attachInputsToDM : function(){
75 var dm = this.getDataModel();
76 this.contextInput.addListener("keypress", function(event){
77 if(event.getKeyIdentifier() != "Enter") return;
78 var path = this.contextInput.getValue();
79 dm.requireContextChange(path);
80 }, this);
81 dm.addListener("changeContextNode", function(event){
82 var ctxtNode = event.getData();
83 this.contextInput.setValue(ctxtNode.getPath());
84 }, this);
85 dm.addListener("changeSelection", function(event){
86 var sel = event.getData();
87 if(!sel.length){
88 this.selectionInput.setValue("/");
89 }else{
90 this.selectionInput.setValue(sel[0].getPath().substring(this.contextInput.getValue().length));
91 }
92 },this);
93 },
94
95 /**
96 * Whether this component is already contained in a scroller (return false) or not (return true).
97 * @return {Boolean}
98 */
99 addScroll : function(){
100 return false;
101 },
102 /**
103 * Called at destruction time
104 * Perform all the clean operations (stopping polling queries, etc.)
105 */
106 close : function(){
107
108 }
109 }
110
111
112 });