Class TemplatesHelper

java.lang.Object
org.libreoffice.ide.eclipse.core.utils.TemplatesHelper

public class TemplatesHelper extends Object
Provides convenient methods to load, and save templates of Java source files into a target projet.

In order to generate the template foo/bar.java.tpl, the following call call be used, where LoadingClass is a class from which it is possible to run a getResource( "foo/bar.java.tpl" ) to get the file.

TemplatesHelper.copyTemplate( myProject, "foo/bar", LoadingClass.class );
  • Field Details

  • Constructor Details

    • TemplatesHelper

      public TemplatesHelper()
  • Method Details

    • copyTemplate

      public static void copyTemplate(IUnoidlProject project, String templateName, Class<?> clazz, String destSuffix, Object... args)
      Copies the template to the UNO project.
      Parameters:
      project - the project where to copy the file
      templateName - the template name (without the extension)
      clazz - the class from which to load the resource file
      destSuffix - the subpath in which the file should be copied, relatively to the implementation package.
      args - additional arguments to pass to the formatter
    • copyTemplate

      public static void copyTemplate(org.eclipse.core.resources.IProject project, String templateName, Class<?> clazz, String destPath, Object... args)
      Copies the template to the project.
      Parameters:
      project - the project where to copy the file
      templateName - the template name (without the extension)
      clazz - the class from which to load the resource file
      destPath - the path in which the file should be copied, relatively to the project root.
      args - additional arguments to pass to the formatter