Author: akazakov
Date: 2009-06-10 13:20:29 -0400 (Wed, 10 Jun 2009)
New Revision: 15869
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractAttribute.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.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/CustomTagLibAttribute.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibComponent.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/IAttribute.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/IComponent.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/internal/taglib/AbstractAttribute.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractAttribute.java 2009-06-10
16:44:26 UTC (rev 15868)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractAttribute.java 2009-06-10
17:20:29 UTC (rev 15869)
@@ -25,6 +25,7 @@
import org.jboss.tools.jst.web.kb.internal.KbObject;
import org.jboss.tools.jst.web.kb.internal.KbXMLStoreConstants;
import org.jboss.tools.jst.web.kb.taglib.IAttribute;
+import org.jboss.tools.jst.web.kb.taglib.IComponent;
import org.jboss.tools.jst.web.model.project.ext.store.XMLValueInfo;
import org.w3c.dom.Element;
@@ -103,6 +104,14 @@
attributesInfo.put(REQUIRED, s);
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.taglib.IAttribute#getComponent()
+ */
+ public IComponent getComponent() {
+ return (IComponent)parent;
+ }
+
/* (non-Javadoc)
* @see
org.jboss.tools.jst.web.kb.IProposalProcessor#getProposals(org.jboss.tools.jst.web.kb.KbQuery,
org.jboss.tools.jst.web.kb.IPageContext)
*/
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java 2009-06-10
16:44:26 UTC (rev 15868)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java 2009-06-10
17:20:29 UTC (rev 15869)
@@ -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.jboss.tools.common.model.project.ext.IValueInfo;
import org.jboss.tools.common.model.project.ext.event.Change;
@@ -28,6 +30,7 @@
import org.jboss.tools.jst.web.kb.taglib.Facet;
import org.jboss.tools.jst.web.kb.taglib.IAttribute;
import org.jboss.tools.jst.web.kb.taglib.IComponent;
+import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
import org.w3c.dom.Element;
/**
@@ -45,6 +48,7 @@
protected String componentType;
protected String description;
protected String name;
+ protected boolean hasExtendedAttributes = false;
private Map<String, IAttribute> attributes = new HashMap<String,
IAttribute>();
private IAttribute[] attributesArray;
private Map<String, IAttribute> preferableAttributes = new HashMap<String,
IAttribute>();
@@ -97,16 +101,64 @@
* @see org.jboss.tools.jst.web.kb.taglib.IComponent#getAttributes(java.lang.String)
*/
public IAttribute[] getAttributes(String nameTemplate) {
+ return getAttributes(nameTemplate, null);
+ }
+
+ public IAttribute[] getAttributes(String nameTemplate, IPageContext context) {
List<IAttribute> list = new ArrayList<IAttribute>();
IAttribute[] atts = getAttributes();
for (int i = 0; i < atts.length; i++) {
- if(atts[i].getName().startsWith(nameTemplate)) {
+ if(atts[i].getName().startsWith(nameTemplate) && (context==null ||
checkExtended(atts[i], context))) {
list.add(atts[i]);
}
}
return list.toArray(new IAttribute[list.size()]);
}
+ protected IAttribute[] getExtendedAttributes(IPageContext context) {
+ if(hasExtendedAttributes) {
+ Set<IAttribute> attrs = new HashSet<IAttribute>();
+ synchronized(attributes) {
+ for (IAttribute attribute : attributes.values()) {
+ if(checkExtended(attribute, context)) {
+ attrs.add(attribute);
+ }
+ }
+ }
+ return attrs.toArray(new IAttribute[0]);
+ }
+ return getAttributes();
+ }
+
+ protected boolean checkExtended(IAttribute attribute, IPageContext context) {
+ if(!attribute.isExtended()) {
+ return true;
+ }
+ IComponent parentComponent = attribute.getComponent();
+ if(parentComponent==null) {
+ return true;
+ }
+ ITagLibrary[] libs = context.getLibraries();
+ for (int i = 0; i < libs.length; i++) {
+ ITagLibrary thisLib = this.getTagLib();
+ if(thisLib==null) {
+ return true;
+ }
+ if(libs[i].getURI().equals(thisLib.getURI())) {
+ IComponent ac = libs[i].getComponent(parentComponent.getName());
+ if(ac!=null && ac!=this) {
+ IAttribute at = ac.getAttribute(attribute.getName());
+ if(at!=null && !at.isExtended()) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ private static final IAttribute[] EMPTY_ARRAY = new IAttribute[0];
+
/* (non-Javadoc)
* @see
org.jboss.tools.jst.web.kb.taglib.IComponent#getAttributes(org.jboss.tools.jst.web.kb.KbQuery,
org.jboss.tools.jst.web.kb.IPageContext)
*/
@@ -123,9 +175,13 @@
return null;
}
if(mask) {
- return getAttributes(attrName);
+ return getAttributes(attrName, context);
}
- return new IAttribute[]{getAttribute(attrName)};
+ IAttribute attr = getAttribute(attrName);
+ if(attr!=null && checkExtended(attr, context)) {
+ return new IAttribute[]{getAttribute(attrName)};
+ }
+ return EMPTY_ARRAY;
}
/* (non-Javadoc)
@@ -307,6 +363,9 @@
public void addAttribute(IAttribute attribute) {
adopt((KbObject)attribute);
attributes.put(attribute.getName(), attribute);
+ if(attribute.isExtended()) {
+ hasExtendedAttributes = true;
+ }
if(attribute.isPreferable()) {
preferableAttributes.put(attribute.getName(), attribute);
}
@@ -330,6 +389,9 @@
attributes.remove(attribute.getName());
preferableAttributes.remove(attribute.getName());
requiredAttributes.remove(attribute.getName());
+ if(hasExtendedAttributes) {
+ initExtendedAttributeFlag();
+ }
clearAttributeArrays();
}
@@ -342,11 +404,12 @@
return false;
}
- /**
- * @param extended
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.taglib.IComponent#getTagLib()
*/
- public void setExtended(boolean extended) {
- // Do nothing
+ public ITagLibrary getTagLib() {
+ return (ITagLibrary)parent;
}
/*
@@ -362,10 +425,23 @@
IAttribute[] as = getAttributes();
for (IAttribute a: as) {
copy.addAttribute(((AbstractAttribute)a).clone());
+ if(a.isExtended()) {
+ copy.hasExtendedAttributes = true;
+ }
}
return copy;
}
+ private void initExtendedAttributeFlag() {
+ synchronized (attributes) {
+ for (IAttribute a : attributes.values()) {
+ if(a.isExtended()) {
+ hasExtendedAttributes = true;
+ }
+ }
+ }
+ }
+
/*
* (non-Javadoc)
* @see
org.jboss.tools.jst.web.kb.internal.KbObject#merge(org.jboss.tools.jst.web.kb.internal.KbObject)
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-10
16:44:26 UTC (rev 15868)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java 2009-06-10
17:20:29 UTC (rev 15869)
@@ -48,7 +48,7 @@
protected INameSpace nameSpace;
protected String uri;
protected String version;
- protected boolean hasExtenededComponents = false;
+ protected boolean hasExtendedComponents = false;
private Map<String, IComponent> components = new HashMap<String,
IComponent>();
private IComponent[] componentsArray;
@@ -90,7 +90,7 @@
}
/* (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.taglib.TagLibrary#getComponents(org.jboss.tools.jst.web.kb.KbQuery,
org.jboss.tools.jst.web.kb.PageContext)
+ * @see
org.jboss.tools.jst.web.kb.taglib.ITagLibrary#getComponents(org.jboss.tools.jst.web.kb.KbQuery,
org.jboss.tools.jst.web.kb.PageContext)
*/
public IComponent[] getComponents(KbQuery query, IPageContext context) {
String prefix = getPrefix(query, context);
@@ -165,7 +165,7 @@
}
protected IComponent[] getExtendedComponents(IPageContext context) {
- if(hasExtenededComponents) {
+ if(hasExtendedComponents) {
Set<IComponent> comps = new HashSet<IComponent>();
synchronized(components) {
for (IComponent component : components.values()) {
@@ -187,7 +187,7 @@
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()) {
+ if(ac!=null && !ac.isExtended()) {
return true;
}
}
@@ -204,7 +204,7 @@
components.put(component.getName(), component);
componentsArray=null;
if(component.isExtended()) {
- hasExtenededComponents = true;
+ hasExtendedComponents = true;
}
}
@@ -215,7 +215,7 @@
this.components = components;
for (IComponent component : components.values()) {
if(component.isExtended()) {
- hasExtenededComponents = true;
+ hasExtendedComponents = true;
break;
}
}
@@ -372,7 +372,7 @@
t.components = new HashMap<String, IComponent>();
for (IComponent c: components.values()) {
if(c.isExtended()) {
- t.hasExtenededComponents = true;
+ t.hasExtendedComponents = true;
}
t.addComponent(((AbstractComponent)c).clone());
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibAttribute.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibAttribute.java 2009-06-10
16:44:26 UTC (rev 15868)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibAttribute.java 2009-06-10
17:20:29 UTC (rev 15869)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.jst.web.kb.internal.taglib;
+import org.jboss.tools.jst.web.kb.taglib.IComponent;
+
/**
* @author Alexey Kazakov
*/
@@ -18,6 +20,7 @@
protected boolean extended = true;
protected String defaultValue;
protected Proposal[] proposals;
+ protected CustomTagLibComponent parentComponent;
/*
* (non-Javadoc)
@@ -141,4 +144,20 @@
this.value = value;
}
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.taglib.IAttribute#getComponent()
+ */
+ @Override
+ public IComponent getComponent() {
+ return parentComponent;
+ }
+
+ /**
+ * @param parentComponent the parent component to set
+ */
+ public void setParentComponent(CustomTagLibComponent parentComponent) {
+ this.parentComponent = parentComponent;
+ }
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibComponent.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibComponent.java 2009-06-10
16:44:26 UTC (rev 15868)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibComponent.java 2009-06-10
17:20:29 UTC (rev 15869)
@@ -11,6 +11,7 @@
package org.jboss.tools.jst.web.kb.internal.taglib;
import org.jboss.tools.jst.web.kb.taglib.ICustomTagLibComponent;
+import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
/**
* @author Alexey Kazakov
@@ -18,11 +19,13 @@
public class CustomTagLibComponent extends AbstractComponent implements
ICustomTagLibComponent {
protected boolean extended = true;
+ protected CustomTagLibrary parentTagLib;
/*
* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.taglib.IComponent#isExtended()
*/
+ @Override
public boolean isExtended() {
return extended;
}
@@ -33,4 +36,20 @@
public void setExtended(boolean extended) {
this.extended = extended;
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.taglib.IComponent#getTagLib()
+ */
+ @Override
+ public ITagLibrary getTagLib() {
+ return parentTagLib;
+ }
+
+ /**
+ * @param parentTagLib the parent tag lib to set
+ */
+ public void setParentTagLib(CustomTagLibrary parentTagLib) {
+ this.parentTagLib = parentTagLib;
+ }
}
\ No newline at end of file
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-10
16:44:26 UTC (rev 15868)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibrary.java 2009-06-10
17:20:29 UTC (rev 15869)
@@ -102,11 +102,13 @@
newComponent.setCanHaveBody(!closeTag);
newComponent.setDescription(description);
newComponent.setExtended(extended);
+ newComponent.setParentTagLib(this);
// Extract attributes
CustomTagLibAttribute[] attributes = getAttributes(component);
for (int i = 0; i < attributes.length; i++) {
newComponent.addAttribute(attributes[i]);
+ attributes[i].setParentComponent(newComponent);
}
return newComponent;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/IAttribute.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/IAttribute.java 2009-06-10
16:44:26 UTC (rev 15868)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/IAttribute.java 2009-06-10
17:20:29 UTC (rev 15869)
@@ -45,7 +45,7 @@
boolean isExtended();
/**
- * @param extended
+ * @return parent component
*/
- void setExtended(boolean extended);
+ IComponent getComponent();
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/IComponent.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/IComponent.java 2009-06-10
16:44:26 UTC (rev 15868)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/IComponent.java 2009-06-10
17:20:29 UTC (rev 15869)
@@ -105,4 +105,9 @@
* @return
*/
boolean isExtended();
+
+ /**
+ * @return parent tag lib.
+ */
+ ITagLibrary getTagLib();
}
\ No newline at end of file