@@ -7,6 +7,7 @@ import { Constraint } from "../constraint/Constraint";
77import { LabelType } from "../labels/LabelType" ;
88import { DefaultFitToScreenAction } from "../fitToScreen/action" ;
99import { FileName } from "../fileName/fileName" ;
10+ import { ConstraintRegistry } from "../constraint/constraintRegistry" ;
1011
1112export interface FileData < T > {
1213 fileName : string ;
@@ -33,6 +34,7 @@ export abstract class LoadJsonCommand extends Command {
3334 constructor (
3435 private readonly logger : ILogger ,
3536 protected readonly labelTypeRegistry : LabelTypeRegistry ,
37+ protected constraintRegistry : ConstraintRegistry ,
3638 protected editorModeController : EditorModeController ,
3739 private actionDispatcher : ActionDispatcher ,
3840 protected fileName : FileName
@@ -75,7 +77,13 @@ export abstract class LoadJsonCommand extends Command {
7577 }
7678 this . logger . info ( this , "Editor mode loaded successfully" ) ;
7779
78- // TODO: load constraints
80+ this . oldConstrains = this . constraintRegistry . getConstraintList ( )
81+ const newConstraints = this . file . content . constraints
82+ if ( newConstraints ) {
83+ this . constraintRegistry . setConstraintsFromArray ( newConstraints )
84+ } else {
85+ this . constraintRegistry . clearConstraints ( )
86+ }
7987
8088 // TODO: post load actions like layout
8189 this . actionDispatcher . dispatch ( DefaultFitToScreenAction . create ( this . newRoot ) )
@@ -108,7 +116,9 @@ export abstract class LoadJsonCommand extends Command {
108116 this . editorModeController . set ( this . oldEditorMode ) ;
109117 }
110118
111- // TODO: load constraints
119+ if ( this . oldConstrains ) {
120+ this . constraintRegistry . setConstraintsFromArray ( this . oldConstrains )
121+ }
112122
113123 this . fileName . setName ( this . oldFileName ?? 'diagram' ) ;
114124
@@ -133,7 +143,12 @@ export abstract class LoadJsonCommand extends Command {
133143 }
134144 this . logger . info ( this , "Editor mode loaded successfully" ) ;
135145
136- // TODO: load constraints
146+ const newConstraints = this . file ?. content . constraints
147+ if ( newConstraints ) {
148+ this . constraintRegistry . setConstraintsFromArray ( newConstraints )
149+ } else {
150+ this . constraintRegistry . clearConstraints ( )
151+ }
137152
138153 this . fileName . setName ( this . file ?. fileName ?? 'diagram' ) ;
139154
0 commit comments