mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2024-12-21 17:29:55 +00:00
Patching file extensions to include upper/lower case in filters.
This commit is contained in:
parent
6915ada616
commit
b14b72476e
@ -160,7 +160,7 @@ public class SwtAppleCommander implements Listener {
|
||||
String[] extensions = new String[fileFilters.length];
|
||||
for (int i=0; i<fileFilters.length; i++) {
|
||||
names[i] = fileFilters[i].getNames();
|
||||
extensions[i] = fileFilters[i].getExtensions();
|
||||
extensions[i] = makeExtensionCaseInsensitive(fileFilters[i].getExtensions());
|
||||
}
|
||||
fileDialog.setFilterNames(names);
|
||||
fileDialog.setFilterExtensions(extensions);
|
||||
@ -182,6 +182,25 @@ public class SwtAppleCommander implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A quick change to any letter in the glob to be a regex of both the lower-case
|
||||
* and upper-case letters. For example, {@code *.dsk} converts to
|
||||
* {@code *.[dD][sS][kK]}.
|
||||
*/
|
||||
protected String makeExtensionCaseInsensitive(String extension) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (char ch : extension.toCharArray()) {
|
||||
if (Character.isLetter(ch)) {
|
||||
sb.append("[");
|
||||
sb.append(Character.toLowerCase(ch));
|
||||
sb.append(Character.toUpperCase(ch));
|
||||
sb.append("]");
|
||||
} else {
|
||||
sb.append(ch);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the unrecognized disk format message.
|
||||
|
Loading…
Reference in New Issue
Block a user