Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Tigerstripe Plugin Miscellany"

Line 3: Line 3:
 
This section includes some handy reference documents that are useful when putting together plugins.
 
This section includes some handy reference documents that are useful when putting together plugins.
  
=Default Velocity context contents=
+
==Default Velocity context contents==
  
 
'''Collections'''
 
'''Collections'''
Line 165: Line 165:
 
</ul></blockquote>
 
</ul></blockquote>
  
<h2>Expander Usage</h2>
+
Expander Usage
 
<blockquote><p>When defining a rule, use the direct syntax. The whole filename string is automatically passed to the default <b>Expander</b>. For example, for an output file the defintion might look like the following:
 
<blockquote><p>When defining a rule, use the direct syntax. The whole filename string is automatically passed to the default <b>Expander</b>. For example, for an output file the defintion might look like the following:
 
<ul>
 
<ul>

Revision as of 10:17, 2 June 2008

< To: Tigerstripe_Tutorials

This section includes some handy reference documents that are useful when putting together plugins.

Default Velocity context contents

Collections

There are a number of Collections in the context that allows access to sets of artifacts. These Collections are described in the following table and would typically be accessed as follows: #foreach ($artifact in $artifacts)

Collection Name Type Contents
$artifactsCollection<IArtifact> All artifacts within this project.
$entitiesCollection<IManagedEntityArtifact> All Managed Entity artifacts within this project.
$datatypesCollection<IDatatypeArtifact> All Datatype artifacts within this project.
$eventsCollection<IEventArtifact> All Event artifacts within this project.
$enumsCollection<IEnumArtifact> All Enumeration artifacts within this project.
$exceptionsCollection<IExceptionArtifact> All Exception artifacts within this project.
$queriesCollection<IQueryArtifact> All Query artifacts within this project.
$updateProceduresCollection<IUpdateProcedureArtifact> All Update Procedure artifacts within this project.
$associationsCollection<IAssociationArtifact> All Association artifacts within this project.
$associationClassesCollection<IAssociationClassArtifact> All Association Class artifacts within this project.
$sessionsCollection<ISessionArtifact> All Session Facade artifacts within this project.
$allArtifactsCollection<IAbstractArtifact> All artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allEntitiesCollection<IManagedEntityArtifact> All Managed Entity artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allDatatypesCollection<IDatatypeArtifact> All Datatype artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allEventsCollection<IEventArtifact> All Event artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allEnumsCollection<IEnumArtifact> All Enumeration artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allExceptionsCollection<IExceptionArtifact> All Exception artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allQueriesCollection<IQueryArtifact> All Query artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allUpdateProceduresCollection<IUpdateProcedureArtifact> All Update Procedure artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allAssociationsCollection<IAssociationArtifact> All Association artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allAssociationClassesCollection<IAssociationClassArtifact> All Association Class artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allSessionsCollection<ISessionArtifact> All Session Facade artifacts within this project, plus those in Referenced Projects and Dependent Modules.

Note : The contents of the collections above may be reduced by the application of Contract facets.

Other contents

$artifact (IAbstractArtifact)

In an Artifact Rule, this is set to the current artifact. That is on each iteration of the rule over a different artifact in the Tigerstripe project, this will have a different value. If a specific artifact type was selected in the rule (the AnyArtifact option has not been selected), the actual artifact will be of that type ( eg IManagedEntityArtifact) and the object can be cast to the precise type for access to the specifics of that artifact type.


$pluginConfig (IPluginConfig)

The plug-in reference gives access to the values of the plug-in Global Properties. For example, $pluginRef.Properties.getProperty(“propname”)

$tsProjectHandle (ITigerstripeModelProject)


Contains information about the Tigerstripe project such as the version, name, and Copyright notice of your project. This information is held in ProjectDetails object, for example $tsProjectHandle.getIextProjectDetails().getProperty("copyrightNotice","")

$runtime (TigerstripeRuntime)

The runtime object contains information about the Tigerstripe installation so you can check the version of Workbench. For example, $runtime.getProperty("tigerstripe.feature.version")

$sessionManager (IArtifactManagerSession)

The artifact manager session is used to gain access to artifacts in the project, or in project dependencies. For example, if you have a String that should be an FQN of another artifact, you can access that artifact using $sessionManager.getIArtifactByFullyQualifiedName($fqnString)

$util (VelocityContextUtil)

A utility class that contains a few simple String handling utilities.

stripExternalQuotes(String arg0)removes leading and trailing quotation (”) characters.
unCapitalize(String arg0)Turns the first character to lower-case.
capitalize(String arg0)Turns the first character to upper-case.
getLastSegment(String arg0)Returns the part of the String after the last “.” character.
toLowerCase(String arg0)Returns entire Strings in lower-case.
toUpperCase(String arg0)Returns entire Strings in upper-case.

Example use : $util.capitalize($attribute.Name)

$exp (IExpander)

A utility that can be used to simplify access to some model, plug-in, or project variables. The currentArtifact or currentModel must be set prior to use for artifact or model attributes, but the pluginRef is pre-set.

Example use : $exp.expandVar($model.TargetNamespace)

$templateName (String)

The local pathname of the template that is currently being used. For example, templates/wsdm/type.vm.

$pluginDir (String)

The path to the root of the plugin when it is deployed. This is useful for gaining access to files that have been included with the deployed plugin.


Using an Expander

An Expander is a utility included in the <a href="velocityContextDetails.html">Default Velocity context</a> that you use to explode references. Uses for an Expander are as follows:


  • Specifying Output files: In many situations, your plug-in needs model attributes to know where to place your output file based on the current Artifact. The default Expander facilitates this behaviour.
  • Abbreviated syntax: Within a template, you have access to plug-in Global Properties, Model Attributes, and Project Properties.

Expander Variable Syntax

  • ${project.Version} and ${project.Name}: This variable will replace your Version and Name properties of your current project.
  • ${artifact.Name}, ${artifact.Package} and ${artifact.Path}: This variable displays a name, package, and a path-like String for your package (eg com/mycompany/myPackage) of the current Artifact. This variable is only useful for Artifact based rules.
  • ${ppProp.propertyName}: This variable displays the value of the Global Property named propertyName in your plug-in.
  • ${model.attributeName}: This variable displays the value of the attribute named attributeName in your model. Note: The Model should be replaced with the name of the model set in the rule specification.

Expander Usage

When defining a rule, use the direct syntax. The whole filename string is automatically passed to the default Expander. For example, for an output file the defintion might look like the following:

  • ${artifact.Path}/${artifact.Name}.java
Within your template, use $exp.expandVar(expanderVariable), where expanderVariable complies with the syntax above. For example, $exp.expandVar("${ppProp.xmlDirectory}").</blockquote>

Copyright © Eclipse Foundation, Inc. All Rights Reserved.