@@ -162,24 +162,50 @@ qx.Class.define("osparc.data.model.StudyUI", {
162162 if ( currentStudy ) {
163163 Object . keys ( uiDiff [ "workbench" ] ) . forEach ( nodeId => {
164164 const node = currentStudy . getWorkbench ( ) . getNode ( nodeId ) ;
165- if ( node ) {
166- if ( "position" in uiDiff [ "workbench" ] [ nodeId ] ) {
167- const position = uiDiff [ "workbench" ] [ nodeId ] [ "position" ] ;
168- const newPos = node . getPosition ( ) ;
169- if ( "x" in position ) {
170- newPos . x = position [ "x" ] [ 1 ] ;
171- }
172- if ( "y" in position ) {
173- newPos . y = position [ "y" ] [ 1 ] ;
174- }
175- node . setPosition ( newPos ) ;
176- }
165+ if ( "position" in uiDiff [ "workbench" ] [ nodeId ] ) {
166+ const positionDiff = uiDiff [ "workbench" ] [ nodeId ] [ "position" ] ;
167+ this . __updatePositionFromDiff ( node , positionDiff ) ;
168+ }
169+ if ( "marker" in uiDiff [ "workbench" ] [ nodeId ] ) {
170+ const markerDiff = uiDiff [ "workbench" ] [ nodeId ] [ "marker" ] ;
171+ this . __updateMarkerFromDiff ( node , markerDiff ) ;
177172 }
178173 } ) ;
179174 }
180175 }
181176 } ,
182177
178+ __updatePositionFromDiff : function ( node , positionDiff ) {
179+ if ( node ) {
180+ const newPos = node . getPosition ( ) ;
181+ if ( "x" in positionDiff ) {
182+ newPos . x = positionDiff [ "x" ] [ 1 ] ;
183+ }
184+ if ( "y" in positionDiff ) {
185+ newPos . y = positionDiff [ "y" ] [ 1 ] ;
186+ }
187+ node . setPosition ( newPos ) ;
188+ }
189+ } ,
190+
191+ __updateMarkerFromDiff : function ( node , markerDiff ) {
192+ if ( node ) {
193+ if ( markerDiff instanceof Array ) {
194+ if ( markerDiff . length === 1 ) {
195+ // it was added
196+ node . addMarker ( markerDiff [ 0 ] ) ;
197+ } else if ( markerDiff . length === 2 && markerDiff [ 1 ] === null ) {
198+ // it was removed
199+ node . setMarker ( null ) ;
200+ }
201+ } else if ( "color" in markerDiff && markerDiff [ "color" ] instanceof Array ) {
202+ // it was updated
203+ const newColor = markerDiff [ "color" ] [ 1 ] ;
204+ node . getMarker ( ) . setColor ( newColor ) ;
205+ }
206+ }
207+ } ,
208+
183209 listenToChanges : function ( ) {
184210 const propertyKeys = Object . keys ( qx . util . PropertyUtil . getProperties ( osparc . data . model . StudyUI ) ) ;
185211 this . self ( ) . ListenChangesProps . forEach ( key => {
0 commit comments