@finos/legend-extension-dsl-data-space 0.1.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/lib/DSLDataSpace_Extension.d.ts +0 -10
  3. package/lib/DSLDataSpace_Extension.d.ts.map +1 -1
  4. package/lib/DSLDataSpace_Extension.js +0 -24
  5. package/lib/DSLDataSpace_Extension.js.map +1 -1
  6. package/lib/components/{query/DataSpaceViewer.d.ts → DataSpaceViewer.d.ts} +1 -1
  7. package/lib/components/DataSpaceViewer.d.ts.map +1 -0
  8. package/lib/components/DataSpaceViewer.js +186 -0
  9. package/lib/components/DataSpaceViewer.js.map +1 -0
  10. package/lib/components/query/{DSLDataSpace_QueryPlugin.d.ts → DSLDataSpace_LegendQueryPlugin.d.ts} +4 -5
  11. package/lib/components/query/DSLDataSpace_LegendQueryPlugin.d.ts.map +1 -0
  12. package/lib/components/query/{DSLDataSpace_QueryPlugin.js → DSLDataSpace_LegendQueryPlugin.js} +4 -7
  13. package/lib/components/query/DSLDataSpace_LegendQueryPlugin.js.map +1 -0
  14. package/lib/components/query/DataSpaceQuerySetup.d.ts.map +1 -1
  15. package/lib/components/query/DataSpaceQuerySetup.js +15 -8
  16. package/lib/components/query/DataSpaceQuerySetup.js.map +1 -1
  17. package/lib/components/studio/{DSLDataSpace_StudioPlugin.d.ts → DSLDataSpace_LegendStudioPlugin.d.ts} +4 -5
  18. package/lib/components/studio/DSLDataSpace_LegendStudioPlugin.d.ts.map +1 -0
  19. package/lib/components/studio/{DSLDataSpace_StudioPlugin.js → DSLDataSpace_LegendStudioPlugin.js} +6 -8
  20. package/lib/components/studio/DSLDataSpace_LegendStudioPlugin.js.map +1 -0
  21. package/lib/graph/DSLDataSpace_PureGraphPlugin.d.ts +1 -2
  22. package/lib/graph/DSLDataSpace_PureGraphPlugin.d.ts.map +1 -1
  23. package/lib/graph/DSLDataSpace_PureGraphPlugin.js +0 -3
  24. package/lib/graph/DSLDataSpace_PureGraphPlugin.js.map +1 -1
  25. package/lib/graphManager/DSLDataSpace_PureGraphManagerPlugin.d.ts +1 -2
  26. package/lib/graphManager/DSLDataSpace_PureGraphManagerPlugin.d.ts.map +1 -1
  27. package/lib/graphManager/DSLDataSpace_PureGraphManagerPlugin.js +0 -3
  28. package/lib/graphManager/DSLDataSpace_PureGraphManagerPlugin.js.map +1 -1
  29. package/lib/index.css +2 -2
  30. package/lib/index.css.map +1 -1
  31. package/lib/index.d.ts +5 -0
  32. package/lib/index.d.ts.map +1 -1
  33. package/lib/index.js +5 -0
  34. package/lib/index.js.map +1 -1
  35. package/lib/models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin.d.ts +13 -2
  36. package/lib/models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin.d.ts.map +1 -1
  37. package/lib/models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin.js +45 -5
  38. package/lib/models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin.js.map +1 -1
  39. package/lib/stores/DataSpaceViewerState.d.ts +59 -0
  40. package/lib/stores/DataSpaceViewerState.d.ts.map +1 -0
  41. package/lib/stores/DataSpaceViewerState.js +137 -0
  42. package/lib/stores/DataSpaceViewerState.js.map +1 -0
  43. package/lib/stores/query/DataSpaceQuerySetupState.d.ts +9 -34
  44. package/lib/stores/query/DataSpaceQuerySetupState.d.ts.map +1 -1
  45. package/lib/stores/query/DataSpaceQuerySetupState.js +44 -136
  46. package/lib/stores/query/DataSpaceQuerySetupState.js.map +1 -1
  47. package/package.json +24 -22
  48. package/src/DSLDataSpace_Extension.ts +0 -30
  49. package/src/components/{query/DataSpaceViewer.tsx → DataSpaceViewer.tsx} +216 -121
  50. package/src/components/query/{DSLDataSpace_QueryPlugin.tsx → DSLDataSpace_LegendQueryPlugin.tsx} +2 -7
  51. package/src/components/query/DataSpaceQuerySetup.tsx +30 -5
  52. package/src/components/studio/{DSLDataSpace_StudioPlugin.tsx → DSLDataSpace_LegendStudioPlugin.tsx} +8 -12
  53. package/src/graph/DSLDataSpace_PureGraphPlugin.ts +1 -8
  54. package/src/graphManager/DSLDataSpace_PureGraphManagerPlugin.ts +0 -5
  55. package/src/index.ts +12 -0
  56. package/src/models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin.ts +71 -5
  57. package/src/stores/DataSpaceViewerState.ts +202 -0
  58. package/src/stores/query/DataSpaceQuerySetupState.ts +99 -200
  59. package/tsconfig.json +5 -3
  60. package/tsconfig.package.json +1 -0
  61. package/lib/components/query/DSLDataSpace_QueryPlugin.d.ts.map +0 -1
  62. package/lib/components/query/DSLDataSpace_QueryPlugin.js.map +0 -1
  63. package/lib/components/query/DataSpaceViewer.d.ts.map +0 -1
  64. package/lib/components/query/DataSpaceViewer.js +0 -163
  65. package/lib/components/query/DataSpaceViewer.js.map +0 -1
  66. package/lib/components/studio/DSLDataSpace_StudioPlugin.d.ts.map +0 -1
  67. package/lib/components/studio/DSLDataSpace_StudioPlugin.js.map +0 -1
