|
Lines 109-135
Link Here
|
| 109 |
|
109 |
|
| 110 |
super.dispose(); |
110 |
super.dispose(); |
| 111 |
} |
111 |
} |
| 112 |
|
|
|
| 113 |
/* |
| 114 |
* @see AbstractTextEditor#doSaveAs() |
| 115 |
* @since 2.1 |
| 116 |
*/ |
| 117 |
public void doSaveAs() { |
| 118 |
if (askIfNonWorkbenchEncodingIsOk()) |
| 119 |
super.doSaveAs(); |
| 120 |
} |
| 121 |
|
112 |
|
| 122 |
/* |
|
|
| 123 |
* @see AbstractTextEditor#doSave(IProgressMonitor) |
| 124 |
* @since 2.1 |
| 125 |
*/ |
| 126 |
public void doSave(IProgressMonitor monitor){ |
| 127 |
if (askIfNonWorkbenchEncodingIsOk()) |
| 128 |
super.doSave(monitor); |
| 129 |
else |
| 130 |
monitor.setCanceled(true); |
| 131 |
} |
| 132 |
|
| 133 |
/** |
113 |
/** |
| 134 |
* Installs the encoding support on the given text editor. |
114 |
* Installs the encoding support on the given text editor. |
| 135 |
* <p> |
115 |
* <p> |
|
Lines 141-177
Link Here
|
| 141 |
protected void installEncodingSupport() { |
121 |
protected void installEncodingSupport() { |
| 142 |
fEncodingSupport= new DefaultEncodingSupport(); |
122 |
fEncodingSupport= new DefaultEncodingSupport(); |
| 143 |
fEncodingSupport.initialize(this); |
123 |
fEncodingSupport.initialize(this); |
| 144 |
} |
|
|
| 145 |
|
| 146 |
/** |
| 147 |
* Asks the user if it is ok to store in non-workbench encoding. |
| 148 |
* |
| 149 |
* @return <true> if the user wants to continue or if no encoding support has been installed |
| 150 |
* @since 2.1 |
| 151 |
*/ |
| 152 |
private boolean askIfNonWorkbenchEncodingIsOk() { |
| 153 |
|
| 154 |
if (fEncodingSupport == null) |
| 155 |
return true; |
| 156 |
|
| 157 |
IDocumentProvider provider= getDocumentProvider(); |
| 158 |
if (provider instanceof IStorageDocumentProvider) { |
| 159 |
IEditorInput input= getEditorInput(); |
| 160 |
IStorageDocumentProvider storageProvider= (IStorageDocumentProvider)provider; |
| 161 |
String encoding= storageProvider.getEncoding(input); |
| 162 |
String defaultEncoding= storageProvider.getDefaultEncoding(); |
| 163 |
if (encoding != null && !encoding.equals(defaultEncoding)) { |
| 164 |
Shell shell= getSite().getShell(); |
| 165 |
String title= TextEditorMessages.getString("Editor.warning.save.nonWorkbenchEncoding.title"); //$NON-NLS-1$ |
| 166 |
String msg; |
| 167 |
if (input != null) |
| 168 |
msg= MessageFormat.format(TextEditorMessages.getString("Editor.warning.save.nonWorkbenchEncoding.message1"), new String[] {input.getName(), encoding});//$NON-NLS-1$ |
| 169 |
else |
| 170 |
msg= MessageFormat.format(TextEditorMessages.getString("Editor.warning.save.nonWorkbenchEncoding.message2"), new String[] {encoding});//$NON-NLS-1$ |
| 171 |
return MessageDialog.openQuestion(shell, title, msg); |
| 172 |
} |
| 173 |
} |
| 174 |
return true; |
| 175 |
} |
124 |
} |
| 176 |
|
125 |
|
| 177 |
/** |
126 |
/** |