From d769555f017b21067f2e9c23398f308c37e8dcfa Mon Sep 17 00:00:00 2001 From: Gregory Shrago Date: Fri, 20 Nov 2009 17:13:19 +0300 Subject: [PATCH] NCDFE: TagPanel.createNamespaceUriModel --- .../src/META-INF/intellilang-javaee-support.xml | 9 ++++ plugins/IntelliLang/src/META-INF/plugin.xml | 1 + .../intelliLang/inject/config/JspSupportProxy.java | 55 ++++++++++++++++++++++ .../intelliLang/inject/config/ui/TagPanel.java | 19 ++------ 4 files changed, 70 insertions(+), 14 deletions(-) create mode 100644 plugins/IntelliLang/src/META-INF/intellilang-javaee-support.xml create mode 100644 plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/JspSupportProxy.java diff --git a/plugins/IntelliLang/src/META-INF/intellilang-javaee-support.xml b/plugins/IntelliLang/src/META-INF/intellilang-javaee-support.xml new file mode 100644 index 0000000000..611d06a732 --- /dev/null +++ b/plugins/IntelliLang/src/META-INF/intellilang-javaee-support.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/plugins/IntelliLang/src/META-INF/plugin.xml b/plugins/IntelliLang/src/META-INF/plugin.xml index 2dab67af95..08fc53463f 100644 --- a/plugins/IntelliLang/src/META-INF/plugin.xml +++ b/plugins/IntelliLang/src/META-INF/plugin.xml @@ -7,6 +7,7 @@ XPathView com.intellij.modules.java + com.intellij.javaee com.intellij.modules.xml org.intellij.groovy diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/JspSupportProxy.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/JspSupportProxy.java new file mode 100644 index 0000000000..6c503dad46 --- /dev/null +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/JspSupportProxy.java @@ -0,0 +1,55 @@ +/* + * Copyright 2000-2009 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.intellij.plugins.intelliLang.inject.config; + +import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.module.Module; +import com.intellij.psi.impl.source.jsp.JspManager; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Proxy class that allows to avoid a hard compile time dependency on the XPathView plugin. + */ +public abstract class JspSupportProxy { + + @NotNull + public abstract String[] getPossibleTldUris(final Module module); + + private static JspSupportProxy ourInstance; + private static boolean isInitialized; + + @Nullable + public static synchronized JspSupportProxy getInstance() { + if (isInitialized) { + return ourInstance; + } + try { + return ourInstance = ServiceManager.getService(JspSupportProxy.class); + } finally { + isInitialized = true; + } + } + + public static class Impl extends JspSupportProxy { + @NotNull + @Override + public String[] getPossibleTldUris(Module module) { + return JspManager.getInstance(module.getProject()).getPossibleTldUris(module); + } + } +} \ No newline at end of file diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/TagPanel.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/TagPanel.java index 660e1aa5bf..d7218366bb 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/TagPanel.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/TagPanel.java @@ -21,12 +21,12 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.ComboBox; -import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Computable; -import com.intellij.psi.impl.source.jsp.JspManager; +import com.intellij.openapi.util.Key; import com.intellij.ui.EditorTextField; import org.intellij.lang.regexp.RegExpLanguage; import org.intellij.plugins.intelliLang.inject.config.AbstractTagInjection; +import org.intellij.plugins.intelliLang.inject.config.JspSupportProxy; import org.intellij.plugins.intelliLang.inject.config.XmlTagInjection; import org.intellij.plugins.intelliLang.util.LanguageTextField; @@ -62,14 +62,14 @@ public class TagPanel extends AbstractInjectionPanel { final List urls = new ArrayList(Arrays.asList(ExternalResourceManager.getInstance().getResourceUrls(null, true))); Collections.sort(urls); - final JspManager jspManager = JspManager.getInstance(project); - if (jspManager != null) { + final JspSupportProxy jspSupport = JspSupportProxy.getInstance(); + if (jspSupport != null) { final List tlds = new ArrayList(); final Module[] modules = ModuleManager.getInstance(project).getModules(); for (final Module module : modules) { final String[] tldUris = ApplicationManager.getApplication().runReadAction(new Computable() { public String[] compute() { - return jspManager.getPossibleTldUris(module); + return jspSupport.getPossibleTldUris(module); } }); for (String uri : tldUris) { @@ -77,15 +77,6 @@ public class TagPanel extends AbstractInjectionPanel { tlds.add(uri); } } - -// That's the OpenAPI way, but TldInfoManager is always null: -// final TldInfoManager manager = TldInfoManager.getTldInfoManager(module); -// if (manager != null) { -// final Collection infos = manager.getTldInfos().getTldInfos(); -// for (TldInfo info : infos) { -// tlds.add(info.getUri()); -// } -// } } Collections.sort(tlds); -- 2.11.4.GIT