Author: dazarov
Date: 2009-06-05 09:25:00 -0400 (Fri, 05 Jun 2009)
New Revision: 15730
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/SeamRenameProcessor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/RenameComponentWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/RenameSeamContextVariableWizard.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-05
12:33:49 UTC (rev 15729)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameSeamContextVariableProcessor.java 2009-06-05
13:25:00 UTC (rev 15730)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
+ * Copyright (c) 2009 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -25,6 +25,7 @@
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.ISeamFactory;
import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCoreMessages;
@@ -34,13 +35,13 @@
* @author Daniel Azarov
*/
public class RenameSeamContextVariableProcessor extends SeamRenameProcessor {
-
+ IFile file;
/**
* @param component Renamed component
*/
public RenameSeamContextVariableProcessor(IFile file, String oldName) {
super();
- declarationFile = file;
+ this.file = file;
setOldName(oldName);
}
@@ -81,30 +82,45 @@
ISeamComponent component = checkComponent();
if(component != null)
renameComponent(component);
+ else{
+ Set<ISeamFactory> factories = checkFactories();
+ if(factories != null)
+ renameFactories(factories);
+ }
return rootChange;
}
private ISeamComponent checkComponent(){
- IProject project = declarationFile.getProject();
+ IProject project = file.getProject();
ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, true);
if (seamProject != null) {
- Set<ISeamComponent> components =
seamProject.getComponentsByPath(declarationFile.getFullPath());
- for(ISeamComponent component : components){
- ISeamJavaComponentDeclaration declaration = component.getJavaDeclaration();
- if(declaration != null){
- IResource resource = declaration.getResource();
- if(resource != null &&
resource.getFullPath().equals(declarationFile.getFullPath())){
- if(declaration.getName().equals(component.getName())){
- return component;
- }
- }
- }
- }
+ 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;
+// }
+// }
+// }
+// }
}
return null;
}
+ private Set<ISeamFactory> checkFactories(){
+ IProject project = file.getProject();
+ ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, true);
+ if (seamProject != null) {
+ return seamProject.getFactoriesByName(getOldName());
+ }
+ return null;
+ }
+
/*
* (non-Javadoc)
* @see
org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getElements()
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-05
12:33:49 UTC (rev 15729)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2009-06-05
13:25:00 UTC (rev 15730)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.seam.internal.core.refactoring;
import java.io.IOException;
@@ -57,6 +67,9 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+/**
+ * @author Daniel Azarov
+ */
public abstract class SeamRenameProcessor extends RenameProcessor {
protected static final String JAVA_EXT = "java"; //$NON-NLS-1$
protected static final String XML_EXT = "xml"; //$NON-NLS-1$
@@ -171,26 +184,30 @@
Set<ISeamFactory> factorySet = seamProject.getFactoriesByName(getOldName());
for(ISeamFactory factory : factorySet){
- IFile file = (IFile)factory.getResource();
- if(file.getFileExtension().equalsIgnoreCase(JAVA_EXT)){
- ITextSourceReference location =
factory.getLocationFor(SeamAnnotations.FACTORY_ANNOTATION_TYPE);
- if(location != null){
- if(!files.contains(file.getFullPath())){
- files.add(file.getFullPath());
- changeAnnotation(location, file);
- }else if(force)
- changeAnnotation(location, file);
- }
- }else{
- ITextSourceReference location =
factory.getLocationFor(ISeamXmlComponentDeclaration.NAME);
- if(location != null){
- if(!files.contains(file.getFullPath())){
- files.add(file.getFullPath());
- changeXMLNode(location, file);
- }else if(force)
- changeXMLNode(location, file);
- }
+ changeFactory(factory, force);
+ }
+ }
+
+ private void changeFactory(ISeamFactory factory, boolean force){
+ IFile file = (IFile)factory.getResource();
+ if(file.getFileExtension().equalsIgnoreCase(JAVA_EXT)){
+ ITextSourceReference location =
factory.getLocationFor(SeamAnnotations.FACTORY_ANNOTATION_TYPE);
+ if(location != null){
+ if(!files.contains(file.getFullPath())){
+ files.add(file.getFullPath());
+ changeAnnotation(location, file);
+ }else if(force)
+ changeAnnotation(location, file);
}
+ }else{
+ ITextSourceReference location =
factory.getLocationFor(ISeamXmlComponentDeclaration.NAME);
+ if(location != null){
+ if(!files.contains(file.getFullPath())){
+ files.add(file.getFullPath());
+ changeXMLNode(location, file);
+ }else if(force)
+ changeXMLNode(location, file);
+ }
}
}
@@ -517,4 +534,12 @@
findELReferences();
}
+
+ protected void renameFactories(Set<ISeamFactory> factories){
+ for(ISeamFactory factory : factories){
+ changeFactory(factory, true);
+ }
+
+ findELReferences();
+ }
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/RenameComponentWizard.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/RenameComponentWizard.java 2009-06-05
12:33:49 UTC (rev 15729)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/RenameComponentWizard.java 2009-06-05
13:25:00 UTC (rev 15730)
@@ -39,7 +39,7 @@
import org.jboss.tools.seam.ui.widget.editor.IFieldEditorFactory;
/**
- * @author Alexey Kazakov
+ * @author Alexey Kazakov, Daniel Azarov
*/
public class RenameComponentWizard extends RefactoringWizard {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/RenameSeamContextVariableWizard.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/RenameSeamContextVariableWizard.java 2009-06-05
12:33:49 UTC (rev 15729)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/RenameSeamContextVariableWizard.java 2009-06-05
13:25:00 UTC (rev 15730)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
+ * Copyright (c) 2009 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -42,11 +42,10 @@
import org.jboss.tools.seam.ui.widget.editor.IFieldEditorFactory;
/**
- * @author Alexey Kazakov
+ * @author Daniel Azarov
*/
public class RenameSeamContextVariableWizard extends RefactoringWizard {
- //private ISeamComponent component;
private String componentName;
private IFieldEditor editor;
private ISeamProject seamProject;
@@ -63,13 +62,13 @@
protected void addUserInputPages() {
setDefaultPageTitle(getRefactoring().getName());
RenameSeamContextVariableProcessor processor= (RenameSeamContextVariableProcessor)
getRefactoring().getAdapter(RenameSeamContextVariableProcessor.class);
- addPage(new RenameComponentWizardPage(processor));
+ addPage(new RenameSeamContextVariableWizardPage(processor));
}
- class RenameComponentWizardPage extends UserInputWizardPage{
+ class RenameSeamContextVariableWizardPage extends UserInputWizardPage{
private SeamRenameProcessor processor;
- public RenameComponentWizardPage(SeamRenameProcessor processor){
+ public RenameSeamContextVariableWizardPage(SeamRenameProcessor processor){
super("");
this.processor = processor;
}