An "auto completion" Java Bean
By francois degrelle on Friday, March 27 2015, 15:21 - PJC - Javabean - Permalink
Purpose
Here is a Java Bean that allows to manage an "auto completion" Swing JComboBox.
The Java code
CBAutoCompletion.java ComboBoxCompletion.java
The implementation class of the Bean Item
oracle.forms.fd.ComboBoxCompletion
The methods you can set
Init the ComboBox values
-- Single value list --
Get_Custom_Property('BLOCK.ITEM',1INIT','value[,value[,...]]');
e.g.:
-- initialise the ComboBox values --
Set_Custom_Property('BL.BEAN',1,'INIT','Ester,Jordi,Jordina,Jorge,Sergi
-- Twin value list (code+value) --
Get_Custom_Property('BLOCK.ITEM',1INIT_TWIN','code,value[,code,value[,...]]');
code(stored value) is provided, then after value (displayed)
e.g.:
-- initialise the ComboBox values --
Set_Custom_Property('BL.BEAN',1,'INIT_TWIN','v1,Ester,v2,Jordi,v3,Jordina,v4,Jorge,v5,Sergi
This method must be the first called.
If you need to incorporate NULL values in the list, use the equivalent INIT_NULL and INIT_TWIN_NULL methods.
To set the focus on the NULL value, use the SELECT_INDEX,'1' or SELECT_CODE,'' methods.
If the amount of data to transfer is greater than 4000 bytes, replace the INIT[_NULL] or INIT_TWIN[_NULL] methods by the equivalent ADD[_NULL] of ADD_TWIN[_NULL]:
Set_Custom_Property('BL.BEAN',1,'CLEAR
Set_Custom_Property('BL.BEAN',1,'ADD_TWIN','v1,Ester,v2,Jordi,v3,Jordina
Set_Custom_Property('BL.BEAN',1,'ADD_TWIN','v4,Jorge,v5,Sergi,v6,Theodor
Set_Custom_Property('BL.BEAN',1,'ADD_TWIN.');
Set_Custom_Property('BL.BEAN',1,'ADD_TWINDATA]');
In this case, the last call to ADD_XXX methods must contains the [END_DATA] string.
Set the Font
Get_Custom_Property('BLOCK.ITEM',1SET_FONT','font_name[,font_weight[,font_size]]);
font_weight could be one of the following:
P : Plain
B : Bold
I : Italic
BI : Bold+Italic
e.g.:
-- set the font --
Set_Custom_Property('BL.BEAN',1,'SET_FONT','Arial,B,12
Enable/disable the combobox
Get_Custom_Property('BLOCK.ITEM',1,'SET_ENABLED','true | false');
e.g.:
-- disable the ComboBox --
Set_Custom_Property('BL.BEAN',1,'SET_ENABLED,'false
Show/hide the ComboBox values
Get_Custom_Property('BLOCK.ITEM',1,'SET_VISIBLE','true | false');
e.g.:
-- hide the ComboBox --
Set_Custom_Property('BL.BEAN',1,'SET_VISIBLE,'false
Set the starting index (by position)
Get_Custom_Property('BLOCK.ITEM',1,'SELECT_INDEX','index_num');
e.g.:
-- set focus on the 3rd option --
Set_Custom_Property('BL.BEAN',1,'SELECT_INDEX','3
Set the starting index (by code)
Get_Custom_Property('BLOCK.ITEM',1,'SELECT_CODE','code');
e.g.:
-- set focus on the 3rd option --
Set_Custom_Property('BL.BEAN',1,'SELECT_CODE','v2
Set the starting index (by value) twin value list only
Get_Custom_Property('BLOCK.ITEM',1,'SELECT_VALUE','value);
e.g.:
-- set focus on the 3rd option --
Set_Custom_Property('BL.BEAN',1,'SELECT_VALUE','Jordi
The event raised by the bean
SELECTION_CHANGED
Each time the end user change the current value of the combobox, a message is send to Forms.
You can get this message in the When-Custom-Item-Event trigger of the Bean Item:
The index number is read from the SELECTION_INDEX list parameter
The code is read from the SELECTION_CODE list parameter
The value is read from the SELECTION_VALUE list parameter
DECLARE
eventName varchar2(30) := :system.custom_item_event;
eventValues ParamList;
eventValueType number;
LC$Index varchar2(10);
LC$Code varchar2(1000);
LC$Value varchar2(1000);
BEGIN
IF (eventName='SELECTION_CHANGED') THEN
eventValues := get_parameter_list(:system.custom_item_event_parameters);
get_parameter_attr(eventValues,'SELECTION_INDEX',eventValueType, LC$Index);
get_parameter_attr(eventValues,'SELECTION_Code',eventValueType, LC$Code);
get_parameter_attr(eventValues,'SELECTION_VALUE',eventValueType, LC$Value);
-- display the current selction --
:BL.SELECT := '[' || LC$Index || '] (' || LC$Code || ') ' || LC$Value ;
END IF;
END;
The sample dialog
. Download the CBAutoCompletion.zip file
. Unzip the file
. copy the ComboBoxCompletion.jar file in the <ORACLE_HOME>/forms/java directory
. Edit your /forms/server/formsweb.cfg file to add the ComboBoxCompletion.jar .
. Open the CBAUTOCOMPLETION.fmb module (Oracle Forms 9.0.2)
. Compile all and run the module
The JAR file has to be signed.