Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbblajer2007-04-10 14:40:08 +0000
committerbblajer2007-04-10 14:40:08 +0000
commitaf164483efdf16a80016240e397d8045ec3f6b4b (patch)
treee42360c6315311538adfa20208440b573b02feec /plugins/org.eclipse.gmf.runtime.lite/src/org
parent1560595bfcd12ac29eb62d53bfd901d07d7ec06f (diff)
downloadorg.eclipse.gmf-tooling-af164483efdf16a80016240e397d8045ec3f6b4b.tar.gz
org.eclipse.gmf-tooling-af164483efdf16a80016240e397d8045ec3f6b4b.tar.xz
org.eclipse.gmf-tooling-af164483efdf16a80016240e397d8045ec3f6b4b.zip
[179970] - Adopt code generater to make use of EMF "conditional resource saving";
Correctly set charset for IFiles
Diffstat (limited to 'plugins/org.eclipse.gmf.runtime.lite/src/org')
-rw-r--r--plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/parts/DiagramDisplayer.java14
-rw-r--r--plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/parts/DiagramEditor.java26
-rw-r--r--plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/parts/DiagramViewPart.java12
3 files changed, 38 insertions, 14 deletions
diff --git a/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/parts/DiagramDisplayer.java b/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/parts/DiagramDisplayer.java
index 2113cfe06..7818356f1 100644
--- a/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/parts/DiagramDisplayer.java
+++ b/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/parts/DiagramDisplayer.java
@@ -14,7 +14,7 @@ package org.eclipse.gmf.runtime.lite.parts;
import java.io.IOException;
import java.util.Collections;
import java.util.EventObject;
-import java.util.Iterator;
+import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -396,16 +396,22 @@ public class DiagramDisplayer implements IDiagramOutlineHost {
}
}
+ /**
+ * @deprecated Use {@link #save(Map, IProgressMonitor)} instead.
+ */
public void save(IProgressMonitor progressMonitor) throws CoreException {
+ save(Collections.emptyMap(), progressMonitor);
+ }
+
+ public void save(Map<?, ?> options, IProgressMonitor progressMonitor) throws CoreException {
if (progressMonitor == null) {
progressMonitor = new NullProgressMonitor();
}
progressMonitor.beginTask("Saving", getEditingDomain().getResourceSet().getResources().size());
try {
- for(Iterator it = getEditingDomain().getResourceSet().getResources().iterator(); it.hasNext(); ) {
- Resource next = (Resource)it.next();
+ for(Resource next : getEditingDomain().getResourceSet().getResources()) {
if (next.isLoaded() && (next.isModified() || !next.isTrackingModification())) {
- next.save(Collections.EMPTY_MAP);
+ next.save(options);
}
progressMonitor.worked(1);
}
diff --git a/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/parts/DiagramEditor.java b/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/parts/DiagramEditor.java
index 6c392cfda..ef3597556 100644
--- a/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/parts/DiagramEditor.java
+++ b/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/parts/DiagramEditor.java
@@ -12,8 +12,9 @@
package org.eclipse.gmf.runtime.lite.parts;
import java.util.Collection;
+import java.util.Collections;
import java.util.EventObject;
-import java.util.Iterator;
+import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -78,8 +79,7 @@ public abstract class DiagramEditor extends EditorPart implements IDiagramManage
}
}
private boolean isSaved() {
- for(Iterator it = getEditingDomain().getResourceSet().getResources().iterator(); it.hasNext(); ) {
- Resource next = (Resource) it.next();
+ for(Resource next : getEditingDomain().getResourceSet().getResources()) {
if (!next.isLoaded()) {
continue;
}
@@ -92,7 +92,14 @@ public abstract class DiagramEditor extends EditorPart implements IDiagramManage
};
protected void save(IProgressMonitor monitor) throws CoreException {
- myDiagramDisplayer.save(monitor);
+ myDiagramDisplayer.save(getSaveOptions(), monitor);
+ }
+
+ /**
+ * Returns the options with which the resources will be saved. Subclasses should override.
+ */
+ protected Map<?, ?> getSaveOptions() {
+ return Collections.emptyMap();
}
public final TransactionalEditingDomain getEditingDomain() {
@@ -346,11 +353,12 @@ public abstract class DiagramEditor extends EditorPart implements IDiagramManage
super.setTarget(newTarget);
if (newTarget instanceof ResourceSet) {
ResourceSet resourceSet = (ResourceSet) newTarget;
- for(Iterator it = resourceSet.getResources().iterator(); it.hasNext(); ) {
- ((Resource) it.next()).setTrackingModification(true);
+ for(Resource next : resourceSet.getResources()) {
+ next.setTrackingModification(true);
}
}
}
+
@Override
public void notifyChanged(Notification msg) {
if (msg.getNotifier() == getTarget() && msg.getFeatureID(ResourceSet.class) == ResourceSet.RESOURCE_SET__RESOURCES) {
@@ -363,9 +371,9 @@ public abstract class DiagramEditor extends EditorPart implements IDiagramManage
break;
case Notification.ADD_MANY:
{
- Collection resources = (Collection) msg.getNewValue();
- for(Iterator it = resources.iterator(); it.hasNext(); ) {
- ((Resource) it.next()).setTrackingModification(true);
+ @SuppressWarnings("unchecked") Collection<Resource> resources = (Collection<Resource>) msg.getNewValue();
+ for(Resource next : resources) {
+ next.setTrackingModification(true);
}
}
}
diff --git a/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/parts/DiagramViewPart.java b/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/parts/DiagramViewPart.java
index 91c083754..aba2715e3 100644
--- a/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/parts/DiagramViewPart.java
+++ b/plugins/org.eclipse.gmf.runtime.lite/src/org/eclipse/gmf/runtime/lite/parts/DiagramViewPart.java
@@ -11,6 +11,9 @@
*/
package org.eclipse.gmf.runtime.lite.parts;
+import java.util.Collections;
+import java.util.Map;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.draw2d.ColorConstants;
@@ -64,7 +67,7 @@ public abstract class DiagramViewPart extends ViewPart implements IDiagramManage
assert event.getSource() == myDiagramDisplayer.getCommandStack();
if (event.isPostChangeEvent()) {
try {
- myDiagramDisplayer.save(new NullProgressMonitor());
+ myDiagramDisplayer.save(getSaveOptions(), new NullProgressMonitor());
myDiagramDisplayer.getCommandStack().markSaveLocation();
} catch (CoreException e) {
Activator.getDefault().getLog().log(e.getStatus());
@@ -78,6 +81,13 @@ public abstract class DiagramViewPart extends ViewPart implements IDiagramManage
super.init(site);
}
+ /**
+ * Returns the options with which the resources will be saved. Subclasses should override.
+ */
+ protected Map<?, ?> getSaveOptions() {
+ return Collections.emptyMap();
+ }
+
@Override
public void dispose() {
if (myDiagramDisplayer != null) {

Back to the top