Author: dazarov
Date: 2009-06-18 12:11:32 -0400 (Thu, 18 Jun 2009)
New Revision: 16049
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameSeamContextVariableProcessor.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4406
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java 2009-06-18
15:48:30 UTC (rev 16048)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java 2009-06-18
16:11:32 UTC (rev 16049)
@@ -56,22 +56,15 @@
public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
CheckConditionsContext context) throws CoreException,
OperationCanceledException {
- pm.beginTask("", 1); //$NON-NLS-1$
- try {
- RefactoringStatus status = new RefactoringStatus();
- if(component != null){
- checkDeclarations(component, status);
-
- rootChange = new
CompositeChange(SeamCoreMessages.RENAME_SEAM_COMPONENT_PROCESSOR_TITLE);
-
- renameComponent(component);
-
- checkResources(status);
- }
- return status;
- } finally {
- pm.done();
+ status = new RefactoringStatus();
+ if(component != null){
+ checkDeclarations(component);
+
+ rootChange = new
CompositeChange(SeamCoreMessages.RENAME_SEAM_COMPONENT_PROCESSOR_TITLE);
+
+ renameComponent(pm, component);
}
+ return status;
}
/*
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameSeamContextVariableProcessor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameSeamContextVariableProcessor.java 2009-06-18
15:48:30 UTC (rev 16048)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameSeamContextVariableProcessor.java 2009-06-18
16:11:32 UTC (rev 16049)
@@ -51,26 +51,20 @@
public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
CheckConditionsContext context) throws CoreException,
OperationCanceledException {
- pm.beginTask("", 1); //$NON-NLS-1$
- try {
- RefactoringStatus status = new RefactoringStatus();
- ISeamComponent component = checkComponent();
- if(component != null){
- checkDeclarations(component, status);
-
- rootChange = new
CompositeChange(SeamCoreMessages.RENAME_SEAM_CONTEXT_VARIABLE_PROCESSOR_TITLE);
-
- renameComponent(component);
- }else{
- Set<ISeamFactory> factories = checkFactories();
- if(factories != null)
- renameFactories(factories);
- }
- checkResources(status);
- return status;
- } finally {
- pm.done();
+ status = new RefactoringStatus();
+ ISeamComponent component = checkComponent();
+ if(component != null){
+ checkDeclarations(component);
+
+ rootChange = new
CompositeChange(SeamCoreMessages.RENAME_SEAM_CONTEXT_VARIABLE_PROCESSOR_TITLE);
+
+ renameComponent(pm, component);
+ }else{
+ Set<ISeamFactory> factories = checkFactories();
+ if(factories != null)
+ renameFactories(pm, factories);
}
+ return status;
}
/*
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2009-06-18
15:48:30 UTC (rev 16048)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2009-06-18
16:11:32 UTC (rev 16049)
@@ -22,6 +22,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.ui.text.FastJavaPartitionScanner;
@@ -85,6 +86,8 @@
protected static final String SEAM_PROPERTIES_FILE = "seam.properties";
//$NON-NLS-1$
+ protected RefactoringStatus status;
+
private SeamContextValidationHelper coreHelper = new SeamContextValidationHelper();
protected CompositeChange rootChange;
@@ -229,6 +232,9 @@
if(isBadLocation(location))
return;
+ if(!isFileCorrect(file))
+ return;
+
String content = null;
try {
content = FileUtil.readStream(file.getContents());
@@ -257,6 +263,9 @@
private void changeAnnotation(ITextSourceReference location, IFile file){
if(isBadLocation(location))
return;
+
+ if(!isFileCorrect(file))
+ return;
String content = null;
try {
@@ -321,7 +330,7 @@
}
}
- protected void checkDeclarations(ISeamComponent component, RefactoringStatus status)
throws CoreException{
+ protected void checkDeclarations(ISeamComponent component) throws CoreException{
if(component.getJavaDeclaration() != null){
if(coreHelper.isJar(component.getJavaDeclaration()))
status.addInfo(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR,
new String[]{component.getName(),
component.getJavaDeclaration().getResource().getFullPath().toString()}));
@@ -335,20 +344,18 @@
}
}
- protected void checkResources(RefactoringStatus status){
- for(int i=0; i < rootChange.getChildren().length; i++){
- TextFileChange change = (TextFileChange)rootChange.getChildren()[i];
- IFile file = change.getFile();
-
- if(!file.isSynchronized(IResource.DEPTH_ZERO))
- status.addInfo(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_OUT_OF_SYNC_FILE,
file.getFullPath().toString()));
-
- if(file.isPhantom())
+ protected boolean isFileCorrect(IFile file){
+ if(!file.isSynchronized(IResource.DEPTH_ZERO)){
+ status.addFatalError(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_OUT_OF_SYNC_FILE,
file.getFullPath().toString()));
+ return false;
+ }else if(file.isPhantom()){
status.addFatalError(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_ERROR_PHANTOM_FILE,
file.getFullPath().toString()));
- else if(file.isReadOnly())
+ return false;
+ }else if(file.isReadOnly()){
status.addFatalError(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE,
file.getFullPath().toString()));
-
- }
+ return false;
+ }
+ return true;
}
private void renameJavaDeclaration(ISeamJavaComponentDeclaration javaDecl) throws
CoreException{
@@ -476,6 +483,10 @@
private void scanForJava(IFile file){
String ext = file.getFileExtension();
+
+ if(!isFileCorrect(file))
+ return;
+
String content = null;
try {
content = FileUtil.readStream(file.getContents());
@@ -493,6 +504,10 @@
private void scan(IFile file){
String ext = file.getFileExtension();
+
+ if(!isFileCorrect(file))
+ return;
+
String content = null;
try {
content = FileUtil.readStream(file.getContents());
@@ -654,19 +669,31 @@
}
}
- protected void renameComponent(ISeamComponent component)throws CoreException{
+ protected void renameComponent(IProgressMonitor pm, ISeamComponent component)throws
CoreException{
+ pm.beginTask("", 3);
findDeclarations(component);
+ pm.worked(1);
+
findAnnotations();
+ pm.worked(1);
+
findELReferences();
+
+ pm.done();
}
- protected void renameFactories(Set<ISeamFactory> factories){
+ protected void renameFactories(IProgressMonitor pm, Set<ISeamFactory> factories){
+ pm.beginTask("", factories.size()+1);
+
for(ISeamFactory factory : factories){
changeFactory(factory, true);
+ pm.worked(1);
}
findELReferences();
+
+ pm.done();
}
}