de.matthias_burbach.flux4eclipse.popup.actions
Class GenerateAction

java.lang.Object
  extended byde.matthias_burbach.flux4eclipse.popup.actions.GenerateAction
All Implemented Interfaces:
org.eclipse.ui.IActionDelegate, org.eclipse.ui.IObjectActionDelegate

public class GenerateAction
extends java.lang.Object
implements org.eclipse.ui.IObjectActionDelegate

Collects Flux preferences and properties, validates them and calls the Flux generator if validation is successfull.

Displays error messages if validation or generation fails, shows a success message otherwise.

Author:
Matthias Burbach

Field Summary
private static java.lang.String MESSAGE_TITLE
          The title of message dialogs displayed.
private static java.lang.String MODULE_VARIABLE
          The module variable that can be used in preference values.
private  org.eclipse.ui.IWorkbenchPart part
           
private  org.eclipse.jface.viewers.IStructuredSelection selection
           
 
Constructor Summary
GenerateAction()
           
 
Method Summary
private  void displayErrorMessage(java.lang.String message)
           
private  void displayFatalMessage(java.lang.Exception e)
           
private  void displayInfoMessage(java.lang.String message)
           
private  void displayModelCheckerMessage(ModelCheckerException mce)
          Uses an extra window to display the potentially long model checker problem report.
private  void generate(org.eclipse.core.resources.IFile selectedFile)
          Collects Flux preferences and properties, validates them and calls the Flux generator if validation is successfull.
private  java.util.Properties getGeneratorProperties(org.eclipse.core.resources.IFile selectedFile)
          Collects Flux preferences and properties and validates them.
private  java.lang.String getMessage(java.lang.String messageSoFar, java.lang.String settingName, java.lang.String settingValue)
          Helps to assemble an error message when validation of preferences and properties (settings) fails.
private  java.lang.String getModuleFromConfigFile(java.lang.String configFile, java.lang.String rootModule)
          Extracts the module part from the struts-config-%MODULE%.xml file name.
private  java.lang.String hasValidSettings(java.lang.String dispatcherAction, java.lang.String modeDispatcherAction, java.lang.String relayAction, java.lang.String enterModuleAction, java.lang.String finalStateAction, java.lang.String physicalPagePrefix, java.lang.String physicalPageSuffix, java.lang.String defaultFormName, java.lang.String defaultPackage, java.lang.String modelFile, java.lang.String configFile)
          Validates all the parameters passed in one by one.
private  boolean isValidBeanName(java.lang.String name)
           
private  boolean isValidConfigFile(java.lang.String configFile)
           
private  boolean isValidDefaultFormName(java.lang.String defaultFormName)
           
private  boolean isValidDefaultPackage(java.lang.String defaultPackage)
           
private  boolean isValidDispatcherAction(java.lang.String dispatcherAction)
           
private  boolean isValidEnterModuleAction(java.lang.String enterModuleAction)
           
private  boolean isValidFinalStateAction(java.lang.String finalStateAction)
           
private  boolean isValidJavaClassName(java.lang.String name)
           
private  boolean isValidJavaPackage(java.lang.String name)
           
private  boolean isValidModeDispatcherAction(java.lang.String modeDispatcherAction)
           
private  boolean isValidModelFile(java.lang.String modelFile)
           
private  boolean isValidPhysicalPagePrefix(java.lang.String physicalPagePrefix)
           
private  boolean isValidPhysicalPageSuffix(java.lang.String physicalPageSuffix)
           
private  boolean isValidRelayAction(java.lang.String relayAction)
           
 void run(org.eclipse.jface.action.IAction action)
           
 void selectionChanged(org.eclipse.jface.action.IAction action, org.eclipse.jface.viewers.ISelection selection)
           
 void setActivePart(org.eclipse.jface.action.IAction action, org.eclipse.ui.IWorkbenchPart targetPart)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MESSAGE_TITLE

private static final java.lang.String MESSAGE_TITLE
The title of message dialogs displayed.

See Also:
Constant Field Values

MODULE_VARIABLE

private static final java.lang.String MODULE_VARIABLE
The module variable that can be used in preference values. Will be substituted by the actual value that names the struts-config module.

See Also:
Constant Field Values

part

private org.eclipse.ui.IWorkbenchPart part

selection

private org.eclipse.jface.viewers.IStructuredSelection selection
Constructor Detail

GenerateAction

public GenerateAction()
Method Detail

setActivePart

public void setActivePart(org.eclipse.jface.action.IAction action,
                          org.eclipse.ui.IWorkbenchPart targetPart)
