Browse Source

ResourceToolkit: Show a message instead of an exception when a resource file cannot be read or written when deleting or renaming keys.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3777 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Christian Hornung 17 years ago
parent
commit
e0791cefb3
  1. BIN
      data/resources/StringResources.de.resources
  2. BIN
      data/resources/StringResources.es-mx.resources
  3. BIN
      data/resources/StringResources.es.resources
  4. BIN
      data/resources/StringResources.nl.resources
  5. BIN
      data/resources/StringResources.no.resources
  6. BIN
      data/resources/StringResources.pt.resources
  7. BIN
      data/resources/StringResources.se.resources
  8. 31
      src/AddIns/Misc/ResourceToolkit/Project/Src/Gui/UnusedResourceKeysViewContent.cs
  9. 37
      src/AddIns/Misc/ResourceToolkit/Project/Src/Refactoring/ResourceRefactoringService.cs
  10. BIN
      src/Main/StartUp/Project/Resources/StringResources.resources

BIN
data/resources/StringResources.de.resources

Binary file not shown.

BIN
data/resources/StringResources.es-mx.resources

Binary file not shown.

BIN
data/resources/StringResources.es.resources

Binary file not shown.

BIN
data/resources/StringResources.nl.resources

Binary file not shown.

BIN
data/resources/StringResources.no.resources

Binary file not shown.

BIN
data/resources/StringResources.pt.resources

Binary file not shown.

BIN
data/resources/StringResources.se.resources

Binary file not shown.

31
src/AddIns/Misc/ResourceToolkit/Project/Src/Gui/UnusedResourceKeysViewContent.cs

@ -389,23 +389,32 @@ namespace Hornung.ResourceToolkit.Gui @@ -389,23 +389,32 @@ namespace Hornung.ResourceToolkit.Gui
/// <param name="key">The key to be deleted.</param>
protected static void DeleteResourceKey(string fileName, string key)
{
IResourceFileContent content = ResourceFileContentRegistry.GetResourceFileContent(fileName);
if (content != null) {
if (content.ContainsKey(key)) {
LoggingService.Debug("ResourceToolkit: Remove key '"+key+"' from resource file '"+fileName+"'");
content.RemoveKey(key);
try {
IResourceFileContent content = ResourceFileContentRegistry.GetResourceFileContent(fileName);
if (content != null) {
if (content.ContainsKey(key)) {
LoggingService.Debug("ResourceToolkit: Remove key '"+key+"' from resource file '"+fileName+"'");
content.RemoveKey(key);
} else {
MessageService.ShowWarningFormatted("${res:Hornung.ResourceToolkit.KeyNotFoundWarning}", key, fileName);
}
} else {
MessageService.ShowWarningFormatted("${res:Hornung.ResourceToolkit.KeyNotFoundWarning}", key, fileName);
MessageService.ShowWarning("ResoureToolkit: Could not get ResourceFileContent for '"+fileName+"' key +'"+key+"'.");
}
} else {
MessageService.ShowWarning("ResoureToolkit: Could not get ResourceFileContent for '"+fileName+"' key +'"+key+"'.");
} catch (Exception ex) {
MessageService.ShowWarningFormatted("${res:Hornung.ResourceToolkit.ErrorProcessingResourceFile}" + Environment.NewLine + ex.Message, fileName);
return;
}
foreach (KeyValuePair<string, IResourceFileContent> entry in ResourceFileContentRegistry.GetLocalizedContents(fileName)) {
LoggingService.Debug("ResourceToolkit: Looking in localized resource file: '"+entry.Value.FileName+"'");
if (entry.Value.ContainsKey(key)) {
LoggingService.Debug("ResourceToolkit: -> Key found, removing.");
entry.Value.RemoveKey(key);
try {
if (entry.Value.ContainsKey(key)) {
LoggingService.Debug("ResourceToolkit: -> Key found, removing.");
entry.Value.RemoveKey(key);
}
} catch (Exception ex) {
MessageService.ShowWarningFormatted("${res:Hornung.ResourceToolkit.ErrorProcessingResourceFile}" + Environment.NewLine + ex.Message, entry.Value.FileName);
}
}
}

37
src/AddIns/Misc/ResourceToolkit/Project/Src/Refactoring/ResourceRefactoringService.cs

@ -308,23 +308,38 @@ namespace Hornung.ResourceToolkit.Refactoring @@ -308,23 +308,38 @@ namespace Hornung.ResourceToolkit.Refactoring
monitor.BeginTask(null, 0, false);
}
// rename references
// FIXME: RenameReferences does not enforce escaping rules. May be a problem if someone uses double-quotes in the new resource key name.
FindReferencesAndRenameHelper.RenameReferences(references, newKey);
// rename definition (if present)
if (rrr.ResourceFileContent.ContainsKey(rrr.Key)) {
rrr.ResourceFileContent.RenameKey(rrr.Key, newKey);
} else {
try {
// rename definition (if present)
if (rrr.ResourceFileContent.ContainsKey(rrr.Key)) {
rrr.ResourceFileContent.RenameKey(rrr.Key, newKey);
} else {
if (monitor != null) monitor.ShowingDialog = true;
MessageService.ShowWarning("${res:Hornung.ResourceToolkit.RenameKeyDefinitionNotFoundWarning}");
if (monitor != null) monitor.ShowingDialog = false;
}
} catch (Exception ex) {
if (monitor != null) monitor.ShowingDialog = true;
MessageService.ShowWarning("${res:Hornung.ResourceToolkit.RenameKeyDefinitionNotFoundWarning}");
MessageService.ShowWarningFormatted("${res:Hornung.ResourceToolkit.ErrorProcessingResourceFile}" + Environment.NewLine + ex.Message, rrr.ResourceFileContent.FileName);
if (monitor != null) monitor.ShowingDialog = false;
if (monitor != null) monitor.Done();
// Do not rename the references when renaming the definition failed.
return;
}
// rename references
// FIXME: RenameReferences does not enforce escaping rules. May be a problem if someone uses double-quotes in the new resource key name.
FindReferencesAndRenameHelper.RenameReferences(references, newKey);
// rename definitions in localized resource files
foreach (KeyValuePair<string, IResourceFileContent> entry in ResourceFileContentRegistry.GetLocalizedContents(rrr.FileName)) {
if (entry.Value.ContainsKey(rrr.Key)) {
entry.Value.RenameKey(rrr.Key, newKey);
try {
if (entry.Value.ContainsKey(rrr.Key)) {
entry.Value.RenameKey(rrr.Key, newKey);
}
} catch (Exception ex) {
if (monitor != null) monitor.ShowingDialog = true;
MessageService.ShowWarningFormatted("${res:Hornung.ResourceToolkit.ErrorProcessingResourceFile}" + Environment.NewLine + ex.Message, entry.Value.FileName);
if (monitor != null) monitor.ShowingDialog = false;
}
}

BIN
src/Main/StartUp/Project/Resources/StringResources.resources

Binary file not shown.
Loading…
Cancel
Save