]> git.argeo.org Git - gpl/argeo-slc.git/blob - ContextNodeInputView.js
bf01cefbc41d22c3c181d03d94a9588ad36980c7
[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: 5,
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.selectionInput.setReadOnly(true);
64 this.add(this.selectionInput);
65
66 this._attachInputsToDM();
67 },
68 /**
69 * The implementation should contain the real data loading (i.o. query...)
70 * @return {Boolean}
71 */
72 load : function(){
73 },
74
75 _attachInputsToDM : function(){
76 var dm = this.getDataModel();
77 this.contextInput.addListener("keypress", function(event){
78 if(event.getKeyIdentifier() != "Enter") return;
79 var path = this.contextInput.getValue();
80 dm.requireContextChange(path);
81 }, this);
82 dm.addListener("changeContextNode", function(event){
83 var ctxtNode = event.getData();
84 this.contextInput.setValue(ctxtNode.getPath());
85 }, this);
86 dm.addListener("changeSelection", function(event){
87 var sel = event.getData();
88 if(!sel.length){
89 this.selectionInput.setValue("/");
90 }else{
91 this.selectionInput.setValue(sel[0].getPath().substring(this.contextInput.getValue().length));
92 }
93 },this);
94 },
95
96 /**
97 * Whether this component is already contained in a scroller (return false) or not (return true).
98 * @return {Boolean}
99 */
100 addScroll : function(){
101 return false;
102 },
103 /**
104 * Called at destruction time
105 * Perform all the clean operations (stopping polling queries, etc.)
106 */
107 close : function(){
108
109 }
110 }
111
112
113 });