org.squashtest.csp.tm.domain.customfield
Class SingleSelectField

java.lang.Object
  extended by org.squashtest.csp.tm.domain.customfield.CustomField
      extended by org.squashtest.csp.tm.domain.customfield.SingleSelectField

@Entity
public class SingleSelectField
extends CustomField

A CustomField which stores a single option selected from a list.

Author:
Gregory Fouquet

Field Summary
 
Fields inherited from class org.squashtest.csp.tm.domain.customfield.CustomField
code, CODE_REGEXP, defaultValue, id, inputType, label, MAX_CODE_SIZE, MIN_CODE_SIZE, name, optional
 
Constructor Summary
SingleSelectField()
          Created a SingleSelectField with a
 
Method Summary
 void accept(CustomFieldVisitor visitor)
           
 void addOption(CustomFieldOption option)
          Will check if label and the code are available among the existing options.
 void changeOptionCode(String optionLabel, String newCode)
          Checks if the newCode is available among all options.
 void changeOptionLabel(String previousLabel, String newlabel)
          Checks if the newlabel is available among all options.
 List<CustomFieldOption> getOptions()
           
 void moveOptions(int newIndex, List<String> optionsLabels)
          Will remove all options and recreate them at their right-full positions.
 void removeOption(String label)
          Checks first if the option is the default one.
 
Methods inherited from class org.squashtest.csp.tm.domain.customfield.CustomField
getCode, getDefaultValue, getId, getInputType, getLabel, getName, isOptional, setCode, setDefaultValue, setLabel, setName, setOptional
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingleSelectField

public SingleSelectField()
Created a SingleSelectField with a

Method Detail

addOption

public void addOption(CustomFieldOption option)
Will check if label and the code are available among the existing options. If so, will add the new option at the end of the list. Else will throw a NameAlreadyInUseException or CodeAlreadyExistsException.

Parameters:
option - : the new option
Throws:
OptionAlreadyExistsException

removeOption

public void removeOption(@NotBlank
                         String label)
Checks first if the option is the default one. If so: throw a CannotDeleteDefaultOptionException

Parameters:
label -
Throws:
CannotDeleteDefaultOptionException

changeOptionLabel

public void changeOptionLabel(String previousLabel,
                              String newlabel)
Checks if the newlabel is available among all options.
If so, will change the defaultValue if needed, remove the option and add a new one at the vacant position. Else throws OptionAlreadyExistException.

Parameters:
previousLabel -
newlabel -
Throws:
OptionAlreadyExistException

changeOptionCode

public void changeOptionCode(String optionLabel,
                             String newCode)
Checks if the newCode is available among all options.
If so, will remove the option and add a new one at the vacant position. Else throws CodeAlreadyExistException.

Parameters:
optionLabel - : the label to identify the concerned option.
newCode - : the new code for the concerned option.
Throws:
CodeAlreadyExistException

getOptions

public List<CustomFieldOption> getOptions()

moveOptions

public void moveOptions(int newIndex,
                        List<String> optionsLabels)
Will remove all options and recreate them at their right-full positions.

Parameters:
newIndex - : the lowest index for the moved selection
optionsLabels - : the labels of the moved options

accept

public void accept(CustomFieldVisitor visitor)
Overrides:
accept in class CustomField


Copyright © 2010-2012 Henix, henix.fr. All Rights Reserved.