Author: akazakov
Date: 2009-06-08 15:33:10 -0400 (Mon, 08 Jun 2009)
New Revision: 15783
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibrary.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/ICustomTagLibrary.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2808
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageProcessor.java 2009-06-08
19:27:21 UTC (rev 15782)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageProcessor.java 2009-06-08
19:33:10 UTC (rev 15783)
@@ -56,7 +56,7 @@
}
}
for (int i = 0; customTagLibs != null && i < customTagLibs.length; i++) {
- // TODO
+ // TODO
}
if(query.getType() == KbQuery.Type.ATTRIBUTE_VALUE || ((query.getType() ==
KbQuery.Type.TEXT )&& context instanceof IFaceletPageContext)) {
String value = query.getValue();
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java 2009-06-08
19:27:21 UTC (rev 15782)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java 2009-06-08
19:33:10 UTC (rev 15783)
@@ -12,9 +12,11 @@
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
@@ -46,6 +48,7 @@
protected INameSpace nameSpace;
protected String uri;
protected String version;
+ protected boolean hasExtenededComponents = false;
private Map<String, IComponent> components = new HashMap<String,
IComponent>();
private IComponent[] componentsArray;
@@ -72,10 +75,14 @@
* @see org.jboss.tools.jst.web.kb.taglib.TagLibrary#getComponents(java.lang.String)
*/
public IComponent[] getComponents(String nameTemplate) {
+ return getComponents(nameTemplate, null);
+ }
+
+ public IComponent[] getComponents(String nameTemplate, IPageContext context) {
List<IComponent> list = new ArrayList<IComponent>();
IComponent[] comps = getComponents();
for (int i = 0; i < comps.length; i++) {
- if(comps[i].getName().startsWith(nameTemplate)) {
+ if(comps[i].getName().startsWith(nameTemplate) && (context==null ||
checkExtended(comps[i], context))) {
list.add(comps[i]);
}
}
@@ -114,14 +121,14 @@
fullTagName = query.getLastParentTag();
}
if(fullTagName == null) {
- return null;
+ return EMPTY_ARRAY;
}
if(mask) {
if(fullTagName.length()==0) {
- return getComponents();
+ return getExtendedComponents(context);
}
if(prefix==null) {
- return getComponents(fullTagName);
+ return getComponents(fullTagName, context);
}
}
String tagName = fullTagName;
@@ -138,21 +145,56 @@
if(mask) {
if(prefixIndex<0) {
if(prefix.startsWith(tagName)) {
- return getComponents();
+ return getExtendedComponents(context);
}
return EMPTY_ARRAY;
}
if(prefix.equals(queryPrefix)) {
if(tagName == null) {
- return getComponents();
+ return getExtendedComponents(context);
}
- return getComponents(tagName);
+ return getComponents(tagName, context);
}
return EMPTY_ARRAY;
}
- return new IComponent[]{getComponent(tagName)};
+ IComponent comp = getComponent(tagName);
+ if(checkExtended(comp, context)) {
+ return new IComponent[]{comp};
+ }
+ return EMPTY_ARRAY;
}
+ protected IComponent[] getExtendedComponents(IPageContext context) {
+ if(hasExtenededComponents) {
+ Set<IComponent> comps = new HashSet<IComponent>();
+ synchronized(components) {
+ for (IComponent component : components.values()) {
+ if(checkExtended(component, context)) {
+ comps.add(component);
+ }
+ }
+ }
+ return comps.toArray(new IComponent[0]);
+ }
+ return getComponents();
+ }
+
+ protected boolean checkExtended(IComponent component, IPageContext context) {
+ if(!component.isExtended()) {
+ return true;
+ }
+ ITagLibrary[] libs = context.getLibraries();
+ for (int i = 0; i < libs.length; i++) {
+ if(libs[i]!=this && libs[i].getURI().equals(uri)) {
+ IComponent ac = libs[i].getComponent(component.getName());
+ if(!ac.isExtended()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
/**
* Adds component to tag lib.
* @param component
@@ -161,6 +203,9 @@
adopt((KbObject)component);
components.put(component.getName(), component);
componentsArray=null;
+ if(component.isExtended()) {
+ hasExtenededComponents = true;
+ }
}
/**
@@ -168,6 +213,12 @@
*/
protected void setComponents(Map<String, IComponent> components) {
this.components = components;
+ for (IComponent component : components.values()) {
+ if(component.isExtended()) {
+ hasExtenededComponents = true;
+ break;
+ }
+ }
componentsArray=null;
}
@@ -264,9 +315,7 @@
IComponent[] components = getComponents(query, prefix, context);
if(query.getType() == KbQuery.Type.TAG_NAME) {
for (int i = 0; i < components.length; i++) {
- if(!components[i].isExtended() || checkExtended(components[i], prefix, query,
context)) {
- proposals.add(getProposal(prefix, components[i]));
- }
+ proposals.add(getProposal(prefix, components[i]));
}
} else {
for (int i = 0; i < components.length; i++) {
@@ -281,11 +330,6 @@
return proposals.toArray(new TextProposal[proposals.size()]);
}
- protected boolean checkExtended(IComponent component, String prefix, KbQuery query,
IPageContext context) {
- // TODO
- return false;
- }
-
protected TextProposal getProposal(String prefix, IComponent component) {
TextProposal proposal = new TextProposal();
proposal.setContextInfo(component.getDescription());
@@ -316,8 +360,8 @@
}
proposal.setPosition(position);
return proposal;
-
}
+
/*
* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.internal.KbObject#clone()
@@ -327,6 +371,9 @@
AbstractTagLib t = (AbstractTagLib)super.clone();
t.components = new HashMap<String, IComponent>();
for (IComponent c: components.values()) {
+ if(c.isExtended()) {
+ t.hasExtenededComponents = true;
+ }
t.addComponent(((AbstractComponent)c).clone());
}
t.components.putAll(components);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibrary.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibrary.java 2009-06-08
19:27:21 UTC (rev 15782)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibrary.java 2009-06-08
19:33:10 UTC (rev 15783)
@@ -22,11 +22,7 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import org.jboss.tools.jst.web.kb.IPageContext;
-import org.jboss.tools.jst.web.kb.KbQuery;
import org.jboss.tools.jst.web.kb.WebKbPlugin;
-import org.jboss.tools.jst.web.kb.taglib.IComponent;
-import org.jboss.tools.jst.web.kb.taglib.ICustomTagLibComponent;
import org.jboss.tools.jst.web.kb.taglib.ICustomTagLibrary;
import org.w3c.dom.CharacterData;
import org.w3c.dom.Document;
@@ -236,20 +232,4 @@
public CustomTagLibAttribute[] getExtendedAttributes() {
return extendedAttributes;
}
-
- /*
- * (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.taglib.ICustomTagLibrary#getExtendedComponents(org.jboss.tools.jst.web.kb.KbQuery,
org.jboss.tools.jst.web.kb.IPageContext)
- */
- public Set<ICustomTagLibComponent> getExtendedComponents(KbQuery query,
IPageContext context) {
- Set<ICustomTagLibComponent> set = new HashSet<ICustomTagLibComponent>();
- IComponent[] components = getComponents(query, context);
- for (int i = 0; i < components.length; i++) {
- ICustomTagLibComponent component = (ICustomTagLibComponent)components[i];
- if(component.isExtended()) {
- set.add(component);
- }
- }
- return set;
- }
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/ICustomTagLibrary.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/ICustomTagLibrary.java 2009-06-08
19:27:21 UTC (rev 15782)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/ICustomTagLibrary.java 2009-06-08
19:33:10 UTC (rev 15783)
@@ -10,20 +10,9 @@
******************************************************************************/
package org.jboss.tools.jst.web.kb.taglib;
-import java.util.Set;
-
-import org.jboss.tools.jst.web.kb.IPageContext;
-import org.jboss.tools.jst.web.kb.KbQuery;
-
/**
* @author Alexey Kazakov
*/
public interface ICustomTagLibrary extends ITagLibrary {
- /**
- * @param query
- * @param context
- * @return Components with "extended" flag. See
org.jboss.tools.jst.web.kb.taglib.ICustomTagLibComponent#isExtended()
- */
- Set<ICustomTagLibComponent> getExtendedComponents(KbQuery query, IPageContext
context);
}
\ No newline at end of file