Commit dca88de6 authored by Juergen Haug's avatar Juergen Haug Committed by Gerrit Code Review @ Eclipse.org
Browse files

Merge "[diagram] do not save and track modification of other resources"

parents eb8d0eee 4a58ad53
......@@ -77,6 +77,12 @@ public class CustomPersistencyBehavior extends DefaultPersistencyBehavior {
}
}
@Override
protected boolean shouldSave(Resource resource) {
// assume all resources we want to save have tracking modification enabled, see ModificationTrackingEnabler
return resource.isTrackingModification() && super.shouldSave(resource);
}
protected boolean validateResourcesBeforeSave(final IProgressMonitor monitor){
final RunnableWithResult<Boolean> runnable = new RunnableWithResult.Impl<Boolean>() {
......
......@@ -10,12 +10,16 @@
package org.eclipse.etrice.ui.common.base.editor;
import java.util.Set;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.transaction.ResourceSetChangeEvent;
import org.eclipse.emf.transaction.ResourceSetListenerImpl;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import com.google.common.collect.Sets;
/**
* description
*
......@@ -24,6 +28,8 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
*/
public class ModificationTrackingEnabler extends ResourceSetListenerImpl {
private final Set<String> fileExtensions = Sets.newHashSet("structure", "behavior", "room");
/* (non-Javadoc)
* @see org.eclipse.emf.transaction.ResourceSetListenerImpl#setTarget(org.eclipse.emf.transaction.TransactionalEditingDomain)
*/
......@@ -47,8 +53,13 @@ public class ModificationTrackingEnabler extends ResourceSetListenerImpl {
protected void setTrackingModification() {
ResourceSet rs = getTarget().getResourceSet();
for (Resource r : rs.getResources()) {
if (!r.isTrackingModification())
if (shouldTrack(r) && !r.isTrackingModification())
r.setTrackingModification(true);
}
}
protected boolean shouldTrack(Resource resource) {
String fileExt = resource.getURI().fileExtension();
return fileExtensions.contains(fileExt.toLowerCase());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment