Author: Alex.Kolonitsky
Date: 2010-04-30 13:26:17 -0400 (Fri, 30 Apr 2010)
New Revision: 16857
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibWriter.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
Log:
RF-7826 Migrate A1 components to new CDK
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-04-30
16:52:02 UTC (rev 16856)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-04-30
17:26:17 UTC (rev 16857)
@@ -22,17 +22,13 @@
package org.richfaces.cdk;
-import static com.google.common.base.Preconditions.*;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.Writer;
-import java.nio.charset.Charset;
-import java.util.Collections;
-import java.util.Locale;
-import java.util.Map;
-
+import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.collect.Maps;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Stage;
+import com.google.inject.name.Names;
import org.richfaces.cdk.apt.AptModule;
import org.richfaces.cdk.generate.freemarker.FreeMakerModule;
import org.richfaces.cdk.generate.java.ClassGeneratorModule;
@@ -43,12 +39,14 @@
import org.richfaces.cdk.templatecompiler.TemplateModule;
import org.richfaces.cdk.xmlconfig.XmlModule;
-import com.google.common.collect.Maps;
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Stage;
-import com.google.inject.name.Names;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.Writer;
+import java.nio.charset.Charset;
+import java.util.Collections;
+import java.util.Locale;
+import java.util.Map;
/**
* @author asmirnov
@@ -62,6 +60,8 @@
private Logger log = new JavaLogger();
private Injector injector;
+
+ private String namespace;
private Locale locale = Locale.getDefault();
@@ -110,13 +110,13 @@
}
- public void init(){
+ public void init() {
injector = Guice.createInjector(Stage.PRODUCTION,
new CdkConfigurationModule(),
new AptModule(),
new ModelModule(),
+ new ClassGeneratorModule(),
new TagHandlerModule(),
- new ClassGeneratorModule(),
new FreeMakerModule(),
new TemplateModule(),
new XmlModule(),
@@ -163,6 +163,7 @@
bind(Logger.class).toInstance(log);
bind(Locale.class).toInstance(locale);
bind(Charset.class).toInstance(charset);
+ bind(Generator.class).toInstance(Generator.this);
for (Map.Entry<Outputs, FileManager> entry : outputFolders.entrySet())
{
bind(FileManager.class).annotatedWith(new
OutputImpl(entry.getKey())).toInstance(entry.getValue());
}
@@ -177,4 +178,12 @@
}
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java 2010-04-30
16:52:02 UTC (rev 16856)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java 2010-04-30
17:26:17 UTC (rev 16857)
@@ -84,7 +84,7 @@
}
private static final ImmutableCollection<String> COMPILER_OPTIONS =
- ImmutableList.of("-proc:only", "-implicit:class",
"-verbose");
+ ImmutableList.of("-proc:only", "-implicit:class"/*,
"-verbose"*/);
@Inject
private Logger log;
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-04-30
16:52:02 UTC (rev 16856)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-04-30
17:26:17 UTC (rev 16857)
@@ -80,11 +80,12 @@
faceletTaglib.addAttribute("xsi:schemaLocation",
"http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd");
faceletTaglib.addAttribute("version", "2.0");
- faceletTaglib.addAttribute("id", id); // TODO do it as param param
+ faceletTaglib.addAttribute("id", id); // TODO do it as param
-
faceletTaglib.addElement("namespace").addText("http://rich...;
// TODO do it as param param
+
faceletTaglib.addElement("namespace").addText("http://rich...
+ id); // TODO do it as param
}
+ @Override
public void visitComponent(ComponentModel model) {
for (TagModel tagModel : model.getTags()) {
if (TagType.Facelets != tagModel.getType()
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibWriter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibWriter.java 2010-04-30
16:52:02 UTC (rev 16856)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibWriter.java 2010-04-30
17:26:17 UTC (rev 16857)
@@ -28,6 +28,7 @@
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Generator;
import org.richfaces.cdk.Output;
import org.richfaces.cdk.Outputs;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -48,12 +49,12 @@
@Output(Outputs.RESOURCES)
private FileManager output;
- // TODO set it as parametr
- private String id = "a4j";
+ @Inject
+ private Generator generator;
@Override
public void render() throws CdkException {
- TaglibGeneratorVisitor visitor = new TaglibGeneratorVisitor(id);
+ TaglibGeneratorVisitor visitor = new
TaglibGeneratorVisitor(generator.getNamespace());
library.accept(visitor);
try {
@@ -70,7 +71,7 @@
protected Writer getOutput() throws CdkException {
try {
- return output.createOutput("META-INF/" + id +
".taglib.xml", library.lastModified());
+ return output.createOutput("META-INF/" + generator.getNamespace() +
".taglib.xml", library.lastModified());
} catch (IOException e) {
throw new CdkException(e);
}
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2010-04-30
16:52:02 UTC (rev 16856)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2010-04-30
17:26:17 UTC (rev 16857)
@@ -35,7 +35,6 @@
import org.apache.maven.model.FileSet;
import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
@@ -57,7 +56,7 @@
* @requiresDependencyResolution compile
* @phase generate-sources
*/
-public class GenerateMojo extends AbstractMojo {
+public class GenerateMojo extends AbstractCDKMojo {
private static final String[] JAVA_INCLUDES = new String[]{"**/*.java"};
private static final String MAIN_CONFIG = "src/main/config";
private static final String MAIN_TEMPLATES = "src/main/templates";
@@ -221,6 +220,7 @@
}
try {
+ generator.setNamespace(this.library.getTaglib().getShortName());
// Build JSF library.
// LibraryBuilder builder = LibraryBuilder.createInstance(context);
@@ -272,14 +272,14 @@
generator.addOutputFolder(type, directory);
}
- /**
- * <p class="changed_added_4_0">This method checks library
configuration and sets default values if necessary.</p>
- */
- protected void checkLibraryConfig() {
+// /**
+// * <p class="changed_added_4_0">This method checks library
configuration and sets default values if necessary.</p>
+// */
+// protected void checkLibraryConfig() {
+//
+// // TODO Auto-generated method stub
+// }
- // TODO Auto-generated method stub
- }
-
private File resolveRelativePath(File file) {
File result = file;
if (!result.isAbsolute()) {