From dd865cf210edf71bebfb92fa2fa9a461003caee5 Mon Sep 17 00:00:00 2001 From: Camille Letavernier Date: Mon, 8 Sep 2014 15:58:08 +0200 Subject: 351146: [Property View] Customization : an error occurs when saving a context depending on another context https://bugs.eclipse.org/bugs/show_bug.cgi?id=351146 --- .../OSGI-INF/l10n/bundle.properties | 12 +++--- .../customization/properties/editor/UIEditor.java | 48 ++++++++++++++++++++++ 2 files changed, 54 insertions(+), 6 deletions(-) (limited to 'plugins/customization/org.eclipse.papyrus.customization.properties') diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/OSGI-INF/l10n/bundle.properties b/plugins/customization/org.eclipse.papyrus.customization.properties/OSGI-INF/l10n/bundle.properties index 995f3e3f84d..4d9caea6513 100644 --- a/plugins/customization/org.eclipse.papyrus.customization.properties/OSGI-INF/l10n/bundle.properties +++ b/plugins/customization/org.eclipse.papyrus.customization.properties/OSGI-INF/l10n/bundle.properties @@ -2,16 +2,16 @@ Bundle-Name = Papyrus properties customization Bundle-Vendor = Eclipse Modeling Project editor.name = Properties View Editor -customize.command.label = Customize Property view +customize.command.label = Customize Properties view customize.command.mnemonic = C -customize.command.tooltip = Customize the content of the Property View +customize.command.tooltip = Customize the content of the Properties View customize.command.description = This command allows customization of the content of the properties view customize.command.name = Customize properties view view.name = Customization preview -perspective.name = Property view Customization -page.name = Property view customization -command.description = Customize the Property view -command.name = Customize property view +perspective.name = Properties view Customization +page.name = Properties view customization +command.description = Customize the Properties view +command.name = Customize properties view command.description.0 = Toggles the customization's Preview view command.name.0 = Toggle preview command.description.1 = Toggles the DataContext display diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/UIEditor.java b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/UIEditor.java index e9ec2377b75..3e0903fba4a 100644 --- a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/UIEditor.java +++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/UIEditor.java @@ -12,9 +12,13 @@ *****************************************************************************/ package org.eclipse.papyrus.customization.properties.editor; +import java.io.IOException; +import java.io.OutputStream; import java.util.EventObject; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.Map; import java.util.Set; import org.eclipse.core.resources.IFile; @@ -32,6 +36,8 @@ import org.eclipse.emf.ecore.presentation.EcoreEditorPlugin; import org.eclipse.emf.ecore.provider.EcoreItemProviderAdapterFactory; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.URIConverter; +import org.eclipse.emf.ecore.resource.URIHandler; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; import org.eclipse.emf.edit.provider.ComposedAdapterFactory; @@ -244,8 +250,50 @@ public class UIEditor extends EcoreEditor implements ITabbedPropertySheetPageCon viewer.addDropSupport(dndOperations, transfers, new MoDiscoDropAdapter(editingDomain, viewer)); } + @Override + protected void updateProblemIndication() { + super.updateProblemIndication(); + // if (updateProblemIndication){ + // for (Diagnostic diag : resourceToDiagnosticMap.values()){ + // if (diag.getSeverity() != Diagnostic.OK) + // Activator.log.error(diag.getMessage(), diag.getException()); + // } + // } + } + @Override public void doSave(IProgressMonitor progressMonitor) { + if (editingDomain.getResourceToReadOnlyMap() == null) { + editingDomain.setResourceToReadOnlyMap(new HashMap()); + } + + Map readOnlyMap = editingDomain.getResourceToReadOnlyMap(); + ResourceSet resourceSet = getEditingDomain().getResourceSet(); + + for (Resource resource : resourceSet.getResources()) { + if (readOnlyMap.containsKey(resource)) { + continue; + } + + URIHandler handler = resourceSet.getURIConverter().getURIHandler(resource.getURI()); + Map options = new HashMap(); + options.put(URIConverter.OPTION_URI_CONVERTER, resourceSet.getURIConverter()); + try { + OutputStream os = handler.createOutputStream(resource.getURI(), options); + readOnlyMap.put(resource, os == null); + if (os != null) { + os.close(); + } + } catch (IOException ex) { + // Currently, createOutputStream() fails on a NPE if the resource is read-only. + // Only log a warning, since the editor is currently not able to properly check for + // read-only state without calling createOutputStream + // See Bug 351146 for potential options regarding a proper fix + Activator.log.warn("Trying to save a read-only resource: " + resource.getURI()); + readOnlyMap.put(resource, true); + } + } + super.doSave(progressMonitor); refreshContext(); } -- cgit v1.2.3