|
@@ -1,5 +1,21 @@
|
|
|
import * as React from "react";
|
|
|
-import {SimpleGrid, Text, Title, Group, Stack, Button, Space, Textarea, Tabs, HoverCard, ActionIcon, Center, Switch, Grid, Modal} from "@mantine/core";
|
|
|
+import {
|
|
|
+ SimpleGrid,
|
|
|
+ Text,
|
|
|
+ Title,
|
|
|
+ Group,
|
|
|
+ Stack,
|
|
|
+ Button,
|
|
|
+ Space,
|
|
|
+ Textarea,
|
|
|
+ Tabs,
|
|
|
+ HoverCard,
|
|
|
+ ActionIcon,
|
|
|
+ Center,
|
|
|
+ Switch,
|
|
|
+ Grid,
|
|
|
+ Modal
|
|
|
+} from "@mantine/core";
|
|
|
|
|
|
import {PrimitiveRegistry} from "../onion/primitive_delta";
|
|
|
import {mockUuid} from "../onion/test_helpers";
|
|
@@ -9,179 +25,184 @@ import {newCorrespondence} from "./correspondence";
|
|
|
import {newManualRenderer, ManualRendererProps} from "./manual_renderer";
|
|
|
|
|
|
export const demo_BM_description =
|
|
|
- <Text>
|
|
|
- Text Number 1
|
|
|
- </Text>;
|
|
|
+ <>
|
|
|
+ <Title order={4}>
|
|
|
+ Blended Modeling
|
|
|
+ </Title>
|
|
|
+ <Text>
|
|
|
+ To be done...
|
|
|
+ </Text>
|
|
|
+ </>;
|
|
|
|
|
|
export function getDemoBM() {
|
|
|
- const generateUUID = mockUuid();
|
|
|
- const primitiveRegistry = new PrimitiveRegistry();
|
|
|
-
|
|
|
- const commonStuff = {generateUUID, primitiveRegistry};
|
|
|
-
|
|
|
- const as = newVersionedModel({readonly: false, ...commonStuff});
|
|
|
- const cs1 = newVersionedModel({readonly: false, ...commonStuff});
|
|
|
- const cs2 = newVersionedModel({readonly: false, ...commonStuff});
|
|
|
- const corr1 = newCorrespondence({cs: cs1, as, ...commonStuff});
|
|
|
- const corr2 = newCorrespondence({cs: cs2, as, ...commonStuff});
|
|
|
-
|
|
|
- const {getModalManualRenderer} = newManualRenderer(commonStuff);
|
|
|
-
|
|
|
- // returns functional react component
|
|
|
- return function() {
|
|
|
- const [asState, setAsState] = React.useState<VersionedModelState>(as.initialState);
|
|
|
- const [cs1State, setCs1State] = React.useState<VersionedModelState>(cs1.initialState);
|
|
|
- const [cs2State, setCs2State] = React.useState<VersionedModelState>(cs2.initialState);
|
|
|
- const [corr1State, setCorr1State] = React.useState<VersionedModelState>(corr1.initialState);
|
|
|
- const [corr2State, setCorr2State] = React.useState<VersionedModelState>(corr2.initialState);
|
|
|
-
|
|
|
- const [manualRendererState, setManualRendererState] = React.useState<null | ManualRendererProps>(null);
|
|
|
-
|
|
|
- const [autoParse1, setAutoParse1] = React.useState<boolean>(true);
|
|
|
- const [autoParse2, setAutoParse2] = React.useState<boolean>(true);
|
|
|
- const [autoRender1, setAutoRender1] = React.useState<boolean>(false);
|
|
|
- const [autoRender2, setAutoRender2] = React.useState<boolean>(false);
|
|
|
-
|
|
|
- const asReducer = as.getReducer(setAsState);
|
|
|
- const cs1Reducer = cs1.getReducer(setCs1State);
|
|
|
- const cs2Reducer = cs2.getReducer(setCs2State);
|
|
|
- const corr1Reducer = corr1.getReducer(setCorr1State, cs1Reducer, asReducer);
|
|
|
- const corr2Reducer = corr2.getReducer(setCorr2State, cs2Reducer, asReducer);
|
|
|
-
|
|
|
- const asComponents = as.getReactComponents(asState, {
|
|
|
- onUserEdit: (deltas, description) => {
|
|
|
- const newVersion = asReducer.createAndGotoNewVersion(deltas, description);
|
|
|
- if (autoRender1) {
|
|
|
- corr1Reducer.renderExistingVersion(newVersion, setManualRendererState);
|
|
|
+ const generateUUID = mockUuid();
|
|
|
+ const primitiveRegistry = new PrimitiveRegistry();
|
|
|
+
|
|
|
+ const commonStuff = {generateUUID, primitiveRegistry};
|
|
|
+
|
|
|
+ const as = newVersionedModel({readonly: false, ...commonStuff});
|
|
|
+ const cs1 = newVersionedModel({readonly: false, ...commonStuff});
|
|
|
+ const cs2 = newVersionedModel({readonly: false, ...commonStuff});
|
|
|
+ const corr1 = newCorrespondence({cs: cs1, as, ...commonStuff});
|
|
|
+ const corr2 = newCorrespondence({cs: cs2, as, ...commonStuff});
|
|
|
+
|
|
|
+ const {getModalManualRenderer} = newManualRenderer(commonStuff);
|
|
|
+
|
|
|
+ // returns functional react component
|
|
|
+ return function () {
|
|
|
+ const [asState, setAsState] = React.useState<VersionedModelState>(as.initialState);
|
|
|
+ const [cs1State, setCs1State] = React.useState<VersionedModelState>(cs1.initialState);
|
|
|
+ const [cs2State, setCs2State] = React.useState<VersionedModelState>(cs2.initialState);
|
|
|
+ const [corr1State, setCorr1State] = React.useState<VersionedModelState>(corr1.initialState);
|
|
|
+ const [corr2State, setCorr2State] = React.useState<VersionedModelState>(corr2.initialState);
|
|
|
+
|
|
|
+ const [manualRendererState, setManualRendererState] = React.useState<null | ManualRendererProps>(null);
|
|
|
+
|
|
|
+ const [autoParse1, setAutoParse1] = React.useState<boolean>(true);
|
|
|
+ const [autoParse2, setAutoParse2] = React.useState<boolean>(true);
|
|
|
+ const [autoRender1, setAutoRender1] = React.useState<boolean>(false);
|
|
|
+ const [autoRender2, setAutoRender2] = React.useState<boolean>(false);
|
|
|
+
|
|
|
+ const asReducer = as.getReducer(setAsState);
|
|
|
+ const cs1Reducer = cs1.getReducer(setCs1State);
|
|
|
+ const cs2Reducer = cs2.getReducer(setCs2State);
|
|
|
+ const corr1Reducer = corr1.getReducer(setCorr1State, cs1Reducer, asReducer);
|
|
|
+ const corr2Reducer = corr2.getReducer(setCorr2State, cs2Reducer, asReducer);
|
|
|
+
|
|
|
+ const asComponents = as.getReactComponents(asState, {
|
|
|
+ onUserEdit: (deltas, description) => {
|
|
|
+ const newVersion = asReducer.createAndGotoNewVersion(deltas, description);
|
|
|
+ if (autoRender1) {
|
|
|
+ corr1Reducer.renderExistingVersion(newVersion, setManualRendererState);
|
|
|
+ }
|
|
|
+ if (autoRender2) {
|
|
|
+ corr2Reducer.renderExistingVersion(newVersion, setManualRendererState);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onUndoClicked: asReducer.undo,
|
|
|
+ onRedoClicked: asReducer.redo,
|
|
|
+ onVersionClicked: asReducer.gotoVersion,
|
|
|
+ });
|
|
|
+
|
|
|
+ const cs1Components = cs1.getReactComponents(cs1State, {
|
|
|
+ onUserEdit: (deltas, description) => {
|
|
|
+ const newVersion = cs1Reducer.createAndGotoNewVersion(deltas, description);
|
|
|
+ if (autoParse1) {
|
|
|
+ corr1Reducer.parseExistingVersion(newVersion);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onUndoClicked: cs1Reducer.undo,
|
|
|
+ onRedoClicked: cs1Reducer.redo,
|
|
|
+ onVersionClicked: cs1Reducer.gotoVersion,
|
|
|
+ });
|
|
|
+ const cs2Components = cs2.getReactComponents(cs2State, {
|
|
|
+ onUserEdit: (deltas, description) => {
|
|
|
+ const newVersion = cs2Reducer.createAndGotoNewVersion(deltas, description);
|
|
|
+ if (autoParse2) {
|
|
|
+ corr2Reducer.parseExistingVersion(newVersion);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onUndoClicked: cs2Reducer.undo,
|
|
|
+ onRedoClicked: cs2Reducer.redo,
|
|
|
+ onVersionClicked: cs2Reducer.gotoVersion,
|
|
|
+ });
|
|
|
+
|
|
|
+ const corr1Components = corr1.getReactComponents(corr1State, {
|
|
|
+ onUndoClicked: corr1Reducer.gotoVersion,
|
|
|
+ onRedoClicked: corr1Reducer.gotoVersion,
|
|
|
+ onVersionClicked: corr1Reducer.gotoVersion,
|
|
|
+ });
|
|
|
+ const corr2Components = corr2.getReactComponents(corr2State, {
|
|
|
+ onUndoClicked: corr2Reducer.gotoVersion,
|
|
|
+ onRedoClicked: corr2Reducer.gotoVersion,
|
|
|
+ onVersionClicked: corr2Reducer.gotoVersion,
|
|
|
+ });
|
|
|
+
|
|
|
+ const csTabs = ["editor", "state", "history", "dependencyL1", "dependencyL0"];
|
|
|
+ const corrTabs = ["state", "history", "dependencyL1", "dependencyL0"];
|
|
|
+ const asTabs = ["state", "history", "dependencyL1", "dependencyL0"];
|
|
|
+
|
|
|
+ function centeredCaption(text) {
|
|
|
+ return <Center><Title order={4}>{text}</Title></Center>;
|
|
|
}
|
|
|
- if (autoRender2) {
|
|
|
- corr2Reducer.renderExistingVersion(newVersion, setManualRendererState);
|
|
|
- }
|
|
|
- },
|
|
|
- onUndoClicked: asReducer.undo,
|
|
|
- onRedoClicked: asReducer.redo,
|
|
|
- onVersionClicked: asReducer.gotoVersion,
|
|
|
- });
|
|
|
-
|
|
|
- const cs1Components = cs1.getReactComponents(cs1State, {
|
|
|
- onUserEdit: (deltas, description) => {
|
|
|
- const newVersion = cs1Reducer.createAndGotoNewVersion(deltas, description);
|
|
|
- if (autoParse1) {
|
|
|
- corr1Reducer.parseExistingVersion(newVersion);
|
|
|
- }
|
|
|
- },
|
|
|
- onUndoClicked: cs1Reducer.undo,
|
|
|
- onRedoClicked: cs1Reducer.redo,
|
|
|
- onVersionClicked: cs1Reducer.gotoVersion,
|
|
|
- });
|
|
|
- const cs2Components = cs2.getReactComponents(cs2State, {
|
|
|
- onUserEdit: (deltas, description) => {
|
|
|
- const newVersion = cs2Reducer.createAndGotoNewVersion(deltas, description);
|
|
|
- if (autoParse2) {
|
|
|
- corr2Reducer.parseExistingVersion(newVersion);
|
|
|
- }
|
|
|
- },
|
|
|
- onUndoClicked: cs2Reducer.undo,
|
|
|
- onRedoClicked: cs2Reducer.redo,
|
|
|
- onVersionClicked: cs2Reducer.gotoVersion,
|
|
|
- });
|
|
|
-
|
|
|
- const corr1Components = corr1.getReactComponents(corr1State, {
|
|
|
- onUndoClicked: corr1Reducer.gotoVersion,
|
|
|
- onRedoClicked: corr1Reducer.gotoVersion,
|
|
|
- onVersionClicked: corr1Reducer.gotoVersion,
|
|
|
- });
|
|
|
- const corr2Components = corr2.getReactComponents(corr2State, {
|
|
|
- onUndoClicked: corr2Reducer.gotoVersion,
|
|
|
- onRedoClicked: corr2Reducer.gotoVersion,
|
|
|
- onVersionClicked: corr2Reducer.gotoVersion,
|
|
|
- });
|
|
|
-
|
|
|
- const csTabs = ["editor", "state", "history", "dependencyL1", "dependencyL0"];
|
|
|
- const corrTabs = ["state", "history", "dependencyL1", "dependencyL0"];
|
|
|
- const asTabs = ["state", "history", "dependencyL1", "dependencyL0"];
|
|
|
-
|
|
|
- function centeredCaption(text) {
|
|
|
- return <Center><Title order={4}>{text}</Title></Center>;
|
|
|
- }
|
|
|
|
|
|
- return (<div style={{minWidth:2200}}>
|
|
|
- {getModalManualRenderer(manualRendererState)}
|
|
|
-
|
|
|
- <Grid columns={5} grow>
|
|
|
- <Grid.Col span={1}>
|
|
|
- {centeredCaption("Concrete Syntax 1")}
|
|
|
- </Grid.Col>
|
|
|
- <Grid.Col span={1}>
|
|
|
- {centeredCaption("Correspondence 1")}
|
|
|
- </Grid.Col>
|
|
|
- <Grid.Col span={1}>
|
|
|
- {centeredCaption("Abstract Syntax")}
|
|
|
- </Grid.Col>
|
|
|
- <Grid.Col span={1}>
|
|
|
- {centeredCaption("Correspondence 2")}
|
|
|
- </Grid.Col>
|
|
|
- <Grid.Col span={1}>
|
|
|
- {centeredCaption("Concrete Syntax 2")}
|
|
|
- </Grid.Col>
|
|
|
-
|
|
|
- <Grid.Col span={1}>
|
|
|
- <Group position="right">
|
|
|
- {corr1Reducer.getCaptionWithParseButton(autoParse1, setAutoParse1, cs1.getCurrentVersion())}
|
|
|
- </Group>
|
|
|
- </Grid.Col>
|
|
|
- <Grid.Col span={1}>
|
|
|
- </Grid.Col>
|
|
|
- <Grid.Col span={1}>
|
|
|
- <Group position="apart">
|
|
|
- {corr1Reducer.getCaptionWithRenderButton(autoRender1, setAutoRender1, as.getCurrentVersion(), setManualRendererState)}
|
|
|
- {corr2Reducer.getCaptionWithRenderButton(autoRender2, setAutoRender2, as.getCurrentVersion(), setManualRendererState, "right")}
|
|
|
- </Group>
|
|
|
- </Grid.Col>
|
|
|
- <Grid.Col span={1}>
|
|
|
- </Grid.Col>
|
|
|
- <Grid.Col span={1}>
|
|
|
- <Group position="left">
|
|
|
- {corr2Reducer.getCaptionWithParseButton(autoParse2, setAutoParse2, cs2.getCurrentVersion(), "left")}
|
|
|
- </Group>
|
|
|
- </Grid.Col>
|
|
|
-
|
|
|
- <Grid.Col span={1}>
|
|
|
- <Stack>
|
|
|
- {cs1Components.makeTabs("editor", csTabs)}
|
|
|
- {cs1Components.makeTabs("history", csTabs)}
|
|
|
- <Center>{cs1Components.undoRedoButtons}</Center>
|
|
|
- </Stack>
|
|
|
- </Grid.Col>
|
|
|
- <Grid.Col span={1}>
|
|
|
- <Stack>
|
|
|
- {corr1Components.makeTabs("state", corrTabs)}
|
|
|
- {corr1Components.makeTabs("history", corrTabs)}
|
|
|
- <Center>{corr1Components.undoRedoButtons}</Center>
|
|
|
- </Stack>
|
|
|
- </Grid.Col>
|
|
|
- <Grid.Col span={1}>
|
|
|
- <Stack>
|
|
|
- {asComponents.makeTabs("state", asTabs)}
|
|
|
- {asComponents.makeTabs("history", asTabs)}
|
|
|
- <Center>{asComponents.undoRedoButtons}</Center>
|
|
|
- </Stack>
|
|
|
- </Grid.Col>
|
|
|
- <Grid.Col span={1}>
|
|
|
- <Stack>
|
|
|
- {corr2Components.makeTabs("state", corrTabs)}
|
|
|
- {corr2Components.makeTabs("history", corrTabs)}
|
|
|
- <Center>{corr2Components.undoRedoButtons}</Center>
|
|
|
- </Stack>
|
|
|
- </Grid.Col>
|
|
|
- <Grid.Col span={1}>
|
|
|
- <Stack>
|
|
|
- {cs2Components.makeTabs("editor", csTabs)}
|
|
|
- {cs2Components.makeTabs("history", csTabs)}
|
|
|
- <Center>{cs2Components.undoRedoButtons}</Center>
|
|
|
- </Stack>
|
|
|
- </Grid.Col>
|
|
|
- </Grid>
|
|
|
- </div>);
|
|
|
- }
|
|
|
+ return (<div style={{minWidth: 2200}}>
|
|
|
+ {getModalManualRenderer(manualRendererState)}
|
|
|
+
|
|
|
+ <Grid columns={5} grow>
|
|
|
+ <Grid.Col span={1}>
|
|
|
+ {centeredCaption("Concrete Syntax 1")}
|
|
|
+ </Grid.Col>
|
|
|
+ <Grid.Col span={1}>
|
|
|
+ {centeredCaption("Correspondence 1")}
|
|
|
+ </Grid.Col>
|
|
|
+ <Grid.Col span={1}>
|
|
|
+ {centeredCaption("Abstract Syntax")}
|
|
|
+ </Grid.Col>
|
|
|
+ <Grid.Col span={1}>
|
|
|
+ {centeredCaption("Correspondence 2")}
|
|
|
+ </Grid.Col>
|
|
|
+ <Grid.Col span={1}>
|
|
|
+ {centeredCaption("Concrete Syntax 2")}
|
|
|
+ </Grid.Col>
|
|
|
+
|
|
|
+ <Grid.Col span={1}>
|
|
|
+ <Group position="right">
|
|
|
+ {corr1Reducer.getCaptionWithParseButton(autoParse1, setAutoParse1, cs1.getCurrentVersion())}
|
|
|
+ </Group>
|
|
|
+ </Grid.Col>
|
|
|
+ <Grid.Col span={1}>
|
|
|
+ </Grid.Col>
|
|
|
+ <Grid.Col span={1}>
|
|
|
+ <Group position="apart">
|
|
|
+ {corr1Reducer.getCaptionWithRenderButton(autoRender1, setAutoRender1, as.getCurrentVersion(), setManualRendererState)}
|
|
|
+ {corr2Reducer.getCaptionWithRenderButton(autoRender2, setAutoRender2, as.getCurrentVersion(), setManualRendererState, "right")}
|
|
|
+ </Group>
|
|
|
+ </Grid.Col>
|
|
|
+ <Grid.Col span={1}>
|
|
|
+ </Grid.Col>
|
|
|
+ <Grid.Col span={1}>
|
|
|
+ <Group position="left">
|
|
|
+ {corr2Reducer.getCaptionWithParseButton(autoParse2, setAutoParse2, cs2.getCurrentVersion(), "left")}
|
|
|
+ </Group>
|
|
|
+ </Grid.Col>
|
|
|
+
|
|
|
+ <Grid.Col span={1}>
|
|
|
+ <Stack>
|
|
|
+ {cs1Components.makeTabs("editor", csTabs)}
|
|
|
+ {cs1Components.makeTabs("history", csTabs)}
|
|
|
+ <Center>{cs1Components.undoRedoButtons}</Center>
|
|
|
+ </Stack>
|
|
|
+ </Grid.Col>
|
|
|
+ <Grid.Col span={1}>
|
|
|
+ <Stack>
|
|
|
+ {corr1Components.makeTabs("state", corrTabs)}
|
|
|
+ {corr1Components.makeTabs("history", corrTabs)}
|
|
|
+ <Center>{corr1Components.undoRedoButtons}</Center>
|
|
|
+ </Stack>
|
|
|
+ </Grid.Col>
|
|
|
+ <Grid.Col span={1}>
|
|
|
+ <Stack>
|
|
|
+ {asComponents.makeTabs("state", asTabs)}
|
|
|
+ {asComponents.makeTabs("history", asTabs)}
|
|
|
+ <Center>{asComponents.undoRedoButtons}</Center>
|
|
|
+ </Stack>
|
|
|
+ </Grid.Col>
|
|
|
+ <Grid.Col span={1}>
|
|
|
+ <Stack>
|
|
|
+ {corr2Components.makeTabs("state", corrTabs)}
|
|
|
+ {corr2Components.makeTabs("history", corrTabs)}
|
|
|
+ <Center>{corr2Components.undoRedoButtons}</Center>
|
|
|
+ </Stack>
|
|
|
+ </Grid.Col>
|
|
|
+ <Grid.Col span={1}>
|
|
|
+ <Stack>
|
|
|
+ {cs2Components.makeTabs("editor", csTabs)}
|
|
|
+ {cs2Components.makeTabs("history", csTabs)}
|
|
|
+ <Center>{cs2Components.undoRedoButtons}</Center>
|
|
|
+ </Stack>
|
|
|
+ </Grid.Col>
|
|
|
+ </Grid>
|
|
|
+ </div>);
|
|
|
+ }
|
|
|
}
|