Author: scabanovich
Date: 2009-05-18 11:19:13 -0400 (Mon, 18 May 2009)
New Revision: 15328
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDLibrary.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/scanner/ClassPathMonitor.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/LibraryScanner.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/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/taglib/IComponent.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/ITagLibrary.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-18
14:21:59 UTC (rev 15327)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2009-05-18
15:19:13 UTC (rev 15328)
@@ -85,6 +85,7 @@
public void setProject(IProject project) {
this.project = project;
+ classPath.init();
}
/**
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-18
14:21:59 UTC (rev 15327)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ClassPathMonitor.java 2009-05-18
15:19:13 UTC (rev 15328)
@@ -174,7 +174,6 @@
processedPaths.add(p);
LibraryScanner scanner = new LibraryScanner();
- scanner.setClassPath(this);
String fileName = new File(p).getName();
if(SYSTEM_JAR_SET.contains(fileName)) continue;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/LibraryScanner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/LibraryScanner.java 2009-05-18
14:21:59 UTC (rev 15327)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/LibraryScanner.java 2009-05-18
15:19:13 UTC (rev 15328)
@@ -23,17 +23,11 @@
* @author Viacheslav Kabanovich
*/
public class LibraryScanner implements IFileScanner {
- ClassPathMonitor classPath = null;
-
//Now it is absolute file on disk
IPath sourcePath = null;
public LibraryScanner() {}
- public void setClassPath(ClassPathMonitor classPath) {
- this.classPath = classPath;
- }
-
public boolean isRelevant(IFile f) {
if(EclipseResourceUtil.isJar(f.getName())) return true;
return false;
@@ -82,14 +76,30 @@
if(metaInf != null) {
XModelObject[] tlds = metaInf.getChildren();
for (XModelObject tld: tlds) {
- XMLScanner s = new XMLScanner();
- //TODO check that tld object is correct.
- LoadedDeclarations ds1 = s.parse(tld, path, sp);
- if(ds1 != null) ds.add(ds1);
+ if(isFaceletTaglibFile(tld) || isTLDFile(tld)) {
+ XMLScanner s = new XMLScanner();
+ LoadedDeclarations ds1 = s.parse(tld, path, sp);
+ if(ds1 != null) ds.add(ds1);
+ }
}
}
return ds;
}
+
+ public static boolean isTLDFile(XModelObject o) {
+ if(o == null) return false;
+ String entity = o.getModelEntity().getName();
+ if(entity.startsWith("FileTLD")) return true;
+ return false;
+ }
+
+ public static boolean isFaceletTaglibFile(XModelObject o) {
+ if(o == null) return false;
+ String entity = o.getModelEntity().getName();
+ if(entity.startsWith("FileFaceletTaglib")) return true;
+ return false;
+ }
}
+
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-18
14:21:59 UTC (rev 15327)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/XMLScanner.java 2009-05-18
15:19:13 UTC (rev 15328)
@@ -33,7 +33,10 @@
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.AbstractComponent;
+import org.jboss.tools.jst.web.kb.internal.taglib.TLDLibrary;
import org.jboss.tools.jst.web.model.helpers.InnerModelHelper;
+import org.jboss.tools.jst.web.model.project.ext.store.XMLValueInfo;
/**
* @author Viacheslav Kabanovich
@@ -49,8 +52,7 @@
* @return
*/
public boolean isRelevant(IFile resource) {
- if(resource.getName().equals("components.xml")) return true; //$NON-NLS-1$
- if(resource.getName().endsWith(".component.xml")) return true; //$NON-NLS-1$
+ if(resource.getName().endsWith(".xml")) return true; //$NON-NLS-1$
return false;
}
@@ -66,8 +68,7 @@
if(model == null) return false;
XModelObject o = EclipseResourceUtil.getObjectByResource(model, f);
if(o == null) return false;
- //TODO
- if(o.getModelEntity().getName().startsWith("FileSeamComponent")) return true;
//$NON-NLS-1$
+ if(LibraryScanner.isTLDFile(o) || LibraryScanner.isFaceletTaglibFile(o)) return true;
return false;
}
@@ -113,21 +114,66 @@
}
LoadedDeclarations ds = new LoadedDeclarations();
- XModelObject[] os = o.getChildren();
- for (int i = 0; i < os.length; i++) {
- XModelEntity componentEntity = os[i].getModelEntity();
- //TODO
-// if(os[i].getModelEntity().getName().startsWith("SeamFactory")) {
//$NON-NLS-1$
-// SeamXmlFactory factory = new SeamXmlFactory();
-// factory.setId(os[i]);
-// factory.setSourcePath(source);
-// factory.setName(new XMLValueInfo(os[i], ISeamXmlComponentDeclaration.NAME));
-// factory.setValue(new XMLValueInfo(os[i], "value")); //$NON-NLS-1$
-// factory.setMethod(new XMLValueInfo(os[i], "method")); //$NON-NLS-1$
-// ds.getLibraries().add(factory);
-// }
+ if(LibraryScanner.isTLDFile(o)) {
+ parseTLD(o, source, sp, ds);
+ } else if(LibraryScanner.isFaceletTaglibFile(o)) {
+ parseFaceletTaglib(o, source, sp, ds);
}
return ds;
}
-
+
+ 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.setShortName(new XMLValueInfo(o, "shortname"));
+ String version = o.getAttributeValue("version");
+ if(version == null) {
+ if("FileTLD_1_2".equals(o.getModelEntity().getName())) {
+ version = "1.2";
+ } else {
+ version = "1.1";
+ }
+ }
+ 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
+
+ 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);
+
+ //TODO
+
+ XModelObject[] as = t.getChildren();
+ for(XModelObject a: as) {
+ //TODO
+ }
+ }
+ }
+
+ }
+
+ private void parseFaceletTaglib(XModelObject o, IPath source, IKbProject sp,
LoadedDeclarations ds) {
+ XModelObject[] os = o.getChildren();
+
+ }
+
}
\ 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-18
14:21:59 UTC (rev 15327)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java 2009-05-18
15:19:13 UTC (rev 15328)
@@ -33,7 +33,6 @@
protected String componentType;
protected String description;
protected String name;
- protected INameSpace nameSpace;
protected Map<String, IAttribute> attributes = new HashMap<String,
IAttribute>();
protected Map<String, IAttribute> preferableAttributes = new HashMap<String,
IAttribute>();
protected Map<String, IAttribute> requiredAttributes = new HashMap<String,
IAttribute>();
@@ -160,20 +159,6 @@
}
/* (non-Javadoc)
- * @see org.jboss.tools.jst.web.kb.taglib.IComponent#getNameSpace()
- */
- public INameSpace getNameSpace() {
- return nameSpace;
- }
-
- /**
- * @param nameSpace the name space to set
- */
- public void setNameSpace(INameSpace nameSpace) {
- this.nameSpace = nameSpace;
- }
-
- /* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.taglib.IComponent#getPreferableAttributes()
*/
public IAttribute[] getPreferableAttributes() {
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-18
14:21:59 UTC (rev 15327)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java 2009-05-18
15:19:13 UTC (rev 15328)
@@ -18,11 +18,13 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
+import org.jboss.tools.common.model.project.ext.IValueInfo;
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.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;
/**
@@ -31,10 +33,14 @@
*/
public abstract class AbstractTagLib implements ITagLibrary {
+ protected INameSpace nameSpace;
protected String uri;
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()
*/
@@ -124,6 +130,20 @@
}
/* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.taglib.IComponent#getNameSpace()
+ */
+ public INameSpace getDefaultNameSpace() {
+ return nameSpace;
+ }
+
+ /**
+ * @param nameSpace the name space to set
+ */
+ public void setDefaultNameSpace(INameSpace nameSpace) {
+ this.nameSpace = nameSpace;
+ }
+
+ /* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.taglib.TagLibrary#getURI()
*/
public String getURI() {
@@ -137,6 +157,12 @@
this.uri = uri;
}
+ public void setURI(IValueInfo s) {
+ uri = s == null ? null : s.getValue();
+ attributes.put("uri", s);
+ }
+
+
/* (non-Javadoc)
* @see
org.jboss.tools.jst.web.kb.ProposalProcessor#getProposals(org.jboss.tools.jst.web.kb.KbQuery,
org.jboss.tools.jst.web.kb.PageContext)
*/
Added:
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
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDLibrary.java 2009-05-18
15:19:13 UTC (rev 15328)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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.common.model.project.ext.IValueInfo;
+import org.jboss.tools.jst.web.kb.taglib.ITLDLibrary;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class TLDLibrary extends AbstractTagLib implements ITLDLibrary {
+ String displayName = null;
+ String shortName = null;
+ String version = null;
+
+ public String displayName() {
+ return displayName;
+ }
+
+ public String getShortName() {
+ return shortName;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setDisplayName(IValueInfo s) {
+ displayName = s == null ? null : s.getValue();
+ attributes.put("display-name", s);
+ }
+
+ public void setShortName(IValueInfo s) {
+ shortName = s == null ? null : s.getValue();
+ attributes.put("short-name", s);
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public void createDefaultNameSpace() {
+
+ }
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/TLDLibrary.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/IComponent.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/IComponent.java 2009-05-18
14:21:59 UTC (rev 15327)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/IComponent.java 2009-05-18
15:19:13 UTC (rev 15328)
@@ -20,11 +20,6 @@
public interface IComponent extends IProposalProcessor {
/**
- * @return name space
- */
- INameSpace getNameSpace();
-
- /**
* @return component name
*/
String getName();
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/ITagLibrary.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/ITagLibrary.java 2009-05-18
14:21:59 UTC (rev 15327)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/ITagLibrary.java 2009-05-18
15:19:13 UTC (rev 15328)
@@ -25,6 +25,10 @@
public IPath getSourcePath();
/**
+ * @return name space
+ */
+ INameSpace getDefaultNameSpace();
+ /**
* @return URI of the tag lib.
*/
String getURI();