diff --git a/.gitignore b/.gitignore index 496ee2c..d965513 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.DS_Store \ No newline at end of file +.DS_Store +.settings/org.eclipse.core.resources.prefs \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 0000000..e1380d0 --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + code2code-master + + + + + + + + diff --git a/CHANGES b/CHANGES index bf9907a..8805c41 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,13 @@ +[nnn] 0.10.7 + +choose generators dirs +new tree style + +[nnn] 0.10.0 + +allow overwrite +add save/load parameters + 0.9.2 better handling no generators found diff --git a/README.markdown b/README.markdown index d1763de..843f072 100644 --- a/README.markdown +++ b/README.markdown @@ -1,12 +1,14 @@ - # What it is -code2code is an eclipse plugin to generate source code from templates. +(nnn.)code2code is an eclipse plugin to generate source code from templates. You can easily create your custom generators using known template engines: Groovy (JSP like), Freemarker or Velocity. See it in action [here](http://elsethenif.wordpress.com/2009/06/12/quickly-cruding-with-code2code-plugin-and-vraptor2/). +Note: +nnn.code2code is a fork of [code2code](https://github.com/srizzo/code2code) with extra features (save/load parameters, allow overwride) + # Creating a Generator The files: @@ -14,7 +16,9 @@ The files: HelloWorld.generator |-- templates |-- HelloWorldTemplate.txt.ftl + |-- ListParams.ftl |-- templates.ftl + |-- postactions.ftl |-- params.ftl @@ -22,44 +26,55 @@ Contents of HelloWorldTemplate.txt.ftl: Hello ${name}!!! +Contents of ListParams.ftl: + + Print vars => name=${name} Contents of params.ftl: name=World - Contents of templates.ftl: templates/HelloWorldTemplate.txt.ftl=src/destinationPath/HelloWorld.txt + +Contents of postactions.ftl - + templates/ListParams.ftl # Usage Installing generators: just create a folder named "generators" at the root of your project, and place your generators there. -Running generators: The plugin adds a “Generate…” option to your project context menu (right-click menu). Run it, choose one of your installed generators, set its parameters, and the plugin will generate the files to the right place. +Running generators: The plugin adds a " Generate... " option to your project context menu (right-click menu). Run it, choose one of your installed generators, set its parameters, and the plugin will generate the files to the right place. See it in action here: [Quickly cruding with code2code plugin and VRaptor2](http://elsethenif.wordpress.com/2009/06/12/quickly-cruding-with-code2code-plugin-and-vraptor2/). +Inner params: + + +* eclipse_project_name : name of selected project +* eclipse_project_path : path of selected project +* eclipse_plugin_name : name of this plugin +* eclipse_plugin_version : version of this plugin # Installation -Current version is 0.9.2 beta, tested against Eclipse Ganymede 3.4.2. +Current version is 0.10.7, tested against Eclipse Kepler SR2. -You can install it from the [Update Site](http://srizzo.github.com/code2code/updatesite) +You can install it from the [Update Site](http://nnn-dev.github.com/code2code/updatesite) # Documentation -[http://wiki.github.com/srizzo/code2code](http://wiki.github.com/srizzo/code2code) +[http://wiki.github.com/nnn-dev/code2code](http://wiki.github.com/nnn-dev/code2code) # Issues/Features -[http://github.com/srizzo/code2code/issues](http://github.com/srizzo/code2code/issues) +[http://github.com/nnn-dev/code2code/issues](http://github.com/nnn-dev/code2code/issues) # Generator Examples -[http://github.com/srizzo/code2code-example-generators/downloads](http://github.com/srizzo/code2code-example-generators/downloads) +[http://github.com/nnn-dev/code2code-example-generators/downloads](http://github.com/nnn-dev/code2code-example-generators/downloads) diff --git a/code2code.feature/.gitignore b/code2code.feature/.gitignore index 3a4edf6..5e56e04 100644 --- a/code2code.feature/.gitignore +++ b/code2code.feature/.gitignore @@ -1 +1 @@ -.project +/bin diff --git a/code2code.feature/.project b/code2code.feature/.project new file mode 100644 index 0000000..7f608c5 --- /dev/null +++ b/code2code.feature/.project @@ -0,0 +1,17 @@ + + + code2code.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/code2code.feature/feature.xml b/code2code.feature/feature.xml index 21b04f6..9995caf 100644 --- a/code2code.feature/feature.xml +++ b/code2code.feature/feature.xml @@ -1,15 +1,16 @@ - - - - - http://srizzo.github.com/code2code - - - + + + + + http://nnn-dev.github.com/code2code + + + + Copyright (c) 2014 3Zen Copyright (c) 2009 Samuel Rizzo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation @@ -29,18 +30,18 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - - - - - - - - - +OTHER DEALINGS IN THE SOFTWARE. + + + + + + + + + diff --git a/code2code.tests/.project b/code2code.tests/.project new file mode 100644 index 0000000..b4ec127 --- /dev/null +++ b/code2code.tests/.project @@ -0,0 +1,11 @@ + + + code2code-tests + + + + + + + + diff --git a/code2code/.gitignore b/code2code/.gitignore index f07c66b..d403440 100644 --- a/code2code/.gitignore +++ b/code2code/.gitignore @@ -1,6 +1,5 @@ .DS_Store .classpath .git -.project .settings bin \ No newline at end of file diff --git a/code2code/META-INF/MANIFEST.MF b/code2code/META-INF/MANIFEST.MF index ebc552a..85ea061 100644 --- a/code2code/META-INF/MANIFEST.MF +++ b/code2code/META-INF/MANIFEST.MF @@ -1,9 +1,9 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: code2code Plug-in -Bundle-SymbolicName: code2code;singleton:=true -Bundle-Version: 0.9.2 -Bundle-Vendor: Samuel Rizzo +Bundle-Name: %Bundle-Name +Bundle-SymbolicName: nnn.code2code;singleton:=true +Bundle-Version: 0.10.7.2 +Bundle-Vendor: %Bundle-Vendor Bundle-RequiredExecutionEnvironment: J2SE-1.5 Require-Bundle: org.eclipse.ui, org.eclipse.core.resources;bundle-version="3.4.0", @@ -18,5 +18,151 @@ Bundle-ClassPath: lib/freemarker.jar, lib/velocity-1.6-dep.jar, lib/groovy-all-1.5.7.jar Export-Package: - code2code.ui.compare, - code2code.utils + code2code, + code2code.core.generator, + code2code.core.generatorfromfiles, + code2code.core.templateengine, + code2code.popupmenu, + code2code.preferences, + code2code.ui.compare;uses:="org.eclipse.swt.widgets,org.eclipse.jface.dialogs", + code2code.ui.wizards.generate, + code2code.ui.wizards.generatorfromfiles, + code2code.utils;uses:="org.eclipse.ui.console,org.eclipse.core.resources,org.eclipse.swt.widgets", + freemarker, + freemarker.cache, + freemarker.core, + freemarker.debug, + freemarker.debug.impl, + freemarker.ext.ant, + freemarker.ext.beans, + freemarker.ext.dom, + freemarker.ext.jdom, + freemarker.ext.jsp, + freemarker.ext.jython, + freemarker.ext.rhino, + freemarker.ext.servlet, + freemarker.ext.util, + freemarker.ext.xml, + freemarker.log, + freemarker.template, + freemarker.template.utility, + groovy.inspect, + groovy.inspect.swingui, + groovy.io, + groovy.lang, + groovy.mock, + groovy.mock.interceptor, + groovy.model, + groovy.security, + groovy.servlet, + groovy.sql, + groovy.swing, + groovy.swing.binding, + groovy.swing.factory, + groovy.swing.impl, + groovy.text, + groovy.time, + groovy.ui, + groovy.ui.icons, + groovy.ui.text, + groovy.ui.view, + groovy.util, + groovy.util.slurpersupport, + groovy.xml, + groovy.xml.dom, + groovy.xml.streamingmarkupsupport, + groovyjarjarantlr, + groovyjarjarantlr.ASdebug, + groovyjarjarantlr.actions.cpp, + groovyjarjarantlr.actions.csharp, + groovyjarjarantlr.actions.java, + groovyjarjarantlr.actions.python, + groovyjarjarantlr.build, + groovyjarjarantlr.collections, + groovyjarjarantlr.collections.impl, + groovyjarjarantlr.debug, + groovyjarjarantlr.debug.misc, + groovyjarjarantlr.preprocessor, + groovyjarjarasm.asm, + groovyjarjarasm.asm.signature, + groovyjarjarasm.asm.tree, + groovyjarjarcommonscli, + org.apache.commons.collections, + org.apache.commons.collections.iterators, + org.apache.commons.collections.map, + org.apache.commons.lang, + org.apache.commons.lang.builder, + org.apache.commons.lang.enums, + org.apache.commons.lang.exception, + org.apache.commons.lang.math, + org.apache.commons.lang.mutable, + org.apache.commons.lang.text, + org.apache.commons.lang.time, + org.apache.oro.io, + org.apache.oro.text, + org.apache.oro.text.awk, + org.apache.oro.text.perl, + org.apache.oro.text.regex, + org.apache.oro.util, + org.apache.velocity, + org.apache.velocity.anakia, + org.apache.velocity.app, + org.apache.velocity.app.event, + org.apache.velocity.app.event.implement, + org.apache.velocity.app.tools, + org.apache.velocity.context, + org.apache.velocity.convert, + org.apache.velocity.exception, + org.apache.velocity.io, + org.apache.velocity.runtime, + org.apache.velocity.runtime.defaults, + org.apache.velocity.runtime.directive, + org.apache.velocity.runtime.log, + org.apache.velocity.runtime.parser, + org.apache.velocity.runtime.parser.node, + org.apache.velocity.runtime.resource, + org.apache.velocity.runtime.resource.loader, + org.apache.velocity.runtime.resource.util, + org.apache.velocity.runtime.visitor, + org.apache.velocity.servlet, + org.apache.velocity.texen, + org.apache.velocity.texen.ant, + org.apache.velocity.texen.defaults, + org.apache.velocity.texen.util, + org.apache.velocity.util, + org.apache.velocity.util.introspection, + org.codehaus.groovy, + org.codehaus.groovy.ant, + org.codehaus.groovy.antlr, + org.codehaus.groovy.antlr.java, + org.codehaus.groovy.antlr.parser, + org.codehaus.groovy.antlr.treewalker, + org.codehaus.groovy.ast, + org.codehaus.groovy.ast.expr, + org.codehaus.groovy.ast.stmt, + org.codehaus.groovy.binding, + org.codehaus.groovy.bsf, + org.codehaus.groovy.classgen, + org.codehaus.groovy.control, + org.codehaus.groovy.control.io, + org.codehaus.groovy.control.messages, + org.codehaus.groovy.groovydoc, + org.codehaus.groovy.reflection, + org.codehaus.groovy.reflection.stdclasses, + org.codehaus.groovy.runtime, + org.codehaus.groovy.runtime.metaclass, + org.codehaus.groovy.runtime.typehandling, + org.codehaus.groovy.runtime.wrappers, + org.codehaus.groovy.syntax, + org.codehaus.groovy.tools, + org.codehaus.groovy.tools.groovydoc, + org.codehaus.groovy.tools.javac, + org.codehaus.groovy.tools.shell, + org.codehaus.groovy.tools.shell.commands, + org.codehaus.groovy.tools.shell.util, + org.codehaus.groovy.tools.xml, + org.codehaus.groovy.vmplugin, + org.codehaus.groovy.vmplugin.v4, + org.codehaus.groovy.vmplugin.v5 +Bundle-Activator: code2code.Activator +Bundle-ActivationPolicy: lazy diff --git a/code2code/OSGI-INF/l10n/bundle.properties b/code2code/OSGI-INF/l10n/bundle.properties new file mode 100644 index 0000000..c17c800 --- /dev/null +++ b/code2code/OSGI-INF/l10n/bundle.properties @@ -0,0 +1,9 @@ +#Properties file for nnn.code2code +Bundle-Vendor = 3Zen (original = Samuel Rizzo) +Bundle-Name = code2code Plug-in modified by 3Zen +wizard.name = File(s) from Template +action.generate = Generate... +action.creategenerator = Create generator from selected files... +page.name = nnn.code2code +transfer.name = nnn.code2code Preferences +transfer.description = nnn.code2code preferences \ No newline at end of file diff --git a/code2code/build.properties b/code2code/build.properties index cf57f0d..ca3be5f 100644 --- a/code2code/build.properties +++ b/code2code/build.properties @@ -6,4 +6,5 @@ bin.includes = META-INF/,\ lib/freemarker.jar,\ icons/,\ lib/velocity-1.6-dep.jar,\ - lib/groovy-all-1.5.7.jar + lib/groovy-all-1.5.7.jar,\ + OSGI-INF/l10n/bundle.properties diff --git a/code2code/plugin.xml b/code2code/plugin.xml index 4c6d9ba..11ae343 100644 --- a/code2code/plugin.xml +++ b/code2code/plugin.xml @@ -11,7 +11,7 @@ category="code2code.category" class="code2code.ui.wizards.generate.GenerateFilesWizard" id="code2code.newWizard" - name="File(s) from Template"> + name="%wizard.name"> @@ -45,10 +45,40 @@ class="code2code.popupmenu.CreateGeneratorAction" enablesFor="*" id="code2code.createGeneratorAction" - label="Create generator from selected files..." + label="%action.creategenerator" menubarPath="code2code"> - - + + + + + + + + + + + + + + + + + + %transfer.description + + + + diff --git a/code2code/src/code2code/Activator.java b/code2code/src/code2code/Activator.java new file mode 100644 index 0000000..cfc79bd --- /dev/null +++ b/code2code/src/code2code/Activator.java @@ -0,0 +1,58 @@ +package code2code; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "nnn.code2code"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} diff --git a/code2code/src/code2code/core/generator/Generator.java b/code2code/src/code2code/core/generator/Generator.java index 91e3398..ceafe33 100644 --- a/code2code/src/code2code/core/generator/Generator.java +++ b/code2code/src/code2code/core/generator/Generator.java @@ -1,15 +1,24 @@ package code2code.core.generator; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.TreeMap; import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; public class Generator { - + final private IFolder generatorFolder; - + final private DescriptionConfig descriptionConfig; final private GlobalParamsConfig globalParamsConfig; final private ParamsConfig paramsConfig; @@ -18,88 +27,158 @@ public class Generator { final private List nestedGenerators; final private List