@@ -136,9 +136,7 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
136136 __isDraggingFile : null ,
137137 __isDraggingLink : null ,
138138 __annotations : null ,
139- __annotatingNote : null ,
140- __annotatingRect : null ,
141- __annotatingText : null ,
139+ __annotating : null ,
142140 __annotationInitPos : null ,
143141 __selectedAnnotations : null ,
144142 __annotationEditor : null ,
@@ -329,19 +327,19 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
329327 } ) ;
330328 temporaryNodeUI . getContentElement ( ) . addClass ( "rotate" ) ;
331329 this . __workbenchLayout . add ( temporaryNodeUI ) ;
332- temporaryNodeUI . rect = this . __svgLayer . drawDashedRect ( boxWidth , boxHeight ) ;
330+ temporaryNodeUI [ " rect" ] = this . __svgLayer . drawDashedRect ( boxWidth , boxHeight ) ;
333331 temporaryNodeUI . setLayoutProperties ( {
334332 left : pos . x + parseInt ( boxWidth / 2 ) - parseInt ( circleSize / 2 ) ,
335333 top : pos . y + parseInt ( boxHeight / 2 ) - parseInt ( circleSize / 2 )
336334 } ) ;
337- osparc . wrapper . Svg . updateItemPos ( temporaryNodeUI . rect , pos . x , pos . y ) ;
335+ osparc . wrapper . Svg . updateItemPos ( temporaryNodeUI [ " rect" ] , pos . x , pos . y ) ;
338336
339337 return temporaryNodeUI ;
340338 } ,
341339
342340 __removeTemporaryNodeUI : function ( temporaryNodeUI ) {
343341 temporaryNodeUI . exclude ( ) ;
344- osparc . wrapper . Svg . removeItem ( temporaryNodeUI . rect ) ;
342+ osparc . wrapper . Svg . removeItem ( temporaryNodeUI [ " rect" ] ) ;
345343 this . __workbenchLayout . add ( temporaryNodeUI ) ;
346344 temporaryNodeUI = null ;
347345 } ,
@@ -1408,7 +1406,7 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
14081406
14091407 __mouseDownOnSVG : function ( e ) {
14101408 if ( e . isLeftPressed ( ) ) {
1411- if ( this . __annotatingNote || this . __annotatingRect || this . __annotatingText ) {
1409+ if ( this . __annotating ) {
14121410 this . __annotationInitPos = this . __pointerEventToWorkbenchPos ( e ) ;
14131411 } else {
14141412 this . __selectionRectInitPos = this . __pointerEventToWorkbenchPos ( e ) ;
@@ -1419,7 +1417,7 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
14191417 __mouseMove : function ( e ) {
14201418 if ( this . __isDraggingLink ) {
14211419 this . __draggingLink ( e , true ) ;
1422- } else if ( this . __tempEdgeRepr === null && ( this . __annotatingNote || this . __annotatingRect || this . __annotatingText ) && this . __annotationInitPos && e . isLeftPressed ( ) ) {
1420+ } else if ( this . __tempEdgeRepr === null && this . __annotating && this . __annotationInitPos && e . isLeftPressed ( ) ) {
14231421 this . __drawingAnnotation ( e ) ;
14241422 } else if ( this . __tempEdgeRepr === null && this . __selectionRectInitPos && e . isLeftPressed ( ) ) {
14251423 this . __drawingSelectionRect ( e ) ;
@@ -1449,23 +1447,13 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
14491447 if ( this . __annotationInitPos ) {
14501448 this . __annotationInitPos = null ;
14511449 }
1452- if ( this . __annotatingNote || this . __annotatingRect || this . __annotatingText ) {
1453- let annotationType = null ;
1454- if ( this . __annotatingNote ) {
1455- annotationType = "note" ;
1456- } else if ( this . __annotatingRect ) {
1457- annotationType = "rect" ;
1458- } else if ( this . __annotatingText ) {
1459- annotationType = "text" ;
1460- }
1461- if ( this . __consolidateAnnotation ( annotationType , annotationInitPos , this . __rectAnnotationRepr ) ) {
1450+ if ( this . __annotating ) {
1451+ if ( this . __consolidateAnnotation ( this . __annotating , annotationInitPos , this . __rectAnnotationRepr ) ) {
14621452 if ( this . __rectAnnotationRepr ) {
14631453 osparc . wrapper . Svg . removeItem ( this . __rectAnnotationRepr ) ;
14641454 this . __rectAnnotationRepr = null ;
14651455 }
1466- this . __annotatingNote = false ;
1467- this . __annotatingRect = false ;
1468- this . __annotatingText = false ;
1456+ this . __annotating = null ;
14691457 this . __toolHint . setValue ( null ) ;
14701458 }
14711459 }
@@ -1607,23 +1595,17 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
16071595 } ,
16081596
16091597 startAnnotationsNote : function ( ) {
1610- this . __annotatingNote = true ;
1611- this . __annotatingRect = false ;
1612- this . __annotatingText = false ;
1598+ this . __annotating = osparc . workbench . Annotation . TYPES . NOTE ;
16131599 this . __toolHint . setValue ( this . tr ( "Pick the position" ) ) ;
16141600 } ,
16151601
16161602 startAnnotationsRect : function ( ) {
1617- this . __annotatingNote = false ;
1618- this . __annotatingRect = true ;
1619- this . __annotatingText = false ;
1603+ this . __annotating = osparc . workbench . Annotation . TYPES . RECT ;
16201604 this . __toolHint . setValue ( this . tr ( "Draw a rectangle" ) ) ;
16211605 } ,
16221606
16231607 startAnnotationsText : function ( workbenchPos ) {
1624- this . __annotatingNote = false ;
1625- this . __annotatingText = true ;
1626- this . __annotatingRect = false ;
1608+ this . __annotating = osparc . workbench . Annotation . TYPES . TEXT ;
16271609 if ( workbenchPos ) {
16281610 this . __annotationInitPos = workbenchPos ;
16291611 this . __mouseUp ( ) ;
@@ -1825,7 +1807,7 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
18251807 } ) ;
18261808 dropHereNodeUI . exclude ( ) ;
18271809 this . __workbenchLayout . add ( dropHereNodeUI ) ;
1828- dropHereNodeUI . rect = this . __svgLayer . drawDashedRect ( boxWidth , boxHeight ) ;
1810+ dropHereNodeUI [ " rect" ] = this . __svgLayer . drawDashedRect ( boxWidth , boxHeight ) ;
18291811 }
18301812 let dropHere = this . __dropHereUI ;
18311813 if ( show ) {
@@ -1836,11 +1818,11 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
18361818 top : posY - parseInt ( dropMeBounds . height / 2 ) - parseInt ( boxHeight / 2 )
18371819 } ) ;
18381820 if ( "rect" in dropHere ) {
1839- osparc . wrapper . Svg . updateItemPos ( dropHere . rect , posX - boxWidth , posY - boxHeight ) ;
1821+ osparc . wrapper . Svg . updateItemPos ( dropHere [ " rect" ] , posX - boxWidth , posY - boxHeight ) ;
18401822 }
18411823 } else {
18421824 dropHere . exclude ( ) ;
1843- osparc . wrapper . Svg . removeItem ( dropHere . rect ) ;
1825+ osparc . wrapper . Svg . removeItem ( dropHere [ " rect" ] ) ;
18441826 dropHere = null ;
18451827 }
18461828 } ,
@@ -1915,13 +1897,14 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
19151897 } ,
19161898
19171899 __consolidateAnnotation : function ( type , initPos , annotation ) {
1900+ const annotationTypes = osparc . workbench . Annotation . TYPES ;
19181901 const color = this . __annotationLastColor ? this . __annotationLastColor : osparc . workbench . Annotation . DEFAULT_COLOR ;
19191902 const serializeData = {
19201903 type,
19211904 color,
19221905 attributes : { }
19231906 } ;
1924- if ( type === "rect" ) {
1907+ if ( type === annotationTypes . RECT ) {
19251908 if ( [ null , undefined ] . includes ( annotation ) ) {
19261909 osparc . FlashMessenger . logAs ( this . tr ( "Draw a rectangle first" ) , "WARNING" ) ;
19271910 return false ;
@@ -1930,7 +1913,7 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
19301913 } else {
19311914 serializeData . attributes = initPos ;
19321915 }
1933- if ( type === "note" ) {
1916+ if ( type === annotationTypes . NOTE ) {
19341917 const noteEditor = new osparc . editor . AnnotationNoteCreator ( this . getStudy ( ) ) ;
19351918 const win = osparc . editor . AnnotationNoteCreator . popUpInWindow ( noteEditor ) ;
19361919 noteEditor . addListener ( "addNote" , ( ) => {
@@ -1945,11 +1928,11 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
19451928 win . close ( ) ;
19461929 } , this ) ;
19471930 noteEditor . addListener ( "cancel" , ( ) => win . close ( ) ) ;
1948- } else if ( type === "rect" ) {
1931+ } else if ( type === annotationTypes . RECT ) {
19491932 this . __addAnnotation ( serializeData ) ;
1950- } else if ( type === "text" ) {
1933+ } else if ( type === annotationTypes . TEXT ) {
19511934 const tempAnnotation = new osparc . workbench . Annotation ( null , {
1952- type : "text" ,
1935+ type : annotationTypes . TEXT ,
19531936 color,
19541937 attributes : {
19551938 text : "" ,
0 commit comments