diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/image/ImageSelectionDialog.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/image/ImageSelectionDialog.java index c404ebefe3..4a3cdaded4 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/image/ImageSelectionDialog.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/image/ImageSelectionDialog.java @@ -119,6 +119,8 @@ public class ImageSelectionDialog extends Dialog { */ private Text imagePathText; + private boolean displayImagePaths; + /** * Create a new instance of {@link ImageSelectionDialog}. * @@ -130,8 +132,10 @@ public class ImageSelectionDialog extends Dialog { * if true there is only the close button instead of OK/Cancel * @param currentImagePath * the path to the image as it is serialized in the model + * @param displayImagePaths + * if true, display the current and new selected image path and a message if the image is not found. */ - public ImageSelectionDialog(Shell parentShell, EObject contextObject, boolean onlyCloseButton, String currentImagePath) { + public ImageSelectionDialog(Shell parentShell, EObject contextObject, boolean onlyCloseButton, String currentImagePath, boolean displayImagePaths) { super(parentShell); this.title = Messages.ImageSelectionDialog_title; this.root = ResourcesPlugin.getWorkspace().getRoot(); @@ -143,6 +147,7 @@ public ImageSelectionDialog(Shell parentShell, EObject contextObject, boolean on if (currentImagePath != null) { this.currentImagePath = URI.decode(currentImagePath.replace("\\", SLASH)); //$NON-NLS-1$ } + this.displayImagePaths = displayImagePaths; this.contextObject = contextObject; } @@ -352,7 +357,7 @@ private Object computeImageWithSameName(Object[] elements, String imageName) { } private void createImagePathComposite(Composite parent) { - if (currentImagePath != null) { + if (currentImagePath != null && displayImagePaths) { Composite imagePathContainer = new Composite(parent, SWT.NONE); GridLayout gridLayout = new GridLayout(2, false); imagePathContainer.setLayout(gridLayout); diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/image/ImageSelector.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/image/ImageSelector.java index 7b297d3686..f491486410 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/image/ImageSelector.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/image/ImageSelector.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2022 THALES GLOBAL SERVICES. + * Copyright (c) 2012, 2024 THALES GLOBAL SERVICES. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -39,6 +39,22 @@ enum SelectionMode { MULTI_SELECTION }; + /** + * Get the selected image paths. + * + * @param eObject + * the {@link EObject} used to associate the image with + * @param selectionMode + * the selectionMode + * @param currentSelection + * the current image path. + * @param displayImagePaths + * if true, the dialog will display the current and new selected image path and a message if the image is + * not found. + * @return a non null list of the selected image paths + */ + List selectImages(EObject eObject, SelectionMode selectionMode, String currentSelection, boolean displayImagePaths); + /** * Get the selected image paths. * @@ -51,7 +67,9 @@ enum SelectionMode { * and a message if the image is not found. * @return a non null list of the selected image paths */ - List selectImages(EObject eObject, SelectionMode selectionMode, String currentSelection); + default List selectImages(EObject eObject, SelectionMode selectionMode, String currentSelection) { + return selectImages(eObject, selectionMode, currentSelection, true); + } /** * Get the selected image paths. @@ -62,6 +80,8 @@ enum SelectionMode { * the selectionMode * @return a non null list of the selected image paths */ - List selectImages(EObject eObject, SelectionMode selectionMode); + default List selectImages(EObject eObject, SelectionMode selectionMode) { + return selectImages(eObject, selectionMode, null); + } } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/image/WorkspaceImageSelector.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/image/WorkspaceImageSelector.java index cc4e27760c..b79cc64a23 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/image/WorkspaceImageSelector.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/image/WorkspaceImageSelector.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2022 THALES GLOBAL SERVICES. + * Copyright (c) 2012, 2024 THALES GLOBAL SERVICES. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -28,11 +28,11 @@ public class WorkspaceImageSelector implements ImageSelector { @Override - public List selectImages(EObject eObject, ImageSelector.SelectionMode selectionMode, String currentImagePath) { + public List selectImages(EObject eObject, ImageSelector.SelectionMode selectionMode, String currentImagePath, boolean displayImagePaths) { String imagePath = null; Shell activeShell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); - ImageSelectionDialog dialog = new ImageSelectionDialog(activeShell, eObject, false, currentImagePath); + ImageSelectionDialog dialog = new ImageSelectionDialog(activeShell, eObject, false, currentImagePath, displayImagePaths); if (dialog.open() == Window.OK) { imagePath = dialog.getImagePath(); } @@ -43,9 +43,4 @@ public List selectImages(EObject eObject, ImageSelector.SelectionMode se } } - @Override - public List selectImages(EObject eObject, SelectionMode selectionMode) { - return selectImages(eObject, selectionMode, null); - } - } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/style/SetStyleToWorkspaceImageAction.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/style/SetStyleToWorkspaceImageAction.java index 7eec6fa116..623f0a9c39 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/style/SetStyleToWorkspaceImageAction.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/style/SetStyleToWorkspaceImageAction.java @@ -82,7 +82,7 @@ public void run() { if (basicLabelStyle instanceof WorkspaceImage img) { workspacePath = img.getWorkspacePath(); } - List imagePaths = imageSelector.selectImages(basicLabelStyle, ImageSelector.SelectionMode.MONO_SELECTION, workspacePath); + List imagePaths = imageSelector.selectImages(basicLabelStyle, ImageSelector.SelectionMode.MONO_SELECTION, workspacePath, false); if (imagePaths.size() == 1) { if (imagePaths.get(0).equals(ImageSelectionDialog.NO_IMAGE_PATH_TEXT)) { WorkspaceImageHelper.INSTANCE.resetStyle(basicLabelStyle); diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/DiagramShapeColorAndFontPropertySection.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/DiagramShapeColorAndFontPropertySection.java index b1040d0e37..174fe43749 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/DiagramShapeColorAndFontPropertySection.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/DiagramShapeColorAndFontPropertySection.java @@ -52,6 +52,7 @@ import org.eclipse.sirius.business.api.session.Session; import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter; import org.eclipse.sirius.diagram.DDiagramElement; +import org.eclipse.sirius.diagram.WorkspaceImage; import org.eclipse.sirius.diagram.business.api.query.DDiagramElementQuery; import org.eclipse.sirius.diagram.business.api.query.EObjectQuery; import org.eclipse.sirius.diagram.ui.business.api.image.ImageSelectionDialog; @@ -417,7 +418,11 @@ protected void setBackgroundImage(final SelectionEvent event) { ImageSelector imageSelector = ImageSelectorService.INSTANCE.getImageSelector(); List styles = getStyles(); for (BasicLabelStyle basicLabelStyle : styles) { - List imagePaths = imageSelector.selectImages(basicLabelStyle, ImageSelector.SelectionMode.MONO_SELECTION); + String workspacePath = null; + if (basicLabelStyle instanceof WorkspaceImage img) { + workspacePath = img.getWorkspacePath(); + } + List imagePaths = imageSelector.selectImages(basicLabelStyle, ImageSelector.SelectionMode.MONO_SELECTION, workspacePath, false); if (imagePaths.size() == 1) { if (imagePaths.get(0).equals(ImageSelectionDialog.NO_IMAGE_PATH_TEXT)) { WorkspaceImageHelper.INSTANCE.resetStyle(basicLabelStyle); diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html index 6aad1d6055..785a7c8ced 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html @@ -248,6 +248,20 @@

Changes in org.eclipse.sirius.diagram.ui.business.api.image.ImageSelectionDialog.isResetImage() and org.eclipse.sirius.diagram.ui.business.api.image.ImageSelectionDialog.setResetImage(boolean) have been added to handle the new “Reset Image Style” feature in the related dialog. +
  • Added + org.eclipse.sirius.diagram.ui.business.api.image.WorkspaceImageHelper.resetStyle(BasicLabelStyle) has been added to reset the WorkspaceImage style assigned to a DDiagramElement, while preserving all other style modifications. In other words, the workspacePath feature is reset. +
  • +
  • Added + org.eclipse.sirius.diagram.ui.business.api.image.ImageSelectionDialog.isResetImage() and + org.eclipse.sirius.diagram.ui.business.api.image.ImageSelectionDialog.setResetImage(boolean) have been added to handle the new “Reset Image Style” feature in the related dialog. +
  • +
  • Added The method + org.eclipse.sirius.diagram.ui.business.api.image.ImageSelector.selectImages(EObject, SelectionMode, String, boolean) has been added to de-corelate the display of current/new image path field from the present of a value to the + currentSelection parameter. Default implementations of the other + ImageSelector.selectImages methods have been added in the interface to match previous behavior for callers of those methods. The + org.eclipse.sirius.diagram.ui.business.api.image.WorkspaceImageSelector.selectImages(EObject, SelectionMode, String, boolean) has been removed in favor of the default implementation of the method in + ImageSelector. +
  • Changes in org.eclipse.sirius.tests.support diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile index a3550f33f8..8623dd2ba8 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile @@ -10,12 +10,16 @@ h3. User-Visible Changes * Added In the @ImageSelectionDialog@, a new feature has been added to reset the WorkspaceImage assigned to a DDiagramElement. Before this improvement, it was necessary to use the “Reset style properties to default values” button, but this also affected all other style modifications. This new button in the dialog resets only the WorkspaceImage style to the style of the element as defined in the Viewpoint Specification Model.
    !{width: 500px}user/diagrams/images/selectImageDialog_resetImage.png! + h3. Developer-Visible Changes h4. Changes in @org.eclipse.sirius.diagram.ui@ * Added @org.eclipse.sirius.diagram.ui.business.api.image.WorkspaceImageHelper.resetStyle(BasicLabelStyle)@ has been added to reset the WorkspaceImage style assigned to a DDiagramElement, while preserving all other style modifications. In other words, the workspacePath feature is reset. * Added @org.eclipse.sirius.diagram.ui.business.api.image.ImageSelectionDialog.isResetImage()@ and @org.eclipse.sirius.diagram.ui.business.api.image.ImageSelectionDialog.setResetImage(boolean)@ have been added to handle the new "Reset Image Style" feature in the related dialog. +* Added @org.eclipse.sirius.diagram.ui.business.api.image.WorkspaceImageHelper.resetStyle(BasicLabelStyle)@ has been added to reset the WorkspaceImage style assigned to a DDiagramElement, while preserving all other style modifications. In other words, the workspacePath feature is reset. +* Added @org.eclipse.sirius.diagram.ui.business.api.image.ImageSelectionDialog.isResetImage()@ and @org.eclipse.sirius.diagram.ui.business.api.image.ImageSelectionDialog.setResetImage(boolean)@ have been added to handle the new "Reset Image Style" feature in the related dialog. +* Added The method @org.eclipse.sirius.diagram.ui.business.api.image.ImageSelector.selectImages(EObject, SelectionMode, String, boolean)@ has been added to de-corelate the display of current/new image path field from the present of a value to the @currentSelection@ parameter. Default implementations of the other @ImageSelector.selectImages@ methods have been added in the interface to match previous behavior for callers of those methods. The @org.eclipse.sirius.diagram.ui.business.api.image.WorkspaceImageSelector.selectImages(EObject, SelectionMode, String, boolean)@ has been removed in favor of the default implementation of the method in @ImageSelector@. h4. Changes in @org.eclipse.sirius.tests.support@