-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal for new editors system #1166
Draft
saskliutas
wants to merge
12
commits into
master
Choose a base branch
from
editors/new-system
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
13214d2
Initial editor system
saskliutas 2fc52eb
Use new editors in property grid
saskliutas cdb8778
Use new editors in tools
saskliutas 9aa93d4
Use new editors in imodel-components-react
saskliutas dfa1a8b
Use new editors in test-app
saskliutas 910c13f
Move formatting stuff to imodel-components-react
saskliutas 7201c83
Cleanup
saskliutas 22c8d3b
Fix types
saskliutas c52b778
Implement EnumGroupEditor that is compatible with current tools
saskliutas 5fdebac
Document core APIs
saskliutas 12c3105
Cleanup after rebase
saskliutas 6a28cab
No need for base editor props
saskliutas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { IModelConnection } from "@itwin/core-frontend"; | ||
import { SchemaContext } from "@itwin/ecschema-metadata"; | ||
import { ECSchemaRpcLocater } from "@itwin/ecschema-rpcinterface-common"; | ||
|
||
const schemaContextsCache = new Map<string, SchemaContext>(); | ||
export function getSchemaContext(imodel: IModelConnection) { | ||
const context = schemaContextsCache.get(imodel.key); | ||
if (context) { | ||
return context; | ||
} | ||
|
||
const newContext = new SchemaContext(); | ||
newContext.addLocater(new ECSchemaRpcLocater(imodel.getRpcProps())); | ||
schemaContextsCache.set(imodel.key, newContext); | ||
|
||
imodel.onClose.addListener(() => schemaContextsCache.delete(imodel.key)); | ||
|
||
return newContext; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,12 +12,8 @@ import { | |
StagePanelSection, | ||
StageUsage, | ||
StandardContentLayouts, | ||
ToolbarItemUtilities, | ||
ToolbarOrientation, | ||
ToolbarUsage, | ||
UiItemsProvider, | ||
} from "@itwin/appui-react"; | ||
import { CreateArcTool, CreateLineStringTool } from "@itwin/editor-frontend"; | ||
import { SvgDraw, SvgEdit } from "@itwin/itwinui-icons-react"; | ||
import { ViewportContent } from "@itwin/appui-test-providers"; | ||
|
||
|
@@ -53,24 +49,6 @@ export function createEditorFrontstageProvider(): UiItemsProvider { | |
icon: <SvgEdit />, | ||
}), | ||
], | ||
getToolbarItems: () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this removed? |
||
const layouts = { | ||
standard: { | ||
orientation: ToolbarOrientation.Horizontal, | ||
usage: ToolbarUsage.ContentManipulation, | ||
}, | ||
}; | ||
return [ | ||
ToolbarItemUtilities.createForTool(CreateLineStringTool, { | ||
itemPriority: 10, | ||
layouts, | ||
}), | ||
ToolbarItemUtilities.createForTool(CreateArcTool, { | ||
itemPriority: 10, | ||
layouts, | ||
}), | ||
]; | ||
}, | ||
getWidgets: () => { | ||
const layouts = { | ||
standard: { | ||
|
130 changes: 130 additions & 0 deletions
130
apps/test-app/src/frontend/appui/providers/PropertyGridProvider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import * as React from "react"; | ||
import { | ||
StagePanelLocation, | ||
StagePanelSection, | ||
UiItemsProvider, | ||
useActiveIModelConnection, | ||
WidgetState, | ||
} from "@itwin/appui-react"; | ||
import { VirtualizedPropertyGridWithDataProvider } from "@itwin/components-react"; | ||
import { useResizeObserver } from "@itwin/core-react/internal"; | ||
import { | ||
IPresentationPropertyDataProvider, | ||
PresentationPropertyDataProvider, | ||
SchemaMetadataContextProvider, | ||
usePropertyDataProviderWithUnifiedSelection, | ||
} from "@itwin/presentation-components"; | ||
import { getSchemaContext } from "../../SchemaContext"; | ||
import { | ||
IModelApp, | ||
NotifyMessageDetails, | ||
OutputMessagePriority, | ||
OutputMessageType, | ||
} from "@itwin/core-frontend"; | ||
|
||
export function createPropertyGridProvider() { | ||
return { | ||
id: "appui-test-app:property-grid-provider", | ||
getWidgets: () => { | ||
return [ | ||
{ | ||
id: "property-grid-widget-new", | ||
label: "With new editors", | ||
content: <PropertyGrid usedEditor="new" />, | ||
defaultState: WidgetState.Open, | ||
layouts: { | ||
standard: { | ||
location: StagePanelLocation.Left, | ||
section: StagePanelSection.Start, | ||
}, | ||
}, | ||
}, | ||
{ | ||
id: "property-grid-widget-old", | ||
label: "With old editors", | ||
content: <PropertyGrid usedEditor="old" />, | ||
defaultState: WidgetState.Open, | ||
layouts: { | ||
standard: { | ||
location: StagePanelLocation.Right, | ||
section: StagePanelSection.Start, | ||
}, | ||
}, | ||
}, | ||
]; | ||
}, | ||
} satisfies UiItemsProvider; | ||
} | ||
|
||
function PropertyGrid({ usedEditor }: { usedEditor: "old" | "new" }) { | ||
const imodel = useActiveIModelConnection(); | ||
const [dataProvider, setDataProvider] = | ||
React.useState<PresentationPropertyDataProvider>(); | ||
React.useEffect(() => { | ||
if (!imodel) { | ||
setDataProvider(undefined); | ||
return; | ||
} | ||
|
||
const provider = new PresentationPropertyDataProvider({ imodel }); | ||
setDataProvider(provider); | ||
return () => { | ||
provider.dispose(); | ||
}; | ||
}, [imodel]); | ||
|
||
if (!dataProvider) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<PropertyGridInternal dataProvider={dataProvider} usedEditor={usedEditor} /> | ||
); | ||
} | ||
|
||
function PropertyGridInternal({ | ||
dataProvider, | ||
usedEditor, | ||
}: { | ||
dataProvider: IPresentationPropertyDataProvider; | ||
usedEditor: "old" | "new"; | ||
}) { | ||
const [{ width, height }, setSize] = React.useState({ | ||
width: 0, | ||
height: 0, | ||
}); | ||
const onResize = React.useCallback((w: number, h: number) => { | ||
setSize({ width: w, height: h }); | ||
}, []); | ||
const ref = useResizeObserver(onResize); | ||
usePropertyDataProviderWithUnifiedSelection({ dataProvider }); | ||
|
||
return ( | ||
<SchemaMetadataContextProvider | ||
imodel={dataProvider.imodel} | ||
schemaContextProvider={getSchemaContext} | ||
> | ||
<div ref={ref} style={{ width: "100%", height: "100%" }}> | ||
<VirtualizedPropertyGridWithDataProvider | ||
height={height} | ||
width={width} | ||
dataProvider={dataProvider} | ||
isPropertyEditingEnabled | ||
onPropertyUpdated={async (args) => { | ||
const message = `Property updated: ${usedEditor} - ${JSON.stringify(args.newValue)}`; | ||
IModelApp.notifications.outputMessage( | ||
new NotifyMessageDetails( | ||
OutputMessagePriority.Info, | ||
message, | ||
undefined, | ||
OutputMessageType.Sticky | ||
) | ||
); | ||
return true; | ||
}} | ||
usedEditor={usedEditor} | ||
/> | ||
</div> | ||
</SchemaMetadataContextProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,42 +2,42 @@ | |
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import React from "react"; | ||
import { createFileRoute, useNavigate } from "@tanstack/react-router"; | ||
import { IModelGrid } from "@itwin/imodel-browser-react"; | ||
import { config } from "../frontend/config"; | ||
import { useAuth } from "../frontend/Auth"; | ||
import { PageLayout } from "@itwin/itwinui-layouts-react"; | ||
import { SignInPage } from "../frontend/SignInPage"; | ||
import React from 'react' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant formatter changes |
||
import { createFileRoute, useNavigate } from '@tanstack/react-router' | ||
import { IModelGrid } from '@itwin/imodel-browser-react' | ||
import { config } from '../frontend/config' | ||
import { useAuth } from '../frontend/Auth' | ||
import { PageLayout } from '@itwin/itwinui-layouts-react' | ||
import { SignInPage } from '../frontend/SignInPage' | ||
|
||
export const Route = createFileRoute("/iTwin_/$iTwinId")({ | ||
component: ITwin, | ||
}); | ||
}) | ||
|
||
const { serverEnvironmentPrefix } = config; | ||
const { serverEnvironmentPrefix } = config | ||
const apiOverrides = { | ||
serverEnvironmentPrefix, | ||
}; | ||
} | ||
|
||
function ITwin() { | ||
const { accessToken } = useAuth(); | ||
const { iTwinId } = Route.useParams(); | ||
const navigate = useNavigate(); | ||
if (!accessToken) return <SignInPage />; | ||
const { accessToken } = useAuth() | ||
const { iTwinId } = Route.useParams() | ||
const navigate = useNavigate() | ||
if (!accessToken) return <SignInPage /> | ||
return ( | ||
<PageLayout.Content padded={true}> | ||
<IModelGrid | ||
onThumbnailClick={(iModel) => { | ||
void navigate({ | ||
to: "/iTwin/$iTwinId/iModel/$iModelId", | ||
to: '/iTwin/$iTwinId/iModel/$iModelId', | ||
params: { iTwinId, iModelId: iModel.id }, | ||
}); | ||
}) | ||
}} | ||
iTwinId={iTwinId} | ||
accessToken={accessToken} | ||
apiOverrides={apiOverrides} | ||
searchText="" | ||
/> | ||
</PageLayout.Content> | ||
); | ||
) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these
presentation
dependencies necessary to showcase the new editors? Should we simply create a new frontstage for editors and use tool settings/dummy data in one of widgets?Need to think about names, current
EditorFrontstage
is really for opening iModels in read-write.(I see the comment now, that this is actually planned to be removed)