MCombo

Description

A MCombo is composed of a label and a drop down list (combo).

The label is given to the constructor.
For the combo, there are two paths. One is the path of value that is selected by default. If null, the combo does not show any selection.
The other is the path of a collection's value which are the options of the combo.
In the constructor, the required parameter means that selection is mandatory.

How to use MCombo ?

  • First of all you need to have a collection
  • 1- Instantiate a Context object (or reuse an existing one)
  • 2- Put the data set you want to fill the combo with in the context.
  • 3- Instantiate the MCombo using one of the provided constructors.

Note that MCombo can also be displayed in radio mode. This means that the drop down list is replaced by a set of radio buttons.

A simple example

A normal combo

 1    //Initialization of the main context
 2    Context ctx = Context.getMainContext();
 3    List<Person> data = PersonService.findPersonsAsList();
 4    ctx.put("persons", data);
 5    ctx.put("person", data.get(0));
 6
 7    //Declares a MCombo and sets the paths
 8    MCombo combo = new MCombo(container, "Choice 2 :", "person", 10, true);
 9    combo.setDisplayPath("name");
10    combo.setCollectionDataPath("persons");

A combo in radio mode

 1    //MCombo
 2    MCombo combo = new MCombo(container, "Choice :", "person2.surname", 10, true);
 3    combo.setCollectionDataPath("surnames");
 4
 5    //Sets the radio's mode
 6    combo.setRadioMode(true);
 7
 8    //Sets the row's mode
 9    combo.setRadioRowMode(true);

API

  • Constructors
MCombo(MonoiContainer container, String label, String selectionDataPath,Integer widthInChar, boolean required, String labelFontInfo,Alignment labelTextAlignment) Constructs a new instance of this class given its parent container, label's text , path of data selected, width of chars,value's requirement , font's information and alignment.
MCombo(MonoiContainer container, String label, String selectionDataPath,Integer widthInChar, boolean required) Constructs a new instance of this class given its parent container, label's text , path of data selected, width of chars and value's requirement.
MCombo(MonoiContainer container, String label, String selectionDataPath,Integer widthInChar, String collectionDataPath) Constructs a new instance of this class given its parent container, label's text , path of data selected, width of charsand the collection's data's path
MCombo(MonoiContainer container, String label, String selectionDataPath,String collectionDataPath) Constructs a new instance of this class given its parent container, label's text , path of data selected and the collection's data's path
  • Methods
void add(Object dataToUse) Adds a new data into the combo's data
Void addInputDelegate(IInputDelegate inputDelegate) Adds an inputDelegate into IDataComponent
String getAbsoluteCollectionDataPath() Gets an absolute collection's data's path
String getCollectionDataPath() Gets a collection's data's path
String getDisplayPath() Gets the displayPath
IMonoiFormatter getFormatter() Gets a formatter
Control getInternalControl() Gets the internal control
Alignment getLabelAlignment() Gets the label's alignment
String getLabelText() Gets the label's text
int getLabelWidthInChar() Gets the width of chars
String getSelectionPath() Gets the path of value selected
Object getValue() Gets the value selected
String getValueDataPath() Gets the path of value
void setCollectionDataPath (String collectionDataPath) Gets the collection's data's path which is not absolute
void setCollectionDataPath (String collectionDataPath,boolean absolute) Gets the collection's data's path with the “absolute” given
void setDisplayPath(String displayPath) Sets the displayPath
void setFormatter (IMonoiFormatter formatter Sets a formatter
void setLabelAlignment (Alignment labelAlignment) Sets the label's alignment
void setLabelText(String labelText) Sets the label's text
void setLabelWidthInChar(int labelWidth) Sets the width of char
void setSelectionPath(String selectionPath) Sets the path of value selected
void setValueDataPath(String valueDataPath) Sets the value selected
void updateModel() Updates the model of combo
boolean isRadioMode() True if radio mode
void setRadioMode(boolean radioMode) Sets the radio mode by column's layout
void setRadioRowMode(boolean rowMode) Sets the radio mode by row's layout
  • See also superclasses
    • MonoiComponent and MonoiDataComponent

MCombo1.jpg (12.8 kB) Frédéric ESNAULT, 02/27/2012 12:12 pm

MCombo2.jpg (16 kB) Frédéric ESNAULT, 02/27/2012 12:12 pm