Author: scabanovich
Date: 2007-07-24 13:29:25 -0400 (Tue, 24 Jul 2007)
New Revision: 2638
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
Log:
EXIN-217 Default class name for a namespaced component contribution in components.xml is
provided.
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-07-24
17:24:49 UTC (rev 2637)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-07-24
17:29:25 UTC (rev 2638)
@@ -135,7 +135,12 @@
if(isClassAttributeSet(c)) {
component.setClassName(new XMLValueInfo(c, ISeamXmlComponentDeclaration.CLASS));
} else if(c.getModelEntity().getName().equals("FileSeamComponent12")) {
- component.setClassName(getImpliedComponentName(c, source));
+ component.setClassName(getImpliedClassName(c, source));
+ } else {
+ String className = getDefaultClassName(c);
+ if(className != null) {
+ component.setClassName(className);
+ }
}
component.setScope(new XMLValueInfo(c, ISeamXmlComponentDeclaration.SCOPE));
component.setPrecedence(new XMLValueInfo(c, ISeamXmlComponentDeclaration.PRECEDENCE));
@@ -231,7 +236,7 @@
return value != null && value.length() > 0;
}
- private String getImpliedComponentName(XModelObject c, IPath path) {
+ private String getImpliedClassName(XModelObject c, IPath path) {
if(path.toString().endsWith(".jar")) {
String suffix = ".component";
String cn = c.getAttributeValue("name");
@@ -241,7 +246,7 @@
cn = p.getAttributeValue("name") + "." + cn;
p = p.getParent();
}
- return cn;
+ return cn;
} else {
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
if(!f.exists()) return "";
@@ -249,12 +254,35 @@
if(!root.getLocation().isPrefixOf(f.getLocation())) return "";
String relative =
f.getLocation().toString().substring(root.getLocation().toString().length());
String suffix = ".component.xml";
- if(!relative.endsWith(suffix)) return null;
- relative = relative.substring(0, relative.length() - suffix.length());
- relative = relative.replace('\\', '/');
- if(relative.startsWith("/")) relative = relative.substring(1);
- return relative.replace('/', '.');
+ if(relative.endsWith(suffix)) {
+ relative = relative.substring(0, relative.length() - suffix.length());
+ relative = relative.replace('\\', '/');
+ if(relative.startsWith("/")) relative = relative.substring(1);
+ return relative.replace('/', '.');
+ }
}
+ return null;
}
+
+ /**
+ * This is only limited to supported namespaces provided by seam.
+ * @param c
+ * @return
+ */
+ private String getDefaultClassName(XModelObject c) {
+ String s = c.getModelEntity().getXMLSubPath();
+ int d = s.indexOf(':');
+ if(d < 0) return null;
+ String namespace = s.substring(0, d);
+ String tag = s.substring(d + 1);
+ String className = "org.jboss.seam." + namespace + ".";
+ String[] parts = tag.split("-");
+ if(parts != null) for (int i = 0; i < parts.length; i++) {
+ if(parts[i].length() < 1) continue;
+ String p = parts[i].substring(0, 1).toUpperCase() + parts[i].substring(1);
+ className += p;
+ }
+ return className;
+ }
}
\ No newline at end of file
Show replies by date