Author: scabanovich
Date: 2009-05-31 05:54:14 -0400 (Sun, 31 May 2009)
New Revision: 15619
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbObject.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/XMLScanner.java
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/ELFunction.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletTag.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletTagLibrary.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacesConfigAttribute.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacesConfigComponent.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacesConfigTagLibrary.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDAttribute.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDLibrary.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDTag.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/Facet.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/KbObject.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbObject.java 2009-05-30
21:59:40 UTC (rev 15618)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbObject.java 2009-05-31
09:54:14 UTC (rev 15619)
@@ -176,7 +176,7 @@
XModelObject o = (XModelObject)id;
XMLStoreHelper.saveModelObject(element, o, XMLStoreConstants.TAG_ID, context);
} else {
- //TODO consider other kinds of id
+ //consider other kinds of id
}
}
XModelObject old = pushModelObject(context);
@@ -204,7 +204,7 @@
} else if(XMLStoreConstants.CLS_MODEL_OBJECT.equals(cls)) {
id = XMLStoreHelper.loadModelObject(e_id, context);
} else {
- //TODO consider other kinds of id
+ //consider other kinds of id
}
}
XModelObject old = pushModelObject(context);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2009-05-30
21:59:40 UTC (rev 15618)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2009-05-31
09:54:14 UTC (rev 15619)
@@ -43,6 +43,7 @@
import org.jboss.tools.jst.web.kb.internal.taglib.AbstractTagLib;
import org.jboss.tools.jst.web.kb.internal.taglib.FaceletTagLibrary;
import org.jboss.tools.jst.web.kb.internal.taglib.TLDLibrary;
+import org.jboss.tools.jst.web.kb.taglib.ICustomTagLibrary;
import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
import org.w3c.dom.Element;
@@ -438,6 +439,7 @@
if(fs != null && !fs.isEmpty()) {
Element cse = XMLUtilities.createElement(pathElement, "libraries");
//$NON-NLS-1$
for (ITagLibrary d: fs) {
+ if(d instanceof ICustomTagLibrary) continue;
AbstractTagLib t = (AbstractTagLib)d;
t.toXML(cse, context);
}
@@ -577,7 +579,7 @@
fireChanges(addedLibraries);
libraryDeclarationsRemoved(currentLibraries);
- //TODO
+
try {
registerComponentsInDependentProjects(ds, source);
} catch (CloneNotSupportedException e) {
@@ -695,7 +697,7 @@
postponedChanges.addAll(changes);
return;
}
- //TODO
+ //TODO Implement if it will be needed events and listeners. and fire events to them.
}
class LibraryStorage {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/XMLScanner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/XMLScanner.java 2009-05-30
21:59:40 UTC (rev 15618)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/XMLScanner.java 2009-05-31
09:54:14 UTC (rev 15619)
@@ -10,9 +10,6 @@
******************************************************************************/
package org.jboss.tools.jst.web.kb.internal.scanner;
-import java.util.HashSet;
-import java.util.Set;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
@@ -44,7 +41,9 @@
* @author Viacheslav Kabanovich
*/
public class XMLScanner implements IFileScanner {
- public static final String ATTR_TAGCLASS ="tagclass"; //$NON-NLS-1$
+ public static final String ATTR_SHORTNAME = "shortname"; //$NON-NLS-1$
+ public static final String ATTR_TAGCLASS = "tagclass"; //$NON-NLS-1$
+ public static final String ATTR_TAG_NAME = "tag-name"; //$NON-NLS-1$
public static final String ATTR_BODY_CONTENT = "bodycontent"; //$NON-NLS-1$
public static final String ATTR_FACET_NAME = "facet-name"; //$NON-NLS-1$
public static final String ATTR_ATTRIBUTE_NAME = "attribute-name";
//$NON-NLS-1$
@@ -76,7 +75,9 @@
if(model == null) return false;
XModelObject o = EclipseResourceUtil.getObjectByResource(model, f);
if(o == null) return false;
- if(LibraryScanner.isTLDFile(o) || LibraryScanner.isFaceletTaglibFile(o)) return true;
+ if(LibraryScanner.isTLDFile(o)
+ || LibraryScanner.isFaceletTaglibFile(o)
+ || LibraryScanner.isFacesConfigFile(o)) return true;
return false;
}
@@ -93,14 +94,6 @@
return parse(o, f.getFullPath(), sp);
}
- static Set<String> INTERNAL_ATTRIBUTES = new HashSet<String>();
-
- static {
- INTERNAL_ATTRIBUTES.add("NAME"); //$NON-NLS-1$
- INTERNAL_ATTRIBUTES.add("EXTENSION"); //$NON-NLS-1$
- INTERNAL_ATTRIBUTES.add("#comment"); //$NON-NLS-1$
- }
-
public LoadedDeclarations parse(XModelObject o, IPath source, IKbProject sp) {
if(o == null) return null;
@@ -137,7 +130,7 @@
library.setId(o);
library.setURI(new XMLValueInfo(o, AbstractTagLib.URI));
library.setDisplayName(new XMLValueInfo(o, TLDLibrary.DISPLAY_NAME));
- library.setShortName(new XMLValueInfo(o, "shortname"));
+ library.setShortName(new XMLValueInfo(o, ATTR_SHORTNAME));
String version = o.getAttributeValue(TLDLibrary.VERSION);
if(version == null) {
if("FileTLD_1_2".equals(o.getModelEntity().getName())) {
@@ -162,8 +155,6 @@
tag.setDescription(new XMLValueInfo(t, AbstractComponent.DESCRIPTION));
tag.setComponentClass(new XMLValueInfo(t, ATTR_TAGCLASS));
tag.setCanHaveBody(new XMLValueInfo(t, ATTR_BODY_CONTENT));
- //TODO
-// tag.setComponentType(componentType);
XModelObject[] as = t.getChildren();
for(XModelObject a: as) {
@@ -197,7 +188,7 @@
if(entity.startsWith("FaceletTaglibTag")) {
FaceletTag tag = new FaceletTag();
tag.setId(t);
- tag.setName(new XMLValueInfo(t, "tag-name"));
+ tag.setName(new XMLValueInfo(t, ATTR_TAG_NAME));
library.addComponent(tag);
} else if(entity.startsWith("FaceletTaglibFunction")) {
ELFunction f = new ELFunction();
@@ -223,11 +214,11 @@
FacesConfigComponent component = new FacesConfigComponent();
component.setId(c);
//what else can we take for the name? only attribute 'component-type' is
available
- component.setName(new XMLValueInfo(c, "component-type"));
+ component.setName(new XMLValueInfo(c, AbstractComponent.COMPONENT_TYPE));
- component.setComponentClass(new XMLValueInfo(c, "component-class"));
- component.setComponentType(c.getAttributeValue("component-type"));
- component.setDescription(new XMLValueInfo(c, "description"));
+ component.setComponentClass(new XMLValueInfo(c, AbstractComponent.COMPONENT_CLASS));
+ component.setComponentType(new XMLValueInfo(c, AbstractComponent.COMPONENT_TYPE));
+ component.setDescription(new XMLValueInfo(c, AbstractComponent.DESCRIPTION));
XModelObject[] as = c.getChildren();
for (XModelObject child: as) {
@@ -235,8 +226,7 @@
if(entity.startsWith("JSFAttribute")) {
FacesConfigAttribute attr = new FacesConfigAttribute();
attr.setId(child);
- attr.setName(new XMLValueInfo(child, ATTR_ATTRIBUTE_NAME));
-
+ attr.setName(new XMLValueInfo(child, ATTR_ATTRIBUTE_NAME));
component.addAttribute(attr);
} else if(entity.startsWith("JSFFacet")) {
Facet f = new Facet();
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-05-30
21:59:40 UTC (rev 15618)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractAttribute.java 2009-05-31
09:54:14 UTC (rev 15619)
@@ -123,6 +123,10 @@
return proposals.toArray(new TextProposal[proposals.size()]);
}
+ public AbstractAttribute clone() throws CloneNotSupportedException {
+ return (AbstractAttribute)super.clone();
+ }
+
public List<Change> merge(KbObject s) {
List<Change> changes = super.merge(s);
@@ -160,14 +164,14 @@
public void loadXML(Element element, Properties context) {
super.loadXML(element, context);
+ setName(attributesInfo.get(XMLStoreConstants.ATTR_NAME));
+ setDescription(attributesInfo.get(AbstractComponent.DESCRIPTION));
+ setRequired(attributesInfo.get(REQUIRED));
+
if(name == null && element.hasAttribute(XMLStoreConstants.ATTR_NAME)) {
name = element.getAttribute(XMLStoreConstants.ATTR_NAME);
}
- setName(attributesInfo.get(XMLStoreConstants.ATTR_NAME));
- setDescription(attributesInfo.get(AbstractComponent.DESCRIPTION));
- setRequired(attributesInfo.get(REQUIRED));
- //TODO
}
@Override
@@ -181,7 +185,7 @@
@Override
protected void loadAttributesInfo(Element element, Properties context) {
- if(context.get(XMLStoreConstants.KEY_MODEL_OBJECT) == getId()) {
+ if(context.get(XMLStoreConstants.KEY_MODEL_OBJECT) == getId() && getId() !=
null) {
XModelObject a = (XModelObject)getId();
attributesInfo.put(XMLStoreConstants.ATTR_NAME, new XMLValueInfo(a,
XMLStoreConstants.ATTR_NAME));
attributesInfo.put(AbstractComponent.DESCRIPTION, new XMLValueInfo(a,
AbstractComponent.DESCRIPTION));
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-05-30
21:59:40 UTC (rev 15618)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java 2009-05-31
09:54:14 UTC (rev 15619)
@@ -152,6 +152,11 @@
this.componentType = componentType;
}
+ public void setComponentType(IValueInfo s) {
+ componentType = s == null ? null : s.getValue();
+ attributesInfo.put(COMPONENT_TYPE, s);
+ }
+
/* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.taglib.IComponent#getDescription()
*/
@@ -287,6 +292,18 @@
requiredAttributes.remove(attribute.getName());
}
+ public AbstractComponent clone() throws CloneNotSupportedException {
+ AbstractComponent copy = (AbstractComponent)super.clone();
+ copy.attributes = new HashMap<String, IAttribute>();
+ copy.preferableAttributes = new HashMap<String, IAttribute>();
+ copy.requiredAttributes = new HashMap<String, IAttribute>();
+ IAttribute[] as = getAttributes();
+ for (IAttribute a: as) {
+ copy.addAttribute(((AbstractAttribute)a).clone());
+ }
+ return copy;
+ }
+
public List<Change> merge(KbObject s) {
List<Change> changes = super.merge(s);
@@ -321,8 +338,8 @@
public void mergeAttributes(AbstractComponent c, Change children) {
Map<Object,AbstractAttribute> attributeMap = new HashMap<Object,
AbstractAttribute>();
- for (IAttribute a: attributes.values()) attributeMap.put(((KbObject)a).getId(),
(AbstractAttribute)a);
- for (IAttribute a: c.attributes.values()) {
+ for (IAttribute a: getAttributes()) attributeMap.put(((KbObject)a).getId(),
(AbstractAttribute)a);
+ for (IAttribute a: c.getAttributes()) {
AbstractAttribute loaded = (AbstractAttribute)a;
AbstractAttribute current = attributeMap.get(loaded.getId());
if(current == null) {
@@ -344,9 +361,6 @@
}
}
- public AbstractComponent clone() throws CloneNotSupportedException {
- return (AbstractComponent)super.clone();
- }
public String getXMLName() {
return KbXMLStoreConstants.TAG_COMPONENT;
}
@@ -358,7 +372,7 @@
element.setAttribute(XMLStoreConstants.ATTR_NAME, name);
}
- for (IAttribute c: attributes.values()) {
+ for (IAttribute c: getAttributes()) {
((KbObject)c).toXML(element, context);
}
@@ -375,9 +389,8 @@
setDescription(attributesInfo.get(DESCRIPTION));
setComponentClass(attributesInfo.get(COMPONENT_CLASS));
setCanHaveBody(attributesInfo.get(BODY_CONTENT));
+ setComponentType(attributesInfo.get(COMPONENT_TYPE));
- //TODO
- //componentType?
Element[] cs = XMLUtilities.getChildren(element, KbXMLStoreConstants.TAG_ATTRIBUTE);
for (Element e: cs) {
String cls = e.getAttribute(XMLStoreConstants.ATTR_CLASS);
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-05-30
21:59:40 UTC (rev 15618)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java 2009-05-31
09:54:14 UTC (rev 15619)
@@ -326,6 +326,8 @@
c = new TLDTag();
} else if(KbXMLStoreConstants.CLS_FACELET_LIBRARY.equals(cls)) {
c = new FaceletTag();
+ } else if(KbXMLStoreConstants.CLS_FACESCONFIG_LIBRARY.equals(cls)) {
+ c = new FacesConfigComponent();
} else {
//consider other cases;
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ELFunction.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ELFunction.java 2009-05-30
21:59:40 UTC (rev 15618)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ELFunction.java 2009-05-31
09:54:14 UTC (rev 15619)
@@ -77,7 +77,7 @@
@Override
protected void loadAttributesInfo(Element element, Properties context) {
- if(context.get(XMLStoreConstants.KEY_MODEL_OBJECT) == getId()) {
+ if(context.get(XMLStoreConstants.KEY_MODEL_OBJECT) == getId() && getId() !=
null) {
XModelObject a = (XModelObject)getId();
attributesInfo.put(XMLStoreConstants.ATTR_NAME, new XMLValueInfo(a,
XMLScanner.ATTR_FUNC_NAME));
attributesInfo.put(SIGNATURE, new XMLValueInfo(a, XMLScanner.ATTR_FUNC_SIGN));
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletTag.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletTag.java 2009-05-30
21:59:40 UTC (rev 15618)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletTag.java 2009-05-31
09:54:14 UTC (rev 15619)
@@ -21,4 +21,8 @@
return KbXMLStoreConstants.CLS_FACELET_LIBRARY;
}
+ public FaceletTag clone() throws CloneNotSupportedException {
+ return (FaceletTag)super.clone();
+ }
+
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletTagLibrary.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletTagLibrary.java 2009-05-30
21:59:40 UTC (rev 15618)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletTagLibrary.java 2009-05-31
09:54:14 UTC (rev 15619)
@@ -11,14 +11,15 @@
package org.jboss.tools.jst.web.kb.internal.taglib;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.jboss.tools.common.model.project.ext.event.Change;
import org.jboss.tools.common.xml.XMLUtilities;
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.Facet;
import org.jboss.tools.jst.web.kb.taglib.IELFunction;
import org.jboss.tools.jst.web.kb.taglib.IFaceletTagLibrary;
import org.w3c.dom.Element;
@@ -50,6 +51,7 @@
public FaceletTagLibrary clone() throws CloneNotSupportedException {
FaceletTagLibrary copy = (FaceletTagLibrary)super.clone();
copy.functions = new ArrayList<ELFunction>();
+ copy.functionArray = null;
for (IELFunction f: getFunctions()) {
copy.addFunction(((ELFunction)f).clone());
}
@@ -62,11 +64,42 @@
public List<Change> merge(KbObject s) {
List<Change> changes = super.merge(s);
- FacesConfigTagLibrary t = (FacesConfigTagLibrary)s;
- //TODO
+ FaceletTagLibrary t = (FaceletTagLibrary)s;
+ Change children = new Change(this, null, null, null);
+ mergeFunctions(t, children);
+ changes = Change.addChange(changes, children);
return changes;
}
+ public void mergeFunctions(FaceletTagLibrary c, Change children) {
+ Map<Object,ELFunction> functionMap = new HashMap<Object, ELFunction>();
+ for (IELFunction f: getFunctions()) functionMap.put(((KbObject)f).getId(),
(ELFunction)f);
+ for (IELFunction f: c.getFunctions()) {
+ ELFunction loaded = (ELFunction)f;
+ ELFunction current = functionMap.get(loaded.getId());
+ if(current == null) {
+ addFunction(loaded);
+ Change change = new Change(this, null, null, loaded);
+ children.addChildren(Change.addChange(null, change));
+ } else {
+ List<Change> rc = current.merge(loaded);
+ if(rc != null) children.addChildren(rc);
+ }
+ }
+ for (ELFunction f: functionMap.values()) {
+ ELFunction removed = f;
+ synchronized (functions) {
+ if(functions.contains(removed)) {
+ continue;
+ }
+ functions.remove(removed.getName());
+ functionArray = null;
+ }
+ Change change = new Change(this, null, removed, null);
+ children.addChildren(Change.addChange(null, change));
+ }
+ }
+
public Element toXML(Element parent, Properties context) {
Element element = super.toXML(parent, context);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacesConfigAttribute.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacesConfigAttribute.java 2009-05-30
21:59:40 UTC (rev 15618)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacesConfigAttribute.java 2009-05-31
09:54:14 UTC (rev 15619)
@@ -30,7 +30,7 @@
@Override
protected void loadAttributesInfo(Element element, Properties context) {
- if(context.get(XMLStoreConstants.KEY_MODEL_OBJECT) == getId()) {
+ if(context.get(XMLStoreConstants.KEY_MODEL_OBJECT) == getId() && getId() !=
null) {
XModelObject a = (XModelObject)getId();
attributesInfo.put(XMLStoreConstants.ATTR_NAME, new XMLValueInfo(a,
XMLScanner.ATTR_ATTRIBUTE_NAME));
attributesInfo.put(AbstractComponent.DESCRIPTION, new XMLValueInfo(a,
AbstractComponent.DESCRIPTION));
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacesConfigComponent.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacesConfigComponent.java 2009-05-30
21:59:40 UTC (rev 15618)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacesConfigComponent.java 2009-05-31
09:54:14 UTC (rev 15619)
@@ -38,10 +38,12 @@
public Facet[] getFacets() {
if(facetArray == null) {
- if(facets.isEmpty()) {
- facetArray = EMPTY_FACET_SET;
- } else {
- facetArray = facets.values().toArray(new Facet[0]);
+ synchronized (facets) {
+ if (facets.isEmpty()) {
+ facetArray = EMPTY_FACET_SET;
+ } else {
+ facetArray = facets.values().toArray(new Facet[0]);
+ }
}
}
return facetArray;
@@ -49,11 +51,12 @@
public Facet[] getFacets(String nameTemplate) {
Facet[] fs = getFacets();
- if(fs == null || fs.length == 0) return EMPTY_FACET_SET;
+ if(fs.length == 0) return EMPTY_FACET_SET;
List<Facet> result = new ArrayList<Facet>();
for (Facet f: fs) {
String name = f.getName();
- boolean match = false; //TODO implement
+ //TODO implement better matching name and nameTemplate
+ boolean match = name.startsWith(nameTemplate);
if(match) result.add(f);
}
return result.isEmpty() ? EMPTY_FACET_SET : result.toArray(new Facet[0]);
@@ -61,10 +64,21 @@
public void addFacet(Facet f) {
adopt((KbObject)f);
- facets.put(f.getName(), f);
- facetArray = null;
+ synchronized(facets) {
+ facets.put(f.getName(), f);
+ facetArray = null;
+ }
}
+ public FacesConfigComponent clone() throws CloneNotSupportedException {
+ FacesConfigComponent copy = new FacesConfigComponent();
+ copy.facets = new HashMap<String, Facet>();
+ for (Facet f: getFacets()) {
+ copy.addFacet(f.clone());
+ }
+ return copy;
+ }
+
public String getXMLClass() {
return KbXMLStoreConstants.CLS_FACESCONFIG_LIBRARY;
}
@@ -82,9 +96,9 @@
public void mergeFacets(FacesConfigComponent c, Change children) {
Map<Object,Facet> facetMap = new HashMap<Object, Facet>();
- for (Facet a: facets.values()) facetMap.put(((KbObject)a).getId(), a);
- for (Facet a: c.facets.values()) {
- Facet loaded = (Facet)a;
+ for (Facet f: getFacets()) facetMap.put(f.getId(), f);
+ for (Facet f: c.getFacets()) {
+ Facet loaded = f;
Facet current = facetMap.get(loaded.getId());
if(current == null) {
addFacet(loaded);
@@ -95,14 +109,17 @@
if(rc != null) children.addChildren(rc);
}
}
- for (Facet a: facetMap.values()) {
- Facet removed = a;
- if(facets.get(removed.getName()) == removed) {
+ for (Facet f: facetMap.values()) {
+ Facet removed = f;
+ synchronized (facets) {
+ if(facets.get(removed.getName()) != removed) {
+ continue;
+ }
facets.remove(removed.getName());
facetArray = null;
- Change change = new Change(this, null, removed, null);
- children.addChildren(Change.addChange(null, change));
}
+ Change change = new Change(this, null, removed, null);
+ children.addChildren(Change.addChange(null, change));
}
}
@@ -110,7 +127,7 @@
Element element = super.toXML(parent, context);
for (Facet f: getFacets()) {
- ((KbObject)f).toXML(element, context);
+ f.toXML(element, context);
}
return element;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacesConfigTagLibrary.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacesConfigTagLibrary.java 2009-05-30
21:59:40 UTC (rev 15618)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacesConfigTagLibrary.java 2009-05-31
09:54:14 UTC (rev 15619)
@@ -17,7 +17,6 @@
import org.jboss.tools.common.model.project.ext.event.Change;
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.Facet;
import org.jboss.tools.jst.web.kb.taglib.IComponent;
import org.jboss.tools.jst.web.kb.taglib.IFacesConfigTagLibrary;
@@ -46,19 +45,11 @@
public List<Change> merge(KbObject s) {
List<Change> changes = super.merge(s);
- FacesConfigTagLibrary t = (FacesConfigTagLibrary)s;
+// FacesConfigTagLibrary t = (FacesConfigTagLibrary)s;
- Change children = new Change(this, null, null, null);
- mergeFunctions(t, children);
- changes = Change.addChange(changes, children);
-
return changes;
}
- public void mergeFunctions(FacesConfigTagLibrary c, Change children) {
- //TODO
- }
-
public String getXMLClass() {
return KbXMLStoreConstants.CLS_FACESCONFIG_LIBRARY;
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDAttribute.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDAttribute.java 2009-05-30
21:59:40 UTC (rev 15618)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDAttribute.java 2009-05-31
09:54:14 UTC (rev 15619)
@@ -14,6 +14,10 @@
public class TLDAttribute extends AbstractAttribute {
+ public TLDAttribute clone() throws CloneNotSupportedException {
+ return (TLDAttribute)super.clone();
+ }
+
public String getXMLClass() {
return KbXMLStoreConstants.CLS_TLD_LIBRARY;
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDLibrary.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDLibrary.java 2009-05-30
21:59:40 UTC (rev 15618)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDLibrary.java 2009-05-31
09:54:14 UTC (rev 15619)
@@ -11,11 +11,11 @@
package org.jboss.tools.jst.web.kb.internal.taglib;
import java.util.List;
-
import org.jboss.tools.common.model.project.ext.IValueInfo;
import org.jboss.tools.common.model.project.ext.event.Change;
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.INameSpace;
import org.jboss.tools.jst.web.kb.taglib.ITLDLibrary;
import org.w3c.dom.Element;
@@ -63,7 +63,16 @@
}
public void createDefaultNameSpace() {
+ setDefaultNameSpace(new INameSpace() {
+ public String getURI() {
+ return uri;
+ }
+
+ public String getPrefix() {
+ return shortName;
+ }
+ });
}
public TLDLibrary clone() throws CloneNotSupportedException {
@@ -72,7 +81,19 @@
public List<Change> merge(KbObject s) {
List<Change> changes = super.merge(s);
- //TODO
+ TLDLibrary l = (TLDLibrary)s;
+ if(!stringsEqual(displayName, l.displayName)) {
+ changes = Change.addChange(changes, new Change(this, DISPLAY_NAME, displayName,
l.displayName));
+ displayName = l.displayName;
+ }
+ if(!stringsEqual(shortName, l.shortName)) {
+ changes = Change.addChange(changes, new Change(this, SHORT_NAME, shortName,
l.shortName));
+ shortName = l.shortName;
+ }
+ if(!stringsEqual(version, l.version)) {
+ changes = Change.addChange(changes, new Change(this, VERSION, version, l.version));
+ version = l.version;
+ }
return changes;
}
@@ -95,7 +116,6 @@
if(version == null && element.hasAttribute(VERSION)) {
version = element.getAttribute(VERSION);
}
- //TODO
}
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDTag.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDTag.java 2009-05-30
21:59:40 UTC (rev 15618)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDTag.java 2009-05-31
09:54:14 UTC (rev 15619)
@@ -36,13 +36,12 @@
@Override
protected void loadAttributesInfo(Element element, Properties context) {
- if(context.get(XMLStoreConstants.KEY_MODEL_OBJECT) == getId()) {
+ if(context.get(XMLStoreConstants.KEY_MODEL_OBJECT) == getId() && getId() !=
null) {
XModelObject a = (XModelObject)getId();
attributesInfo.put(XMLStoreConstants.ATTR_NAME, new XMLValueInfo(a,
XMLStoreConstants.ATTR_NAME));
attributesInfo.put(AbstractComponent.DESCRIPTION, new XMLValueInfo(a,
AbstractComponent.DESCRIPTION));
attributesInfo.put(COMPONENT_CLASS, new XMLValueInfo(a, XMLScanner.ATTR_TAGCLASS));
attributesInfo.put(BODY_CONTENT, new XMLValueInfo(a, XMLScanner.ATTR_BODY_CONTENT));
- //TODO other attributes as in XMLScanner
} else {
super.loadAttributesInfo(element, context);
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/Facet.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/Facet.java 2009-05-30
21:59:40 UTC (rev 15618)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/Facet.java 2009-05-31
09:54:14 UTC (rev 15619)
@@ -10,10 +10,12 @@
******************************************************************************/
package org.jboss.tools.jst.web.kb.taglib;
+import java.util.List;
import java.util.Properties;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.project.ext.IValueInfo;
+import org.jboss.tools.common.model.project.ext.event.Change;
import org.jboss.tools.common.model.project.ext.store.XMLStoreConstants;
import org.jboss.tools.jst.web.kb.internal.KbObject;
import org.jboss.tools.jst.web.kb.internal.KbXMLStoreConstants;
@@ -63,6 +65,24 @@
attributesInfo.put(AbstractComponent.DESCRIPTION, s);
}
+ public Facet clone() throws CloneNotSupportedException {
+ return (Facet)super.clone();
+ }
+
+ public List<Change> merge(KbObject s) {
+ List<Change> changes = super.merge(s);
+ Facet f = (Facet)s;
+ if(!stringsEqual(name, f.name)) {
+ changes = Change.addChange(changes, new Change(this, XMLStoreConstants.ATTR_NAME,
name, f.name));
+ name = f.name;
+ }
+ if(!stringsEqual(description, f.description)) {
+ changes = Change.addChange(changes, new Change(this, AbstractComponent.DESCRIPTION,
description, f.description));
+ description = f.description;
+ }
+ return changes;
+ }
+
public String getXMLName() {
return KbXMLStoreConstants.TAG_FACET;
}
@@ -99,7 +119,7 @@
@Override
protected void loadAttributesInfo(Element element, Properties context) {
- if(context.get(XMLStoreConstants.KEY_MODEL_OBJECT) == getId()) {
+ if(context.get(XMLStoreConstants.KEY_MODEL_OBJECT) == getId() && getId() !=
null) {
XModelObject a = (XModelObject)getId();
attributesInfo.put(XMLStoreConstants.ATTR_NAME, new XMLValueInfo(a,
XMLScanner.ATTR_FACET_NAME));
attributesInfo.put(AbstractComponent.DESCRIPTION, new XMLValueInfo(a,
AbstractComponent.DESCRIPTION));