Skip to content

Commit

Permalink
Fix simulation images in product
Browse files Browse the repository at this point in the history
  • Loading branch information
mbats committed Jun 23, 2015
1 parent 1ad818e commit 8cc6c3b
Showing 1 changed file with 5 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package fr.obeo.dsl.arduino.simulator.design.services;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.emf.ecore.EObject;
import org.osgi.framework.Bundle;

Expand Down Expand Up @@ -136,23 +132,12 @@ public String getSimulatingImage(Module module) {
String imageName = getImageLevel(module, level);
Bundle bundle = org.eclipse.core.runtime.Platform
.getBundle("fr.obeo.dsl.arduino.simulator.design");
URL fileURL = bundle.getEntry("images/" + imageName);
File file;
try {
file = new File(FileLocator.resolve(fileURL).toURI());
if (!file.exists()) {
ArduinoServices service = new ArduinoServices();
return service.getImage(module);
}
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
URL fileURL = bundle.getEntry("/images/" + imageName);
if (fileURL == null) {
ArduinoServices service = new ArduinoServices();
return service.getImage(module);
}

return "fr.obeo.dsl.arduino.simulator.design/images/" + imageName;
return "/fr.obeo.dsl.arduino.simulator.design/images/" + imageName;
}

private String getImageLevel(Module module, int level) {
Expand Down

0 comments on commit 8cc6c3b

Please sign in to comment.