Specified by:
setActivePart in interface org.eclipse.ui.IObjectActionDelegate
See Also:
IObjectActionDelegate.setActivePart(IAction, IWorkbenchPart)

selectionChanged

public void selectionChanged(org.eclipse.jface.action.IAction action,
                             org.eclipse.jface.viewers.ISelection selection)
Specified by:
selectionChanged in interface org.eclipse.ui.IActionDelegate
See Also:
IActionDelegate#selectionChanged(IAction, ISelection)

run

public void run(org.eclipse.jface.action.IAction action)
Specified by:
run in interface org.eclipse.ui.IActionDelegate
See Also:
IActionDelegate#run(IAction)

generate

private void generate(org.eclipse.core.resources.IFile selectedFile)
Collects Flux preferences and properties, validates them and calls the Flux generator if validation is successfull.

Parameters:
selectedFile - the struts-config-%MODULE%.xml file the user selected to perform the generation for

getGeneratorProperties

private java.util.Properties getGeneratorProperties(org.eclipse.core.resources.IFile selectedFile)
Collects Flux preferences and properties and validates them.

Parameters:
selectedFile - the struts-config-%MODULE%.xml file the user selected to perform the generation for
Returns:
the validated settings in the format the generator understands or null if validation was not successfull

hasValidSettings

private java.lang.String hasValidSettings(java.lang.String dispatcherAction,
                                          java.lang.String modeDispatcherAction,
                                          java.lang.String relayAction,
                                          java.lang.String enterModuleAction,
                                          java.lang.String finalStateAction,
                                          java.lang.String physicalPagePrefix,
                                          java.lang.String physicalPageSuffix,
                                          java.lang.String defaultFormName,
                                          java.lang.String defaultPackage,
                                          java.lang.String modelFile,
                                          java.lang.String configFile)
Validates all the parameters passed in one by one.

Parameters:
dispatcherAction -
modeDispatcherAction -
relayAction -
enterModuleAction -
physicalPagePrefix -
physicalPageSuffix -
defaultFormName -
defaultPackage -
modelFile -
configFile -
Returns:
the validation error message or null if validation was successfull

getMessage

private java.lang.String getMessage(java.lang.String messageSoFar,
                                    java.lang.String settingName,
                                    java.lang.String settingValue)
Helps to assemble an error message when validation of preferences and properties (settings) fails.

Parameters:
messageSoFar - the message having been assembled so far
settingName - the setting that has a problem
settingValue - the erroneous value of the setting
Returns:
the messageSoFar plus the new info about the erroneous setting

isValidDispatcherAction

private boolean isValidDispatcherAction(java.lang.String dispatcherAction)

isValidModeDispatcherAction

private boolean isValidModeDispatcherAction(java.lang.String modeDispatcherAction)

isValidRelayAction

private boolean isValidRelayAction(java.lang.String relayAction)

isValidEnterModuleAction

private boolean isValidEnterModuleAction(java.lang.String enterModuleAction)

isValidFinalStateAction

private boolean isValidFinalStateAction(java.lang.String finalStateAction)

isValidPhysicalPagePrefix

private boolean isValidPhysicalPagePrefix(java.lang.String physicalPagePrefix)

isValidPhysicalPageSuffix

private boolean isValidPhysicalPageSuffix(java.lang.String physicalPageSuffix)

isValidDefaultFormName

private boolean isValidDefaultFormName(java.lang.String defaultFormName)

isValidDefaultPackage

private boolean isValidDefaultPackage(java.lang.String defaultPackage)

isValidModelFile

private boolean isValidModelFile(java.lang.String modelFile)

isValidConfigFile

private boolean isValidConfigFile(java.lang.String configFile)

isValidJavaClassName

private boolean isValidJavaClassName(java.lang.String name)

isValidJavaPackage

private boolean isValidJavaPackage(java.lang.String name)

isValidBeanName

private boolean isValidBeanName(java.lang.String name)

getModuleFromConfigFile

private java.lang.String getModuleFromConfigFile(java.lang.String configFile,
                                                 java.lang.String rootModule)
Extracts the module part from the struts-config-%MODULE%.xml file name.

Parameters:
configFile - the struts-config file name
rootModule - the name returned if configFile is the the root file 'struts-config.xml'
Returns:
the module name as it occurs in the file name

displayInfoMessage

private void displayInfoMessage(java.lang.String message)

displayErrorMessage

private void displayErrorMessage(java.lang.String message)

displayFatalMessage

private void displayFatalMessage(java.lang.Exception e)

displayModelCheckerMessage

private void displayModelCheckerMessage(ModelCheckerException mce)
Uses an extra window to display the potentially long model checker problem report.

Parameters:
mce - the exception holding the problem report facts