Author: scabanovich
Date: 2009-05-20 11:48:31 -0400 (Wed, 20 May 2009)
New Revision: 15366
Added:
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/taglib/TLDAttribute.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDTag.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbProjectFactory.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/KbXMLStoreConstants.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ClassPathMonitor.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/TLDLibrary.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/KbProjectFactory.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbProjectFactory.java 2009-05-20
15:01:44 UTC (rev 15365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/KbProjectFactory.java 2009-05-20
15:48:31 UTC (rev 15366)
@@ -17,12 +17,12 @@
public class KbProjectFactory {
/**
- * Factory method creating seam project instance by project resource.
+ * Factory method creating kb project instance by project resource.
* Returns null if
* (1) project does not exist
* (2) project is closed
- * (3) project has no seam nature
- * (4) creating seam project failed.
+ * (3) project has no kb nature
+ * (4) creating kb project failed.
* @param project
* @param resolve if true and results of last build have not been resolved they are
loaded.
* @return
Added:
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
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbObject.java 2009-05-20
15:48:31 UTC (rev 15366)
@@ -0,0 +1,236 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import java.util.Properties;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+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.common.xml.XMLUtilities;
+import org.jboss.tools.jst.web.kb.IKbProject;
+import org.jboss.tools.jst.web.model.project.ext.store.XMLStoreHelper;
+import org.w3c.dom.Element;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class KbObject {
+ /**
+ * Object that allows to identify this object.
+ */
+ protected Object id;
+
+ /**
+ * Path of resource where this object is declared.
+ */
+ protected IPath source;
+
+ /**
+ * Resource where this object is declared.
+ */
+ protected IResource resource = null;
+
+ /**
+ * Parent kb object in the kb model.
+ */
+ protected KbObject parent;
+
+ //locations of xml attributes
+ protected Map<String,IValueInfo> attributesInfo = new HashMap<String,
IValueInfo>();
+
+ public KbObject() {}
+
+ public IKbProject getKbProject() {
+ return parent == null ? null : parent.getKbProject();
+ }
+
+ public Object getId() {
+ return id;
+ }
+
+ /**
+ * Sets id for this object.
+ * For most objects it is object of Java or XML model
+ * from which this object is loaded.
+ */
+ public void setId(Object id) {
+ this.id = id;
+ }
+
+ /**
+ * Sets path of resource that declares this object.
+ */
+ public void setSourcePath(IPath path) {
+ source = path;
+ }
+
+ /**
+ * Returns path of resource that declares this object.
+ * @return
+ */
+ public IPath getSourcePath() {
+ if(source == null && parent != null) return parent.getSourcePath();
+ return source;
+ }
+
+ public IResource getResource() {
+ if(resource != null) return resource;
+ if(source != null) {
+ resource = ResourcesPlugin.getWorkspace().getRoot().getFile(source);
+ }
+ if(resource == null && parent != null) {
+ return parent.getResource();
+ }
+ return resource;
+ }
+
+ /**
+ * Returns parent object of kb model.
+ * @return
+ */
+ public KbObject getParent() {
+ return parent;
+ }
+
+ public void setParent(KbObject parent) {
+ this.parent = parent;
+ }
+
+ protected void adopt(KbObject child) {
+ if(child.getKbProject() != null && child.getKbProject() != getKbProject())
return;
+ ((KbObject)child).setParent(this);
+ }
+
+
+ /**
+ * Merges loaded object into current object.
+ * If changes were done returns a list of changes.
+ * If there are no changes, null is returned,
+ * which prevents creating a lot of unnecessary objects.
+ * @param f
+ * @return list of changes
+ */
+ public List<Change> merge(KbObject s) {
+ KbObject o = (KbObject)s;
+ source = o.source;
+ id = o.id;
+ resource = o.resource;
+ //If there are no changes, null is returned,
+ //which prevents creating a lot of unnecessary objects.
+ //Subclasses and clients must check returned
+ //value for null, before using it.
+ o.attributesInfo = new HashMap<String, IValueInfo>();
+ o.attributesInfo.putAll(attributesInfo);
+ return null;
+ }
+
+ public KbObject clone() throws CloneNotSupportedException {
+ KbObject c = (KbObject)super.clone();
+ c.parent = null;
+ //do not copy parent
+ return c;
+ }
+
+ //Serializing to XML
+
+ public String getXMLName() {
+ return "object";
+ }
+
+ public String getXMLClass() {
+ return null;
+ }
+
+ public Element toXML(Element parent, Properties context) {
+ Element element = XMLUtilities.createElement(parent, getXMLName());
+ if(getXMLClass() != null) {
+ element.setAttribute(XMLStoreConstants.ATTR_CLASS, getXMLClass());
+ }
+ if(source != null && !source.equals(context.get(XMLStoreConstants.ATTR_PATH)))
{
+ element.setAttribute(XMLStoreConstants.ATTR_PATH, source.toString());
+ }
+ if(id != null) {
+ if(id instanceof String) {
+ Element eid = XMLUtilities.createElement(element, XMLStoreConstants.TAG_ID);
+ eid.setAttribute(XMLStoreConstants.ATTR_CLASS, XMLStoreConstants.CLS_STRING);
+ eid.setAttribute(XMLStoreConstants.ATTR_VALUE, id.toString());
+ } else if(id instanceof XModelObject) {
+ XModelObject o = (XModelObject)id;
+ XMLStoreHelper.saveModelObject(element, o, XMLStoreConstants.TAG_ID, context);
+ } else {
+ //TODO consider other kinds of id
+ }
+ }
+ XModelObject old = pushModelObject(context);
+ XMLStoreHelper.saveMap(element, attributesInfo, "attributes", context);
+ popModelObject(context, old);
+ return element;
+ }
+
+ public void loadXML(Element element, Properties context) {
+ String s = element.getAttribute(XMLStoreConstants.ATTR_PATH);
+ if(s != null && s.length() > 0) {
+ source = new Path(s);
+ } else {
+ source = (IPath)context.get(XMLStoreConstants.ATTR_PATH);
+ }
+ Element e_id = XMLUtilities.getUniqueChild(element, XMLStoreConstants.TAG_ID);
+ if(e_id != null) {
+ String cls = e_id.getAttribute(XMLStoreConstants.ATTR_CLASS);
+ if(XMLStoreConstants.CLS_STRING.equals(cls)) {
+ id = e_id.getAttribute("string");
+ } else if(XMLStoreConstants.CLS_MODEL_OBJECT.equals(cls)) {
+ id = XMLStoreHelper.loadModelObject(e_id, context);
+ } else {
+ //TODO consider other kinds of id
+ }
+ }
+ XModelObject old = pushModelObject(context);
+ XMLStoreHelper.loadMap(element, attributesInfo, "attributes", context);
+ popModelObject(context, old);
+ }
+
+ protected XModelObject pushModelObject(Properties context) {
+ XModelObject old = (XModelObject)context.get(XMLStoreConstants.KEY_MODEL_OBJECT);
+
+ if(id instanceof XModelObject) {
+ context.put(XMLStoreConstants.KEY_MODEL_OBJECT, id);
+ }
+
+ return old;
+ }
+
+ protected void popModelObject(Properties context, XModelObject old) {
+ if(old != null) {
+ context.put(XMLStoreConstants.KEY_MODEL_OBJECT, old);
+ } else {
+ context.remove(XMLStoreConstants.KEY_MODEL_OBJECT);
+ }
+ }
+
+ protected boolean stringsEqual(String s1, String s2) {
+ return s1 == null ? s2 == null : s1.equals(s2);
+ }
+
+ public Object getAdapter(Class cls) {
+ return null;
+ }
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbObject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-20
15:01:44 UTC (rev 15365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2009-05-20
15:48:31 UTC (rev 15366)
@@ -15,6 +15,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -49,12 +50,12 @@
* @author V.Kabanovich
*
*/
-public class KbProject implements IKbProject {
+public class KbProject extends KbObject implements IKbProject {
IProject project;
ClassPathMonitor classPath = new ClassPathMonitor(this);
- Set<IPath> sourcePaths = new HashSet<IPath>();
+// Set<IPath> sourcePaths = new HashSet<IPath>();
Map<IPath, LoadedDeclarations> sourcePaths2 = new HashMap<IPath,
LoadedDeclarations>();
@@ -67,7 +68,7 @@
LibraryStorage libraries = new LibraryStorage();
public ITagLibrary[] getTagLibraries() {
- return libraries.getAllFactoriesArray();
+ return libraries.getAllLibrariesArray();
}
public void configure() throws CoreException {
@@ -82,12 +83,14 @@
return project;
}
- public IPath getSourcePath() {
- return project == null ? null : project.getFullPath();
+ public IKbProject getKbProject() {
+ return this;
}
public void setProject(IProject project) {
this.project = project;
+ setSourcePath(project.getFullPath());
+ resource = project;
classPath.init();
}
@@ -95,10 +98,10 @@
*
* @param p
*/
- public void addSeamProject(KbProject p) {
+ public void addKbProject(KbProject p) {
if(dependsOn.contains(p)) return;
dependsOn.add(p);
- p.addDependentSeamProject(this);
+ p.addDependentKbProject(this);
if(!p.isStorageResolved) {
p.resolve();
} else {
@@ -119,7 +122,7 @@
*
* @return
*/
- public Set<KbProject> getSeamProjects() {
+ public Set<KbProject> getKbProjects() {
return dependsOn;
}
@@ -127,7 +130,7 @@
*
* @param p
*/
- public void addDependentSeamProject(KbProject p) {
+ public void addDependentKbProject(KbProject p) {
usedBy.add(p);
}
@@ -135,7 +138,7 @@
*
* @param p
*/
- public void removeSeamProject(KbProject p) {
+ public void removeKbProject(KbProject p) {
if(!dependsOn.contains(p)) return;
p.usedBy.remove(this);
dependsOn.remove(p);
@@ -233,11 +236,11 @@
/**
- * Method testing how long it takes to load Seam model
+ * Method testing how long it takes to load Kb model
* serialized previously.
* This approach makes sure, that all other services
* (JDT, XModel, etc) are already loaded at first start of
- * Seam model, so that now it is more or less pure time
+ * Kb model, so that now it is more or less pure time
* to be computed.
*
* @return
@@ -245,7 +248,7 @@
public long reload() {
statistics = new ArrayList<Long>();
classPath = new ClassPathMonitor(this);
- sourcePaths.clear();
+// sourcePaths.clear();
sourcePaths2.clear();
isStorageResolved = false;
dependsOn.clear();
@@ -270,10 +273,9 @@
File file = getStorageFile();
file.getParentFile().mkdirs();
- Element root = XMLUtilities.createDocumentElement("seam-project");
//$NON-NLS-1$
+ Element root = XMLUtilities.createDocumentElement("kb-project");
//$NON-NLS-1$
storeProjectDependencies(root);
-// storeSourcePaths(root);
storeSourcePaths2(root);
XMLUtilities.serialize(root, file.getAbsolutePath());
@@ -308,7 +310,7 @@
KbProject sp = (KbProject)KbProjectFactory.getKbProject(project, false);
if(sp != null) {
dependsOn.add(sp);
- sp.addDependentSeamProject(this);
+ sp.addDependentKbProject(this);
}
}
}
@@ -330,7 +332,7 @@
private void loadSourcePaths2(Element root) {
Properties context = new Properties();
- context.put("seamProject", this);
+ context.put("kbProject", this);
Element sourcePathsElement = XMLUtilities.getUniqueChild(root, "paths");
//$NON-NLS-1$
if(sourcePathsElement == null) return;
Element[] paths = XMLUtilities.getChildren(sourcePathsElement, "path");
//$NON-NLS-1$
@@ -503,9 +505,70 @@
* @param source
*/
public void registerComponents(LoadedDeclarations ds, IPath source) {
+ ITagLibrary[] libraries = ds.getLibraries().toArray(new ITagLibrary[0]);
+
+ if(libraries.length == 0) {
+ pathRemoved(source);
+ if(EclipseResourceUtil.isJar(source.toString())) {
+// if(!sourcePaths.contains(source)) sourcePaths.add(source);
+ sourcePaths2.put(source, ds);
+ }
+ return;
+ }
+ sourcePaths2.put(source, ds);
+
+ Map<Object,ITagLibrary> currentLibraries = findLibraryDeclarations(source);
+ List<Change> addedLibraries = null;
+
+ for (ITagLibrary library: libraries) {
+ AbstractTagLib loaded = (AbstractTagLib)library;
+ AbstractTagLib current = (AbstractTagLib)currentLibraries.remove(loaded.getId());
+ if(current != null && current.getClass() != loaded.getClass()) {
+ this.libraries.removeLibrary((ITagLibrary)current);
+ current = null;
+ }
+ if(current != null) {
+ List<Change> changes = current.merge(loaded);
+ fireChanges(changes);
+ continue;
+ }
+ if(((KbObject)library).getParent() == null) {
+ adopt((KbObject)library);
+ }
+ this.libraries.addLibrary(library);
+ addedLibraries = Change.addChange(addedLibraries, new Change(this, null, null,
loaded));
+ }
+ fireChanges(addedLibraries);
+
+ libraryDeclarationsRemoved(currentLibraries);
//TODO
+ try {
+ registerComponentsInDependentProjects(ds, source);
+ } catch (CloneNotSupportedException e) {
+ WebModelPlugin.getPluginLog().logError(e);
+ }
}
+ /**
+ *
+ * @param ds
+ * @param source
+ * @throws CloneNotSupportedException
+ */
+ public void registerComponentsInDependentProjects(LoadedDeclarations ds, IPath source)
throws CloneNotSupportedException {
+ if(usedBy.isEmpty()) return;
+ if(EclipseResourceUtil.isJar(source.toString())) return;
+
+ for (KbProject p : usedBy) {
+ p.resolve();
+ LoadedDeclarations ds1 = new LoadedDeclarations();
+ for (ITagLibrary f : ds.getLibraries()) {
+ ds1.getLibraries().add(f.clone());
+ }
+ p.registerComponents(ds1, source);
+ }
+ }
+
public boolean isPathLoaded(IPath source) {
return sourcePaths2.containsKey(source);
}
@@ -516,12 +579,10 @@
* @param source
*/
public void pathRemoved(IPath source) {
- if(!sourcePaths.contains(source) && !sourcePaths2.containsKey(source)) return;
- sourcePaths.remove(source);
+ if(!sourcePaths2.containsKey(source)) return;
sourcePaths2.remove(source);
List<Change> changes = null;
- //TODO
Set<ITagLibrary> ls = libraries.removePath(source);
if(ls != null) for (ITagLibrary l: ls) {
@@ -529,9 +590,50 @@
}
fireChanges(changes);
-// firePathRemovedToDependentProjects(source);
+ firePathRemovedToDependentProjects(source);
}
+ public void firePathRemovedToDependentProjects(IPath source) {
+ if(usedBy.isEmpty()) return;
+ if(EclipseResourceUtil.isJar(source.toString())) return;
+
+ for (KbProject p : usedBy) {
+ p.resolve();
+ p.pathRemoved(source);
+ }
+ }
+
+ /**
+ *
+ * @param source
+ * @return
+ */
+ public Map<Object,ITagLibrary> findLibraryDeclarations(IPath source) {
+ Map<Object,ITagLibrary> map = new HashMap<Object, ITagLibrary>();
+ Set<ITagLibrary> fs = libraries.getLibrariesBySource(source);
+ if(fs != null) for (ITagLibrary c: fs) {
+ KbObject ci = (KbObject)c;
+ map.put(ci.getId(), c);
+ }
+ return map;
+ }
+
+ /**
+ *
+ * @param removed
+ */
+ void libraryDeclarationsRemoved(Map<Object,ITagLibrary> removed) {
+ if(removed == null || removed.isEmpty()) return;
+ Iterator<ITagLibrary> iterator = removed.values().iterator();
+ List<Change> changes = null;
+ while(iterator.hasNext()) {
+ ITagLibrary c = iterator.next();
+ libraries.removeLibrary(c);
+ changes = Change.addChange(changes, new Change(this, null, c, null));
+ }
+ fireChanges(changes);
+ }
+
List<Change> postponedChanges = null;
public void postponeFiring() {
@@ -559,77 +661,78 @@
}
//TODO
}
+
class LibraryStorage {
- private Set<ITagLibrary> allFactories = new HashSet<ITagLibrary>();
- private ITagLibrary[] allFactoriesArray = null;
- Map<IPath, Set<ITagLibrary>> factoriesBySource = new HashMap<IPath,
Set<ITagLibrary>>();
+ private Set<ITagLibrary> allLibraries = new HashSet<ITagLibrary>();
+ private ITagLibrary[] allLibrariesArray = null;
+ Map<IPath, Set<ITagLibrary>> librariesBySource = new HashMap<IPath,
Set<ITagLibrary>>();
public void clear() {
- synchronized(allFactories) {
- allFactories.clear();
- allFactoriesArray = null;
+ synchronized(allLibraries) {
+ allLibraries.clear();
+ allLibrariesArray = null;
}
- factoriesBySource.clear();
+ librariesBySource.clear();
}
- public ITagLibrary[] getAllFactoriesArray() {
- ITagLibrary[] result = allFactoriesArray;
+ public ITagLibrary[] getAllLibrariesArray() {
+ ITagLibrary[] result = allLibrariesArray;
if(result == null) {
- synchronized(allFactories) {
- allFactoriesArray = allFactories.toArray(new ITagLibrary[0]);
- result = allFactoriesArray;
+ synchronized(allLibraries) {
+ allLibrariesArray = allLibraries.toArray(new ITagLibrary[0]);
+ result = allLibrariesArray;
}
}
return result;
}
- public Set<ITagLibrary> getFactoriesBySource(IPath path) {
- return factoriesBySource.get(path);
+ public Set<ITagLibrary> getLibrariesBySource(IPath path) {
+ return librariesBySource.get(path);
}
- public void addFactory(ITagLibrary f) {
- synchronized(allFactories) {
- allFactories.add(f);
- allFactoriesArray = null;
+ public void addLibrary(ITagLibrary f) {
+ synchronized(allLibraries) {
+ allLibraries.add(f);
+ allLibrariesArray = null;
}
IPath path = f.getSourcePath();
if(path != null) {
- Set<ITagLibrary> fs = factoriesBySource.get(path);
+ Set<ITagLibrary> fs = librariesBySource.get(path);
if(fs == null) {
fs = new HashSet<ITagLibrary>();
- factoriesBySource.put(path, fs);
+ librariesBySource.put(path, fs);
}
fs.add(f);
}
}
- public void removeFactory(ITagLibrary f) {
- synchronized(allFactories) {
- allFactories.remove(f);
- allFactoriesArray = null;
+ public void removeLibrary(ITagLibrary f) {
+ synchronized(allLibraries) {
+ allLibraries.remove(f);
+ allLibrariesArray = null;
}
IPath path = f.getSourcePath();
if(path != null) {
- Set<ITagLibrary> fs = factoriesBySource.get(path);
+ Set<ITagLibrary> fs = librariesBySource.get(path);
if(fs != null) {
fs.remove(f);
}
if(fs.isEmpty()) {
- factoriesBySource.remove(fs);
+ librariesBySource.remove(fs);
}
}
}
public Set<ITagLibrary> removePath(IPath path) {
- Set<ITagLibrary> fs = factoriesBySource.get(path);
+ Set<ITagLibrary> fs = librariesBySource.get(path);
if(fs == null) return null;
for (ITagLibrary f: fs) {
- synchronized(allFactories) {
- allFactories.remove(f);
- allFactoriesArray = null;
+ synchronized(allLibraries) {
+ allLibraries.remove(f);
+ allLibrariesArray = null;
}
}
- factoriesBySource.remove(path);
+ librariesBySource.remove(path);
return fs;
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbXMLStoreConstants.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbXMLStoreConstants.java 2009-05-20
15:01:44 UTC (rev 15365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbXMLStoreConstants.java 2009-05-20
15:48:31 UTC (rev 15366)
@@ -19,6 +19,7 @@
public String TAG_LIBRARY = "library"; //$NON-NLS-1$
public String TAG_COMPONENT = "component"; //$NON-NLS-1$
+ public String TAG_ATTRIBUTE = "attribute"; //$NON-NLS-1$
public String CLS_TLD_LIBRARY = "tld"; //$NON-NLS-1$
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ClassPathMonitor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ClassPathMonitor.java 2009-05-20
15:01:44 UTC (rev 15365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ClassPathMonitor.java 2009-05-20
15:48:31 UTC (rev 15366)
@@ -40,7 +40,7 @@
import org.jboss.tools.jst.web.model.helpers.InnerModelHelper;
/**
- * Monitors class path of project and loads seam components of it.
+ * Monitors class path of project and loads kb components of it.
*
* @author Viacheslav Kabanovich
*/
@@ -54,7 +54,7 @@
Set<String> processedPaths = new HashSet<String>();
/**
- * Creates instance of class path for seam project
+ * Creates instance of class path for kb project
* @param project
*/
public ClassPathMonitor(KbProject project) {
@@ -62,7 +62,7 @@
}
/**
- * Returns seam project
+ * Returns kb project
* @return
*/
public KbProject getProject() {
@@ -158,7 +158,7 @@
}
/**
- * Loads seam components from items recently added to class path.
+ * Loads kb components from items recently added to class path.
*/
public void process() {
Iterator<String> it = processedPaths.iterator();
@@ -204,21 +204,21 @@
List<KbProject> ps = null;
try {
- ps = getSeamProjects(project.getProject());
+ ps = getKbProjects(project.getProject());
} catch (CoreException e) {
WebModelPlugin.getPluginLog().logError(e);
}
if(ps != null) {
- Set<KbProject> set = project.getSeamProjects();
+ Set<KbProject> set = project.getKbProjects();
Set<KbProject> removable = new HashSet<KbProject>();
removable.addAll(set);
removable.removeAll(ps);
ps.removeAll(set);
for (KbProject p : ps) {
- project.addSeamProject(p);
+ project.addKbProject(p);
}
for (KbProject p : removable) {
- project.removeSeamProject(p);
+ project.removeKbProject(p);
}
}
}
@@ -227,12 +227,12 @@
List<KbProject> ps = null;
try {
- ps = getSeamProjects(project.getProject());
+ ps = getKbProjects(project.getProject());
} catch (CoreException e) {
WebModelPlugin.getPluginLog().logError(e);
}
if(ps != null) {
- Set<KbProject> set = project.getSeamProjects();
+ Set<KbProject> set = project.getKbProjects();
Set<KbProject> removable = new HashSet<KbProject>();
removable.addAll(set);
removable.removeAll(ps);
@@ -252,7 +252,7 @@
project.registerComponents(c, path);
}
- List<KbProject> getSeamProjects(IProject project) throws CoreException {
+ List<KbProject> getKbProjects(IProject project) throws CoreException {
List<KbProject> list = new ArrayList<KbProject>();
IJavaProject javaProject = JavaCore.create(project);
IClasspathEntry[] es = javaProject.getResolvedClasspath(true);
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-20
15:01:44 UTC (rev 15365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/XMLScanner.java 2009-05-20
15:48:31 UTC (rev 15366)
@@ -29,12 +29,17 @@
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.impl.FolderImpl;
import org.jboss.tools.common.model.plugin.ModelPlugin;
+import org.jboss.tools.common.model.project.ext.store.XMLStoreConstants;
import org.jboss.tools.common.model.util.EclipseJavaUtil;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.model.util.NamespaceMapping;
import org.jboss.tools.jst.web.kb.IKbProject;
+import org.jboss.tools.jst.web.kb.internal.taglib.AbstractAttribute;
import org.jboss.tools.jst.web.kb.internal.taglib.AbstractComponent;
+import org.jboss.tools.jst.web.kb.internal.taglib.AbstractTagLib;
+import org.jboss.tools.jst.web.kb.internal.taglib.TLDAttribute;
import org.jboss.tools.jst.web.kb.internal.taglib.TLDLibrary;
+import org.jboss.tools.jst.web.kb.internal.taglib.TLDTag;
import org.jboss.tools.jst.web.model.helpers.InnerModelHelper;
import org.jboss.tools.jst.web.model.project.ext.store.XMLValueInfo;
@@ -124,48 +129,51 @@
private void parseTLD(XModelObject o, IPath source, IKbProject sp, LoadedDeclarations
ds) {
TLDLibrary library = new TLDLibrary();
- library.setURI(new XMLValueInfo(o, "uri"));
- library.setDisplayName(new XMLValueInfo(o, "display-name"));
+ library.setId(o);
+ library.setURI(new XMLValueInfo(o, AbstractTagLib.URI));
+ library.setDisplayName(new XMLValueInfo(o, TLDLibrary.DISPLAY_NAME));
library.setShortName(new XMLValueInfo(o, "shortname"));
- String version = o.getAttributeValue("version");
+ String version = o.getAttributeValue(TLDLibrary.VERSION);
if(version == null) {
if("FileTLD_1_2".equals(o.getModelEntity().getName())) {
version = "1.2";
} else {
version = "1.1";
}
+ library.setVersion(version);
+ } else {
+ library.setVersion(new XMLValueInfo(o, TLDLibrary.VERSION));
}
- library.setVersion(version);
ds.getLibraries().add(library);
XModelObject[] ts = o.getChildren();
for (XModelObject t: ts) {
if(t.getModelEntity().getName().startsWith("TLDTag")) {
- AbstractComponent tag = new AbstractComponent() {}; //TODO
+ AbstractComponent tag = new TLDTag();
+ tag.setId(t);
- String name = t.getAttributeValue("name");
- tag.setName(name);
-
- String description = t.getAttributeValue("description");
- if(description != null) {
- //in version 1.1 this attribute is not available
- tag.setDescription(description);
- }
-
- String cls = t.getAttributeValue("tagclass");
- tag.setComponentClass(cls);
-
- String bodycontent = t.getAttributeValue("bodycontent");
- boolean canHaveBody = !"empty".equals(bodycontent);
- tag.setCanHaveBody(canHaveBody);
-
+ tag.setName(new XMLValueInfo(t, XMLStoreConstants.ATTR_NAME));
+ tag.setDescription(new XMLValueInfo(t, AbstractComponent.DESCRIPTION));
+ tag.setComponentClass(new XMLValueInfo(t, "tagclass"));
+ tag.setCanHaveBody(new XMLValueInfo(t, "bodycontent"));
//TODO
+// tag.setComponentType(componentType);
XModelObject[] as = t.getChildren();
for(XModelObject a: as) {
- //TODO
+ if(a.getModelEntity().getName().startsWith("TLDAttribute")) {
+ AbstractAttribute attr = new TLDAttribute();
+ attr.setId(a);
+ attr.setName(new XMLValueInfo(a, XMLStoreConstants.ATTR_NAME));
+ attr.setDescription(new XMLValueInfo(a, AbstractComponent.DESCRIPTION));
+ attr.setRequired(new XMLValueInfo(a, AbstractAttribute.REQUIRED));
+
+ tag.addAttribute(attr);
+ }
}
+
+ library.addComponent(tag);
}
}
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-20
15:01:44 UTC (rev 15365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractAttribute.java 2009-05-20
15:48:31 UTC (rev 15366)
@@ -12,22 +12,29 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Properties;
import org.jboss.tools.common.el.core.resolver.ELResolver;
+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.common.text.TextProposal;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
+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.w3c.dom.Element;
/**
* Abstract implementation of IAttribute
* @author Alexey Kazakov
*/
-public abstract class AbstractAttribute implements IAttribute {
+public abstract class AbstractAttribute extends KbObject implements IAttribute {
+ public static final String REQUIRED = "required";
protected String description;
protected String name;
- protected boolean preferable;
protected boolean required;
/* (non-Javadoc)
@@ -44,6 +51,11 @@
this.description = description;
}
+ public void setDescription(IValueInfo s) {
+ description = s == null ? null : s.getValue();
+ attributesInfo.put(AbstractComponent.DESCRIPTION, s);
+ }
+
/* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.taglib.IAttribute#getName()
*/
@@ -58,20 +70,18 @@
this.name = name;
}
+ public void setName(IValueInfo s) {
+ name = s == null ? null : s.getValue();
+ attributesInfo.put(XMLStoreConstants.ATTR_NAME, s);
+ }
+
/* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.taglib.IAttribute#isPreferable()
*/
public boolean isPreferable() {
- return preferable;
+ return isRequired();
}
- /**
- * @param preferable the preferable to set
- */
- public void setPreferable(boolean preferable) {
- this.preferable = preferable;
- }
-
/* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.taglib.IAttribute#isRequired()
*/
@@ -86,6 +96,11 @@
this.required = required;
}
+ public void setRequired(IValueInfo s) {
+ required = s != null && "true".equals(s.getValue());
+ attributesInfo.put(REQUIRED, s);
+ }
+
/* (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)
*/
@@ -97,4 +112,52 @@
}
return proposals.toArray(new TextProposal[proposals.size()]);
}
+
+ public List<Change> merge(KbObject s) {
+ List<Change> changes = super.merge(s);
+
+ AbstractAttribute a = (AbstractAttribute)s;
+ if(!stringsEqual(name, a.name)) {
+ changes = Change.addChange(changes, new Change(this, XMLStoreConstants.ATTR_NAME,
name, a.name));
+ name = a.name;
+ }
+ if(!stringsEqual(description, a.description)) {
+ changes = Change.addChange(changes, new Change(this, AbstractComponent.DESCRIPTION,
description, a.description));
+ description = a.description;
+ }
+ if(required != a.required) {
+ changes = Change.addChange(changes, new Change(this, REQUIRED, "" +
required, "" + a.required));
+ required = a.required;
+ }
+
+ return changes;
+ }
+
+ public String getXMLName() {
+ return KbXMLStoreConstants.TAG_ATTRIBUTE;
+ }
+
+ public Element toXML(Element parent, Properties context) {
+ Element element = super.toXML(parent, context);
+
+ if(attributesInfo.get(XMLStoreConstants.ATTR_NAME) == null && name != null) {
+ element.setAttribute(XMLStoreConstants.ATTR_NAME, name);
+ }
+
+ return element;
+ }
+
+ public void loadXML(Element element, Properties context) {
+ super.loadXML(element, context);
+
+ 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
+ }
+
}
\ 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/AbstractComponent.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java 2009-05-20
15:01:44 UTC (rev 15365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java 2009-05-20
15:48:31 UTC (rev 15366)
@@ -16,11 +16,14 @@
import java.util.Map;
import java.util.Properties;
+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.common.text.TextProposal;
import org.jboss.tools.common.xml.XMLUtilities;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
+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;
@@ -31,7 +34,11 @@
* Abstract implementation of IComponent
* @author Alexey Kazakov
*/
-public abstract class AbstractComponent implements IComponent {
+public abstract class AbstractComponent extends KbObject implements IComponent {
+ public static final String DESCRIPTION = "description";
+ public static final String COMPONENT_CLASS = "component-class";
+ public static final String COMPONENT_TYPE = "component-type";
+ public static final String BODY_CONTENT = "bodycontent";
protected boolean canHaveBody;
protected String componentClass;
@@ -56,6 +63,11 @@
this.canHaveBody = canHaveBody;
}
+ public void setCanHaveBody(IValueInfo s) {
+ canHaveBody = s == null || "empty".equals(s.getValue());
+ attributesInfo.put(BODY_CONTENT, s);
+ }
+
/* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.taglib.IComponent#getAttribute(java.lang.String)
*/
@@ -121,6 +133,11 @@
this.componentClass = componentClass;
}
+ public void setComponentClass(IValueInfo s) {
+ componentClass = s == null ? null : s.getValue();
+ attributesInfo.put(COMPONENT_CLASS, s);
+ }
+
/* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.taglib.IComponent#getComponentType()
*/
@@ -149,6 +166,11 @@
this.description = description;
}
+ public void setDescription(IValueInfo s) {
+ description = s == null ? null : s.getValue();
+ attributesInfo.put(DESCRIPTION, s);
+ }
+
/* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.taglib.IComponent#getName()
*/
@@ -163,6 +185,11 @@
this.name = name;
}
+ public void setName(IValueInfo s) {
+ name = s == null ? null : s.getValue();
+ attributesInfo.put(XMLStoreConstants.ATTR_NAME, s);
+ }
+
/* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.taglib.IComponent#getPreferableAttributes()
*/
@@ -211,6 +238,7 @@
* @param attribute
*/
public void addAttribute(IAttribute attribute) {
+ adopt((KbObject)attribute);
attributes.put(attribute.getName(), attribute);
if(attribute.isPreferable()) {
preferableAttributes.put(attribute.getName(), attribute);
@@ -230,21 +258,105 @@
requiredAttributes.remove(attribute.getName());
}
- public String getXMLClass() {
- return null;
+ public List<Change> merge(KbObject s) {
+ List<Change> changes = super.merge(s);
+
+ AbstractComponent c = (AbstractComponent)s;
+ if(!stringsEqual(name, c.name)) {
+ changes = Change.addChange(changes, new Change(this, XMLStoreConstants.ATTR_NAME,
name, c.name));
+ name = c.name;
+ }
+ if(!stringsEqual(description, c.description)) {
+ changes = Change.addChange(changes, new Change(this, DESCRIPTION, description,
c.description));
+ description = c.description;
+ }
+ if(!stringsEqual(componentClass, c.componentClass)) {
+ changes = Change.addChange(changes, new Change(this, COMPONENT_CLASS, componentClass,
c.componentClass));
+ componentClass = c.componentClass;
+ }
+ if(!stringsEqual(componentType, c.componentType)) {
+ changes = Change.addChange(changes, new Change(this, COMPONENT_CLASS, componentType,
c.componentType));
+ componentType = c.componentType;
+ }
+ if(canHaveBody != c.canHaveBody) {
+ changes = Change.addChange(changes, new Change(this, BODY_CONTENT, "" +
canHaveBody, "" + c.canHaveBody));
+ canHaveBody = c.canHaveBody;
+ }
+
+ Change children = new Change(this, null, null, null);
+ mergeAttributes(c, children);
+ changes = Change.addChange(changes, children);
+
+ return changes;
}
+
+ 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()) {
+ AbstractAttribute loaded = (AbstractAttribute)a;
+ AbstractAttribute current = attributeMap.get(loaded.getId());
+ if(current == null) {
+ addAttribute(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 (IAttribute a: attributeMap.values()) {
+ AbstractAttribute removed = (AbstractAttribute)a;
+ if(attributes.get(removed.getName()) == removed) {
+ attributes.remove(removed.getName());
+ Change change = new Change(this, null, removed, null);
+ children.addChildren(Change.addChange(null, change));
+ }
+ }
+ }
+
+ public String getXMLName() {
+ return KbXMLStoreConstants.TAG_COMPONENT;
+ }
public Element toXML(Element parent, Properties context) {
- Element element = XMLUtilities.createElement(parent,
KbXMLStoreConstants.TAG_COMPONENT);
- if(getXMLClass() != null) {
- element.setAttribute(XMLStoreConstants.ATTR_CLASS, getXMLClass());
+ Element element = super.toXML(parent, context);
+
+ if(attributesInfo.get(XMLStoreConstants.ATTR_NAME) == null && name != null) {
+ element.setAttribute(XMLStoreConstants.ATTR_NAME, name);
}
-
+
+ for (IAttribute c: attributes.values()) {
+ ((KbObject)c).toXML(parent, context);
+ }
+
return element;
}
public void loadXML(Element element, Properties context) {
+ super.loadXML(element, context);
+
+ setName(attributesInfo.get(XMLStoreConstants.ATTR_NAME));
+ if(name == null && element.hasAttribute(XMLStoreConstants.ATTR_NAME)) {
+ name = element.getAttribute(XMLStoreConstants.ATTR_NAME);
+ }
+ //TODO
+ //componentType?
+ Element[] cs = XMLUtilities.getChildren(element, KbXMLStoreConstants.TAG_ATTRIBUTE);
+ for (Element e: cs) {
+ String cls = e.getAttribute(XMLStoreConstants.ATTR_CLASS);
+ AbstractAttribute c = null;
+ if(KbXMLStoreConstants.CLS_TLD_LIBRARY.equals(cls)) {
+ c = new TLDAttribute();
+ } else {
+ //consider other cases;
+ }
+ if(c != null) {
+ c.loadXML(e, context);
+ addAttribute(c);
+ }
+ }
}
}
\ 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/AbstractTagLib.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java 2009-05-20
15:01:44 UTC (rev 15365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java 2009-05-20
15:48:31 UTC (rev 15366)
@@ -20,7 +20,6 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.project.ext.IValueInfo;
import org.jboss.tools.common.model.project.ext.store.XMLStoreConstants;
@@ -28,31 +27,25 @@
import org.jboss.tools.common.xml.XMLUtilities;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
+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.kb.taglib.INameSpace;
import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
-import org.jboss.tools.jst.web.model.project.ext.store.XMLStoreHelper;
import org.w3c.dom.Element;
/**
* Abstract implementation of ITagLibrary
* @author Alexey Kazakov
*/
-public abstract class AbstractTagLib implements ITagLibrary {
+public abstract class AbstractTagLib extends KbObject implements ITagLibrary {
+ public static String URI = "uri";
- Object id;
-
protected INameSpace nameSpace;
protected String uri;
- protected IPath source;
- protected IFile resource;
protected Map<String, IComponent> components = new HashMap<String,
IComponent>();
- //locations of xml attributes
- protected Map<String,IValueInfo> attributes = new HashMap<String,
IValueInfo>();
-
/* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.taglib.TagLibrary#getAllComponents()
*/
@@ -109,6 +102,7 @@
* @param component
*/
public void addComponent(IComponent component) {
+ adopt((KbObject)component);
components.put(component.getName(), component);
}
@@ -175,7 +169,7 @@
public void setURI(IValueInfo s) {
uri = s == null ? null : s.getValue();
- attributes.put("uri", s);
+ attributesInfo.put(URI, s);
}
@@ -228,18 +222,6 @@
return proposals.toArray(new TextProposal[proposals.size()]);
}
- public void setID(Object id) {
- this.id = id;
- }
-
- public Object getID() {
- return id;
- }
-
- public String getXMLClass() {
- return null;
- }
-
public AbstractTagLib clone() throws CloneNotSupportedException {
AbstractTagLib t = (AbstractTagLib)super.clone();
t.components = new HashMap<String, IComponent>();
@@ -247,64 +229,55 @@
return t;
}
+ public String getXMLName() {
+ return KbXMLStoreConstants.TAG_LIBRARY;
+ }
+
public Element toXML(Element parent, Properties context) {
- Element element = XMLUtilities.createElement(parent, KbXMLStoreConstants.TAG_LIBRARY);
- if(getXMLClass() != null) {
- element.setAttribute(XMLStoreConstants.ATTR_CLASS, getXMLClass());
- }
- IPath source = getSourcePath();
- if(source != null && !source.equals(context.get(XMLStoreConstants.ATTR_PATH)))
{
- element.setAttribute(XMLStoreConstants.ATTR_PATH, source.toString());
- }
- if(id != null) {
- if(id instanceof XModelObject) {
- XModelObject o = (XModelObject)id;
- XMLStoreHelper.saveModelObject(element, o, XMLStoreConstants.TAG_ID, context);
- } else {
- //TODO consider other kinds of id
- }
- }
+ Element element = super.toXML(parent, context);
+ XModelObject old = pushModelObject(context);
+
saveAttributeValues(element);
for (IComponent c: components.values()) {
- //TODO save component
+ ((KbObject)c).toXML(parent, context);
}
+ popModelObject(context, old);
return element;
}
protected void saveAttributeValues(Element element) {
- if(uri != null) element.setAttribute(KbXMLStoreConstants.ATTR_URI, uri);
}
public void loadXML(Element element, Properties context) {
- String s = element.getAttribute(XMLStoreConstants.ATTR_PATH);
- if(s != null && s.length() > 0) {
- source = new Path(s);
- } else {
- source = (IPath)context.get(XMLStoreConstants.ATTR_PATH);
- }
- Element e_id = XMLUtilities.getUniqueChild(element, XMLStoreConstants.TAG_ID);
- if(e_id != null) {
- String cls = e_id.getAttribute(XMLStoreConstants.ATTR_CLASS);
- if(XMLStoreConstants.CLS_MODEL_OBJECT.equals(cls)) {
- id = XMLStoreHelper.loadModelObject(e_id, context);
+ super.loadXML(element, context);
+
+ XModelObject old = pushModelObject(context);
+
+ loadAttributeValues(element);
+
+ Element[] cs = XMLUtilities.getChildren(element, KbXMLStoreConstants.TAG_COMPONENT);
+ for (Element e: cs) {
+ String cls = e.getAttribute(XMLStoreConstants.ATTR_CLASS);
+ AbstractComponent c = null;
+ if(KbXMLStoreConstants.CLS_TLD_LIBRARY.equals(cls)) {
+ c = new TLDTag();
} else {
- //TODO consider other kinds of id
+ //consider other cases;
}
+ if(c != null) {
+ c.loadXML(e, context);
+ addComponent(c);
+ }
}
- loadAttributeValues(element);
-
- //TODO load components
-
+ popModelObject(context, old);
}
protected void loadAttributeValues(Element element) {
- if(element.hasAttribute(KbXMLStoreConstants.ATTR_URI)) {
- uri = element.getAttribute(KbXMLStoreConstants.ATTR_URI);
- }
+ setURI(attributesInfo.get(URI));
}
}
\ No newline at end of file
Added:
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
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDAttribute.java 2009-05-20
15:48:31 UTC (rev 15366)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.taglib;
+
+import org.jboss.tools.jst.web.kb.internal.KbXMLStoreConstants;
+
+public class TLDAttribute extends AbstractAttribute {
+
+ public String getXMLClass() {
+ return KbXMLStoreConstants.CLS_TLD_LIBRARY;
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDAttribute.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-20
15:01:44 UTC (rev 15365)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDLibrary.java 2009-05-20
15:48:31 UTC (rev 15366)
@@ -19,6 +19,10 @@
* @author Viacheslav Kabanovich
*/
public class TLDLibrary extends AbstractTagLib implements ITLDLibrary {
+ public static final String DISPLAY_NAME = "display-name";
+ public static final String SHORT_NAME = "short-name";
+ public static final String VERSION = "version";
+
String displayName = null;
String shortName = null;
String version = null;
@@ -37,18 +41,23 @@
public void setDisplayName(IValueInfo s) {
displayName = s == null ? null : s.getValue();
- attributes.put("display-name", s);
+ attributesInfo.put(DISPLAY_NAME, s);
}
public void setShortName(IValueInfo s) {
shortName = s == null ? null : s.getValue();
- attributes.put("short-name", s);
+ attributesInfo.put(SHORT_NAME, s);
}
public void setVersion(String version) {
this.version = version;
}
+ public void setVersion(IValueInfo s) {
+ version = s == null ? null : s.getValue();
+ attributesInfo.put(VERSION, s);
+ }
+
public void createDefaultNameSpace() {
}
@@ -59,14 +68,18 @@
protected void saveAttributeValues(Element element) {
super.saveAttributeValues(element);
- if(shortName != null) element.setAttribute(KbXMLStoreConstants.ATTR_SHORT_NAME,
shortName);
- //TODO
+ if(attributesInfo.get(VERSION) == null && version != null) {
+ element.setAttribute(VERSION, version);
+ }
}
protected void loadAttributeValues(Element element) {
super.loadAttributeValues(element);
- if(element.hasAttribute(KbXMLStoreConstants.ATTR_SHORT_NAME)) {
- shortName = element.getAttribute(KbXMLStoreConstants.ATTR_SHORT_NAME);
+ setShortName(attributesInfo.get(SHORT_NAME));
+ setDisplayName(attributesInfo.get(DISPLAY_NAME));
+ setVersion(attributesInfo.get(VERSION));
+ if(version == null && element.hasAttribute(VERSION)) {
+ version = element.getAttribute(VERSION);
}
//TODO
}
Added:
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
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDTag.java 2009-05-20
15:48:31 UTC (rev 15366)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.taglib;
+
+import org.jboss.tools.jst.web.kb.internal.KbXMLStoreConstants;
+
+public class TLDTag extends AbstractComponent {
+
+ public String getXMLClass() {
+ return KbXMLStoreConstants.CLS_TLD_LIBRARY;
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDTag.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain