Author: scabanovich
Date: 2009-05-19 12:58:17 -0400 (Tue, 19 May 2009)
New Revision: 15350
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbXMLStoreConstants.java
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/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/internal/KbProject.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2009-05-19
15:59:50 UTC (rev 15349)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2009-05-19
16:58:17 UTC (rev 15350)
@@ -30,6 +30,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
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.model.util.EclipseResourceUtil;
import org.jboss.tools.common.xml.XMLUtilities;
import org.jboss.tools.jst.web.WebModelPlugin;
@@ -38,6 +39,8 @@
import org.jboss.tools.jst.web.kb.WebKbPlugin;
import org.jboss.tools.jst.web.kb.internal.scanner.ClassPathMonitor;
import org.jboss.tools.jst.web.kb.internal.scanner.LoadedDeclarations;
+import org.jboss.tools.jst.web.kb.internal.taglib.AbstractTagLib;
+import org.jboss.tools.jst.web.kb.internal.taglib.TLDLibrary;
import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
import org.w3c.dom.Element;
@@ -281,7 +284,7 @@
*/
private File getStorageFile() {
IPath path = WebKbPlugin.getDefault().getStateLocation();
- File file = new File(path.toFile(), "projects/" + project.getName());
//$NON-NLS-1$
+ File file = new File(path.toFile(), "projects/" + project.getName() +
".xml"); //$NON-NLS-1$
return file;
}
@@ -342,16 +345,27 @@
if(f == null || !f.exists() || !f.isSynchronized(IResource.DEPTH_ZERO)) continue;
}
- //TODO
+ context.put(XMLStoreConstants.ATTR_PATH, path);
long t1 = System.currentTimeMillis();
LoadedDeclarations ds = new LoadedDeclarations();
Element libraries = XMLUtilities.getUniqueChild(paths[i], "libraries");
if(libraries != null) {
-
- //TODO
-
+ Element[] cs = XMLUtilities.getChildren(libraries, KbXMLStoreConstants.TAG_LIBRARY);
+ for (Element library: cs) {
+ String cls = library.getAttribute(XMLStoreConstants.ATTR_CLASS);
+ AbstractTagLib tagLib = null;
+ if(KbXMLStoreConstants.CLS_TLD_LIBRARY.equals(cls)) {
+ tagLib = new TLDLibrary();
+ } else {
+ //consider other cases;
+ }
+ if(tagLib != null) {
+ tagLib.loadXML(library, context);
+ ds.getLibraries().add(tagLib);
+ }
+ }
}
getClassPath().pathLoaded(path);
@@ -376,23 +390,23 @@
if(f != null && f.exists() && f.getProject() != project) {
continue;
}
- //TODO
-// context.put(SeamXMLConstants.ATTR_PATH, path);
+
+ context.put(XMLStoreConstants.ATTR_PATH, path);
LoadedDeclarations ds = sourcePaths2.get(path);
Element pathElement = XMLUtilities.createElement(sourcePathsElement,
"path"); //$NON-NLS-1$
pathElement.setAttribute("value", path.toString()); //$NON-NLS-1$
List<ITagLibrary> fs = ds.getLibraries();
if(fs != null && !fs.isEmpty()) {
- Element cse = XMLUtilities.createElement(pathElement, "factories");
//$NON-NLS-1$
+ Element cse = XMLUtilities.createElement(pathElement, "libraries");
//$NON-NLS-1$
for (ITagLibrary d: fs) {
- //TODO
-// SeamObject o = (SeamObject)d;
-// o.toXML(cse, context);
+ AbstractTagLib t = (AbstractTagLib)d;
+ t.toXML(cse, context);
}
}
}
}
+
/*
*
*/
Added:
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
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbXMLStoreConstants.java 2009-05-19
16:58:17 UTC (rev 15350)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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 org.jboss.tools.common.model.project.ext.store.XMLStoreConstants;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public interface KbXMLStoreConstants extends XMLStoreConstants {
+
+ public String TAG_LIBRARY = "library"; //$NON-NLS-1$
+ public String TAG_COMPONENT = "component"; //$NON-NLS-1$
+
+ public String CLS_TLD_LIBRARY = "tld"; //$NON-NLS-1$
+
+ public String ATTR_URI = "uri"; //$NON-NLS-1$
+ public String ATTR_SHORT_NAME = "short-name"; //$NON-NLS-1$
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbXMLStoreConstants.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/AbstractComponent.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java 2009-05-19
15:59:50 UTC (rev 15349)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java 2009-05-19
16:58:17 UTC (rev 15350)
@@ -14,13 +14,18 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
+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.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.w3c.dom.Element;
/**
* Abstract implementation of IComponent
@@ -224,4 +229,22 @@
preferableAttributes.remove(attribute.getName());
requiredAttributes.remove(attribute.getName());
}
+
+ public String getXMLClass() {
+ return null;
+ }
+
+ public Element toXML(Element parent, Properties context) {
+ Element element = XMLUtilities.createElement(parent,
KbXMLStoreConstants.TAG_COMPONENT);
+ if(getXMLClass() != null) {
+ element.setAttribute(XMLStoreConstants.ATTR_CLASS, getXMLClass());
+ }
+
+ return element;
+ }
+
+ public void loadXML(Element element, Properties context) {
+
+ }
+
}
\ 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-19
15:59:50 UTC (rev 15349)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java 2009-05-19
16:58:17 UTC (rev 15350)
@@ -14,18 +14,27 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import org.eclipse.core.resources.IFile;
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;
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.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
@@ -33,8 +42,11 @@
*/
public abstract class AbstractTagLib implements ITagLibrary {
+ Object id;
+
protected INameSpace nameSpace;
protected String uri;
+ protected IPath source;
protected IFile resource;
protected Map<String, IComponent> components = new HashMap<String,
IComponent>();
@@ -108,17 +120,21 @@
}
public IPath getSourcePath() {
- //TODO
- if(resource != null) {
- return resource.getFullPath();
- }
- return null;
+ return source;
}
+ public void setSourcePath(IPath source) {
+ this.source = source;
+ }
+
/* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.taglib.TagLibrary#getResource()
*/
public IResource getResource() {
+ if(resource != null) return resource;
+ if(source != null) {
+ resource = ResourcesPlugin.getWorkspace().getRoot().getFile(source);
+ }
return resource;
}
@@ -212,10 +228,83 @@
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>();
t.components.putAll(components);
return t;
}
+
+ 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
+ }
+ }
+
+ saveAttributeValues(element);
+
+ for (IComponent c: components.values()) {
+ //TODO save component
+ }
+
+ 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);
+ } else {
+ //TODO consider other kinds of id
+ }
+ }
+
+ loadAttributeValues(element);
+
+ //TODO load components
+
+ }
+
+ protected void loadAttributeValues(Element element) {
+ if(element.hasAttribute(KbXMLStoreConstants.ATTR_URI)) {
+ uri = element.getAttribute(KbXMLStoreConstants.ATTR_URI);
+ }
+ }
+
}
\ 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/TLDLibrary.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDLibrary.java 2009-05-19
15:59:50 UTC (rev 15349)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDLibrary.java 2009-05-19
16:58:17 UTC (rev 15350)
@@ -11,7 +11,9 @@
package org.jboss.tools.jst.web.kb.internal.taglib;
import org.jboss.tools.common.model.project.ext.IValueInfo;
+import org.jboss.tools.jst.web.kb.internal.KbXMLStoreConstants;
import org.jboss.tools.jst.web.kb.taglib.ITLDLibrary;
+import org.w3c.dom.Element;
/**
* @author Viacheslav Kabanovich
@@ -50,4 +52,23 @@
public void createDefaultNameSpace() {
}
+
+ public String getXMLClass() {
+ return KbXMLStoreConstants.CLS_TLD_LIBRARY;
+ }
+
+ protected void saveAttributeValues(Element element) {
+ super.saveAttributeValues(element);
+ if(shortName != null) element.setAttribute(KbXMLStoreConstants.ATTR_SHORT_NAME,
shortName);
+ //TODO
+ }
+
+ protected void loadAttributeValues(Element element) {
+ super.loadAttributeValues(element);
+ if(element.hasAttribute(KbXMLStoreConstants.ATTR_SHORT_NAME)) {
+ shortName = element.getAttribute(KbXMLStoreConstants.ATTR_SHORT_NAME);
+ }
+ //TODO
+ }
+
}