Programmatic Invocation

You can invoke the generator from another Eclipse plug-in that lists the generator (com.ibm.dptk) as a dependency (see the dependencies tab on the plugin.xml editor).

There are a number of variations, but your tool will create an input model (XML string, Eclipse resource containing parsable source, an org.w3c.dom node, etc.) and call PatternApplicator to actually apply a pattern (identified by pattern ID) to the input model. The API is described below.

        // IProject proj is the default project to use when a project attribute is not
        //               specified on a template tag.  Can be null if the pattern does
        //               not make use of the default project feature.

        // Object model is the model against which the transformation will be applied.
        //               The model can be an Eclipse resource, a List containing Eclipse
        //               resources, a String containing XML, an org.w3c.dom.Node instance
        //               or other objects understood by extensions to DPTK.

        // String patternID is the id of the pattern to apply

        // Hashtable parms contains name-value pairs that are available via the <genParm> tag

        // IProgressMonitor progressMonitor is either null if DPTK is to apply the pattern under a newly
        //               created IProjectMonitor or is the project monitor for an existing process that
        //               wants to apply the pattern as part of a broader workspace action.  Most Eclipse
        //               wizards and other tooling will pass a null progressMonitor, but RSA transformations
        //               need to pass the project monitor obtained from the tranformation context. 
		
        PatternApplicationStatus status;

		status = PatternApplicator.singleton().applyPattern(proj, model, patternID, parms, progressMonitor);
 
        if (!status.isSuccessful())) {
            status.report(new Shell());
        }


© Copyright IBM Corporation 2000, 2005. All Rights Reserved.