Author: dgeraskov
Date: 2008-04-07 07:37:37 -0400 (Mon, 07 Apr 2008)
New Revision: 7377
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/SaveQueryEditorListener.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2008
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/SaveQueryEditorListener.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/SaveQueryEditorListener.java 2008-04-07
10:27:11 UTC (rev 7376)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/SaveQueryEditorListener.java 2008-04-07
11:37:37 UTC (rev 7377)
@@ -35,7 +35,7 @@
*/
public class SaveQueryEditorListener implements IPropertyListener {
- public static final String id = "AbstractQueryEditor.ReplaceString";
+ public static final String id =
"AbstractQueryEditor.ReplaceString"; //$NON-NLS-1$
public static final int HQLEditor = 0;
@@ -95,6 +95,24 @@
String editorTitle = fromEditorPart.getTitle();
if (IEditorPart.PROP_DIRTY == propId && !editor.isDirty()){
+ IDocumentProvider docProvider = fromEditorPart.getDocumentProvider();
+
+ IDocument doc = docProvider.getDocument( fromEditorPart.getEditorInput() );
+ boolean isDocChanged = true;
+ try {
+ if (query.equals(doc.get(position.x, position.y))){
+ isDocChanged = false;
+ }
+ } catch (BadLocationException e1) {
+ //document changed and we can get the exception
+ }
+
+ if (isDocChanged){
+ String confirm_changed =
NLS.bind(JdtUIMessages.SaveQueryEditorListener_replaceQuestion_confirm, query,
editorTitle);
+ MessageDialog.openConfirm( null,
JdtUIMessages.SaveQueryEditorListener_replaceTitle_confirm, confirm_changed);
+ return;
+ }
+
String newQuery = editor.getQueryString();
String question = NLS.bind(JdtUIMessages.SaveQueryEditorListener_replaceQuestion, new
String[]{query, editorTitle, newQuery});
@@ -112,25 +130,7 @@
if (Window.CANCEL == ans){
return;
}
-
- IDocumentProvider docProvider = fromEditorPart.getDocumentProvider();
-
- IDocument doc = docProvider.getDocument( fromEditorPart.getEditorInput() );
- boolean isDocChanged = true;
- try {
- if (query.equals(doc.get(position.x, position.y))){
- isDocChanged = false;
- }
- } catch (BadLocationException e1) {
- //document changed and we can get the exception
- }
- if (isDocChanged){
- String confirm_changed =
NLS.bind(JdtUIMessages.SaveQueryEditorListener_replaceQuestion_confirm, query,
editorTitle);
- MessageDialog.openConfirm( null,
JdtUIMessages.SaveQueryEditorListener_replaceTitle_confirm, confirm_changed);
- return;
- }
-
try {
// replace old string with new one and change positions
doc.replace(position.x, position.y, newQuery);