Applying Patterns Automatically

DPTK patterns are usually applied to an Eclipse resource as a result of an explicit user interaction, "Apply Pattern". The source resource for the pattern is usually edited directly by the user in Eclipse before the pattern is applied. The automatic pattern application feature in DPTK lets users specify Eclipse resources for which DPTK patterns should be applied in the event that the file is modified, either from within Eclipse or by some other process in the system.

Before an eclipse resource can have a pattern automatically applied whenever the resource is changed, you must configure the project containing the resource. The configuration consists of adding a builder to the list of builders and defining the resource and pattern to be applied. Multiple resource/pattern pairs can be configured for each project. The example below shows a sample project configuration.

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>Auto Built</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec> 
        <buildCommand>
            <name>com.ibm.sse.model.structuredbuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>com.ibm.dptk.autoPatternApply</name>
            <arguments>
                <dictionary>
                    <key>a/b/sample.appdef</key>
                    <value>dummy.auto.pattern</value>
                </dictionary> 
                <dictionary>
                    <key>a/b/c/e.appdef</key>
                    <value>dummy.auto.pattern</value>
                </dictionary>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
    </natures>
</projectDescription>

This example shows that two resources in this project, with project relative paths "a/b/sample.appdef" and "a/b/c/e.appdef", respectively, will have the pattern with id "dummy.auto.pattern" applied whenever they are modified.


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