fix
diff --git a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/internal/services/impl/MigrationServiceImpl.java b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/internal/services/impl/MigrationServiceImpl.java
index 49ed2df..a688a7e 100644
--- a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/internal/services/impl/MigrationServiceImpl.java
+++ b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/internal/services/impl/MigrationServiceImpl.java
@@ -15,7 +15,9 @@
*******************************************************************************/
package org.eclipse.graphiti.internal.services.impl;
-import java.util.HashSet;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
@@ -29,12 +31,11 @@
public class MigrationServiceImpl implements IMigrationService {
-
@Override
public void migrate070To080(Diagram d) {
// Traverse model and collect fonts
- HashSet<Font> fonts = new HashSet<Font>();
+ Map<Font, ArrayList<EObject>> fonts = new HashMap<Font, ArrayList<EObject>>();
Resource eResource = d.eResource();
TreeIterator<EObject> allContents = eResource.getAllContents();
while (allContents.hasNext()) {
@@ -42,20 +43,37 @@
if (next instanceof AbstractText) {
AbstractText t = (AbstractText) next;
Font font = t.getFont();
- if (font != null)
- fonts.add(font);
+ addFontUser(fonts, next, font);
} else if (next instanceof Style) {
Style s = (Style) next;
Font font = s.getFont();
- if (font != null)
- fonts.add(font);
+ addFontUser(fonts, next, font);
}
}
- // Manage collected fonts, including possibly a write.
+ // Manage collected fonts and set the new font on the respective
+ // elements. Includes possibly a write.
// The caller has to use a write transaction.
- for (Font font : fonts) {
- Graphiti.getGaService().manageFont(d, font.getName(), font.getSize(), font.isItalic(), font.isBold());
+ for (Font font : fonts.keySet()) {
+ Font newFont = Graphiti.getGaService().manageFont(d, font.getName(), font.getSize(), font.isItalic(), font.isBold());
+ ArrayList<EObject> arrayList = fonts.get(font);
+ for (EObject eObject : arrayList) {
+ if (eObject instanceof AbstractText) {
+ ((AbstractText) eObject).setFont(newFont);
+ } else {
+ ((Style) eObject).setFont(newFont);
+ }
+ }
+ }
+ }
+
+
+ private void addFontUser(Map<Font, ArrayList<EObject>> fonts, EObject next, Font font) {
+ if (font != null) {
+ if (fonts.get(font) == null) {
+ fonts.put(font, new ArrayList<EObject>());
+ }
+ fonts.get(font).add(next);
}
}