1- import { injectable } from "inversify" ;
1+ import { inject , injectable } from "inversify" ;
22import { KeyListener , SModelElementImpl , CommitModelAction } from "sprotty" ;
33import { Action } from "sprotty-protocol" ;
44import { matchesKeystroke } from "sprotty/lib/utils/keyboard" ;
55import { LoadDefaultDiagramAction } from "../serialize/loadDefaultDiagram" ;
66import { LoadJsonFileAction } from "../serialize/loadJsonFile" ;
77import { SaveJsonFileAction } from "../serialize/saveJsonFile" ;
88import { AnalyzeAction } from "../serialize/analyze" ;
9+ import { SelectConstraintsAction } from "../constraint/selection" ;
10+ import { ConstraintRegistry } from "../constraint/constraintRegistry" ;
911
1012@injectable ( )
1113export class SerializeKeyListener extends KeyListener {
14+ constructor ( @inject ( ConstraintRegistry ) private readonly constraintRegistry : ConstraintRegistry ) {
15+ super ( ) ;
16+ }
17+
1218 keyDown ( _element : SModelElementImpl , event : KeyboardEvent ) : Action [ ] {
1319 if ( matchesKeystroke ( event , "KeyO" , "ctrlCmd" ) ) {
1420 // Prevent the browser file open dialog from opening
@@ -23,7 +29,11 @@ export class SerializeKeyListener extends KeyListener {
2329 return [ SaveJsonFileAction . create ( ) ] ;
2430 } else if ( matchesKeystroke ( event , "KeyA" , "ctrlCmd" , "shift" ) ) {
2531 event . preventDefault ( ) ;
26- return [ AnalyzeAction . create ( ) , CommitModelAction . create ( ) ] ;
32+ return [
33+ AnalyzeAction . create ( ) ,
34+ SelectConstraintsAction . create ( this . constraintRegistry . getConstraintList ( ) . map ( ( c ) => c . name ) ) ,
35+ CommitModelAction . create ( ) ,
36+ ] ;
2737 }
2838
2939 return [ ] ;
0 commit comments