forked from eclipse-sirius/sirius-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cleanup] Extract the default extension registry in a dedicated file
Signed-off-by: Stéphane Bégaudeau <[email protected]>
- Loading branch information
1 parent
e22d731
commit 0fd1db4
Showing
2 changed files
with
147 additions
and
110 deletions.
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
142 changes: 142 additions & 0 deletions
142
...ges/sirius-web/frontend/sirius-web-application/src/extension/DefaultExtensionRegistry.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,142 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
import { | ||
ExtensionRegistry, | ||
RepresentationMetadata, | ||
WorkbenchViewContribution, | ||
representationFactoryExtensionPoint, | ||
workbenchMainAreaExtensionPoint, | ||
workbenchViewContributionExtensionPoint, | ||
} from '@eclipse-sirius/sirius-components-core'; | ||
import { DeckRepresentation } from '@eclipse-sirius/sirius-components-deck'; | ||
import { DiagramRepresentation } from '@eclipse-sirius/sirius-components-diagrams'; | ||
import { FormDescriptionEditorRepresentation } from '@eclipse-sirius/sirius-components-formdescriptioneditors'; | ||
import { | ||
DetailsView, | ||
FormRepresentation, | ||
RelatedElementsView, | ||
RepresentationsView, | ||
} from '@eclipse-sirius/sirius-components-forms'; | ||
import { GanttRepresentation } from '@eclipse-sirius/sirius-components-gantt'; | ||
import { PortalRepresentation } from '@eclipse-sirius/sirius-components-portals'; | ||
import { ExplorerView } from '@eclipse-sirius/sirius-components-trees'; | ||
import { ValidationView } from '@eclipse-sirius/sirius-components-validation'; | ||
import AccountTreeIcon from '@material-ui/icons/AccountTree'; | ||
import Filter from '@material-ui/icons/Filter'; | ||
import LinkIcon from '@material-ui/icons/Link'; | ||
import MenuIcon from '@material-ui/icons/Menu'; | ||
import WarningIcon from '@material-ui/icons/Warning'; | ||
import { OnboardArea } from '../onboarding/OnboardArea'; | ||
|
||
const getType = (representation: RepresentationMetadata): string | null => { | ||
const query = representation.kind.substring(representation.kind.indexOf('?') + 1, representation.kind.length); | ||
const params = new URLSearchParams(query); | ||
const type = params.get('type'); | ||
return type; | ||
}; | ||
|
||
const defaultExtensionRegistry = new ExtensionRegistry(); | ||
|
||
/******************************************************************************* | ||
* | ||
* Workbench main area | ||
* | ||
* Used to register the component used by default when no representation is opened | ||
* | ||
*******************************************************************************/ | ||
defaultExtensionRegistry.addComponent(workbenchMainAreaExtensionPoint, { | ||
identifier: `siriusweb_${workbenchMainAreaExtensionPoint.identifier}`, | ||
Component: OnboardArea, | ||
}); | ||
|
||
/******************************************************************************* | ||
* | ||
* Workbench views | ||
* | ||
* Used to register all the views available in the left and right of the workbench | ||
* | ||
*******************************************************************************/ | ||
const workbenchViewContributions: WorkbenchViewContribution[] = [ | ||
{ | ||
side: 'left', | ||
title: 'Explorer', | ||
icon: <AccountTreeIcon />, | ||
component: ExplorerView, | ||
}, | ||
{ | ||
side: 'left', | ||
title: 'Validation', | ||
icon: <WarningIcon />, | ||
component: ValidationView, | ||
}, | ||
{ | ||
side: 'right', | ||
title: 'Details', | ||
icon: <MenuIcon />, | ||
component: DetailsView, | ||
}, | ||
{ | ||
side: 'right', | ||
title: 'Representations', | ||
icon: <Filter />, | ||
component: RepresentationsView, | ||
}, | ||
{ | ||
side: 'right', | ||
title: 'Related Elements', | ||
icon: <LinkIcon />, | ||
component: RelatedElementsView, | ||
}, | ||
]; | ||
defaultExtensionRegistry.putData(workbenchViewContributionExtensionPoint, { | ||
identifier: `siriusweb_${workbenchViewContributionExtensionPoint.identifier}`, | ||
data: workbenchViewContributions, | ||
}); | ||
|
||
/******************************************************************************* | ||
* | ||
* Workbench representation factories | ||
* | ||
* Used to register all the type of representations that are supported in Sirius Web | ||
* | ||
*******************************************************************************/ | ||
|
||
defaultExtensionRegistry.putData(representationFactoryExtensionPoint, { | ||
identifier: `siriusweb_${representationFactoryExtensionPoint.identifier}_diagram`, | ||
data: [(representation) => (getType(representation) === 'Diagram' ? DiagramRepresentation : null)], | ||
}); | ||
defaultExtensionRegistry.putData(representationFactoryExtensionPoint, { | ||
identifier: `siriusweb_${representationFactoryExtensionPoint.identifier}_form`, | ||
data: [(representation) => (getType(representation) === 'Form' ? FormRepresentation : null)], | ||
}); | ||
defaultExtensionRegistry.putData(representationFactoryExtensionPoint, { | ||
identifier: `siriusweb_${representationFactoryExtensionPoint.identifier}_formdescriptioneditor`, | ||
data: [ | ||
(representation) => | ||
getType(representation) === 'FormDescriptionEditor' ? FormDescriptionEditorRepresentation : null, | ||
], | ||
}); | ||
defaultExtensionRegistry.putData(representationFactoryExtensionPoint, { | ||
identifier: `siriusweb_${representationFactoryExtensionPoint.identifier}_gantt`, | ||
data: [(representation) => (getType(representation) === 'Gantt' ? GanttRepresentation : null)], | ||
}); | ||
defaultExtensionRegistry.putData(representationFactoryExtensionPoint, { | ||
identifier: `siriusweb_${representationFactoryExtensionPoint.identifier}_deck`, | ||
data: [(representation) => (getType(representation) === 'Deck' ? DeckRepresentation : null)], | ||
}); | ||
defaultExtensionRegistry.putData(representationFactoryExtensionPoint, { | ||
identifier: `siriusweb_${representationFactoryExtensionPoint.identifier}_portal`, | ||
data: [(representation) => (getType(representation) === 'Portal' ? PortalRepresentation : null)], | ||
}); | ||
|
||
export { defaultExtensionRegistry }; |