Class KitUtilities


  • public class KitUtilities
    extends java.lang.Object
    Utility functions for creating new wizard kits.
    Since:
    3.0
    Author:
    Chris Jennings
    See Also:
    PluginWizardDialog.WizardKit
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.io.File getFile​(Task t, NamePage np, java.lang.String path)
      Returns a File object for a file within a plug-in within the given task folder.
      static java.lang.String getResourcePath​(NamePage np, java.lang.String path)
      Returns the path to a resource file in the plug-in, taking into account the base location set on a NamePage.
      static java.lang.String getTemplateText​(java.lang.String templateFileName)
      Returns the text of a template file stored in resources/projects/pluginwizard.
      static void makeTaskFolders​(Task t, NamePage np, java.lang.String path)
      Creates one or more subfolders in a task folder.
      static void setBundleName​(Task t, java.lang.String bundleFileName)
      Sets the file name used for a task's plug-in bundle when the Make Bundle action is applied to it.
      static void setBundleName​(Task t, NamePage np)
      Sets the file name used for a task's plug-in bundle when the Make Bundle action is applied to it.
      static void setPluginTypeConditionals​(SETemplateProcessor proc, ContentType type)
      Sets conditional variables in a template processor based on the plug-in type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • makeTaskFolders

        public static void makeTaskFolders​(Task t,
                                           NamePage np,
                                           java.lang.String path)
                                    throws java.io.IOException
        Creates one or more subfolders in a task folder. If path is null, then this will create the plug-in's base location, the location identified by the "Location" field of NamePage. Typically, this is something like resources/myplugin. If path is non-null, then it will create a subfolder (using path as the name) within the base location. If path contains one or more slashes (/), then the entire path will be created. For example, "fonts/body" would create a fonts folder in the base location, and a body folder within the fonts folder.

        If the name page np is null, then the task folder is used as the base location.

        If a folder that would have been created by this method already exists, the creation of that folder is skipped without causing an exception.

        Parameters:
        t - the task that is being created
        np - a name page that allowed the user to describe basic data about the plug-in task
        path - the path to create within the base location
        Throws:
        java.io.IOException - if an error occurs while creating the folders
      • getTemplateText

        public static java.lang.String getTemplateText​(java.lang.String templateFileName)
                                                throws java.io.IOException
        Returns the text of a template file stored in resources/projects/pluginwizard.
        Parameters:
        templateFileName - the name of the template file
        Returns:
        the text of the template
        Throws:
        java.io.IOException - if an error occurs while reading the template
      • setPluginTypeConditionals

        public static void setPluginTypeConditionals​(SETemplateProcessor proc,
                                                     ContentType type)
        Sets conditional variables in a template processor based on the plug-in type. The conditional variables are isActivated, isInjected, isExtension, isLibrary, and isTheme.
        Parameters:
        proc - the processor to set conditional variables in
        type - the plug-in type that will determine the values of the conditionals
      • setBundleName

        public static void setBundleName​(Task t,
                                         java.lang.String bundleFileName)
        Sets the file name used for a task's plug-in bundle when the Make Bundle action is applied to it.
        Parameters:
        t - the task whose bundle file should be set
        bundleFileName - the file name for the bundle
      • setBundleName

        public static void setBundleName​(Task t,
                                         NamePage np)
        Sets the file name used for a task's plug-in bundle when the Make Bundle action is applied to it. This method uses the file name supplied by the user on a NamePage.
        Parameters:
        t - the task whose bundle file should be set
        np - the name page containing the bundle name
      • getFile

        public static java.io.File getFile​(Task t,
                                           NamePage np,
                                           java.lang.String path)
        Returns a File object for a file within a plug-in within the given task folder. If the name page is non-null, then the base location given on that page will be the parent of the file. Otherwise, the task folder will be the parent of the file. The path argument specifies a path relative to this parent and ending in the file of interest.
        Parameters:
        t - the task folder that contains the plug-in files
        np - if non-null, used to determine the base location within the task
        path - a path indicating the desired file location, using / to separate folders
        Returns:
        the specified file within the task folder
      • getResourcePath

        public static java.lang.String getResourcePath​(NamePage np,
                                                       java.lang.String path)
        Returns the path to a resource file in the plug-in, taking into account the base location set on a NamePage.
        Parameters:
        np - the name page where the user set a base location
        path - the path relative to the base location, e.g., icons/up.png
        Returns:
        the complete resource path, e.g., myplugin/icons/up.png