Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.nio.file.Path;
import java.util.function.Supplier;

import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.util.Policy;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.graphics.Device;
Expand Down Expand Up @@ -92,7 +92,8 @@ public static ImageDescriptor createFromFile(Class<?> location, String filename)
URL url;
if (location == null) {
try {
url = Path.of(filename).toUri().toURL();
// Use IPath, which can handle illegal path's on Windows like: /C:/data/other
url = IPath.fromOSString(filename).toPath().toUri().toURL();
} catch (MalformedURLException e) {
Policy.logException(e);
url = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;

import java.io.IOException;
import java.net.URL;
Expand Down Expand Up @@ -55,7 +54,7 @@ public class FileImageDescriptorTest {
* Test loading the image descriptors.
*/
@Test
public void testFileImageDescriptorWorkbench() {
public void testFileImageDescriptorWorkbench() throws IOException {

Class<?> missing = null;
ArrayList<Image> images = new ArrayList<>();
Expand All @@ -64,7 +63,6 @@ public void testFileImageDescriptorWorkbench() {
Enumeration<String> bundleEntries = bundle.getEntryPaths(IMAGES_DIRECTORY);

while (bundleEntries.hasMoreElements()) {
ImageDescriptor descriptor;
String localImagePath = bundleEntries.nextElement();
URL[] files = FileLocator.findEntries(bundle, IPath.fromOSString(localImagePath));

Expand All @@ -75,12 +73,8 @@ public void testFileImageDescriptorWorkbench() {
continue;
}

try {
descriptor = ImageDescriptor.createFromFile(missing, FileLocator.toFileURL(file).getFile());
} catch (IOException e) {
fail(e.getLocalizedMessage());
continue;
}
ImageDescriptor descriptor = ImageDescriptor.createFromFile(missing,
FileLocator.toFileURL(file).getFile());

Image image = descriptor.createImage();
images.add(image);
Expand Down
Loading