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 "Post-Generation Extension Point"

 
(13 intermediate revisions by 2 users not shown)
Line 6: Line 6:
  
 
*'''Usage''' : Post-generate extensions can subscribe to one of three notification modes:
 
*'''Usage''' : Post-generate extensions can subscribe to one of three notification modes:
ALWAYS will run your extension upon generation whether the generation was successful or not.
+
ALWAYS will run your extension upon generation whether the generation was successful or not.<br/>
ON_SUCCESS_ONLY will run your extension only if generation is successful.
+
ON_SUCCESS_ONLY will run your extension only if generation is successful.<br/>
 
ON_FAILURE_ONLY will run your extension only if one or more plugin fails to generate successfully. NOTE: The runStatus object passed to the run method will be from all the generated plugins, it is up to you to pick out only the ones that failed.
 
ON_FAILURE_ONLY will run your extension only if one or more plugin fails to generate successfully. NOTE: The runStatus object passed to the run method will be from all the generated plugins, it is up to you to pick out only the ones that failed.
  
 
The listener class must implement the IGenerateCompleteListener interface which has one method:
 
The listener class must implement the IGenerateCompleteListener interface which has one method:
public PluginRunStatus run(GenerateCompletionStatus status, ITigerstripeModelProject project, PluginRunStatus[] runStatus);
+
public GenerateCompleteListenerRunStatus run(
 +
        GenerateCompletionStatus status,  
 +
        ITigerstripeModelProject project,  
 +
        PluginRunStatus[] runStatus);
 
where:
 
where:
status is either GenerateCompletionStatus.SUCCESS or GenerateCompletionStatus.FAILURE - This is intended for listeners that listen ALWAYS
+
status - Either GenerateCompletionStatus.SUCCESS or GenerateCompletionStatus.FAILURE
project is the Tigerstripe project the generation was ran against
+
project - The Tigerstripe project the generation was ran against
runStatus is a list of statuses from all the generators that ran
+
runStatus - A list of statuses from all the generators that ran  
You can also return a PluginRunStatus object to show the user the status of your post-generate action. If you have no status to return than null is acceptable.
+
Return - A GenerateCompleteListenerRunStatus object to show the user the status of your post-generate action.  
 +
          If you have no status to return than null is acceptable.
  
 
*'''Example''' :
 
*'''Example''' :
  
<plugin>
+
Sample Project: [[Media:PostgenerationSamplev1.zip]] <br/>
  <extension
+
This sample is also available under Tigerstripe CVS: /samples/org.eclipse.tigerstripe.postgeneration.sample <br/>
        id="generateCompleteTestListener"
+
This project contains two post-generation actions as outlined below:
        name="Generate Complete Test Listener"
+
 
        point="org.eclipse.tigerstripe.workbench.base.generateComplete">
+
  <plugin>
    <generateCompleteListener
+
      <extension
          class="org.eclipse.tigerstripe.workbench.base.test.generation.SampleGenerateCompleteListener"
+
            id="postGenerationSample"
          notificationMode="ON_SUCCESS_ONLY">
+
            name="Post-generation custom action sample"
    </generateCompleteListener>
+
            point="org.eclipse.tigerstripe.workbench.base.generateComplete">
  </extension>
+
            <generateCompleteListener
  ...
+
                    class="org.eclipse.tigerstripe.postgeneration.sample.PostSuccessfulGeneration"
  </plugin>
+
                    notificationMode="ON_SUCCESS_ONLY">
 +
            </generateCompleteListener>
 +
            <generateCompleteListener
 +
                    class="org.eclipse.tigerstripe.postgeneration.sample.PostFailedGeneration"
 +
                    notificationMode="ON_FAILURE_ONLY">
 +
            </generateCompleteListener>
 +
      </extension>
 +
  </plugin>
 +
 
 +
 
 +
/**
 +
  * Invoked on a successful generation
 +
  * This class moves the following file from user's workspace:
 +
  * /SampleProject/Source/source.xml  TO  /SampleProject/Target
 +
  *
 +
  * If the project or folders do not exist, they're created. If 'source.xml' already
 +
  * exists under /Sample/Target, it's removed before the move.
 +
  *
 +
  */
 +
public class PostSuccessfulGeneration
 +
 
 +
 
 +
  /**
 +
  * Invoked on a generation that fails
 +
  * This class generates an error dialog upon generation failure.
 +
  *
 +
  */
 +
public class PostFailedGeneration
 +
 
  
 
*''' Some important notes''' :
 
*''' Some important notes''' :
  
 
A "Generate" with no generators will still fire this extension passing GenerateCompletionStatus.SUCCESS as a status.
 
A "Generate" with no generators will still fire this extension passing GenerateCompletionStatus.SUCCESS as a status.

Latest revision as of 14:47, 5 November 2010

< To: Tigerstripe Extension Points

  • Full name : org.eclipse.tigerstripe.workbench.base.generateComplete

Purpose : This extension point is fired when a Tigerstripe project "Generate" is completed allowing post-generate actions to be ran.

  • Usage : Post-generate extensions can subscribe to one of three notification modes:

ALWAYS will run your extension upon generation whether the generation was successful or not.
ON_SUCCESS_ONLY will run your extension only if generation is successful.
ON_FAILURE_ONLY will run your extension only if one or more plugin fails to generate successfully. NOTE: The runStatus object passed to the run method will be from all the generated plugins, it is up to you to pick out only the ones that failed.

The listener class must implement the IGenerateCompleteListener interface which has one method:

public GenerateCompleteListenerRunStatus run(
       GenerateCompletionStatus status, 
       ITigerstripeModelProject project, 
       PluginRunStatus[] runStatus);

where:

status - Either GenerateCompletionStatus.SUCCESS or GenerateCompletionStatus.FAILURE
project - The Tigerstripe project the generation was ran against
runStatus - A list of statuses from all the generators that ran 
Return - A GenerateCompleteListenerRunStatus object to show the user the status of your post-generate action. 
         If you have no status to return than null is acceptable.
  • Example :

Sample Project: Media:PostgenerationSamplev1.zip
This sample is also available under Tigerstripe CVS: /samples/org.eclipse.tigerstripe.postgeneration.sample
This project contains two post-generation actions as outlined below:

 <plugin>
      <extension
            id="postGenerationSample"
            name="Post-generation custom action sample"
            point="org.eclipse.tigerstripe.workbench.base.generateComplete">
            <generateCompleteListener
                   class="org.eclipse.tigerstripe.postgeneration.sample.PostSuccessfulGeneration"
                   notificationMode="ON_SUCCESS_ONLY">
            </generateCompleteListener>
            <generateCompleteListener
                   class="org.eclipse.tigerstripe.postgeneration.sample.PostFailedGeneration"
                   notificationMode="ON_FAILURE_ONLY">
            </generateCompleteListener>
      </extension>
 </plugin>


/**
 * Invoked on a successful generation
 * This class moves the following file from user's workspace: 
 * /SampleProject/Source/source.xml  TO  /SampleProject/Target
 *
 * If the project or folders do not exist, they're created.  If 'source.xml' already
 * exists under /Sample/Target, it's removed before the move.
 * 
 */
public class PostSuccessfulGeneration


/**
 * Invoked on a generation that fails
 * This class generates an error dialog upon generation failure.
 * 
 */
public class PostFailedGeneration


  • Some important notes :

A "Generate" with no generators will still fire this extension passing GenerateCompletionStatus.SUCCESS as a status.

Back to the top