diff --git a/platform/platform-resources/src/META-INF/XmlPlugin.xml b/platform/platform-resources/src/META-INF/XmlPlugin.xml
index c39432bffaed..8a997f8703d0 100644
--- a/platform/platform-resources/src/META-INF/XmlPlugin.xml
+++ b/platform/platform-resources/src/META-INF/XmlPlugin.xml
@@ -311,7 +311,7 @@
-
+
diff --git a/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXRenameTest.java b/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXRenameTest.java
index 7b5893da6b90..702f0aa0fbd5 100644
--- a/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXRenameTest.java
+++ b/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXRenameTest.java
@@ -18,6 +18,7 @@ package org.jetbrains.plugins.javaFX.fxml;
import com.intellij.codeInsight.TargetElementUtilBase;
import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase;
import com.intellij.openapi.application.PluginPathManager;
+import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.refactoring.rename.RenameProcessor;
import com.intellij.refactoring.rename.inplace.MemberInplaceRenameHandler;
@@ -51,7 +52,15 @@ public class JavaFXRenameTest extends DaemonAnalyzerTestCase {
public void testCustomComponentTag() throws Exception {
doTest("Foo", true);
}
-
+
+ public void testFromReference() throws Exception {
+ final String newName = "lbl1";
+ doTest(newName);
+ final PsiClass controllerClass = findClass(getTestName(false));
+ assertNotNull(controllerClass);
+ assertNotNull(controllerClass.findFieldByName(newName, false));
+ }
+
public void testIdWithRefs() throws Exception {
configureByFiles(null, getTestName(true) + ".fxml");
PsiElement element = TargetElementUtilBase
diff --git a/plugins/javaFX/src/META-INF/common-javaFX-plugin.xml b/plugins/javaFX/src/META-INF/common-javaFX-plugin.xml
index ce37e7bf9534..ebe56efb50d1 100644
--- a/plugins/javaFX/src/META-INF/common-javaFX-plugin.xml
+++ b/plugins/javaFX/src/META-INF/common-javaFX-plugin.xml
@@ -42,6 +42,7 @@
+
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/JavaFxRenameAttributeProcessor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/JavaFxRenameAttributeProcessor.java
new file mode 100644
index 000000000000..fd9945ebec50
--- /dev/null
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/JavaFxRenameAttributeProcessor.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.javaFX;
+
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiField;
+import com.intellij.psi.PsiReference;
+import com.intellij.psi.search.SearchScope;
+import com.intellij.psi.xml.XmlAttribute;
+import com.intellij.psi.xml.XmlAttributeValue;
+import com.intellij.refactoring.rename.RenameXmlAttributeProcessor;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.javaFX.fxml.FxmlConstants;
+import org.jetbrains.plugins.javaFX.fxml.JavaFxFileTypeFactory;
+
+import java.util.Map;
+
+/**
+ * User: anna
+ * Date: 4/2/13
+ */
+public class JavaFxRenameAttributeProcessor extends RenameXmlAttributeProcessor {
+ @Override
+ public boolean canProcessElement(@NotNull PsiElement element) {
+ if (element instanceof XmlAttributeValue && JavaFxFileTypeFactory.isFxml(element.getContainingFile())) {
+ final PsiElement parent = element.getParent();
+ return parent instanceof XmlAttribute && FxmlConstants.FX_ID.equals(((XmlAttribute)parent).getName());
+ }
+ return false;
+ }
+
+ @Override
+ public void prepareRenaming(PsiElement element, String newName, Map allRenames, SearchScope scope) {
+ if (element instanceof XmlAttributeValue) {
+ final XmlAttributeValue refId = (XmlAttributeValue)element;
+ final PsiReference refIdReference = refId.getReference();
+ if (refIdReference != null) {
+ final PsiElement resolveRefId = refIdReference.resolve();
+ if (resolveRefId instanceof PsiField) {
+ allRenames.put(resolveRefId, newName);
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/javaFX/testData/rename/FromReference.java b/plugins/javaFX/testData/rename/FromReference.java
new file mode 100644
index 000000000000..63a025eec6d5
--- /dev/null
+++ b/plugins/javaFX/testData/rename/FromReference.java
@@ -0,0 +1,4 @@
+import javafx.control.Label;
+public class FromReference {
+ public Label lb;
+}
\ No newline at end of file
diff --git a/plugins/javaFX/testData/rename/fromReference.fxml b/plugins/javaFX/testData/rename/fromReference.fxml
new file mode 100644
index 000000000000..0c7df76f5d20
--- /dev/null
+++ b/plugins/javaFX/testData/rename/fromReference.fxml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/javaFX/testData/rename/fromReference_after.fxml b/plugins/javaFX/testData/rename/fromReference_after.fxml
new file mode 100644
index 000000000000..4fa09b02606d
--- /dev/null
+++ b/plugins/javaFX/testData/rename/fromReference_after.fxml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file