hudson.plugins.pmd.util
Class AbstractProjectAction<T extends ResultAction<?>>

java.lang.Object
  extended by hudson.plugins.pmd.util.AbstractProjectAction<T>
Type Parameters:
T - result action type
All Implemented Interfaces:
hudson.model.Action, hudson.model.ModelObject
Direct Known Subclasses:
PmdProjectAction

public abstract class AbstractProjectAction<T extends ResultAction<?>>
extends java.lang.Object
implements hudson.model.Action

A project action displays a link on the side panel of a project.

Author:
Ulli Hafner

Constructor Summary
AbstractProjectAction(hudson.model.AbstractProject<?,?> project, java.lang.Class<T> resultActionType, PluginDescriptor plugin)
          Creates a new instance of AbstractProjectAction.
 
Method Summary
 GraphConfiguration createGraphConfiguration(org.kohsuke.stapler.StaplerRequest request, ResultAction<?> action)
          Creates the graph configuration from the cookie.
 void doIndex(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
          Redirects the index page to the last result.
 void doTrend(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
          Display the trend graph.
 void doTrendMap(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
          Display the trend map.
 java.lang.Object getDynamic(java.lang.String link, org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
          Returns the graph configuration for this project.
 java.lang.String getIconFileName()
          Returns the icon URL for the side-panel in the project screen.
 ResultAction<?> getLastAction()
          Returns the last valid result action.
 hudson.model.AbstractBuild<?,?> getLastFinishedBuild()
          Returns the last finished build.
 hudson.model.AbstractProject<?,?> getProject()
          Returns the project.
abstract  java.lang.String getTrendName()
          Returns the title of the trend graph.
 java.lang.String getUrlName()
          
 boolean hasValidResults()
          Returns whether we have enough valid results in order to draw a meaningful graph.
 boolean isTrendVisible(org.kohsuke.stapler.StaplerRequest request)
          Returns whether the trend graph is visible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface hudson.model.Action
getDisplayName
 

Constructor Detail

AbstractProjectAction

public AbstractProjectAction(hudson.model.AbstractProject<?,?> project,
                             java.lang.Class<T> resultActionType,
                             PluginDescriptor plugin)
Creates a new instance of AbstractProjectAction.

Parameters:
project - the project that owns this action
resultActionType - the type of the result action
plugin - the plug-in that owns this action
Method Detail

getTrendName

public abstract java.lang.String getTrendName()
Returns the title of the trend graph.

Returns:
the title of the trend graph.

getProject

public final hudson.model.AbstractProject<?,?> getProject()
Returns the project.

Returns:
the project

getDynamic

public java.lang.Object getDynamic(java.lang.String link,
                                   org.kohsuke.stapler.StaplerRequest request,
                                   org.kohsuke.stapler.StaplerResponse response)
Returns the graph configuration for this project.

Parameters:
link - not used
request - Stapler request
response - Stapler response
Returns:
the dynamic result of the analysis (detail page).

hasValidResults

public final boolean hasValidResults()
Returns whether we have enough valid results in order to draw a meaningful graph.

Returns:
true if the results are valid in order to draw a graph

getIconFileName

public java.lang.String getIconFileName()
Returns the icon URL for the side-panel in the project screen. If there is yet no valid result, then null is returned.

Specified by:
getIconFileName in interface hudson.model.Action
Returns:
the icon URL for the side-panel in the project screen

getUrlName

public final java.lang.String getUrlName()

Specified by:
getUrlName in interface hudson.model.Action

getLastAction

public ResultAction<?> getLastAction()
Returns the last valid result action.

Returns:
the last valid result action, or null if no such action is found

getLastFinishedBuild

public hudson.model.AbstractBuild<?,?> getLastFinishedBuild()
Returns the last finished build.

Returns:
the last finished build or null if there is no such build

doTrend

public void doTrend(org.kohsuke.stapler.StaplerRequest request,
                    org.kohsuke.stapler.StaplerResponse response)
             throws java.io.IOException
Display the trend graph.

Parameters:
request - Stapler request
response - Stapler response
Throws:
java.io.IOException - in case of an error

doTrendMap

public void doTrendMap(org.kohsuke.stapler.StaplerRequest request,
                       org.kohsuke.stapler.StaplerResponse response)
                throws java.io.IOException
Display the trend map. Delegates to the the associated ResultAction.

Parameters:
request - Stapler request
response - Stapler response
Throws:
java.io.IOException - in case of an error

isTrendVisible

public boolean isTrendVisible(org.kohsuke.stapler.StaplerRequest request)
Returns whether the trend graph is visible.

Parameters:
request - the request to get the cookie from
Returns:
the graph configuration

createGraphConfiguration

public GraphConfiguration createGraphConfiguration(org.kohsuke.stapler.StaplerRequest request,
                                                   ResultAction<?> action)
Creates the graph configuration from the cookie.

Parameters:
request - the request to get the cookie from
action - the last result action
Returns:
the graph configuration

doIndex

public void doIndex(org.kohsuke.stapler.StaplerRequest request,
                    org.kohsuke.stapler.StaplerResponse response)
             throws java.io.IOException
Redirects the index page to the last result.

Parameters:
request - Stapler request
response - Stapler response
Throws:
java.io.IOException - in case of an error


Copyright © 2009. All Rights Reserved.