[jbosstools-commits] JBoss Tools SVN: r17690 - in trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process: wizard and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue Sep 22 06:30:59 EDT 2009


Author: vyemialyanchyk
Date: 2009-09-22 06:30:58 -0400 (Tue, 22 Sep 2009)
New Revision: 17690

Modified:
   trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AllEntitiesProcessor.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/ChangeStructure.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/EntitiesList.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/HibernateJPARefactoring.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/HibernateJPAWizard.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4901 - fixed - the solution was to use TextFileChange instead of DocumentChange


Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AllEntitiesProcessor.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AllEntitiesProcessor.java	2009-09-22 08:12:08 UTC (rev 17689)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AllEntitiesProcessor.java	2009-09-22 10:30:58 UTC (rev 17690)
@@ -26,8 +26,8 @@
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
 import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.UndoEdit;
 import org.hibernate.eclipse.console.HibernateConsolePlugin;
 import org.hibernate.eclipse.jdt.ui.Activator;
 import org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo;
@@ -150,8 +150,8 @@
 		setJavaProject(project);
 		// get the buffer manager
 		ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
-		Iterator<Map.Entry<String, EntityInfo>> it = entities.entrySet().iterator();
-		/*String outText = ""; //$NON-NLS-1$
+		/*Iterator<Map.Entry<String, EntityInfo>> it = entities.entrySet().iterator();
+		String outText = ""; //$NON-NLS-1$
 		String ls = System.getProperties().getProperty("line.separator", "\n");  //$NON-NLS-1$//$NON-NLS-2$
 		while (it.hasNext()) {
 			Map.Entry<String, EntityInfo> entry = it.next();
@@ -237,10 +237,10 @@
 		for (int i = 0; i < changes.size(); i++) {
 			ChangeStructure cs = changes.get(i);
 			try {
-				if (cs.textFileBuffer != null && cs.document != null && cs.textEdit != null &&
+				if (cs.textFileBuffer != null && cs.textEdit != null &&
 					((cs.change != null && cs.change.isEnabled()) || (cs.change == null))) {
-					cs.document = cs.textFileBuffer.getDocument();
-					UndoEdit undo = cs.textEdit.apply(cs.document);
+					IDocument document = cs.textFileBuffer.getDocument();
+					cs.textEdit.apply(document);
 					// commit changes to underlying file
 					cs.textFileBuffer.commit(null, true);
 				}
@@ -288,7 +288,7 @@
 			bufferManager.connect(cs.path, LocationKind.IFILE, null);
 			cs.textFileBuffer = bufferManager.getTextFileBuffer(cs.path, LocationKind.IFILE);
 			// retrieve the buffer
-			cs.document = cs.textFileBuffer.getDocument();
+			cs.icu = icu;
 			AST ast = cu.getAST();
 			ASTRewrite rewriter = ASTRewrite.create(ast);
 			// ... rewrite
@@ -300,8 +300,9 @@
 			processor.setEntities(entities);
 			processor.setASTRewrite(rewriter);
 			cu.accept(processor);
-			//
-			cs.textEdit = rewriter.rewriteAST(cs.document, JavaCore.getOptions());
+			////
+			IDocument documentChange = cs.textFileBuffer.getDocument();
+			cs.textEdit = rewriter.rewriteAST(documentChange, JavaCore.getOptions());
 			// add change to array of changes
 			changes.add(cs);
 		} catch (JavaModelException e) {

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/ChangeStructure.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/ChangeStructure.java	2009-09-22 08:12:08 UTC (rev 17689)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/ChangeStructure.java	2009-09-22 10:30:58 UTC (rev 17690)
@@ -2,7 +2,7 @@
 
 import org.eclipse.core.filebuffers.ITextFileBuffer;
 import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.text.IDocument;
+import org.eclipse.jdt.core.ICompilationUnit;
 import org.eclipse.ltk.core.refactoring.Change;
 import org.eclipse.text.edits.TextEdit;
 
@@ -12,7 +12,7 @@
 public class ChangeStructure {
 	public String fullyQualifiedName;
 	public IPath path;
-	public IDocument document;
+	public ICompilationUnit icu;
 	public TextEdit textEdit;
 	public ITextFileBuffer textFileBuffer;
 	public Change change;

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/EntitiesList.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/EntitiesList.java	2009-09-22 08:12:08 UTC (rev 17689)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/EntitiesList.java	2009-09-22 10:30:58 UTC (rev 17690)
@@ -41,6 +41,7 @@
  *
  * @author Vitali
  */
+ at SuppressWarnings("restriction")
 public class EntitiesList extends UserInputWizardPage {
 	
 	protected IHibernateJPAWizardData data;

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/HibernateJPARefactoring.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/HibernateJPARefactoring.java	2009-09-22 08:12:08 UTC (rev 17689)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/HibernateJPARefactoring.java	2009-09-22 10:30:58 UTC (rev 17690)
@@ -12,13 +12,14 @@
 
 import java.util.ArrayList;
 
+import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.ltk.core.refactoring.Change;
 import org.eclipse.ltk.core.refactoring.CompositeChange;
-import org.eclipse.ltk.core.refactoring.DocumentChange;
 import org.eclipse.ltk.core.refactoring.Refactoring;
 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
 import org.hibernate.eclipse.jdt.ui.internal.JdtUiMessages;
 import org.hibernate.eclipse.jdt.ui.internal.jpa.process.ChangeStructure;
 
@@ -55,7 +56,8 @@
 		for (int i = 0; i < changes.size(); i++) {
 			ChangeStructure cs = changes.get(i);
 			String change_name = cs.fullyQualifiedName;
-			DocumentChange change = new DocumentChange(change_name, cs.document);
+			TextFileChange change = new TextFileChange(change_name, (IFile)cs.icu.getResource());
+			change.setSaveMode(TextFileChange.FORCE_SAVE);
 			change.setEdit(cs.textEdit);
 			cs.change = change;
 			cc.add(change);

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/HibernateJPAWizard.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/HibernateJPAWizard.java	2009-09-22 08:12:08 UTC (rev 17689)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/HibernateJPAWizard.java	2009-09-22 10:30:58 UTC (rev 17690)
@@ -12,9 +12,9 @@
 
 import org.eclipse.jdt.ui.refactoring.RefactoringSaveHelper;
 import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
 import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
 import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
+import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
 import org.hibernate.eclipse.jdt.ui.internal.JdtUiMessages;
@@ -24,6 +24,7 @@
  *
  * @author Vitali
  */
+ at SuppressWarnings("restriction")
 public class HibernateJPAWizard extends RefactoringWizard {
 
 	protected final String wizard_title = JdtUiMessages.AllEntitiesProcessor_header;
@@ -55,10 +56,11 @@
 	}
 
 	public boolean showWizard() {
-		IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-		RefactoringStarter refactoringStarter = new RefactoringStarter();
-		boolean res = refactoringStarter.activate(this, win.getShell(), wizard_title, RefactoringSaveHelper.SAVE_ALL);
-		RefactoringStatus rs = refactoringStarter.getInitialConditionCheckingStatus();
+		final IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+		final Shell shell = win.getShell();
+		final RefactoringStarter refactoringStarter = new RefactoringStarter();
+		boolean res = refactoringStarter.activate(this, shell, wizard_title, RefactoringSaveHelper.SAVE_ALL);
+		//RefactoringStatus rs = refactoringStarter.getInitialConditionCheckingStatus();
 		return res;
 	}
 



More information about the jbosstools-commits mailing list