-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4522] Restore contribution of custom tools to the diagram palette
Bug: #4522 Signed-off-by: Florian ROUËNÉ <[email protected]>
- Loading branch information
Showing
7 changed files
with
155 additions
and
53 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
55 changes: 55 additions & 0 deletions
55
integration-tests/cypress/e2e/project/diagrams/custom-tool.cy.ts
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,55 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 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 { Explorer } from '../../../workbench/Explorer'; | ||
import { Diagram } from '../../../workbench/Diagram'; | ||
import { Papaya } from '../../../usecases/Papaya'; | ||
import { Project } from '../../../pages/Project'; | ||
|
||
describe('Custom tools', () => { | ||
context('Given a papaya blank project', () => { | ||
let projectId: string = ''; | ||
beforeEach(() => { | ||
new Papaya().createPapayaBlankProject().then((createdProjectData) => { | ||
projectId = createdProjectData.projectId; | ||
const project = new Project(); | ||
project.visit(projectId); | ||
const explorer = new Explorer(); | ||
explorer.expandWithDoubleClick('Papaya'); | ||
explorer.expandWithDoubleClick('Project Project'); | ||
explorer.expandWithDoubleClick('Component Component'); | ||
explorer.createRepresentation('Component Component', 'Component Diagram', 'diagram'); | ||
}); | ||
}); | ||
|
||
afterEach(() => cy.deleteProject(projectId)); | ||
|
||
it('Check diagram custom tool exist', () => { | ||
const diagram = new Diagram(); | ||
diagram.getDiagram('diagram').should('exist'); | ||
cy.getByTestId('rf__wrapper').should('exist').rightclick(100, 100).rightclick(100, 100); | ||
diagram.getPalette().should('exist'); | ||
cy.getByTestId('coordinates-tool').should('exist'); | ||
}); | ||
|
||
it('Check diagram element custom tool exist', () => { | ||
const diagram = new Diagram(); | ||
diagram.getDiagram('diagram').should('exist'); | ||
cy.getByTestId('rf__wrapper').should('exist').rightclick(100, 100).rightclick(100, 100); | ||
diagram.getPalette().should('exist'); | ||
cy.getByTestId('tool-New component').should('exist').click(); | ||
diagram.fitToScreen(); | ||
diagram.getNodes('diagram', 'Component').should('exist').rightclick(); | ||
cy.getByTestId('label-detail').should('exist'); | ||
}); | ||
}); | ||
}); |
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
66 changes: 66 additions & 0 deletions
66
...irius-web/frontend/sirius-web-papaya/src/tools/PapayaComponentDiagramToolContribution.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,66 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 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 RadarIcon from '@mui/icons-material/Radar'; | ||
import Dialog from '@mui/material/Dialog'; | ||
import DialogContent from '@mui/material/DialogContent'; | ||
import DialogContentText from '@mui/material/DialogContentText'; | ||
import IconButton from '@mui/material/IconButton'; | ||
import { Fragment, useState } from 'react'; | ||
import { makeStyles } from 'tss-react/mui'; | ||
|
||
const useToolStyle = makeStyles()(() => ({ | ||
tool: { | ||
width: '36px', | ||
}, | ||
})); | ||
|
||
type Modal = 'dialog'; | ||
export const PapayaComponentDiagramToolContribution = ({ x, y }) => { | ||
const [modal, setModal] = useState<Modal | null>(null); | ||
const { classes } = useToolStyle(); | ||
|
||
const onClose = () => { | ||
setModal(null); | ||
}; | ||
|
||
let modalElement: JSX.Element | null = null; | ||
if (modal === 'dialog') { | ||
modalElement = ( | ||
<> | ||
<Dialog open={true} onClose={onClose} fullWidth> | ||
<DialogContent> | ||
<DialogContentText> | ||
x: {x}, y:{y} | ||
</DialogContentText> | ||
</DialogContent> | ||
</Dialog> | ||
</> | ||
); | ||
} | ||
|
||
return ( | ||
<Fragment key="coordinates-modal-contribution"> | ||
<IconButton | ||
className={classes.tool} | ||
size="small" | ||
color="inherit" | ||
aria-label="Coordinates" | ||
title="Coordinates" | ||
onClick={() => setModal('dialog')} | ||
data-testid="coordinates-tool"> | ||
<RadarIcon /> | ||
</IconButton> | ||
{modalElement} | ||
</Fragment> | ||
); | ||
}; |