From 022e49781c4f0e4f4e8bca36ed2b09d6d059cb4f Mon Sep 17 00:00:00 2001 From: Sergey Vasiliev Date: Mon, 2 Jul 2007 10:31:37 +0400 Subject: [PATCH] spring external beans support --- dom/openapi/src/com/intellij/util/xml/DomUtil.java | 31 +++++++++++++++++++++- .../actions/generate/GenerateDomElementAction.java | 29 ++------------------ resources_eng/src/messages/JamBundle.properties | 6 ++++- 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/dom/openapi/src/com/intellij/util/xml/DomUtil.java b/dom/openapi/src/com/intellij/util/xml/DomUtil.java index 854d4842f9..e0375c5c6b 100644 --- a/dom/openapi/src/com/intellij/util/xml/DomUtil.java +++ b/dom/openapi/src/com/intellij/util/xml/DomUtil.java @@ -3,9 +3,15 @@ */ package com.intellij.util.xml; +import com.intellij.openapi.editor.Editor; +import com.intellij.psi.PsiDocumentManager; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.psi.xml.XmlAttributeValue; import com.intellij.psi.xml.XmlElement; +import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; -import com.intellij.psi.xml.XmlAttributeValue; import com.intellij.util.ReflectionCache; import com.intellij.util.ReflectionUtil; import com.intellij.util.xml.reflect.DomAttributeChildDescription; @@ -206,4 +212,27 @@ public class DomUtil { } return null; } + + @Nullable + public static DomElement getContextElement(@Nullable final Editor editor) { + if(editor == null) return null; + + final PsiFile file = PsiDocumentManager.getInstance(editor.getProject()).getPsiFile(editor.getDocument()); + if (!(file instanceof XmlFile)) { + return null; + } + + int offset = editor.getCaretModel().getOffset(); + PsiElement element = file.findElementAt(offset); + if (element == null) return null; + + XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class); + while (tag != null) { + final DomElement domElement = DomManager.getDomManager(file.getProject()).getDomElement(tag); + if(domElement != null) return domElement; + + tag = PsiTreeUtil.getParentOfType(tag, XmlTag.class, true); + } + return null; + } } diff --git a/dom/openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementAction.java b/dom/openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementAction.java index 1eb6a1722a..2b8b17fda2 100644 --- a/dom/openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementAction.java +++ b/dom/openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementAction.java @@ -6,14 +6,9 @@ import com.intellij.openapi.application.Result; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; -import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.psi.xml.XmlFile; -import com.intellij.psi.xml.XmlTag; import com.intellij.util.xml.DomElement; -import com.intellij.util.xml.DomManager; -import org.jetbrains.annotations.Nullable; +import com.intellij.util.xml.DomUtil; /** * User: Sergey.Vasiliev @@ -44,28 +39,8 @@ public class GenerateDomElementAction extends BaseGenerateAction { myProvider = generateProvider; } - @Nullable - protected DomElement getContextElement(final Project project, final Editor editor, final PsiFile file) { - if (!(file instanceof XmlFile)) { - return null; - } - - int offset = editor.getCaretModel().getOffset(); - PsiElement element = file.findElementAt(offset); - if (element == null) return null; - - XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class); - while (tag != null) { - final DomElement domElement = DomManager.getDomManager(project).getDomElement(tag); - if(domElement != null) return domElement; - - tag = PsiTreeUtil.getParentOfType(tag, XmlTag.class, true); - } - return null; - } - protected boolean isValidForFile(final Project project, final Editor editor, final PsiFile file) { - final DomElement element = getContextElement(project, editor, file); + final DomElement element = DomUtil.getContextElement(editor); return element != null && myProvider.isAvailableForElement(element); } } diff --git a/resources_eng/src/messages/JamBundle.properties b/resources_eng/src/messages/JamBundle.properties index 71cbd11100..b3f44427df 100644 --- a/resources_eng/src/messages/JamBundle.properties +++ b/resources_eng/src/messages/JamBundle.properties @@ -10,4 +10,8 @@ column.name.elements.to.delete=Elements to Delete dialog.title.select.elements.to.delete=Select Elements to Delete button.delete=&Delete button.do.not.delete=Do &Not Delete -postfix.not.physical.element=nonexistent \ No newline at end of file +postfix.not.physical.element=nonexistent + +this.0.1.belongs.to.2.search.usages.2=This {0} ''{1}'' belongs to {2}.\nDo you want to search for the {2} usages instead? +confirmation.text.0.1.belongs.to.2.rename.2={0} ''{1}'' belongs to {2}.\nDo you want to rename {2} instead? +dialog.title.rename.0.classes=Rename {0} Classes \ No newline at end of file -- 2.11.4.GIT