@@ -72,69 +72,86 @@ qx.Class.define("osparc.widget.Renamer", {
7272 } ,
7373
7474 members : {
75- __save : null ,
75+ _createChildControlImpl : function ( id ) {
76+ let control ;
77+ switch ( id ) {
78+ case "main-layout" :
79+ control = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( 10 ) ) ;
80+ this . add ( control ) ;
81+ break ;
82+ case "text-field" :
83+ control = new qx . ui . form . TextField ( ) . set ( {
84+ placeholder : this . tr ( "Type text" ) ,
85+ allowGrowX : true
86+ } ) ;
87+ this . getChildControl ( "main-layout" ) . add ( control , {
88+ flex : 1
89+ } ) ;
90+ break ;
91+ case "save-button" :
92+ control = new qx . ui . form . Button ( this . tr ( "Save" ) ) . set ( {
93+ appearance : "form-button" ,
94+ padding : [ 1 , 5 ]
95+ } ) ;
96+ control . addListener ( "execute" , ( ) => {
97+ const newLabel = this . getChildControl ( "text-field" ) . getValue ( ) ;
98+ const data = {
99+ newLabel
100+ } ;
101+ this . fireDataEvent ( "labelChanged" , data ) ;
102+ } , this ) ;
103+ this . getChildControl ( "main-layout" ) . add ( control ) ;
104+ break ;
105+ case "subtitle" :
106+ control = new qx . ui . basic . Label ( ) . set ( {
107+ font : "text-12"
108+ } ) ;
109+ this . add ( control ) ;
110+ break ;
111+ }
112+ return control || this . base ( arguments , id ) ;
113+ } ,
76114
77115 __populateNodeLabelEditor : function ( oldLabel , labelWidth ) {
78116 const nodeLabelEditor = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( 10 ) ) ;
79117
80118 // Create a text field in which to edit the data
81- const labelEditor = new qx . ui . form . TextField ( oldLabel ) . set ( {
82- placeholder : this . tr ( "Type text" ) ,
83- allowGrowX : true ,
84- minWidth : labelWidth
85- } ) ;
86- nodeLabelEditor . add ( labelEditor , {
87- flex : 1
119+ const textField = this . getChildControl ( "text-field" ) . set ( {
120+ value : oldLabel ,
121+ minWidth : labelWidth ,
88122 } ) ;
89123
90124 this . addListener ( "appear" , e => {
91- labelEditor . focus ( ) ;
92- if ( labelEditor . getValue ( ) ) {
93- labelEditor . setTextSelection ( 0 , labelEditor . getValue ( ) . length ) ;
125+ textField . focus ( ) ;
126+ if ( textField . getValue ( ) ) {
127+ textField . setTextSelection ( 0 , textField . getValue ( ) . length ) ;
94128 }
95129 } , this ) ;
96130
97131 // Create the "Save" button to close the cell editor
98- const save = this . __save = new qx . ui . form . Button ( this . tr ( "Save" ) ) ;
99- save . set ( {
100- appearance : "form-button" ,
101- padding : [ 1 , 5 ]
102- } ) ;
103- save . addListener ( "execute" , e => {
104- const newLabel = labelEditor . getValue ( ) ;
105- const data = {
106- newLabel
107- } ;
108- this . fireDataEvent ( "labelChanged" , data ) ;
109- } , this ) ;
110- nodeLabelEditor . add ( save ) ;
111-
112- this . add ( nodeLabelEditor ) ;
132+ this . getChildControl ( "save-button" ) ;
113133 } ,
114134
115135 __applyMaxChars : function ( value ) {
116136 this . __addSubtitle ( this . tr ( "%1 characters max" , value ) ) ;
117137 } ,
118138
119- __addSubtitle : function ( subtitleLabel ) {
120- if ( subtitleLabel ) {
121- const subtitle = new qx . ui . basic . Label ( subtitleLabel ) . set ( {
122- font : "text-12"
123- } ) ;
124- this . add ( subtitle ) ;
139+ __addSubtitle : function ( subtitleText ) {
140+ if ( subtitleText ) {
141+ this . getChildControl ( "subtitle" ) . setValue ( subtitleText ) ;
125142 }
126143 } ,
127144
128145 __attachEventHandlers : function ( ) {
129146 let command = new qx . ui . command . Command ( "Enter" ) ;
130- command . addListener ( "execute" , e => {
131- this . __save . execute ( ) ;
147+ command . addListener ( "execute" , ( ) => {
148+ this . getChildControl ( "save-button" ) . execute ( ) ;
132149 command . dispose ( ) ;
133150 command = null ;
134151 } ) ;
135152
136153 let commandEsc = new qx . ui . command . Command ( "Esc" ) ;
137- commandEsc . addListener ( "execute" , e => {
154+ commandEsc . addListener ( "execute" , ( ) => {
138155 this . close ( ) ;
139156 commandEsc . dispose ( ) ;
140157 commandEsc = null ;
0 commit comments