-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4301] Fix Extension VSCode extension regressions
Bug: #4301 Signed-off-by: Guillaume Coutable <guillaume.coutable@obeo.fr>
- Loading branch information
Showing
12 changed files
with
688 additions
and
22 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
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
File renamed without changes.
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,121 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023, 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 { getCSSColor } from '@eclipse-sirius/sirius-components-core'; | ||
import { | ||
ConnectionCreationHandles, | ||
ConnectionHandles, | ||
ConnectionTargetHandle, | ||
DiagramContext, | ||
DiagramContextValue, | ||
DiagramElementPalette, | ||
Label, | ||
useConnectorNodeStyle, | ||
useDrop, | ||
useDropNodeStyle, | ||
useRefreshConnectionHandles, | ||
} from '@eclipse-sirius/sirius-components-diagrams'; | ||
import { Theme, useTheme } from '@mui/material/styles'; | ||
import { Node, NodeProps, NodeResizer } from '@xyflow/react'; | ||
import React, { memo, useContext } from 'react'; | ||
import { EllipseNodeData, NodeComponentsMap } from './EllipseNode.types'; | ||
|
||
const ellipseNodeStyle = ( | ||
theme: Theme, | ||
style: React.CSSProperties, | ||
selected: boolean, | ||
hovered: boolean, | ||
faded: boolean | ||
): React.CSSProperties => { | ||
const ellipseNodeStyle: React.CSSProperties = { | ||
display: 'flex', | ||
padding: '8px', | ||
width: '100%', | ||
height: '100%', | ||
borderRadius: '50%', | ||
border: 'black solid 1px', | ||
opacity: faded ? '0.4' : '', | ||
...style, | ||
background: getCSSColor(String(style.background), theme), | ||
}; | ||
|
||
if (selected || hovered) { | ||
ellipseNodeStyle.outline = `${theme.palette.selected} solid 1px`; | ||
} | ||
|
||
return ellipseNodeStyle; | ||
}; | ||
|
||
const resizeLineStyle = (theme: Theme): React.CSSProperties => { | ||
return { borderWidth: theme.spacing(0.15) }; | ||
}; | ||
|
||
const resizeHandleStyle = (theme: Theme): React.CSSProperties => { | ||
return { | ||
width: theme.spacing(1), | ||
height: theme.spacing(1), | ||
borderRadius: '100%', | ||
}; | ||
}; | ||
|
||
export const EllipseNode: NodeComponentsMap['ellipseNode'] = memo( | ||
({ data, id, selected, dragging }: NodeProps<Node<EllipseNodeData>>) => { | ||
const { readOnly } = useContext<DiagramContextValue>(DiagramContext); | ||
const theme = useTheme(); | ||
const { onDrop, onDragOver } = useDrop(); | ||
const { style: connectionFeedbackStyle } = useConnectorNodeStyle(id, data.nodeDescription.id); | ||
const { style: dropFeedbackStyle } = useDropNodeStyle(data.isDropNodeTarget, data.isDropNodeCandidate, dragging); | ||
|
||
const handleOnDrop = (event: React.DragEvent) => { | ||
onDrop(event, id); | ||
}; | ||
|
||
useRefreshConnectionHandles(id, data.connectionHandles); | ||
|
||
return ( | ||
<> | ||
{data.nodeDescription?.userResizable !== 'NONE' && !readOnly ? ( | ||
<NodeResizer | ||
handleStyle={{ ...resizeHandleStyle(theme) }} | ||
lineStyle={{ ...resizeLineStyle(theme) }} | ||
color={theme.palette.selected} | ||
isVisible={!!selected} | ||
shouldResize={() => !data.isBorderNode} | ||
keepAspectRatio={data.nodeDescription?.keepAspectRatio} | ||
/> | ||
) : null} | ||
<div | ||
style={{ | ||
...ellipseNodeStyle(theme, data.style, !!selected, data.isHovered, data.faded), | ||
...connectionFeedbackStyle, | ||
...dropFeedbackStyle, | ||
}} | ||
onDragOver={onDragOver} | ||
onDrop={handleOnDrop} | ||
data-testid={`Ellipse - ${data?.insideLabel?.text}`}> | ||
{data.insideLabel ? <Label diagramElementId={id} label={data.insideLabel} faded={data.faded} /> : null} | ||
{!!selected ? ( | ||
<DiagramElementPalette | ||
diagramElementId={id} | ||
targetObjectId={data.targetObjectId} | ||
labelId={data.insideLabel ? data.insideLabel.id : null} | ||
/> | ||
) : null} | ||
{!!selected ? <ConnectionCreationHandles nodeId={id} /> : null} | ||
<ConnectionTargetHandle nodeId={id} nodeDescription={data.nodeDescription} isHovered={data.isHovered} /> | ||
<ConnectionHandles connectionHandles={data.connectionHandles} /> | ||
</div> | ||
</> | ||
); | ||
} | ||
); |
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,31 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023, 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 { GQLNodeStyle, NodeData } from '@eclipse-sirius/sirius-components-diagrams'; | ||
import { Node, NodeProps } from '@xyflow/react'; | ||
import { FC } from 'react'; | ||
|
||
export interface EllipseNodeData extends NodeData {} | ||
|
||
export interface GQLEllipseNodeStyle extends GQLNodeStyle { | ||
background: string; | ||
borderColor: string; | ||
borderStyle: string; | ||
borderSize: string; | ||
} | ||
|
||
export interface NodeDataMap { | ||
ellipseNode: EllipseNodeData; | ||
} | ||
export type NodeComponentsMap = { | ||
[K in keyof NodeDataMap]: FC<NodeProps<Node<NodeDataMap[K], K>>>; | ||
}; |
Oops, something went wrong.