Author: dazarov
Date: 2009-06-22 09:03:23 -0400 (Mon, 22 Jun 2009)
New Revision: 16111
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameSeamContextVariableProcessor.java
Log:
Rename Seam Context Variable
https://jira.jboss.org/jira/browse/JBIDE-1077
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-22
08:28:57 UTC (rev 16110)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameSeamContextVariableProcessor.java 2009-06-22
13:03:23 UTC (rev 16111)
@@ -24,6 +24,8 @@
import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
import org.jboss.tools.seam.core.ISeamComponent;
+import org.jboss.tools.seam.core.ISeamContextShortVariable;
+import org.jboss.tools.seam.core.ISeamContextVariable;
import org.jboss.tools.seam.core.ISeamFactory;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCoreMessages;
@@ -91,23 +93,35 @@
return rootChange;
}
+ private boolean checked = false;
+
+ public String getOldName(){
+ if(!checked){
+ ISeamComponent component = checkComponent();
+ if(component != null){
+ setOldName(component.getName());
+ }
+ checked = true;
+ }
+ return super.getOldName();
+ }
+
private ISeamComponent checkComponent(){
IProject project = file.getProject();
ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, true);
if (seamProject != null) {
- return seamProject.getComponent(getOldName());
-// Set<ISeamComponent> components =
seamProject.getComponentsByPath(file.getFullPath());
-// for(ISeamComponent component : components){
-// ISeamJavaComponentDeclaration declaration = component.getJavaDeclaration();
-// if(declaration != null){
-// IResource resource = declaration.getResource();
-// if(resource != null &&
resource.getFullPath().equals(file.getFullPath())){
-// if(declaration.getName().equals(component.getName())){
-// return component;
-// }
-// }
-// }
-// }
+ ISeamComponent component = seamProject.getComponent(super.getOldName());
+ if(component != null)
+ return component;
+
+ Set<ISeamContextVariable> variables =
seamProject.getVariablesByName(super.getOldName());
+ for(ISeamContextVariable variable : variables){
+ if(variable instanceof ISeamContextShortVariable){
+ ISeamContextVariable original =
((ISeamContextShortVariable)variable).getOriginal();
+ if(original instanceof ISeamComponent)
+ return (ISeamComponent)original;
+ }
+ }
}
return null;
}