NCDFE: TagPanel.createNamespaceUriModel

This commit is contained in:
Gregory Shrago
2009-11-20 17:13:19 +03:00
parent 58120ca05c
commit d769555f01
4 changed files with 70 additions and 14 deletions
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<idea-plugin version="2">
<extensions defaultExtensionNs="com.intellij">
<applicationService serviceInterface="org.intellij.plugins.intelliLang.inject.config.JspSupportProxy"
serviceImplementation="org.intellij.plugins.intelliLang.inject.config.JspSupportProxy$Impl"/>
</extensions>
</idea-plugin>
@@ -7,6 +7,7 @@
<depends optional="true" config-file="intellilang-xpath-support.xml">XPathView</depends>
<depends optional="true" config-file="intellilang-java-support.xml">com.intellij.modules.java</depends>
<depends optional="true" config-file="intellilang-javaee-support.xml">com.intellij.javaee</depends>
<depends optional="true" config-file="intellilang-xml-support.xml">com.intellij.modules.xml</depends>
<depends optional="true" config-file="intellilang-groovy-support.xml">org.intellij.groovy</depends>
@@ -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);
}
}
}
@@ -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<AbstractTagInjection> {
final List<String> urls = new ArrayList<String>(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<String> tlds = new ArrayList<String>();
final Module[] modules = ModuleManager.getInstance(project).getModules();
for (final Module module : modules) {
final String[] tldUris = ApplicationManager.getApplication().runReadAction(new Computable<String[]>() {
public String[] compute() {
return jspManager.getPossibleTldUris(module);
return jspSupport.getPossibleTldUris(module);
}
});
for (String uri : tldUris) {
@@ -77,15 +77,6 @@ public class TagPanel extends AbstractInjectionPanel<AbstractTagInjection> {
tlds.add(uri);
}
}
// That's the OpenAPI way, but TldInfoManager is always null:
// final TldInfoManager manager = TldInfoManager.getTldInfoManager(module);
// if (manager != null) {
// final Collection<TldInfo> infos = manager.getTldInfos().getTldInfos();
// for (TldInfo info : infos) {
// tlds.add(info.getUri());
// }
// }
}
Collections.sort(tlds);