diff options
Diffstat (limited to 'subprojects/frontend')
-rw-r--r-- | subprojects/frontend/src/editor/EditorArea.tsx | 3 | ||||
-rw-r--r-- | subprojects/frontend/src/editor/EditorButtons.tsx | 16 | ||||
-rw-r--r-- | subprojects/frontend/src/editor/EditorStore.ts | 13 | ||||
-rw-r--r-- | subprojects/frontend/src/editor/EditorTheme.ts | 13 | ||||
-rw-r--r-- | subprojects/frontend/src/editor/GeneratedModelStore.ts | 15 | ||||
-rw-r--r-- | subprojects/frontend/src/graph/DotGraphVisualizer.tsx | 4 | ||||
-rw-r--r-- | subprojects/frontend/src/graph/GraphStore.ts | 12 | ||||
-rw-r--r-- | subprojects/frontend/src/graph/GraphTheme.tsx | 9 |
8 files changed, 63 insertions, 22 deletions
diff --git a/subprojects/frontend/src/editor/EditorArea.tsx b/subprojects/frontend/src/editor/EditorArea.tsx index 905fa2ec..aafaad40 100644 --- a/subprojects/frontend/src/editor/EditorArea.tsx +++ b/subprojects/frontend/src/editor/EditorArea.tsx | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/> | 2 | * SPDX-FileCopyrightText: 2021-2024 The Refinery Authors <https://refinery.tools/> |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: EPL-2.0 | 4 | * SPDX-License-Identifier: EPL-2.0 |
5 | */ | 5 | */ |
@@ -38,6 +38,7 @@ export default observer(function EditorArea({ | |||
38 | <EditorTheme | 38 | <EditorTheme |
39 | showLineNumbers={editorStore.showLineNumbers} | 39 | showLineNumbers={editorStore.showLineNumbers} |
40 | showActiveLine={!editorStore.hasSelection} | 40 | showActiveLine={!editorStore.hasSelection} |
41 | colorIdentifiers={editorStore.colorIdentifiers} | ||
41 | ref={editorParentRef} | 42 | ref={editorParentRef} |
42 | /> | 43 | /> |
43 | </Box> | 44 | </Box> |
diff --git a/subprojects/frontend/src/editor/EditorButtons.tsx b/subprojects/frontend/src/editor/EditorButtons.tsx index ca51f975..f4513909 100644 --- a/subprojects/frontend/src/editor/EditorButtons.tsx +++ b/subprojects/frontend/src/editor/EditorButtons.tsx | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/> | 2 | * SPDX-FileCopyrightText: 2021-2024 The Refinery Authors <https://refinery.tools/> |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: EPL-2.0 | 4 | * SPDX-License-Identifier: EPL-2.0 |
5 | */ | 5 | */ |
@@ -8,8 +8,9 @@ import type { Diagnostic } from '@codemirror/lint'; | |||
8 | import CancelIcon from '@mui/icons-material/Cancel'; | 8 | import CancelIcon from '@mui/icons-material/Cancel'; |
9 | import CheckIcon from '@mui/icons-material/Check'; | 9 | import CheckIcon from '@mui/icons-material/Check'; |
10 | import FormatListNumberedIcon from '@mui/icons-material/FormatListNumbered'; | 10 | import FormatListNumberedIcon from '@mui/icons-material/FormatListNumbered'; |
11 | import FormatPaint from '@mui/icons-material/FormatPaint'; | 11 | import FormatPaintIcon from '@mui/icons-material/FormatPaint'; |
12 | import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; | 12 | import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; |
13 | import LooksIcon from '@mui/icons-material/Looks'; | ||
13 | import RedoIcon from '@mui/icons-material/Redo'; | 14 | import RedoIcon from '@mui/icons-material/Redo'; |
14 | import SearchIcon from '@mui/icons-material/Search'; | 15 | import SearchIcon from '@mui/icons-material/Search'; |
15 | import UndoIcon from '@mui/icons-material/Undo'; | 16 | import UndoIcon from '@mui/icons-material/Undo'; |
@@ -72,6 +73,15 @@ export default observer(function EditorButtons({ | |||
72 | <FormatListNumberedIcon fontSize="small" /> | 73 | <FormatListNumberedIcon fontSize="small" /> |
73 | </ToggleButton> | 74 | </ToggleButton> |
74 | <ToggleButton | 75 | <ToggleButton |
76 | selected={editorStore?.colorIdentifiers ?? false} | ||
77 | disabled={editorStore === undefined} | ||
78 | onClick={() => editorStore?.toggleColorIdentifiers()} | ||
79 | aria-label="Color identifiers" | ||
80 | value="color-identifiers" | ||
81 | > | ||
82 | <LooksIcon fontSize="small" /> | ||
83 | </ToggleButton> | ||
84 | <ToggleButton | ||
75 | selected={editorStore?.searchPanel?.state ?? false} | 85 | selected={editorStore?.searchPanel?.state ?? false} |
76 | disabled={editorStore === undefined} | 86 | disabled={editorStore === undefined} |
77 | onClick={() => editorStore?.searchPanel?.toggle()} | 87 | onClick={() => editorStore?.searchPanel?.toggle()} |
@@ -104,7 +114,7 @@ export default observer(function EditorButtons({ | |||
104 | aria-label="Automatic format" | 114 | aria-label="Automatic format" |
105 | color="inherit" | 115 | color="inherit" |
106 | > | 116 | > |
107 | <FormatPaint fontSize="small" /> | 117 | <FormatPaintIcon fontSize="small" /> |
108 | </IconButton> | 118 | </IconButton> |
109 | <ConnectButton editorStore={editorStore} /> | 119 | <ConnectButton editorStore={editorStore} /> |
110 | </Stack> | 120 | </Stack> |
diff --git a/subprojects/frontend/src/editor/EditorStore.ts b/subprojects/frontend/src/editor/EditorStore.ts index 87c4040e..5e7d05e1 100644 --- a/subprojects/frontend/src/editor/EditorStore.ts +++ b/subprojects/frontend/src/editor/EditorStore.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/> | 2 | * SPDX-FileCopyrightText: 2021-2024 The Refinery Authors <https://refinery.tools/> |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: EPL-2.0 | 4 | * SPDX-License-Identifier: EPL-2.0 |
5 | */ | 5 | */ |
@@ -62,6 +62,8 @@ export default class EditorStore { | |||
62 | 62 | ||
63 | showLineNumbers = false; | 63 | showLineNumbers = false; |
64 | 64 | ||
65 | colorIdentifiers = true; | ||
66 | |||
65 | disposed = false; | 67 | disposed = false; |
66 | 68 | ||
67 | analyzing = false; | 69 | analyzing = false; |
@@ -96,7 +98,7 @@ export default class EditorStore { | |||
96 | })().catch((error) => { | 98 | })().catch((error) => { |
97 | log.error('Failed to load XtextClient', error); | 99 | log.error('Failed to load XtextClient', error); |
98 | }); | 100 | }); |
99 | this.graph = new GraphStore(); | 101 | this.graph = new GraphStore(this); |
100 | makeAutoObservable<EditorStore, 'client'>(this, { | 102 | makeAutoObservable<EditorStore, 'client'>(this, { |
101 | id: false, | 103 | id: false, |
102 | state: observable.ref, | 104 | state: observable.ref, |
@@ -279,6 +281,11 @@ export default class EditorStore { | |||
279 | log.debug('Show line numbers', this.showLineNumbers); | 281 | log.debug('Show line numbers', this.showLineNumbers); |
280 | } | 282 | } |
281 | 283 | ||
284 | toggleColorIdentifiers(): void { | ||
285 | this.colorIdentifiers = !this.colorIdentifiers; | ||
286 | log.debug('Color identifiers', this.colorIdentifiers); | ||
287 | } | ||
288 | |||
282 | get hasSelection(): boolean { | 289 | get hasSelection(): boolean { |
283 | return this.state.selection.ranges.some(({ from, to }) => from !== to); | 290 | return this.state.selection.ranges.some(({ from, to }) => from !== to); |
284 | } | 291 | } |
@@ -324,7 +331,7 @@ export default class EditorStore { | |||
324 | } | 331 | } |
325 | 332 | ||
326 | addGeneratedModel(uuid: string, randomSeed: number): void { | 333 | addGeneratedModel(uuid: string, randomSeed: number): void { |
327 | this.generatedModels.set(uuid, new GeneratedModelStore(randomSeed)); | 334 | this.generatedModels.set(uuid, new GeneratedModelStore(randomSeed, this)); |
328 | this.selectGeneratedModel(uuid); | 335 | this.selectGeneratedModel(uuid); |
329 | } | 336 | } |
330 | 337 | ||
diff --git a/subprojects/frontend/src/editor/EditorTheme.ts b/subprojects/frontend/src/editor/EditorTheme.ts index b536dc0c..1cad4a36 100644 --- a/subprojects/frontend/src/editor/EditorTheme.ts +++ b/subprojects/frontend/src/editor/EditorTheme.ts | |||
@@ -18,7 +18,13 @@ import { range } from 'lodash-es'; | |||
18 | 18 | ||
19 | import svgURL from '../utils/svgURL'; | 19 | import svgURL from '../utils/svgURL'; |
20 | 20 | ||
21 | function createTypeHashStyles(theme: Theme): CSSObject { | 21 | function createTypeHashStyles( |
22 | theme: Theme, | ||
23 | colorIdentifiers: boolean, | ||
24 | ): CSSObject { | ||
25 | if (!colorIdentifiers) { | ||
26 | return {}; | ||
27 | } | ||
22 | const result: CSSObject = {}; | 28 | const result: CSSObject = {}; |
23 | range(theme.palette.highlight.typeHash.length).forEach((i) => { | 29 | range(theme.palette.highlight.typeHash.length).forEach((i) => { |
24 | result[`.tok-problem-typeHash-${i}`] = { | 30 | result[`.tok-problem-typeHash-${i}`] = { |
@@ -38,7 +44,8 @@ export default styled('div', { | |||
38 | })<{ | 44 | })<{ |
39 | showLineNumbers: boolean; | 45 | showLineNumbers: boolean; |
40 | showActiveLine: boolean; | 46 | showActiveLine: boolean; |
41 | }>(({ theme, showLineNumbers, showActiveLine }) => { | 47 | colorIdentifiers: boolean; |
48 | }>(({ theme, showLineNumbers, showActiveLine, colorIdentifiers }) => { | ||
42 | const editorFontStyle: CSSObject = { | 49 | const editorFontStyle: CSSObject = { |
43 | ...theme.typography.editor, | 50 | ...theme.typography.editor, |
44 | fontWeight: theme.typography.fontWeightEditorNormal, | 51 | fontWeight: theme.typography.fontWeightEditorNormal, |
@@ -148,7 +155,7 @@ export default styled('div', { | |||
148 | fontStyle: 'normal', | 155 | fontStyle: 'normal', |
149 | }, | 156 | }, |
150 | }, | 157 | }, |
151 | ...createTypeHashStyles(theme), | 158 | ...createTypeHashStyles(theme, colorIdentifiers), |
152 | }; | 159 | }; |
153 | 160 | ||
154 | const matchingStyle: CSSObject = { | 161 | const matchingStyle: CSSObject = { |
diff --git a/subprojects/frontend/src/editor/GeneratedModelStore.ts b/subprojects/frontend/src/editor/GeneratedModelStore.ts index 5088d603..f2695d9a 100644 --- a/subprojects/frontend/src/editor/GeneratedModelStore.ts +++ b/subprojects/frontend/src/editor/GeneratedModelStore.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/> | 2 | * SPDX-FileCopyrightText: 2021-2024 The Refinery Authors <https://refinery.tools/> |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: EPL-2.0 | 4 | * SPDX-License-Identifier: EPL-2.0 |
5 | */ | 5 | */ |
@@ -9,6 +9,8 @@ import { makeAutoObservable } from 'mobx'; | |||
9 | import GraphStore from '../graph/GraphStore'; | 9 | import GraphStore from '../graph/GraphStore'; |
10 | import type { SemanticsSuccessResult } from '../xtext/xtextServiceResults'; | 10 | import type { SemanticsSuccessResult } from '../xtext/xtextServiceResults'; |
11 | 11 | ||
12 | import type EditorStore from './EditorStore'; | ||
13 | |||
12 | export default class GeneratedModelStore { | 14 | export default class GeneratedModelStore { |
13 | title: string; | 15 | title: string; |
14 | 16 | ||
@@ -18,10 +20,15 @@ export default class GeneratedModelStore { | |||
18 | 20 | ||
19 | graph: GraphStore | undefined; | 21 | graph: GraphStore | undefined; |
20 | 22 | ||
21 | constructor(randomSeed: number) { | 23 | constructor( |
24 | randomSeed: number, | ||
25 | private readonly editorStore: EditorStore, | ||
26 | ) { | ||
22 | const time = new Date().toLocaleTimeString(undefined, { hour12: false }); | 27 | const time = new Date().toLocaleTimeString(undefined, { hour12: false }); |
23 | this.title = `Generated at ${time} (${randomSeed})`; | 28 | this.title = `Generated at ${time} (${randomSeed})`; |
24 | makeAutoObservable(this); | 29 | makeAutoObservable<GeneratedModelStore, 'editorStore'>(this, { |
30 | editorStore: false, | ||
31 | }); | ||
25 | } | 32 | } |
26 | 33 | ||
27 | get running(): boolean { | 34 | get running(): boolean { |
@@ -43,7 +50,7 @@ export default class GeneratedModelStore { | |||
43 | 50 | ||
44 | setSemantics(semantics: SemanticsSuccessResult): void { | 51 | setSemantics(semantics: SemanticsSuccessResult): void { |
45 | if (this.running) { | 52 | if (this.running) { |
46 | this.graph = new GraphStore(); | 53 | this.graph = new GraphStore(this.editorStore); |
47 | this.graph.setSemantics(semantics); | 54 | this.graph.setSemantics(semantics); |
48 | } | 55 | } |
49 | } | 56 | } |
diff --git a/subprojects/frontend/src/graph/DotGraphVisualizer.tsx b/subprojects/frontend/src/graph/DotGraphVisualizer.tsx index eec72a7d..72ac58fa 100644 --- a/subprojects/frontend/src/graph/DotGraphVisualizer.tsx +++ b/subprojects/frontend/src/graph/DotGraphVisualizer.tsx | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/> | 2 | * SPDX-FileCopyrightText: 2023-2024 The Refinery Authors <https://refinery.tools/> |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: EPL-2.0 | 4 | * SPDX-License-Identifier: EPL-2.0 |
5 | */ | 5 | */ |
@@ -150,7 +150,7 @@ function DotGraphVisualizer({ | |||
150 | ], | 150 | ], |
151 | ); | 151 | ); |
152 | 152 | ||
153 | return <GraphTheme ref={setElement} />; | 153 | return <GraphTheme ref={setElement} colorNodes={graph.colorNodes} />; |
154 | } | 154 | } |
155 | 155 | ||
156 | DotGraphVisualizer.defaultProps = { | 156 | DotGraphVisualizer.defaultProps = { |
diff --git a/subprojects/frontend/src/graph/GraphStore.ts b/subprojects/frontend/src/graph/GraphStore.ts index ecb016b5..58c4422d 100644 --- a/subprojects/frontend/src/graph/GraphStore.ts +++ b/subprojects/frontend/src/graph/GraphStore.ts | |||
@@ -1,11 +1,12 @@ | |||
1 | /* | 1 | /* |
2 | * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/> | 2 | * SPDX-FileCopyrightText: 2023-2024 The Refinery Authors <https://refinery.tools/> |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: EPL-2.0 | 4 | * SPDX-License-Identifier: EPL-2.0 |
5 | */ | 5 | */ |
6 | 6 | ||
7 | import { makeAutoObservable, observable } from 'mobx'; | 7 | import { makeAutoObservable, observable } from 'mobx'; |
8 | 8 | ||
9 | import type EditorStore from '../editor/EditorStore'; | ||
9 | import type { | 10 | import type { |
10 | RelationMetadata, | 11 | RelationMetadata, |
11 | SemanticsSuccessResult, | 12 | SemanticsSuccessResult, |
@@ -65,8 +66,9 @@ export default class GraphStore { | |||
65 | 66 | ||
66 | selectedSymbol: RelationMetadata | undefined; | 67 | selectedSymbol: RelationMetadata | undefined; |
67 | 68 | ||
68 | constructor() { | 69 | constructor(private readonly editorStore: EditorStore) { |
69 | makeAutoObservable(this, { | 70 | makeAutoObservable<GraphStore, 'editorStore'>(this, { |
71 | editorStore: false, | ||
70 | semantics: observable.ref, | 72 | semantics: observable.ref, |
71 | }); | 73 | }); |
72 | } | 74 | } |
@@ -184,4 +186,8 @@ export default class GraphStore { | |||
184 | }); | 186 | }); |
185 | this.setSelectedSymbol(this.selectedSymbol); | 187 | this.setSelectedSymbol(this.selectedSymbol); |
186 | } | 188 | } |
189 | |||
190 | get colorNodes(): boolean { | ||
191 | return this.editorStore.colorIdentifiers; | ||
192 | } | ||
187 | } | 193 | } |
diff --git a/subprojects/frontend/src/graph/GraphTheme.tsx b/subprojects/frontend/src/graph/GraphTheme.tsx index 60fd7925..7334f559 100644 --- a/subprojects/frontend/src/graph/GraphTheme.tsx +++ b/subprojects/frontend/src/graph/GraphTheme.tsx | |||
@@ -37,7 +37,10 @@ function createEdgeColor( | |||
37 | }; | 37 | }; |
38 | } | 38 | } |
39 | 39 | ||
40 | function createTypeHashStyles(theme: Theme): CSSObject { | 40 | function createTypeHashStyles(theme: Theme, colorNodes: boolean): CSSObject { |
41 | if (!colorNodes) { | ||
42 | return {}; | ||
43 | } | ||
41 | const result: CSSObject = {}; | 44 | const result: CSSObject = {}; |
42 | range(theme.palette.highlight.typeHash.length).forEach((i) => { | 45 | range(theme.palette.highlight.typeHash.length).forEach((i) => { |
43 | result[`.node-typeHash-${i}`] = { | 46 | result[`.node-typeHash-${i}`] = { |
@@ -51,7 +54,7 @@ function createTypeHashStyles(theme: Theme): CSSObject { | |||
51 | 54 | ||
52 | export default styled('div', { | 55 | export default styled('div', { |
53 | name: 'GraphTheme', | 56 | name: 'GraphTheme', |
54 | })(({ theme }) => ({ | 57 | })<{ colorNodes: boolean }>(({ theme, colorNodes }) => ({ |
55 | '& svg': { | 58 | '& svg': { |
56 | userSelect: 'none', | 59 | userSelect: 'none', |
57 | '.node': { | 60 | '.node': { |
@@ -86,7 +89,7 @@ export default styled('div', { | |||
86 | '.node-exists-UNKNOWN [stroke="black"]': { | 89 | '.node-exists-UNKNOWN [stroke="black"]': { |
87 | strokeDasharray: '5 2', | 90 | strokeDasharray: '5 2', |
88 | }, | 91 | }, |
89 | ...createTypeHashStyles(theme), | 92 | ...createTypeHashStyles(theme, colorNodes), |
90 | '.edge': { | 93 | '.edge': { |
91 | '& text': { | 94 | '& text': { |
92 | fontFamily: theme.typography.fontFamily, | 95 | fontFamily: theme.typography.fontFamily, |