Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Barbin2019-04-01 08:51:15 +0000
committerFlorian Barbin2019-04-08 07:42:13 +0000
commitff64f4a7bdd8c23055d56d1a4c88a6d1a7ce8849 (patch)
tree2f73c1b5bf318fd395f487ee8566292112d30114
parent4e9117181bb73c3898fe1b4e9153febc104eb469 (diff)
downloadorg.eclipse.sirius-ff64f4a7bdd8c23055d56d1a4c88a6d1a7ce8849.tar.gz
org.eclipse.sirius-ff64f4a7bdd8c23055d56d1a4c88a6d1a7ce8849.tar.xz
org.eclipse.sirius-ff64f4a7bdd8c23055d56d1a4c88a6d1a7ce8849.zip
[546028] Have the problem decorator on resources in modeling project
* The error decorator was not displayed on resources with the modeling nature. Bug: 546028 Change-Id: Iecd66bed2103be4f6744e4f113e437f8868b5dba Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/SiriusCommonLabelProvider.java54
1 files changed, 49 insertions, 5 deletions
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/SiriusCommonLabelProvider.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/SiriusCommonLabelProvider.java
index ba26418667..94a18569cf 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/SiriusCommonLabelProvider.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/SiriusCommonLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2018 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2011, 2019 THALES GLOBAL SERVICES and others.
* 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
@@ -16,8 +16,10 @@ import java.util.Collections;
import java.util.List;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ColumnLabelProvider;
@@ -76,6 +78,21 @@ public class SiriusCommonLabelProvider extends ColumnLabelProvider implements IC
public static final ImageDescriptor SIRIUS_MODELING_OVERLAY_DESC = AbstractUIPlugin.imageDescriptorFromPlugin(SiriusEditPlugin.ID, "/icons/full/ovr16/SessionDecorator.gif"); //$NON-NLS-1$ ;
/**
+ * Error image descriptor for the error decorator overlay.
+ */
+ public static final ImageDescriptor ERROR_OVERLAY_DESC = AbstractUIPlugin.imageDescriptorFromPlugin(SiriusEditPlugin.ID, "/icons/full/validation/error_co.png"); //$NON-NLS-1$ ;
+
+ /**
+ * Warning image descriptor for the warning decorator overlay.
+ */
+ public static final ImageDescriptor WARNING_OVERLAY_DESC = AbstractUIPlugin.imageDescriptorFromPlugin(SiriusEditPlugin.ID, "/icons/full/validation/warning_co.png"); //$NON-NLS-1$ ;
+
+ /**
+ * Info image descriptor for the info decorator overlay.
+ */
+ public static final ImageDescriptor INFO_OVERLAY_DESC = AbstractUIPlugin.imageDescriptorFromPlugin(SiriusEditPlugin.ID, "/icons/full/validation/info_co.png"); //$NON-NLS-1$ ;
+
+ /**
* The overlay decorator used to distinguish representation types/categories from actual representations
* (instances).
*/
@@ -159,9 +176,19 @@ public class SiriusCommonLabelProvider extends ColumnLabelProvider implements IC
if (new IFileQuery(file).isResourceHandledByOpenedSession()) {
// Add "Sirius Modeling" overlay on this semantic file.
String fileExtension = file.getFileExtension();
+
+ // -1 means no problem (see org.eclipse.core.resources.IResource.findMaxProblemSeverity(String, boolean,
+ // int)).
+ int severity = -1;
+ try {
+ // We retrieve the severity from the problem marker.
+ severity = file.findMaxProblemSeverity(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
+ } catch (CoreException e) {
+ // We do nothing (no severity decorator will be displayed)
+ }
// Create a key to store/restore the image in image registry of
// SiriusEditPlugin
- String imgKey = fileExtension + "Decorated"; //$NON-NLS-1$
+ String imgKey = fileExtension + "Decorated" + severity; //$NON-NLS-1$
// Get the existing image (if any)
img = SiriusEditPlugin.getPlugin().getImageRegistry().get(imgKey);
// If the image has already been computed, use it.
@@ -174,9 +201,7 @@ public class SiriusCommonLabelProvider extends ColumnLabelProvider implements IC
}
if (imageDescriptor != null) {
// Add an overlay with the "Sirius Modeling" overlay
- ImageDescriptor[] imageDescriptors = new ImageDescriptor[5];
- imageDescriptors[IDecoration.TOP_RIGHT] = SiriusCommonLabelProvider.SIRIUS_MODELING_OVERLAY_DESC;
- img = new DecorationOverlayIcon(imageDescriptor.createImage(), imageDescriptors).createImage();
+ img = addIFileDecorators(severity, imageDescriptor);
SiriusEditPlugin.getPlugin().getImageRegistry().put(imgKey, img);
}
}
@@ -185,6 +210,25 @@ public class SiriusCommonLabelProvider extends ColumnLabelProvider implements IC
return img;
}
+ private Image addIFileDecorators(int severity, ImageDescriptor imageDescriptor) {
+ ImageDescriptor[] imageDescriptors = new ImageDescriptor[5];
+ imageDescriptors[IDecoration.TOP_RIGHT] = SiriusCommonLabelProvider.SIRIUS_MODELING_OVERLAY_DESC;
+ switch (severity) {
+ case IMarker.SEVERITY_ERROR:
+ imageDescriptors[IDecoration.BOTTOM_LEFT] = SiriusCommonLabelProvider.ERROR_OVERLAY_DESC;
+ break;
+ case IMarker.SEVERITY_WARNING:
+ imageDescriptors[IDecoration.BOTTOM_LEFT] = SiriusCommonLabelProvider.WARNING_OVERLAY_DESC;
+ break;
+ case IMarker.SEVERITY_INFO:
+ imageDescriptors[IDecoration.BOTTOM_LEFT] = SiriusCommonLabelProvider.INFO_OVERLAY_DESC;
+ break;
+ default:
+ break;
+ }
+ return new DecorationOverlayIcon(imageDescriptor.createImage(), imageDescriptors).createImage();
+ }
+
private boolean isInvalidRepresentation(Object element) {
DRepresentationDescriptor representationDescriptor = getRepresentationDescriptor(element);
return representationDescriptor != null && !new DRepresentationDescriptorQuery(representationDescriptor).isRepresentationValid();

Back to the top