mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
WEB-34093 JSON Schema: improve the status for not yet downloaded schemas
+ fix rewriting urls when file extension is already provided
This commit is contained in:
@@ -40,7 +40,8 @@ public class JsonFileResolver {
|
||||
return JsonSchemaCatalogManager.DEFAULT_CATALOG_HTTPS;
|
||||
}
|
||||
if (StringUtil.startsWithIgnoreCase(urlString, JsonSchemaRemoteContentProvider.STORE_URL_PREFIX_HTTP)) {
|
||||
return StringUtil.replace(urlString, "http://json.schemastore.org/", "https://schemastore.azurewebsites.net/schemas/json/") + ".json";
|
||||
String newUrl = StringUtil.replace(urlString, "http://json.schemastore.org/", "https://schemastore.azurewebsites.net/schemas/json/");
|
||||
return newUrl.endsWith(".json") ? newUrl : newUrl + ".json";
|
||||
}
|
||||
return urlString;
|
||||
}
|
||||
|
||||
@@ -126,23 +126,10 @@ class JsonSchemaStatusWidget extends EditorBasedStatusBarPopup {
|
||||
//noinspection EnumSwitchStatementWhichMissesCases
|
||||
switch (info.getState()) {
|
||||
case DOWNLOADING_NOT_STARTED:
|
||||
addDownloadingUpdateListener(info);
|
||||
return getNoSchemaState();
|
||||
case DOWNLOADING_IN_PROGRESS:
|
||||
info.addDownloadingListener(new FileDownloadingAdapter() {
|
||||
@Override
|
||||
public void fileDownloaded(VirtualFile localFile) {
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void errorOccurred(@NotNull String errorMessage) {
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadingCancelled() {
|
||||
update();
|
||||
}
|
||||
});
|
||||
addDownloadingUpdateListener(info);
|
||||
return new MyWidgetState("Download is scheduled or in progress", "Downloading JSON schema", false);
|
||||
case ERROR_OCCURRED:
|
||||
return getDownloadErrorState(info.getErrorMessage());
|
||||
@@ -171,6 +158,25 @@ class JsonSchemaStatusWidget extends EditorBasedStatusBarPopup {
|
||||
true);
|
||||
}
|
||||
|
||||
private void addDownloadingUpdateListener(@NotNull RemoteFileInfo info) {
|
||||
info.addDownloadingListener(new FileDownloadingAdapter() {
|
||||
@Override
|
||||
public void fileDownloaded(VirtualFile localFile) {
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void errorOccurred(@NotNull String errorMessage) {
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadingCancelled() {
|
||||
update();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isValidSchemaFile(VirtualFile schemaFile) {
|
||||
if (schemaFile == null || !myService.isApplicableToFile(schemaFile) || !myService.isSchemaFile(schemaFile)) return false;
|
||||
FileType type = schemaFile.getFileType();
|
||||
|
||||
Reference in New Issue
Block a user