Author: dazarov
Date: 2009-06-18 11:42:49 -0400 (Thu, 18 Jun 2009)
New Revision: 16045
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreMessages.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/messages.properties
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/core/SeamCoreMessages.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreMessages.java 2009-06-18
15:01:29 UTC (rev 16044)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreMessages.java 2009-06-18
15:42:49 UTC (rev 16045)
@@ -45,4 +45,7 @@
public static String RENAME_SEAM_COMPONENT_PROCESSOR_THIS_IS_NOT_A_SEAM_COMPONENT;
public static String RENAME_SEAM_CONTEXT_VARIABLE_PROCESSOR_TITLE;
public static String SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR;
+ public static String SEAM_RENAME_PROCESSOR_OUT_OF_SYNC_FILE;
+ public static String SEAM_RENAME_PROCESSOR_ERROR_PHANTOM_FILE;
+ public static String SEAM_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE;
}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/messages.properties
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/messages.properties 2009-06-18
15:01:29 UTC (rev 16044)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/messages.properties 2009-06-18
15:42:49 UTC (rev 16045)
@@ -32,5 +32,8 @@
RENAME_SEAM_COMPONENT_PROCESSOR_TITLE=Rename Seam Component
RENAME_SEAM_COMPONENT_PROCESSOR_THIS_IS_NOT_A_SEAM_COMPONENT=This is not a Seam
Component.
RENAME_SEAM_CONTEXT_VARIABLE_PROCESSOR_TITLE=Rename Seam Context Variable
-SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR=This component has a declaration
which is located in jar file
+SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR=Component
''{0}'' has a declaration which is located in jar file:
''{1}''. Press next to force rename.
+SEAM_RENAME_PROCESSOR_OUT_OF_SYNC_FILE=File ''{0}'' is not in sync. Press
next to force rename.
+SEAM_RENAME_PROCESSOR_ERROR_PHANTOM_FILE=Cannot change phantom file:
''{0}''.
+SEAM_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE=Cannot change read-only file:
''{0}''.
SEAM_INSTALL_WIZARD_PROJECT_NAME_WITH_UPPERCASE=Project names which start with a capital
letter may break Seam/JSF applications; use lower case.
\ No newline at end of file
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:01:29 UTC (rev 16044)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java 2009-06-18
15:42:49 UTC (rev 16045)
@@ -56,10 +56,22 @@
public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
CheckConditionsContext context) throws CoreException,
OperationCanceledException {
- RefactoringStatus status = new RefactoringStatus();
- if(component != null && isJarDeclarations(component))
- status.addWarning(SeamCoreMessages.SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR);
- return status;
+ 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();
+ }
}
/*
@@ -83,9 +95,7 @@
@Override
public Change createChange(IProgressMonitor pm) throws CoreException,
OperationCanceledException {
- rootChange = new
CompositeChange(SeamCoreMessages.RENAME_SEAM_COMPONENT_PROCESSOR_TITLE);
- renameComponent(component);
return rootChange;
}
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:01:29 UTC (rev 16044)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameSeamContextVariableProcessor.java 2009-06-18
15:42:49 UTC (rev 16045)
@@ -14,7 +14,6 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
@@ -26,7 +25,6 @@
import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamFactory;
-import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCoreMessages;
import org.jboss.tools.seam.core.SeamCorePlugin;
@@ -53,11 +51,26 @@
public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
CheckConditionsContext context) throws CoreException,
OperationCanceledException {
- RefactoringStatus status = new RefactoringStatus();
- ISeamComponent component = checkComponent();
- if(component != null && isJarDeclarations(component))
- status.addWarning(SeamCoreMessages.SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR);
- return status;
+ 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();
+ }
}
/*
@@ -79,16 +92,7 @@
public Change createChange(IProgressMonitor pm) throws CoreException,
OperationCanceledException {
- rootChange = new
CompositeChange(SeamCoreMessages.RENAME_SEAM_CONTEXT_VARIABLE_PROCESSOR_TITLE);
- ISeamComponent component = checkComponent();
- if(component != null)
- renameComponent(component);
- else{
- Set<ISeamFactory> factories = checkFactories();
- if(factories != null)
- renameFactories(factories);
- }
return rootChange;
}
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:01:29 UTC (rev 16044)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2009-06-18
15:42:49 UTC (rev 16045)
@@ -22,7 +22,6 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.ui.text.FastJavaPartitionScanner;
@@ -35,6 +34,7 @@
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
+import org.eclipse.ltk.internal.core.refactoring.Messages;
import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEdit;
@@ -321,21 +321,36 @@
}
}
- protected boolean isJarDeclarations(ISeamComponent component) throws CoreException{
+ protected void checkDeclarations(ISeamComponent component, RefactoringStatus status)
throws CoreException{
if(component.getJavaDeclaration() != null){
if(coreHelper.isJar(component.getJavaDeclaration()))
- return true;
+ status.addInfo(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR,
new String[]{component.getName(),
component.getJavaDeclaration().getResource().getFullPath().toString()}));
}
Set<ISeamXmlComponentDeclaration> xmlDecls = component.getXmlDeclarations();
for(ISeamXmlComponentDeclaration xmlDecl : xmlDecls){
if(coreHelper.isJar(xmlDecl))
- return true;
+ status.addInfo(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR,
new String[]{component.getName(), xmlDecl.getResource().getFullPath().toString()}));
}
- return false;
}
+ 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())
+ status.addFatalError(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_ERROR_PHANTOM_FILE,
file.getFullPath().toString()));
+ else if(file.isReadOnly())
+ status.addFatalError(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE,
file.getFullPath().toString()));
+
+ }
+ }
+
private void renameJavaDeclaration(ISeamJavaComponentDeclaration javaDecl) throws
CoreException{
IFile file = (IFile)javaDecl.getResource();