Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Fasani2018-01-09 18:23:17 +0000
committerLaurent Fasani2018-01-10 10:43:24 +0000
commitdea2bf7dabcb6ac0480691993bc950557db7fe45 (patch)
treeb76cb38f1cf4c61e3ce30545b1245c5d21818f2f
parentad818891becb7e08e5675368c018797a203a0075 (diff)
downloadorg.eclipse.sirius-dea2bf7dabcb6ac0480691993bc950557db7fe45.tar.gz
org.eclipse.sirius-dea2bf7dabcb6ac0480691993bc950557db7fe45.tar.xz
org.eclipse.sirius-dea2bf7dabcb6ac0480691993bc950557db7fe45.zip
[529620] Memento: avoid creating a non existing resourcev5.1.1rc3
* Call domain.getResourceSet().getResource(uri.trimFragment(), true) with loadOnDemand=true to create and get the resource rather than createResource which will create the resource even if it is not existing physically. Bug:529620 Cherry-picked-from: 529615 Change-Id: Ia818f36f47f30966017b20f90430c00074d07228 Signed-off-by: Laurent Fasani <laurent.fasani@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/resource/CustomSiriusDocumentProvider.java22
1 files changed, 9 insertions, 13 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/resource/CustomSiriusDocumentProvider.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/resource/CustomSiriusDocumentProvider.java
index 7b80620811..2b05073729 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/resource/CustomSiriusDocumentProvider.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/resource/CustomSiriusDocumentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2009, 2018 THALES GLOBAL SERVICES and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -92,7 +92,8 @@ public class CustomSiriusDocumentProvider extends AbstractDocumentProvider imple
protected IDocument createDocument(final Object element) throws CoreException {
if (!(element instanceof FileEditorInput) && !(element instanceof URIEditorInput)) {
throw new CoreException(new Status(IStatus.ERROR, DiagramPlugin.ID, 0,
- MessageFormat.format(Messages.SiriusDocumentProvider_IncorrectInputError, new Object[] { element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput", }), //$NON-NLS-1$ //$NON-NLS-2$
+ MessageFormat.format(Messages.SiriusDocumentProvider_IncorrectInputError,
+ new Object[] { element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput", }), //$NON-NLS-1$ //$NON-NLS-2$
null));
}
final IDocument document = createEmptyDocument();
@@ -143,7 +144,8 @@ public class CustomSiriusDocumentProvider extends AbstractDocumentProvider imple
caseURIEditorInput(document, (URIEditorInput) element, domain);
} else {
throw new CoreException(new Status(IStatus.ERROR, DiagramPlugin.ID, 0,
- MessageFormat.format(Messages.SiriusDocumentProvider_IncorrectInputError, new Object[] { element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput", }), //$NON-NLS-1$ //$NON-NLS-2$
+ MessageFormat.format(Messages.SiriusDocumentProvider_IncorrectInputError,
+ new Object[] { element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput", }), //$NON-NLS-1$ //$NON-NLS-2$
null));
}
} finally {
@@ -174,10 +176,7 @@ public class CustomSiriusDocumentProvider extends AbstractDocumentProvider imple
final URI uri = element.getURI();
Resource resource = null;
try {
- resource = domain.getResourceSet().getResource(uri.trimFragment(), false);
- if (resource == null) {
- resource = domain.getResourceSet().createResource(uri.trimFragment());
- }
+ resource = domain.getResourceSet().getResource(uri.trimFragment(), true);
if (!resource.isLoaded()) {
try {
final Map<?, ?> options = new HashMap<Object, Object>(GMFResourceFactory.getDefaultLoadOptions());
@@ -243,9 +242,8 @@ public class CustomSiriusDocumentProvider extends AbstractDocumentProvider imple
}
/**
- * Sets up the given document as it would be provided for the given element.
- * The content of the document is not changed. This default implementation
- * is empty. Subclasses may reimplement.
+ * Sets up the given document as it would be provided for the given element. The content of the document is not
+ * changed. This default implementation is empty. Subclasses may reimplement.
*
* @param element
* the blue-print element
@@ -272,9 +270,7 @@ public class CustomSiriusDocumentProvider extends AbstractDocumentProvider imple
* {@inheritDoc}
*
* @see org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider#doSaveDocument(org.eclipse.core.runtime.IProgressMonitor,
- * java.lang.Object,
- * org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument,
- * boolean)
+ * java.lang.Object, org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument, boolean)
*/
@Override
protected void doSaveDocument(final IProgressMonitor monitor, final Object element, final IDocument document, final boolean overwrite) throws CoreException {

Back to the top