Skip to content
Draft
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 @@ -25,6 +25,7 @@
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.TreeSet;

Expand Down Expand Up @@ -151,7 +152,7 @@ public class ExtensionsSection extends TreeSection implements IPropertyChangeLis
"commandId", "property", "activityId", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"attribute", "value"}; //$NON-NLS-1$ //$NON-NLS-2$

private static final String[] VALID_IMAGE_TYPES = {"png", "bmp", "ico", "gif", "jpg", "tiff"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
private static final Set<String> VALID_IMAGE_TYPES = Set.of("svg", "png", "bmp", "ico", "gif", "jpg", "tiff"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually every image format that SWT supports could be listed here.
Maybe we should consider to introduce some kind of ImageFileDialog as extension of FileDialog that allows to load and save images of the formats that SWT supports and returns the path or even the Image/ImageData directly as convenience.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AWT allows to enumerate supported images (with Java SPI + ImageReader interface) in what case e.g. JFace could offer such smarter FileChooser Dialogs...

private static final String MENU_NEW_ID = "NewMenu"; //$NON-NLS-1$

class ExtensionContentProvider implements ITreeContentProvider {
Expand Down Expand Up @@ -975,15 +976,8 @@ static Image getCustomImage(IPluginElement element) {
if (ext == null) {
return null;
}
boolean valid = false;
// ensure the resource is an image
for (String imageType : VALID_IMAGE_TYPES) {
if (ext.equalsIgnoreCase(imageType)) {
valid = true;
break;
}
}
// if the resource is an image, get the image, otherwise return null
boolean valid = VALID_IMAGE_TYPES.contains(ext.toLowerCase(Locale.ROOT));
return valid ? getImageFromPlugin(element, iconPath) : null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ private void handleBrowse() {
FileExtensionsFilter filter = new FileExtensionsFilter();
filter.addFileExtension("gif"); //$NON-NLS-1$
filter.addFileExtension("png"); //$NON-NLS-1$
filter.addFileExtension("svg"); //$NON-NLS-1$
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if SVG can be generally allowed for images that are associated with the application window? This might be renderer natively by the OS.

dialog.addFilter(filter);
dialog.setInput(PDEPlugin.getWorkspace().getRoot());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ private void handleBrowse(FormEntry entry) {
FileExtensionsFilter filter = new FileExtensionsFilter();
filter.addFileExtension("gif"); //$NON-NLS-1$
filter.addFileExtension("png"); //$NON-NLS-1$
filter.addFileExtension("svg"); //$NON-NLS-1$
dialog.addFilter(filter);
dialog.setInput(PDEPlugin.getWorkspace().getRoot());

Expand Down
Loading