diff options
author | Dani Megert | 2010-03-26 07:22:17 +0000 |
---|---|---|
committer | Dani Megert | 2010-03-26 07:22:17 +0000 |
commit | 397e74ea11ce4ef97e2c51ab44b5fe81d81aef1a (patch) | |
tree | dfad8d0129ed2eee3af3a7bd45f3a9ded4363bde | |
parent | ad9b204d1b485dcb7c060c8dab8fe2e314d65fa0 (diff) | |
download | eclipse.platform.text-397e74ea11ce4ef97e2c51ab44b5fe81d81aef1a.tar.gz eclipse.platform.text-397e74ea11ce4ef97e2c51ab44b5fe81d81aef1a.tar.xz eclipse.platform.text-397e74ea11ce4ef97e2c51ab44b5fe81d81aef1a.zip |
Better handling of read/write exceptions.
3 files changed, 21 insertions, 17 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java index 0b8021f6f5f..67ebc9f9f90 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java @@ -59,6 +59,9 @@ import org.eclipse.swt.widgets.Widget; import org.eclipse.core.expressions.Expression; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; + import org.eclipse.jface.action.Action; import org.eclipse.jface.action.GroupMarker; import org.eclipse.jface.action.IAction; @@ -1311,9 +1314,9 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I fTableViewer.setCheckedElements(getEnabledTemplates()); } catch (FileNotFoundException e) { - openReadErrorDialog(); + openReadErrorDialog(e); } catch (IOException e) { - openReadErrorDialog(); + openReadErrorDialog(e); } } @@ -1361,7 +1364,7 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I TemplateReaderWriter writer= new TemplateReaderWriter(); writer.save(templates, output); } catch (IOException e) { - openWriteErrorDialog(); + openWriteErrorDialog(e); } finally { if (output != null) { try { @@ -1451,7 +1454,7 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I try { fTemplateStore.save(); } catch (IOException e) { - openWriteErrorDialog(); + openWriteErrorDialog(e); } return super.performOk(); @@ -1473,7 +1476,7 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I try { fTemplateStore.load(); } catch (IOException e) { - openReadErrorDialog(); + openReadErrorDialog(e); return false; } return super.performCancel(); @@ -1482,7 +1485,9 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I /* * @since 3.2 */ - private void openReadErrorDialog() { + private void openReadErrorDialog(IOException ex) { + IStatus status= new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, "Failed to read templates.", ex); //$NON-NLS-1$ + TextEditorPlugin.getDefault().getLog().log(status); String title= TemplatesMessages.TemplatePreferencePage_error_read_title; String message= TemplatesMessages.TemplatePreferencePage_error_read_message; MessageDialog.openError(getShell(), title, message); @@ -1491,7 +1496,9 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I /* * @since 3.2 */ - private void openWriteErrorDialog() { + private void openWriteErrorDialog(IOException ex) { + IStatus status= new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, "Failed to write templates.", ex); //$NON-NLS-1$ + TextEditorPlugin.getDefault().getLog().log(status); String title= TemplatesMessages.TemplatePreferencePage_error_write_title; String message= TemplatesMessages.TemplatePreferencePage_error_write_message; MessageDialog.openError(getShell(), title, message); diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatesMessages.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatesMessages.java index 353af411dff..ed80bffe2b6 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatesMessages.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatesMessages.java @@ -27,8 +27,6 @@ final class TemplatesMessages extends NLS { // Do not instantiate } - public static String TemplatePreferencePage_error_import; - public static String TemplatePreferencePage_error_export; public static String TemplatePreferencePage_error_read_title; public static String TemplatePreferencePage_error_write_title; public static String TemplatePreferencePage_message; @@ -38,6 +36,7 @@ final class TemplatesMessages extends NLS { public static String TemplatePreferencePage_import; public static String TemplatePreferencePage_export; public static String TemplatePreferencePage_remove; + public static String TemplatePreferencePage_editor; public static String TemplatePreferencePage_revert; public static String TemplatePreferencePage_restore; diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatesMessages.properties b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatesMessages.properties index 799a956126c..2c82d4ec1a7 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatesMessages.properties +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatesMessages.properties @@ -11,10 +11,8 @@ ############################################################################### # preference page -TemplatePreferencePage_error_import=Failed to import templates. -TemplatePreferencePage_error_export=Failed to export templates. TemplatePreferencePage_error_read_title=Reading Templates -TemplatePreferencePage_error_write_title=Reading Templates +TemplatePreferencePage_error_write_title=Writing Templates TemplatePreferencePage_message=&Create, edit or remove templates: TemplatePreferencePage_title=Templates @@ -37,24 +35,24 @@ TemplatePreferencePage_on=on TemplatePreferencePage_use_code_formatter=Use code &formatter -TemplatePreferencePage_import_title=Importing Templates +TemplatePreferencePage_import_title=Import Templates TemplatePreferencePage_import_extension=*.xml TemplatePreferencePage_export_title=Export Templates TemplatePreferencePage_export_filename=templates.xml TemplatePreferencePage_export_extension=*.xml -TemplatePreferencePage_export_exists_title= Exporting Templates +TemplatePreferencePage_export_exists_title= Export Templates TemplatePreferencePage_export_exists_message= {0} already exists.\nDo you want to replace it? -TemplatePreferencePage_export_error_title= Exporting Templates +TemplatePreferencePage_export_error_title= Export Templates TemplatePreferencePage_export_error_hidden= Export failed.\n{0} is a hidden file. TemplatePreferencePage_export_error_canNotWrite= Export failed.\n{0} cannot be modified. TemplatePreferencePage_export_error_fileNotFound= Export failed:\n{0} TemplatePreferencePage_error_parse_message= Failed to parse templates:\n{0} -TemplatePreferencePage_error_read_message= Failed to read templates. -TemplatePreferencePage_error_write_message= Failed to write templates. +TemplatePreferencePage_error_read_message= Failed to read templates. See the error log for details. +TemplatePreferencePage_error_write_message= Failed to write templates. See the error log for details. TemplatePreferencePage_question_create_new_title= Edit Template TemplatePreferencePage_question_create_new_message= The name of the template has been changed. Click 'Yes' to create an additional template with the new name or 'No' to rename the existing one. |