ch.sahits.codegen.java.gui.util
Class GUIHelper

java.lang.Object
  extended by ch.sahits.codegen.java.gui.util.GUIHelper
Direct Known Subclasses:
SWTGUIHelper

public class GUIHelper
extends java.lang.Object

This is a helper class for GUIs

Since:
0.9.4
Author:
Andi Hotz

Constructor Summary
GUIHelper(IJavaForm _form)
          Initialize the form
 
Method Summary
 java.util.List<IFormGroup> containerFields()
          Retrieve a list of all Group fields
 IJavaForm convertOneColumnLayout()
          Since a on column layout is not encapsuled in groups the elements are put into groups.
 java.lang.String getBrowseButtonName(IFormFileUpload elem)
          Compute the name of the browse button of the file browse element
 EGUIGroup getGroupType(IFormGroup group)
          Translate the contents of the group into an enumeration element
 java.util.List<IFormHidden> getHiddenFields()
          Retrieve all hidden fields of the form or in a group of the form one level down
 int getNumberOfColums()
          Convert the EFormLayout into a number
 IFormGroup getParentGroup(IFormElement e)
          Retrieve the parent group of the element
 boolean hasButton()
          Check if there is a button
 boolean hasCheckBox()
          Check if there is a check box
 boolean hasCombo()
          Check if there is a combo box
 boolean hasFileBrowse()
          Check if there is a File browser field
 boolean hasHiddenFields()
          Check if the form has hidden fields
 boolean hasImageButton()
          Check if there is an image button
 boolean hasInputField()
          Check if there is a input field
 boolean hasList()
          Check if there is a list
 boolean hasPasswordField()
          Check if there is a password field
 boolean hasRadioButton()
          Check if there is a radio button
 boolean hasResetButton()
          Check if there is a reset button
 boolean hasTextArea()
          Check if there is a text input area
 java.util.List<IFormElement> inputFields()
          Retrieve a list of all input elements
 boolean isCheckBoxGroup(IFormGroup group)
          Check if the group is a check box group
 boolean isFileUpload(IFormGroup group)
          Check whether the group contains a file upload field
 boolean isFormGroup(IFormGroup group)
          Check if the group is a form group
 boolean isRadioGroup(IFormGroup group)
          Check if the group is a radio button group
 boolean isValidGroup(IFormGroup group)
          Check if the group is a valid group
 java.lang.String toFileFilter(java.lang.String fileType)
          Convert to a file-type
 java.lang.String toName(IFormElement element)
          Convert the name of an element into a variable name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GUIHelper

public GUIHelper(IJavaForm _form)
Initialize the form

Parameters:
_form -
Method Detail

hasHiddenFields

public final boolean hasHiddenFields()
Check if the form has hidden fields

Returns:
true if there are hidden fields

getHiddenFields

public final java.util.List<IFormHidden> getHiddenFields()
Retrieve all hidden fields of the form or in a group of the form one level down

Returns:
List of all hidden fields or null

toFileFilter

public final java.lang.String toFileFilter(java.lang.String fileType)
Convert to a file-type

Parameters:
fileType - string that is to be converted
Returns:
file extension or null if conversion is not possible

getNumberOfColums

public final int getNumberOfColums()
Convert the EFormLayout into a number

Returns:
number of columns in the layout

hasInputField

public final boolean hasInputField()
Check if there is a input field

Returns:
true if an input field is detected

hasPasswordField

public final boolean hasPasswordField()
Check if there is a password field

Returns:
true if a password field is detected

hasTextArea

public final boolean hasTextArea()
Check if there is a text input area

Returns:
true if a text input area is detected

hasCombo

public final boolean hasCombo()
Check if there is a combo box

Returns:
true if a combo box is detected

hasFileBrowse

public final boolean hasFileBrowse()
Check if there is a File browser field

Returns:
true if a file browse is detected

hasList

public final boolean hasList()
Check if there is a list

Returns:
true if a list is detected

hasButton

public final boolean hasButton()
Check if there is a button

Returns:
true if there is a button that is neither a reset button nor an image button

hasImageButton

public final boolean hasImageButton()
Check if there is an image button

Returns:
true if there is an image button detected

hasResetButton

public final boolean hasResetButton()
Check if there is a reset button

Returns:
true if a reset button is detected

hasRadioButton

public final boolean hasRadioButton()
Check if there is a radio button

Returns:
true if a radio button is detected

hasCheckBox

public final boolean hasCheckBox()
Check if there is a check box

Returns:
true if a checkbox is detected

isValidGroup

public final boolean isValidGroup(IFormGroup group)
Check if the group is a valid group

Parameters:
group - to be checked
Returns:
true if the group is a form group, radio group or check box group
See Also:
isCheckBoxGroup(IFormGroup), isFormGroup(IFormGroup), isRadioGroup(IFormGroup)

isRadioGroup

public final boolean isRadioGroup(IFormGroup group)
Check if the group is a radio button group

Parameters:
group - to be checked
Returns:
true if all elements of the group are of type IFormRadioButton

isCheckBoxGroup

public final boolean isCheckBoxGroup(IFormGroup group)
Check if the group is a check box group

Parameters:
group - to be checked
Returns:
true if all elements of the group are of type IFormCheckbox

isFormGroup

public final boolean isFormGroup(IFormGroup group)
Check if the group is a form group

Parameters:
group - to be checked
Returns:
true if the group contains a label and a form element

toName

public final java.lang.String toName(IFormElement element)
Convert the name of an element into a variable name

Parameters:
element - to be converted
Returns:
variable name

isFileUpload

public final boolean isFileUpload(IFormGroup group)
Check whether the group contains a file upload field

Parameters:
group - to be checked
Returns:
true if an IFormFileUpload element is found

inputFields

public final java.util.List<IFormElement> inputFields()
Retrieve a list of all input elements

Returns:
List of elements

containerFields

public final java.util.List<IFormGroup> containerFields()
Retrieve a list of all Group fields

Returns:
List of all container fields
Since:
1.0.0

getGroupType

public final EGUIGroup getGroupType(IFormGroup group)
Translate the contents of the group into an enumeration element

Parameters:
group - to be translated
Returns:
EGUIGroup constant or null if the element could not be translated

getBrowseButtonName

public final java.lang.String getBrowseButtonName(IFormFileUpload elem)
Compute the name of the browse button of the file browse element

Parameters:
elem - IFormFileUpload element
Returns:
name of the button variable

convertOneColumnLayout

public final IJavaForm convertOneColumnLayout()
Since a on column layout is not encapsuled in groups the elements are put into groups. Where labels are missing an empty label is generated.
The converted form is made the new base of this class

Returns:
converted form

getParentGroup

public final IFormGroup getParentGroup(IFormElement e)
Retrieve the parent group of the element

Parameters:
e - Element whose parent is searched
Returns:
parent group or null
Since:
1.0.0