[304999] [refactoring] JSPs should react to java field refactorings
diff --git a/bundles/org.eclipse.jst.jsp.ui/plugin.properties b/bundles/org.eclipse.jst.jsp.ui/plugin.properties index 35aa393..b176a2e 100644 --- a/bundles/org.eclipse.jst.jsp.ui/plugin.properties +++ b/bundles/org.eclipse.jst.jsp.ui/plugin.properties
@@ -54,6 +54,7 @@ JSP_Type_Rename_Participant_Extension_Element.name=JSP Type Rename Participant JSP_Method_Rename_Participant_Extension_Element.name=JSP Method Rename Participant JSP_Package_Rename_Participant_Extension_Element.name=JSP Package Rename Participant +JSP_Field_Rename_Participant_Extension_Element.name=JSP Field Rename Participant JSP_Type_Move_Participant_Extension_Element.name=JSP Type Move Participant All_JSP_context_type_Extension_Element.name=All JSP JSP_New_context_type_Extension_Element.name=New JSP
diff --git a/bundles/org.eclipse.jst.jsp.ui/plugin.xml b/bundles/org.eclipse.jst.jsp.ui/plugin.xml index bb02d00..6b125fc 100644 --- a/bundles/org.eclipse.jst.jsp.ui/plugin.xml +++ b/bundles/org.eclipse.jst.jsp.ui/plugin.xml
@@ -331,6 +331,23 @@ </with> </enablement> </renameParticipant> + <renameParticipant + class="org.eclipse.jst.jsp.ui.internal.java.refactoring.JSPFieldRenameParticipant" + id="org.eclipse.jst.jsp.ui.java.refactoring.JSFieldRenameParticipant" + name="%JSP_Field_Rename_Participant_Extension_Element.name"> + <enablement> + <with variable="affectedNatures"> + <iterate operator="or"> + <equals value="org.eclipse.jdt.core.javanature"> + </equals> + </iterate> + </with> + <with variable="element"> + <instanceof value="org.eclipse.jdt.core.IField"> + </instanceof> + </with> + </enablement> + </renameParticipant> </extension> <!--======================================================================================-->
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIMessages.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIMessages.java index 2f70c20..5460e8e 100644 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIMessages.java +++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIMessages.java
@@ -58,6 +58,7 @@ public static String BasicRefactorSearchRequestor_4; public static String BasicRefactorSearchRequestor_5; public static String BasicRefactorSearchRequestor_6; + public static String BasicRefactorSearchRequestor_7; public static String BreakpointNotAllowed; public static String _UI_WIZARD_NEW_TITLE; public static String _UI_WIZARD_NEW_HEADING;
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIPluginResources.properties b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIPluginResources.properties index a5d31eb..8d7e070 100644 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIPluginResources.properties +++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIPluginResources.properties
@@ -33,6 +33,7 @@ BasicRefactorSearchRequestor_4=Rename Type ''{0}'' to ''{1}'' BasicRefactorSearchRequestor_5=Rename Package ''{0}'' to ''{1}'' BasicRefactorSearchRequestor_6=JSP Rename Change +BasicRefactorSearchRequestor_7=Rename Field ''{0}'' to ''{1}'' # _UI_WIZARD_NEW_TITLE = New JSP File _UI_WIZARD_NEW_HEADING = JSP
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPFieldRenameParticipant.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPFieldRenameParticipant.java new file mode 100644 index 0000000..bd9111e --- /dev/null +++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPFieldRenameParticipant.java
@@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2010 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are 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: + * IBM Corporation - initial API and implementation + * + *******************************************************************************/ +package org.eclipse.jst.jsp.ui.internal.java.refactoring; + +import org.eclipse.jdt.core.IField; +import org.eclipse.jdt.core.IJavaElement; + +/** + * <p>Participant for renaming Java fields in JSP documents</p> + * + */ +public class JSPFieldRenameParticipant extends JSPRenameParticipant { + + /** + * <p>Initializes the name of this participant to the name of the {@link IField}</p> + * + * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object) + */ + protected boolean initialize(Object element) { + boolean success = false; + if(element instanceof IField) { + super.fName = ((IField)element).getElementName(); + success = true; + } + return success; + } + + /** + * @see org.eclipse.jst.jsp.ui.internal.java.refactoring.JSPRenameParticipant#isLegalElementType(org.eclipse.jdt.core.IJavaElement) + */ + protected boolean isLegalElementType(IJavaElement element) { + return (element instanceof IField); + } + + /** + * @see org.eclipse.jst.jsp.ui.internal.java.refactoring.JSPRenameParticipant#getSearchRequestor(org.eclipse.jdt.core.IJavaElement, java.lang.String) + */ + protected BasicRefactorSearchRequestor getSearchRequestor(IJavaElement element, String newName) { + BasicRefactorSearchRequestor searchRequestor = null; + + if(isLegalElementType(element)) { + searchRequestor = new JSPFieldRenameRequestor(element, newName); + } + + return searchRequestor; + } +} \ No newline at end of file
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPFieldRenameRequestor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPFieldRenameRequestor.java new file mode 100644 index 0000000..9ccdaf6 --- /dev/null +++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPFieldRenameRequestor.java
@@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2010 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are 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: + * IBM Corporation - initial API and implementation + * + *******************************************************************************/ +package org.eclipse.jst.jsp.ui.internal.java.refactoring; + +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; +import org.eclipse.osgi.util.NLS; + +/** + * <p>Reactor search requestor to rename Java fields in JSP documents</p> + * + */ +public class JSPFieldRenameRequestor extends BasicRefactorSearchRequestor { + + /** + * <p>Constructor</p> + * + * @param element the old field name + * @param newName the new field name + */ + public JSPFieldRenameRequestor(IJavaElement element, String newName) { + super(element, newName); + } + + /** + * @see org.eclipse.jst.jsp.ui.internal.java.refactoring.BasicRefactorSearchRequestor#getDescription() + */ + protected String getDescription() { + String fieldName = getElement().getElementName(); + String newName = getNewName(); + String description = NLS.bind(JSPUIMessages.BasicRefactorSearchRequestor_7, (new String[]{fieldName, newName})); //$NON-NLS-1$ + return description; + } + +}
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/RenameElementHandler.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/RenameElementHandler.java index 1c1b962..20399f9 100644 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/RenameElementHandler.java +++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/RenameElementHandler.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 IBM Corporation and others. + * Copyright (c) 2008, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,7 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.CoreException; +import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IPackageFragment; @@ -47,6 +48,9 @@ case IJavaElement.PACKAGE_FRAGMENT: renameSupport= RenameSupport.create((IPackageFragment)element, element.getElementName(), RenameSupport.UPDATE_REFERENCES); break; + case IJavaElement.FIELD: + renameSupport = RenameSupport.create((IField)element, element.getElementName(), RenameSupport.UPDATE_REFERENCES); + break; } if(renameSupport != null) { renameSupport.openDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());