@@ -16,12 +16,11 @@
16
16
 
17
17
  import packageJson from '../../../package.json';
18
18
  import type {
19
- StudioPluginManager,
20
19
  NewElementFromStateCreator,
21
20
  ElementTypeGetter,
22
21
  ElementProjectExplorerDnDTypeGetter,
23
22
  ElementIconGetter,
24
- DSL_StudioPlugin_Extension,
23
+ DSL_LegendStudioPlugin_Extension,
25
24
  NewElementState,
26
25
  ElementEditorStateCreator,
27
26
  EditorStore,
@@ -29,7 +28,7 @@ import type {
29
28
  } from '@finos/legend-studio';
30
29
  import {
31
30
  UnsupportedElementEditorState,
32
- StudioPlugin,
31
+ LegendStudioPlugin,
33
32
  } from '@finos/legend-studio';
34
33
  import { SquareIcon } from '@finos/legend-art';
35
34
  import type { PackageableElement } from '@finos/legend-graph';
@@ -37,23 +36,20 @@ import {
37
36
  DataSpace,
38
37
  DataSpaceExecutionContext,
39
38
  } from '../../models/metamodels/pure/model/packageableElements/dataSpace/DataSpace';
39
+ import { LATEST_VERSION_ALIAS } from '@finos/legend-server-depot';
40
40
 
41
41
  const DATA_SPACE_ELEMENT_TYPE = 'DATA SPACE';
42
42
  const DATA_SPACE_ELEMENT_PROJECT_EXPLORER_DND_TYPE =
43
43
  'PROJECT_EXPLORER_DATA_SPACE';
44
44
 
45
- export class DSLDataSpace_StudioPlugin
46
- extends StudioPlugin
47
- implements DSL_StudioPlugin_Extension
45
+ export class DSLDataSpace_LegendStudioPlugin
46
+ extends LegendStudioPlugin
47
+ implements DSL_LegendStudioPlugin_Extension
48
48
  {
49
49
  constructor() {
50
50
  super(packageJson.extensions.studioPlugin, packageJson.version);
51
51
  }
52
52
 
53
- install(pluginManager: StudioPluginManager): void {
54
- pluginManager.registerStudioPlugin(this);
55
- }
56
-
57
53
  getExtraSupportedElementTypes(): string[] {
58
54
  return [DATA_SPACE_ELEMENT_TYPE];
59
55
  }
@@ -74,7 +70,7 @@ export class DSLDataSpace_StudioPlugin
74
70
  (type: string): React.ReactNode | undefined => {
75
71
  if (type === DATA_SPACE_ELEMENT_TYPE) {
76
72
  return (
77
- <div className="icon icon--text-element">
73
+ <div className="icon icon--data-space">
78
74
  <SquareIcon />
79
75
  </div>
80
76
  );
@@ -97,7 +93,7 @@ export class DSLDataSpace_StudioPlugin
97
93
  state.editorStore.projectConfigurationEditorState.currentProjectConfiguration.groupId;
98
94
  dataSpace.artifactId =
99
95
  state.editorStore.projectConfigurationEditorState.currentProjectConfiguration.artifactId;
100
- dataSpace.versionId = 'latest';
96
+ dataSpace.versionId = LATEST_VERSION_ALIAS;
101
97
  const dataSpaceExecutionContext = new DataSpaceExecutionContext();
102
98
  dataSpaceExecutionContext.name = 'dummyContext';
103
99
  dataSpaceExecutionContext.mapping = 'dummyMapping';
@@ -17,10 +17,7 @@
17
17
  import packageJson from '../../package.json';
18
18
  import { DataSpace } from '../models/metamodels/pure/model/packageableElements/dataSpace/DataSpace';
19
19
  import type { Clazz } from '@finos/legend-shared';
20
- import type {
21
- GraphPluginManager,
22
- PackageableElement,
23
- } from '@finos/legend-graph';
20
+ import type { PackageableElement } from '@finos/legend-graph';
24
21
  import { PureGraphPlugin } from '@finos/legend-graph';
25
22
 
26
23
  export class DSLDataSpace_PureGraphPlugin extends PureGraphPlugin {
@@ -28,10 +25,6 @@ export class DSLDataSpace_PureGraphPlugin extends PureGraphPlugin {
28
25
  super(packageJson.extensions.pureGraphPlugin, packageJson.version);
29
26
  }
30
27
 
31
- install(pluginManager: GraphPluginManager): void {
32
- pluginManager.registerPureGraphPlugin(this);
33
- }
34
-
35
28
  override getExtraPureGraphExtensionClasses(): Clazz<PackageableElement>[] {
36
29
  return [DataSpace];
37
30
  }
@@ -17,7 +17,6 @@
17
17
  import packageJson from '../../package.json';
18
18
  import { DataSpace } from '../models/metamodels/pure/model/packageableElements/dataSpace/DataSpace';
19
19
  import type {
20
- GraphPluginManager,
21
20
  PackageableElement,
22
21
  PureGrammarElementLabeler,
23
22
  } from '@finos/legend-graph';
@@ -31,10 +30,6 @@ export class DSLDataSpace_PureGraphManagerPlugin extends PureGraphManagerPlugin
31
30
  super(packageJson.extensions.pureGraphManagerPlugin, packageJson.version);
32
31
  }
33
32
 
34
- install(pluginManager: GraphPluginManager): void {
35
- pluginManager.registerPureGraphManagerPlugin(this);
36
- }
37
-
38
33
  override getExtraPureGrammarParserNames(): string[] {
39
34
  return [PURE_GRAMMAR_DATA_SPACE_PARSER_NAME];
40
35
  }
package/src/index.ts CHANGED
@@ -15,3 +15,15 @@
15
15
  */
16
16
 
17
17
  export * from './DSLDataSpace_Extension';
18
+ export { DSLDataSpace_LegendStudioPlugin } from './components/studio/DSLDataSpace_LegendStudioPlugin';
19
+ export { DSLDataSpace_LegendQueryPlugin } from './components/query/DSLDataSpace_LegendQueryPlugin';
20
+
21
+ export { DataSpaceViewer } from './components/DataSpaceViewer';
22
+
23
+ export {
24
+ DATA_SPACE_ELEMENT_CLASSIFIER_PATH,
25
+ extractDataSpaceTaxonomyNodes,
26
+ getResolvedDataSpace,
27
+ } from './models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin';
28
+
29
+ export { DataSpaceViewerState } from './stores/DataSpaceViewerState';
@@ -23,6 +23,7 @@ import {
23
23
  } from './v1/model/packageableElements/dataSpace/V1_DataSpace';
24
24
  import type { PlainObject } from '@finos/legend-shared';
25
25
  import {
26
+ uuid,
26
27
  guaranteeNonEmptyString,
27
28
  guaranteeNonNullable,
28
29
  UnsupportedOperationError,
@@ -42,7 +43,6 @@ import {
42
43
  DataSpaceSupportEmail,
43
44
  } from '../../metamodels/pure/model/packageableElements/dataSpace/DataSpace';
44
45
  import type {
45
- GraphPluginManager,
46
46
  Mapping,
47
47
  PackageableElement,
48
48
  PackageableElementReference,
@@ -56,8 +56,10 @@ import type {
56
56
  V1_GraphTransformerContext,
57
57
  V1_PackageableElement,
58
58
  V1_PureModelContextData,
59
+ V1_TaggedValue,
59
60
  } from '@finos/legend-graph';
60
61
  import {
62
+ V1_taggedValueSchema,
61
63
  PackageableElementExplicitReference,
62
64
  V1_PackageableElementPointer,
63
65
  V1_PackageableElementPointerType,
@@ -67,6 +69,7 @@ import {
67
69
  PureProtocolProcessorPlugin,
68
70
  V1_ElementBuilder,
69
71
  V1_initPackageableElement,
72
+ V1_StereotypePtr,
70
73
  } from '@finos/legend-graph';
71
74
  import {
72
75
  Diagram,
@@ -84,10 +87,6 @@ export class DSLDataSpace_PureProtocolProcessorPlugin extends PureProtocolProces
84
87
  );
85
88
  }
86
89
 
87
- install(pluginManager: GraphPluginManager): void {
88
- pluginManager.registerPureProtocolProcessorPlugin(this);
89
- }
90
-
91
90
  override V1_getExtraElementBuilders(): V1_ElementBuilder<V1_PackageableElement>[] {
92
91
  return [
93
92
  new V1_ElementBuilder<V1_DataSpace>({
@@ -317,6 +316,13 @@ export class ResolvedDataSpaceExecutionContext {
317
316
  * element pointers to actual reference, hence this model.
318
317
  */
319
318
  export class ResolvedDataSpace {
319
+ taggedValues: {
320
+ uuid: string;
321
+ profile: string;
322
+ tag: string;
323
+ value: string;
324
+ }[] = [];
325
+ stereotypes: { uuid: string; profile: string; stereotype: string }[] = [];
320
326
  path!: string;
321
327
  groupId!: string;
322
328
  artifactId!: string;
@@ -336,6 +342,33 @@ export const getResolvedDataSpace = (
336
342
  if (json._type === V1_DATA_SPACE_ELEMENT_PROTOCOL_TYPE) {
337
343
  const protocol = deserialize(V1_dataSpaceModelSchema, json);
338
344
  dataSpace.path = protocol.path;
345
+ if (Array.isArray(json.taggedValues)) {
346
+ dataSpace.taggedValues = (
347
+ json.taggedValues as PlainObject<V1_TaggedValue>[]
348
+ )
349
+ .map((taggedValueJson) =>
350
+ deserialize(V1_taggedValueSchema, taggedValueJson),
351
+ )
352
+ .map((taggedValue) => ({
353
+ uuid: uuid(),
354
+ profile: taggedValue.tag.profile,
355
+ tag: taggedValue.tag.value,
356
+ value: taggedValue.value,
357
+ }));
358
+ }
359
+ if (Array.isArray(json.stereotypes)) {
360
+ dataSpace.stereotypes = (
361
+ json.stereotypes as PlainObject<V1_StereotypePtr>[]
362
+ )
363
+ .map((stereotypePtrJson) =>
364
+ deserialize(V1_StereotypePtr, stereotypePtrJson),
365
+ )
366
+ .map((stereotypePtr) => ({
367
+ uuid: uuid(),
368
+ profile: stereotypePtr.profile,
369
+ stereotype: stereotypePtr.value,
370
+ }));
371
+ }
339
372
  dataSpace.groupId = guaranteeNonEmptyString(
340
373
  protocol.groupId,
341
374
  `Data space 'groupId' field is missing or empty`,
@@ -403,3 +436,36 @@ export const getResolvedDataSpace = (
403
436
  }
404
437
  throw new UnsupportedOperationError(`Can't resolve data space`, json);
405
438
  };
439
+
440
+ export const extractDataSpaceTaxonomyNodes = (
441
+ json: PlainObject<V1_DataSpace>,
442
+ ): string[] => {
443
+ const ENTERPRISE_PROFILE_PATH = `meta::pure::profiles::enterprise`;
444
+ const TAXONOMY_NODES_TAG = `taxonomyNodes`;
445
+ const TAXONOMY_NODES_TAG_VALUE_DELIMITER = `,`;
446
+
447
+ const taxonomyNodes = new Set<string>();
448
+ if (json._type === V1_DATA_SPACE_ELEMENT_PROTOCOL_TYPE) {
449
+ if (Array.isArray(json.taggedValues)) {
450
+ const taggedValues = (
451
+ json.taggedValues as PlainObject<V1_TaggedValue>[]
452
+ ).map((taggedValueJson) =>
453
+ deserialize(V1_taggedValueSchema, taggedValueJson),
454
+ );
455
+ taggedValues
456
+ .filter(
457
+ (taggedValue) =>
458
+ taggedValue.tag.profile === ENTERPRISE_PROFILE_PATH &&
459
+ taggedValue.tag.value === TAXONOMY_NODES_TAG,
460
+ )
461
+ .forEach((taggedValue) => {
462
+ taggedValue.value
463
+ .split(TAXONOMY_NODES_TAG_VALUE_DELIMITER)
464
+ .map((value) => value.trim())
465
+ .filter((value) => Boolean(value))
466
+ .forEach((value) => taxonomyNodes.add(value));
467
+ });
468
+ }
469
+ }
470
+ return Array.from(taxonomyNodes.values());
471
+ };
@@ -0,0 +1,202 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import type {
18
+ ClassView,
19
+ DiagramRenderer,
20
+ } from '@finos/legend-extension-dsl-diagram';
21
+ import {
22
+ Diagram,
23
+ DIAGRAM_INTERACTION_MODE,
24
+ } from '@finos/legend-extension-dsl-diagram';
25
+ import type {
26
+ GraphManagerState,
27
+ PackageableElementReference,
28
+ PackageableRuntime,
29
+ } from '@finos/legend-graph';
30
+ import { guaranteeNonNullable } from '@finos/legend-shared';
31
+ import { action, computed, makeObservable, observable } from 'mobx';
32
+ import type {
33
+ ResolvedDataSpace,
34
+ ResolvedDataSpaceExecutionContext,
35
+ } from '../models/protocols/pure/DSLDataSpace_PureProtocolProcessorPlugin';
36
+
37
+ export enum DATA_SPACE_VIEWER_ACTIVITY_MODE {
38
+ MODELS_OVERVIEW = 'MODELS_OVERVIEW',
39
+ EXECUTION = 'EXECUTION',
40
+ ENTITLEMENT = 'ENTITLEMENT',
41
+ TEST_DATA = 'TEST_DATA',
42
+ TEST_COVERAGE = 'TEST_COVERAGE',
43
+ TAGS = 'TAGS',
44
+ SUPPORT = 'SUPPORT',
45
+ }
46
+
47
+ export class DataSpaceViewerState {
48
+ graphManagerState: GraphManagerState;
49
+ dataSpaceGroupId: string;
50
+ dataSpaceArtifactId: string;
51
+ dataSpaceVersionId: string;
52
+ dataSpace: ResolvedDataSpace;
53
+ _renderer?: DiagramRenderer | undefined;
54
+ currentDiagram?: Diagram | undefined;
55
+ currentActivity = DATA_SPACE_VIEWER_ACTIVITY_MODE.MODELS_OVERVIEW;
56
+ currentExecutionContext: ResolvedDataSpaceExecutionContext;
57
+ currentRuntime: PackageableRuntime;
58
+ viewProject?:
59
+ | ((
60
+ groupId: string,
61
+ artifactId: string,
62
+ versionId: string,
63
+ entityPath: string | undefined,
64
+ ) => void)
65
+ | undefined;
66
+ onDiagramClassDoubleClick?: ((classView: ClassView) => void) | undefined;
67
+
68
+ constructor(
69
+ graphManagerState: GraphManagerState,
70
+ dataSpaceGroupId: string,
71
+ dataSpaceArtifactId: string,
72
+ dataSpaceVersionId: string,
73
+ dataSpace: ResolvedDataSpace,
74
+ options?: {
75
+ viewProject?: (
76
+ groupId: string,
77
+ artifactId: string,
78
+ versionId: string,
79
+ entityPath: string | undefined,
80
+ ) => void;
81
+ onDiagramClassDoubleClick?: (classView: ClassView) => void;
82
+ },
83
+ ) {
84
+ makeObservable(this, {
85
+ _renderer: observable,
86
+ currentDiagram: observable,
87
+ currentActivity: observable,
88
+ currentExecutionContext: observable,
89
+ currentRuntime: observable,
90
+ renderer: computed,
91
+ setRenderer: action,
92
+ setCurrentDiagram: action,
93
+ setCurrentActivity: action,
94
+ setCurrentExecutionContext: action,
95
+ setCurrentRuntime: action,
96
+ });
97
+
98
+ this.graphManagerState = graphManagerState;
99
+ this.dataSpace = dataSpace;
100
+ this.dataSpaceGroupId = dataSpaceGroupId;
101
+ this.dataSpaceArtifactId = dataSpaceArtifactId;
102
+ this.dataSpaceVersionId = dataSpaceVersionId;
103
+ this.currentExecutionContext = this.dataSpace.defaultExecutionContext;
104
+ this.currentRuntime =
105
+ this.dataSpace.defaultExecutionContext.defaultRuntime.value;
106
+ this.currentDiagram = this.dataSpace.featuredDiagrams.length
107
+ ? (
108
+ this.dataSpace
109
+ .featuredDiagrams[0] as PackageableElementReference<Diagram>
110
+ ).value
111
+ : this.diagrams.length
112
+ ? this.diagrams[0]
113
+ : undefined;
114
+ this.viewProject = options?.viewProject;
115
+ this.onDiagramClassDoubleClick = options?.onDiagramClassDoubleClick;
116
+ }
117
+
118
+ get renderer(): DiagramRenderer {
119
+ return guaranteeNonNullable(
120
+ this._renderer,
121
+ `Diagram renderer must be initialized (this is likely caused by calling this method at the wrong place)`,
122
+ );
123
+ }
124
+
125
+ get isDiagramRendererInitialized(): boolean {
126
+ return Boolean(this._renderer);
127
+ }
128
+
129
+ get featuredDiagrams(): Diagram[] {
130
+ return this.dataSpace.featuredDiagrams.map((ref) => ref.value);
131
+ }
132
+
133
+ get diagrams(): Diagram[] {
134
+ return this.graphManagerState.graph
135
+ .getExtensionElements(Diagram)
136
+ .concat(
137
+ this.graphManagerState.graph.dependencyManager.getExtensionElements(
138
+ Diagram,
139
+ ),
140
+ );
141
+ }
142
+
143
+ get runtimes(): PackageableRuntime[] {
144
+ return this.graphManagerState.graph.ownRuntimes
145
+ .concat(this.graphManagerState.graph.dependencyManager.runtimes)
146
+ .filter((runtime) =>
147
+ runtime.runtimeValue.mappings
148
+ .map((mapping) => mapping.value)
149
+ .includes(this.currentExecutionContext.mapping.value),
150
+ );
151
+ }
152
+
153
+ // NOTE: we have tried to use React to control the cursor and
154
+ // could not overcome the jank/lag problem, so we settle with CSS-based approach
155
+ // See https://css-tricks.com/using-css-cursors/
156
+ // See https://developer.mozilla.org/en-US/docs/Web/CSS/cursor
157
+ get diagramCursorClass(): string {
158
+ if (!this.isDiagramRendererInitialized) {
159
+ return '';
160
+ }
161
+ if (this.renderer.middleClick || this.renderer.rightClick) {
162
+ return 'diagram-editor__cursor--grabbing';
163
+ }
164
+ switch (this.renderer.interactionMode) {
165
+ case DIAGRAM_INTERACTION_MODE.LAYOUT: {
166
+ if (this.renderer.mouseOverClassView) {
167
+ return 'diagram-editor__cursor--pointer';
168
+ }
169
+ return '';
170
+ }
171
+ default:
172
+ return '';
173
+ }
174
+ }
175
+
176
+ setRenderer(val: DiagramRenderer): void {
177
+ this._renderer = val;
178
+ }
179
+
180
+ setCurrentDiagram(val: Diagram): void {
181
+ this.currentDiagram = val;
182
+ }
183
+
184
+ setCurrentActivity(val: DATA_SPACE_VIEWER_ACTIVITY_MODE): void {
185
+ this.currentActivity = val;
186
+ }
187
+
188
+ setCurrentExecutionContext(val: ResolvedDataSpaceExecutionContext): void {
189
+ this.currentExecutionContext = val;
190
+ this.currentRuntime = val.defaultRuntime.value;
191
+ }
192
+
193
+ setCurrentRuntime(val: PackageableRuntime): void {
194
+ this.currentRuntime = val;
195
+ }
196
+
197
+ setupRenderer(): void {
198
+ this.renderer.setIsReadOnly(true);
199
+ this.renderer.onClassViewDoubleClick = (classView: ClassView): void =>
200
+ this.onDiagramClassDoubleClick?.(classView);
201
+ }
202
+ }