mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
allow passing resource class and correct relative path to xml resource
This commit is contained in:
+12
-4
@@ -36,14 +36,14 @@ public class DecodeDefaultsUtil {
|
||||
public static URL getDefaults(Object requestor, @NotNull String componentResourcePath) {
|
||||
URL url = RESOURCE_CACHE.get(componentResourcePath);
|
||||
if (url == null) {
|
||||
Class<?> requestorClass = requestor.getClass();
|
||||
Class<?> requestorClass = requestor instanceof Class ? (Class<?>)requestor : requestor.getClass();
|
||||
if (StringUtil.startsWithChar(componentResourcePath, '/')) {
|
||||
url = requestorClass.getResource(componentResourcePath + FileStorageCoreUtil.DEFAULT_EXT);
|
||||
url = requestorClass.getResource(appendExt(componentResourcePath));
|
||||
}
|
||||
else {
|
||||
url = requestorClass.getResource('/' + ApplicationManagerEx.getApplicationEx().getName() + '/' + componentResourcePath + FileStorageCoreUtil.DEFAULT_EXT);
|
||||
url = requestorClass.getResource(appendExt('/' + ApplicationManagerEx.getApplicationEx().getName() + '/' + componentResourcePath));
|
||||
if (url == null) {
|
||||
url = requestorClass.getResource('/' + componentResourcePath + FileStorageCoreUtil.DEFAULT_EXT);
|
||||
url = requestorClass.getResource(appendExt('/' + componentResourcePath));
|
||||
}
|
||||
}
|
||||
RESOURCE_CACHE.put(componentResourcePath, url);
|
||||
@@ -51,6 +51,14 @@ public class DecodeDefaultsUtil {
|
||||
return url;
|
||||
}
|
||||
|
||||
private static String appendExt(@NotNull String s) {
|
||||
return appendIfNeeded(s, FileStorageCoreUtil.DEFAULT_EXT);
|
||||
}
|
||||
|
||||
private static String appendIfNeeded(@NotNull String head, @NotNull String tail) {
|
||||
return head.endsWith(tail) ? head : head + tail;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static InputStream getDefaultsInputStream(Object requestor, @NotNull String componentResourcePath) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user