Elexis API documentation
Version 2.1.6 as of December 11 2011

ch.elexis.util
Class FirstnameListener

java.lang.Object
  extended by SelectionAdapter
      extended by ch.elexis.util.FirstnameListener

public class FirstnameListener
extends SelectionAdapter

class for the FocusListener, KeyListener and SelectionAdapter for the combined fields firstname and gender field. You just need to create an instance of FirstnameListener. The constructor takes the parameters and automatically adds the necessary listeners to the name- and gender fields. eg:

 (new FirstnameListener(firstNameField_Text, genderCombo)).setDefaultListeners();
 OR: (new FirstnameListener(firstNameField_Text, genderList)).setDefaultListeners();
 OR: (new FirstnameListener(firstNameField_Text, genderRadioM, genderRadioW)).setDefaultListeners();
 OR: (new FirstnameListener(firstNameField_Text, genderCheckM, genderCheckW)).setDefaultListeners();
 OR: (new FirstnameListener(firstNameField_Combo, genderText)).setDefaultListeners()
        .setGenderStrings("münnlüsch", "wüblüsch");
 
The items (Combo/List/Radio/CheckBox) for the controls must have already been set BEFORE calling this.
The first item MUST be the male, the second item MUST be the female item.

If the firstname field is a Text field, then you must call the method setGenderStrings() to tell the listeners which string means "male" and "female".

An extended example of how to do this can be found in the plugin ch.marlovits-firstnames in the view "MarlovitsFirstnameTestView.java". You must activate the view in the plugin.xml for displaying it in elexis.

Author:
Harald Marlovits

Field Summary
static boolean reReadPlugin
           
 
Constructor Summary
FirstnameListener(java.lang.Object firstnameField, java.lang.Object genderComboOrListOrText)
          generic constructor for firstnameField having type Text, Combo or List and genderField having type Combo or List or Text
FirstnameListener(java.lang.Object firstnameField, java.lang.Object genderMaleRadioOrCheck, java.lang.Object genderFemaleRadioOrCheck)
          generic constructor for firstnameField having type Text, Combo or List and genderMaleRadioOrCheck/genderFemaleRadioOrCheck having type Radio or Checkbox
 
Method Summary
 void focusGained(FocusEvent e)
          FocusListener for firstname field and gender field
 void focusLost(FocusEvent e)
          FocusListener for firstname field and gender field
static IGenderService getPlugin()
          We're looking for the GenderPlugin defined in the settings.
 boolean isDBGenderAllowed(java.lang.String gender)
          test if the passed gender is allowed - just "m" and "w" and "" are allowed Empty is always allowed.
 boolean isGenderAllowed(java.lang.String gender)
          test if the passed gender is allowed as a selection for the shown control items.
 void keyPressed(KeyEvent e)
          KeyListener for gender field
 void keyReleased(KeyEvent e)
          KeyListener for gender field
 int openFreeDialog(Shell parentShell, java.lang.String title, Image dialogTitleImage, java.lang.String dialogMessage, int dialogImageType, java.lang.String[] dialogButtonLabels, int defaultIndex)
          displays a dialog with the given parameters
 FirstnameListener setDefaultListeners()
          Sets the default FocusListener for the firstname field and the FocusListener/KeyListener/SelectionListener for the gender field
 void setGenderStrings(java.lang.String maleString, java.lang.String femaleString)
          sets the maleString and the femaleString to be used by the control.
static void setReReadPlugin(boolean pReReadPlugin)
          This sets if the GenderService plugin should be reread again.
 void widgetSelected(SelectionEvent e)
          SelectionListener for gender field
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reReadPlugin

public static boolean reReadPlugin
Constructor Detail

FirstnameListener

public FirstnameListener(java.lang.Object firstnameField,
                         java.lang.Object genderComboOrListOrText)
generic constructor for firstnameField having type Text, Combo or List and genderField having type Combo or List or Text

Parameters:
firstnameField -
genderComboOrListOrText -

FirstnameListener

public FirstnameListener(java.lang.Object firstnameField,
                         java.lang.Object genderMaleRadioOrCheck,
                         java.lang.Object genderFemaleRadioOrCheck)
generic constructor for firstnameField having type Text, Combo or List and genderMaleRadioOrCheck/genderFemaleRadioOrCheck having type Radio or Checkbox

Parameters:
firstnameField -
genderMaleRadioOrCheck -
genderFemaleRadioOrCheck -
Method Detail

getPlugin

public static IGenderService getPlugin()
We're looking for the GenderPlugin defined in the settings. If there is no plugin defined, then we use the simple built in method which uses the very simple method isFemale(). This is the method that was used previously

Returns:

setReReadPlugin

public static void setReReadPlugin(boolean pReReadPlugin)
This sets if the GenderService plugin should be reread again. This is used after changing in the prefs to ensure that the newly selected plugin will immediately active.

Parameters:
pReReadPlugin -

setDefaultListeners

public FirstnameListener setDefaultListeners()
Sets the default FocusListener for the firstname field and the FocusListener/KeyListener/SelectionListener for the gender field


focusGained

public void focusGained(FocusEvent e)
FocusListener for firstname field and gender field


focusLost

public void focusLost(FocusEvent e)
FocusListener for firstname field and gender field


keyPressed

public void keyPressed(KeyEvent e)
KeyListener for gender field


keyReleased

public void keyReleased(KeyEvent e)
KeyListener for gender field


widgetSelected

public void widgetSelected(SelectionEvent e)
SelectionListener for gender field


setGenderStrings

public void setGenderStrings(java.lang.String maleString,
                             java.lang.String femaleString)
sets the maleString and the femaleString to be used by the control. This is only used for text fields. For the other types of controls (combo, radio, checkboxes, list) this has no effect since the actual item names are used (as returned by calcGenderStrings() )

Parameters:
maleString -
femaleString -

isGenderAllowed

public boolean isGenderAllowed(java.lang.String gender)
test if the passed gender is allowed as a selection for the shown control items. Empty is always allowed.

Parameters:
gender -
Returns:

isDBGenderAllowed

public boolean isDBGenderAllowed(java.lang.String gender)
test if the passed gender is allowed - just "m" and "w" and "" are allowed Empty is always allowed.

Parameters:
gender -
Returns:

openFreeDialog

public int openFreeDialog(Shell parentShell,
                          java.lang.String title,
                          Image dialogTitleImage,
                          java.lang.String dialogMessage,
                          int dialogImageType,
                          java.lang.String[] dialogButtonLabels,
                          int defaultIndex)
displays a dialog with the given parameters

Parameters:
parentShell -
title -
dialogTitleImage -
dialogMessage -
dialogImageType -
dialogButtonLabels -
defaultIndex -
Returns:

Elexis API documentation
Version 2.1.6 as of December 11 2011

Copyright 2005-2011 by Gerry Weirich, Elexis