diff options
| author | Laurent Fasani | 2017-06-22 14:09:49 +0000 |
|---|---|---|
| committer | Laurent Fasani | 2017-07-07 15:56:03 +0000 |
| commit | b281e69bf082c6a18a48634c5bed027397669c29 (patch) | |
| tree | 9d3ca8047aeee33e2423cc50a4a664f4c7e57726 | |
| parent | 9170ebe72a21487bb0304518ee773058fcaf64c7 (diff) | |
| download | org.eclipse.sirius-b281e69bf082c6a18a48634c5bed027397669c29.tar.gz org.eclipse.sirius-b281e69bf082c6a18a48634c5bed027397669c29.tar.xz org.eclipse.sirius-b281e69bf082c6a18a48634c5bed027397669c29.zip | |
[516669] Correctly fail if the representation is not loadable
* If the representation resource can not be found, then the exception is
catched and logged.
* DRepresentation.getRepresentation will return null if the
representation is not loadable.
Bug: 516669
Change-Id: I45c73fbd391462e63240f3cbe6375ccae454f1cd
Signed-off-by: Laurent Fasani <laurent.fasani@obeo.fr>
3 files changed, 22 insertions, 9 deletions
diff --git a/plugins/org.eclipse.sirius/plugin.properties b/plugins/org.eclipse.sirius/plugin.properties index bf5984413e..0c5c573888 100644 --- a/plugins/org.eclipse.sirius/plugin.properties +++ b/plugins/org.eclipse.sirius/plugin.properties @@ -133,13 +133,14 @@ DeleteRepresentationCommand_label = Delete representation DeleteWithoutToolTask_label = Delete without tool DialectManagerImpl_refreshImpactedMsg = Refresh impacted representation elements DialectManagerImpl_refreshMsg = Refresh representation +DRepresentationDescriptorToDRepresentationLinkManager_repLoading = Can not load the resource {0} DViewOperations_addSelectedViewMsg = View selection DViewOperations_createViewMsg = View creation for Sirius : {0} DViewOperations_initRepresentationMsg = Initialize representations DViewOperations_notContainedErrorMsg = The view is not contained in the analysis DViewOperations_removeSelectedViewMsg = View unselection DViewOperations_updateSelectedVPDataMsg = Update selected Viewpoints data -EAttributeCustomizationAttributeNameCommonToAppliedOnConstraint_EAttributeDiffernentTypesErrorMsg = {0} and {1}have each a EAttribute named {2} but with differents types +EAttributeCustomizationAttributeNameCommonToAppliedOnConstraint_EAttributeDiffernentTypesErrorMsg = {0} and {1} have each a EAttribute named {2} but with different types EAttributeCustomizationAttributeNameCommonToAppliedOnConstraint_notEAttributeErrorMsg = {0} EAttribute name on {1} concerns {2} which is not a EAttribute EAttributeCustomizationAttributeNameCommonToAppliedOnConstraint_validationNotExistErrorMsg = {0} EAttribute name on {1} doesn''t exists EAttributeCustomizationAttributeNameCommonToAppliedOnConstraint_validationStyleDescriptionErrorMsg = {0} doesn''t concerns a style description or a style description element diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/representation/DRepresentationDescriptorToDRepresentationLinkManager.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/representation/DRepresentationDescriptorToDRepresentationLinkManager.java index 24bb527ed0..f62b8e1924 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/representation/DRepresentationDescriptorToDRepresentationLinkManager.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/representation/DRepresentationDescriptorToDRepresentationLinkManager.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.sirius.business.internal.representation; +import java.text.MessageFormat; import java.util.Optional; import org.eclipse.core.runtime.Assert; @@ -22,6 +23,8 @@ import org.eclipse.sirius.business.api.session.Session; import org.eclipse.sirius.common.tools.api.util.EclipseUtil; import org.eclipse.sirius.viewpoint.DRepresentation; import org.eclipse.sirius.viewpoint.DRepresentationDescriptor; +import org.eclipse.sirius.viewpoint.Messages; +import org.eclipse.sirius.viewpoint.SiriusPlugin; /** * This class is intended to manage the link between the {@link DRepresentationDescriptor} and its @@ -110,13 +113,19 @@ public class DRepresentationDescriptorToDRepresentationLinkManager { ResourceDescriptor resourceDescriptor = repDescriptor.getRepPath(); Resource resource = repDescriptor.eResource(); if (resourceDescriptor != null) { - // @formatter:off - return Optional.ofNullable(resource).map(Resource::getResourceSet) - .map(rSet -> rSet.getEObject(resourceDescriptor.getResourceURI(), loadOnDemand)) - .filter(DRepresentation.class::isInstance) - .map(DRepresentation.class::cast) - .orElse(null); - // @formatter:on + try { + // @formatter:off + return Optional.ofNullable(resource).map(Resource::getResourceSet) + .map(rSet -> rSet.getEObject(resourceDescriptor.getResourceURI(), loadOnDemand)) + .filter(DRepresentation.class::isInstance) + .map(DRepresentation.class::cast) + .orElse(null); + // @formatter:on + // CHECKSTYLE:OFF + } catch (Exception e) { + // CHECKSTYLE:ON + SiriusPlugin.getDefault().error(MessageFormat.format(Messages.DRepresentationDescriptorToDRepresentationLinkManager_repLoading, resourceDescriptor.getResourceURI()), e); + } } return null; } diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/viewpoint/Messages.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/viewpoint/Messages.java index 6cecb0d926..225b926947 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/viewpoint/Messages.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/viewpoint/Messages.java @@ -193,6 +193,9 @@ public final class Messages { public static String DialectManagerImpl_refreshMsg; @TranslatableMessage + public static String DRepresentationDescriptorToDRepresentationLinkManager_repLoading; + + @TranslatableMessage public static String DViewOperations_addSelectedViewMsg; @TranslatableMessage @@ -497,7 +500,7 @@ public final class Messages { @TranslatableMessage public static String SessionFactoryImpl_sessionLoadingMsg; - + @TranslatableMessage public static String SessionInterpreter_evaluationError; |
