Overblog Suivre ce blog
Administration Créer mon blog
16 octobre 2008 4 16 /10 /octobre /2008 17:19

Purpose

Here is a Pluggable Java Component that allows to manage a FTP connection.

It is based on the Calvin Tai ftpbean.

simpleFTP bean


The Java source

     SimpleFTP.java



The implementation class of the Bean Area

     oracle.forms.fd.SimpleFTP


The methods you can set

  • managing connection


-- connect the FTP host --
Set_Custom_Property('BL.BEAN', 1, 'CONNECT', 'host_name,user[,password]' );

-- set the port number (if <> 21)
Set_Custom_Property('BL.BEAN', 1, 'SET_PORT', 'port_number' );

-- set the socket timeout number --
Set_Custom_Property('BL.BEAN', 1, 'SET_SOCKET_TIMEOUT', 'number' );

-- set the passive mode (default true) --
Set_Custom_Property('BL.BEAN', 1, 'SET_PASSIVE_MODE_TRANSFER, 'true|false');'

-- close the connection --
Set_Custom_Property('BL.BEAN', 1, 'CLOSE', '' );


  • managing content


-- change host directory --
Set_Custom_Property('BL.BEAN', 1, 'SET_DIRECTORY', 'remote_directory' );

-- get the host directory list --
Set_Custom_Property('BL.BEAN', 1, 'DIRECTORY_LIST', 'remote_directory' );

-- get a binary file --
Set_Custom_Property('BL.BEAN', 1, 'GET_BINARY_FILE', 'remote_filename,local_filename[,remote_file_size][,...]' );

You can provide multiple pairs of remote/local/file_size:
Set_Custom_Property('BL.BEAN',1,'GET_BINARY_FILE','file1.jpg,d:\file1.jpg,0,file2.jpg,d:\file2.jpg,0');

If the remote_file_size is not provided, the progress bar will not display the exact values.

-- get an ascii file --
Set_Custom_Property('BL.BEAN', 1, 'GET_ACSII_FILE', 'remote_filename,local_filename[,remote_file_size]' );

If the remote_file_size is not provided, the progress bar will not display the exact values.

-- put a binary file --
Set_Custom_Property('BL.BEAN', 1, 'PUT_BINARY_FILE', 'locale_filename,remote_filename[,...]' );

You can provide multiple pairs of remote/local/file_size:

Set_Custom_Property('BL.BEAN',1,'PUT_BINARY_FILE','d:\file1.jpg,file1.jpg,d:\file2.jpg,file2.jpg');


-- change to the parent host directory --
Set_Custom_Property('BL.BEAN', 1, 'TO_PARENT_DIR', '' );

-- create a host directory --
Set_Custom_Property('BL.BEAN', 1, 'MAKE_DIRECTORY', 'remote_directory' );

-- remove a host directory --
Set_Custom_Property('BL.BEAN', 1, 'REMOVE_DIRECTORY', 'remote_directory' );

-- delete a remote file --
Set_Custom_Property('BL.BEAN', 1, 'FILE_DELETE', 'remote_filename' );     

-- rename a remote file --
Set_Custom_Property('BL.BEAN', 1, 'FILE_RENAME', 'remote_filename' );

-- execute a command --
Set_Custom_Property('BL.BEAN', 1, 'EXECUTE', 'command' );


  • progress bar


To not just making the wrapper around the great Calvin work, I have added a nice progress bar you can display while transfering files.
The progress bar can be as simple as possible to include it in your existing design, but it can also have a titled border.
All the dimensions must be given in pixel.

-- display/hide the file transfer progress bar --
Set_Custom_Property('BL.BEAN', 1, 'SET_PROGRESS_BAR, 'true|false');'

-- set the progress bar location --
Set_Custom_Property('BL.BEAN', 1, 'SET_PROGRESS_BAR_LOCATION', 'X_POS,Y_POS' );

The coordinates are pixel based, and relative to the upper-left corner of the canvas.
If it is not provided or equals to -1,-1  the progress bar is centered to the canvas.

-- set the progress bar size --
Set_Custom_Property('BL.BEAN', 1, 'SET_PROGRESS_BAR_SIZE', 'width,height' );

If it is not provided, the default values are : 200,16

-- set the progress bar title --
Set_Custom_Property('BL.BEAN', 1, 'SET_PROGRESS_BAR_TITLE', 'title' );

If it is not provided, the progress bar is displayed without any titled border

-- switch on/off the Java console loggin --
Set_Custom_Property('BL.BEAN', 1, 'SET_LOG', 'true|false');


The methods you can get

-- get the message corresponding to the last FTP order --
var := Get_Custom_Property('BL.BEAN', 1, 'GET_MESSAGE');

Generally used after every FTP order to check the execution status.
Returns "OK" if the command succeeded, else returns the error message.

-- get the file list --
var := Get_Custom_Property('BL.BEAN', 1, 'GET_FILE_LIST');

Returns a delimited string of all records founds. The fields are separated by a CHR(9), and the records are separated by a CHR(10).

The record is composed by the following:
 - File type (DIR | FILE | LINK | OTHER)
 - File name
 - File size
 - File date

-- get the FTP reply string --
var := Get_Custom_Property('BL.BEAN', 1, 'GET_REPLY');

It is composed by the FTP code and the FTP message.

-- get the FTP port number --
var := Get_Custom_Property('BL.BEAN', 1, 'GET_PORT');

-- get the FTP socket timeout value --
var := Get_Custom_Property('BL.BEAN', 1, 'GET_SOCKET_TIMEOUT');

-- get the host server name --
var := Get_Custom_Property('BL.BEAN', 1, 'GET_SERVER_NAME');


The events raised by the bean

PROGRESS_MESSAGE
Is raised by the bean by the progress bar

PROGRESS_VALUE
is the current progress bar value

-- example of When-Custom-Item-Event trigger --
DECLARE
    eventName varchar2(30) := :system.custom_item_event;
    eventValues ParamList;
    eventValueType number;
    LC$Value  varchar2(1000);
BEGIN
   IF (eventName='PROGRESS_MESSAGE') THEN
      eventValues := get_parameter_list(:system.custom_item_event_parameters);
      get_parameter_attr(eventValues,'PROGRESS_VALUE',eventValueType, LC$Value);  
      -- display the current transfert percentage --
      :BL.PROGRESS := LC$Value || '%' ;
      Synchronize;
   END IF;
END;



The sample dialog


     . Download the simpleFTP.zip file
     . Unzip the file
     . copy the ftpbean.jar and simpleFTP.jar files in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file
     archive_jini=f90all_jinit.jar,ftpbean.jar,simpleFTP.jar
     archive=f90all.jar,ftpbean.jar,simpleFTP.jar

     . Open the simpleFTP.fmb module (Oracle Forms 9.0.2)
     . Compile all and run the module

In the sample dialog, when you are connected to the FTP server, double-clicking one line of the file content table-block will open and display the new folder if the file type is DIR, or download the underlying file on the c:/ folder if the file type is FILE.


The two JAR files have to be signed.
Those, shipped with the zip file are already signed.


Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
6 février 2008 3 06 /02 /février /2008 11:34

Purpose

Here is a Java Bean that allows to manage an "auto completion" Swing JComboBox.



Key Pressed



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',1,'
INIT','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',1,'
INIT_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_TWIN','[END_DATA]');

 

In this case, the last call to ADD_XXX methods must contains the [END_DATA] string.

 

 

 

Set the Font

Get_Custom_Property('BLOCK.ITEM',1,'SET_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.

 

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
25 janvier 2008 5 25 /01 /janvier /2008 14:59

Purpose

Here is a Java Bean that allows to get some client machine information.


Key Pressed



The Java code

     ClientInfos.java



The implementation class of the Bean Item

     oracle.forms.fd.ClientInfos


The methods you can get



Get all client information

Get_Custom_Property('BLOCK.ITEM',1,'GET_CLIENT_INFOS');


e.g.:
-- get all information --
:BL.INFOS := Get_Custom_Property('BL.BEAN', 1, 'GET_CLIENT_INFOS' ) ;
 



Get a particular client information

Get_Custom_Property('BLOCK.ITEM',1,'property');

where property could be one of the following:


OPERATING : Operating System
ARCHITECTURE : architecture
OSVERSION : OS version
IP : IP address
MAC : MAC address
JAVAVERSION : Java version
JAVAVENDOR : Java vendor
JAVAVENDORURL : Java vendor URL
JAVAHOME : Java vendor home page
JAVAVMSPECIFICATIONVERSION : Virtual machine version
JAVAVMSPECIFICATIONVENDOR : Virtual machine vendor
JAVAVMSPECIFICATIONNAME : Virtual machine name
USERNAME : user name
USERHOME : user home


e.g.:
-- get MAC address --
:BL.INFOS := Get_Custom_Property('BL.BEAN', 1, 'MAC' ) ;
 


 

 





The sample dialog


     . Download the clientinfos.zip file
     . Unzip the file
     . copy the clientinfos.jar file in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file to add the clientinfos.jar .
     . Open the CLIENTINFOS.fmb module (Oracle Forms 9.0.2)
     . Compile all and run the module

     The JAR file has to be signed.

 

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
21 décembre 2007 5 21 /12 /décembre /2007 13:14

Purpose

Here is a Java bean that allows to choose a date from a Java swing calendar.

The Java calendar itself is from Kai Toedter - Released under GNU Lesser General Public License - www.toedter.com

It needs the Sun Java plugin to run (won't run with JInitiator).

(the JInitiator 1.3.28 compatible version is downlodable at the end of the article)



JCalendar

Just double-click a day in the calendar to send an event to Forms with the date parameters.



The Java code

     JCalendar.java



The implementation class of the Bean Item

     oracle.forms.fd.JCalendar


The properties you can set



Set some properties

Set_Custom_Property('BL.BEAN', 1, 'SET_PROPERTY', 'property_name,property_value');

property_name can be one of the following:

  • title : set the frame title
  • background : set the background color
  • foreground : set the foreground color
  • decorationforeground : set the decoration foreground color (Sun plugin only)
  • sundayforeground : set the sunday foreground color (Sun plugin only)
  • weekdayforeground : set the week day foreground color (Sun plugin only)
  • date : set the starting date (year,month,day) (Sun plugin only)
  • locale : set a new Locale
  • plasticLAF : set the PlasticLAF Look & Feel
  • log : set the trace to the Java console (true | false)

colors are sent with the following format : rXgXbX where x must be between 0 and 255

e.g. :
Set_Custom_Property('BL.BEAN',1, 'SET_PROPERTY','plasticLAF,true');
Set_Custom_Property('BL.BEAN',1, 'SET_PROPERTY','log,true');
Set_Custom_Property('BL.BEAN',1, 'SET_PROPERTY','title,Choose...');
Set_Custom_Property('BL.BEAN',1, 'SET_PROPERTY','locale,US');
Set_Custom_Property('BL.BEAN',1, 'SET_PROPERTY','foreground,r128g50b50');

Set_Custom_Property('BL.BEAN',1, 'SET_PROPERTY','date,2007,12,25');


Show the calendar


Set_Custom_Property('BL.BEAN', 1, 'SHOW_CALENDAR', '[x_position,y_position]');

 

 

If x_position and y_position are given, the calendar will be shown at this position (top-left corner).

e.g:
-- show calendar --
Set_Custom_Property('BL.BEAN',1, 'SHOW_CALENDAR','');

-- show calendar at position 50,50 --
Set_Custom_Property('BL.BEAN',1, 'SHOW_CALENDAR','50,50');

 

The event received from the Bean

CALENDAR_EVENT


this event tells Forms that a date has been chosen in the calendar.
You can get it in a WHEN-CUSTOM-ITEM-EVENT event:

DECLARE
   
    eventName varchar2(30) := :system.custom_item_event;
    eventValues ParamList;
    eventValueType number;
    LC$Date   varchar2(256); -- complete date
    LC$Day    varchar2(256); -- day number (1-31)
    LC$Month  varchar2(256); -- month number (1-12)
    LC$Year   varchar2(256); -- year number
   
BEGIN
   
   IF (eventName='CALENDAR_EVENT') THEN
      eventValues := get_parameter_list(:system.custom_item_event_parameters);
      get_parameter_attr(eventValues,'CALENDAR_EVENT_DATE',eventValueType, LC$Date);
      get_parameter_attr(eventValues,'CALENDAR_EVENT_DAY',eventValueType, LC$Day);
      get_parameter_attr(eventValues,'CALENDAR_EVENT_MONTH',eventValueType, LC$Month);
      get_parameter_attr(eventValues,'CALENDAR_EVENT_YEAR',eventValueType, LC$Year);
      Clear_Message;
      Message('Selected date:'|| LC$Date || '(' || LC$Day||'/'||LC$Month||'/'||LC$Year || ')');
      Synchronize ;           
   END IF;  
   
END;



The sample dialog

     . Download the JCalendar.zip file
     . Unzip the file
     . copy the FJCalendar.jar, jcalendar-1.3.2.jar and looks-2.0.1.jar files in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file to add these 3 JAR files
     . Open the JCALENDAR.fmb module (Oracle Forms 9.0.2)
     . Compile all and run the module

     the FJCalendar.jar file must be signed.
     the jar file provided in this article is already signed.


Jinitiator 1.3.28 compatible version

     . Download the JCalendarJinit.zip file
     . Unzip the file
     . copy the JCalendarJinit.jar and jcalendar.jar files in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file to add these 2 JAR files

     . The Implementation Class property must be : oracle.forms.fd.JCalendarJinit

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
20 décembre 2007 4 20 /12 /décembre /2007 11:00

Purpose

Here is a Java Bean that allows reading, displaying with scaling and writing images.

It allows scaling images to fit the target item size, and includes a FileChooser with image preview dialog.

In its third version, it does not need any JDBC connexion to handle images from/to the database
.

It uses the JRE 1.4 javax.imageio.ImageIO package, so it needs, at least the Sun Java plugin 1.4.
It won't run against JInitiator.



handleimage3



The Java code

     HandleImage.java      GetImageFileName.java



The implementation class of the Bean Item

     oracle.forms.fd.HandleImage


The methods you can call




Read an image from a file

Set_Custom_Property('BLOCK.ITEM',1,'READIMGFILE','the_complete_filename');

e.g.:
-- read image from the file system --
Set_Custom_Property( 'BLZ.BEAN', 1, 'READIMGFILE', 'D:/image.jpg' ) ;
 

-- read image from the JAR file --
Set_Custom_Property( 'BLZ.BEAN', 1, 'READIMGFILE', '/image.jpg' ) ;

-- read image from the Internet --
Set_Custom_Property( 'BLZ.BEAN', 1, 'READIMGFILE', 'http://the_url/image.jpg' ) ;




Read an image from the database table

The reading process is composed by three steps:

1. Select the Blob table's column
2. Read the image chunks and send them to the Java Bean
3. End the sending process


1. Select the Blob table's column:

Pkg_Read_Blob_Image.Select_Blob(LC$Clause); (*)

LC$Clause is a string that must contain the Select order to fetch the corresponding single row:

 LC$Clause := 'Select PHOTO_JAVA From PHOTOS Where IDENTIFIANT = 10'  ;
 -- Select the Blob column --
 If Pkg_Read_Blob_Image.Select_Blob(LC$Clause) Then
    ...


2. Read the image chunks from the database then send them to the Java Bean:

Pkg_Read_Blob_Image.Get_B64_Chunk() (*)

     -- Get the image chunks from the database --
     LC$Image := Pkg_Read_Blob_Image.Get_B64_Chunk ;
     If LC$Image Is Not Null Then
       -- Send the chunks to the Java Bean --
       Set_Custom_Property( 'BLZ.BEAN', 1, 'READIMGBASE', LC$Image ) ;

3. End the sending process:

     Else
       -- End the sending process --
       Set_Custom_Property( 'BLZ.BEAN', 1, 'READIMGBASE', '[END_IMAGE]' )
;


(*) the PKG_READ_BLOB_IMAGE database's package is provided with the zip file.


e.g.:

PROCEDURE Read_Image IS
  LB$Ok      boolean ;
  LC$Image   Varchar2(32767) ;
  LC$Clause  Varchar2(4000) ;
BEGIN
 
 --
 -- Read an image from the database
 --
 LC$Clause := 'Select PHOTO_JAVA From PHOTOS Where IDENTIFIANT = ' || :PHOTOS.IDENTIFIANT ;
 -- Select the Blob column --
 If Pkg_Read_Blob_Image.Select_Blob(LC$Clause) Then
   Loop
     -- Get the image chunks from the database --
     LC$Image := Pkg_Read_Blob_Image.Get_B64_Chunk ;
     If LC$Image Is Not Null Then
       -- Send the chunks to the Java Bean --
       Set_Custom_Property( 'BLZ.BEAN', 1, 'READIMGBASE', LC$Image ) ;
     Else
       -- End the sending process --
       Set_Custom_Property( 'BLZ.BEAN', 1, 'READIMGBASE', '[END_IMAGE]' ) ;
       Exit ;
     End if ; 
   End loop ;
 End if ; 
  
END;



Put this method into the When-New-Record-Instance block-level trigger


Write an image to the database table

The writing process is also composed by three steps:

1. Initialize the transfer
2. Read the image chunks from the Java Bean and send them to the database
3. Update the Blob column with the new content


1. Initialize the transfer:

Pkg_Read_Blob_Image.Init_Transfer() (*)

This will empty the current Blob column:

 Pkg_Read_Blob_Image.Init_Transfer ;

2. Read the image chunks from the Java Bean and send them to the database:

Get_Custom_Property('BLZ.BEAN',1,'GETIMAGE');

Pkg_Read_Blob_Image.Set_B64_Chunk(LC$Req) (*)

    Loop
      -- Get the image chunk from the Java Bean --
      LC$Req := Get_Custom_Property('BLZ.BEAN',1,'GETIMAGE');
      Exit When LC$Req is null ;
      ...   
      -- Send the image chunks to the Database --
      Pkg_Read_Blob_Image.Set_B64_Chunk(LC$Req);
    End loop;

3. Update the Blob column with the new content:

     LC$Res := Pkg_Read_Blob_Image.Save_Blob('PHOTOS','PHOTO_JAVA','IDENTIFIANT=' || :PHOTOS.IDENTIFIANT );

The Save_Blob() function takes the table name, the blob column name and the Where clause arguments.


(*) the PKG_READ_BLOB_IMAGE database's package is provided with the zip file.

Put this method into the Post-Insert and Post-Update block-level trigger

e.g.:

PROCEDURE Save_Image IS
    LC$Req  Varchar2(32000);
    LN$Cpt  Pls_integer := 0 ;
    LC$Res  Varchar2(2000) ;
BEGIN
    --
    -- Save the image to the database
    --
    Loop
      -- Get the image chunk from the Java Bean --
      LC$Req := Get_Custom_Property('BLZ.BEAN',1,'GETIMAGE');
      Exit When LC$Req is null ;
      LN$Cpt := LN$Cpt + 1 ;
      If Ln$Cpt = 1 Then
         Pkg_Read_Blob_Image.Init_Transfer ;
      End if ;  
      -- Send the image chunks to the Database --
      Pkg_Read_Blob_Image.Set_B64_Chunk(LC$Req);
    End loop;
    If LN$Cpt > 0 Then
      -- Update the Blob column with the new content --
      LC$Res := Pkg_Read_Blob_Image.Save_Blob('PHOTOS','PHOTO_JAVA','IDENTIFIANT=' || :PHOTOS.IDENTIFIANT );
    End if ;
    Clear_Message ;
    Message('Result:'|| LC$Res, no_acknowledge);
END;


Put this method into the Post-Insert and Post-Update block-level triggers


Clear the image

Set_Custom_Property( 'BL.BEAN', 1, '
CLEAR' , '' ) ;

This function has to be called in a When-New-Record-Instance trigger if the record does not exist:

When-New-Record-Instance trigger:
If :PHOTOS.IDENTIFIANT is not null Then
   Read_Image ;
Else
   Set_Custom_Property( 'BLZ.BEAN', 1, 'CLEAR', '' ) ;
End if ;
:BLZ.IMG_SIZE := Get_Custom_Property( 'BLZ.BEAN', 1, 'GETSIZE' ) ;


Set the display image scalling

This function concerns only the image displayed. The image stored with the WRITEIMGBASE method will be the initial image.

Set_Custom_Property( 'BL.BEAN', 1, '
SCALE_IMAGE
','Width=x,Height= y' ) ;

Both Width and Height parameters must be transmitted

x and y can take the following values:


Any value greater then 0 that express an absolute size in pixels
the special value: FIT that extends the image to fit the exact size of the image panel' size
-1 that to keep the corresponding aspect ratio
0 that indicates no scale at all



Examples:

-- Scale the image to fit horizontally and vertically the image item --

Set_Custom_Property('BLZ.BEAN',1,'SCALE_IMAGE', 'Width=FIT,Height=FIT' ) ;

-- Scale the image to 200x100 pixels --
Set_Custom_Property('BLZ.BEAN',1,'SCALE_IMAGE', 'Width=200,Height=100' ) ;

-- Scale the image to 200 horizontal pixels and keep vertical aspect ratio --
Set_Custom_Property('BLZ.BEAN',1,'SCALE_IMAGE', 'Width=200,Height=-1' ) ;





Display/hide the image panel' scrollbars

Set_Custom_Property('BLOCK.ITEM',1,'SETSCROLL','true|false');


e.g.:
Set_Custom_Property( 'BLZ.BEAN', 1, 'SETSCROLL', 'true' ) ; 





Set the item border

Set_Custom_Property('BLOCK.ITEM',1,'SETBORDER','thick[,color]');


e.g.:

-- set a null border --
Set_Custom_Property( 'BLZ.BEAN', 1, 'SETBORDER', '0' ) ; 

-- set a 4 pixel red border --
Set_Custom_Property( 'BLZ.BEAN', 1, 'SETBORDER', '4,r255g0b0' ) ; 



Set the JFileChooser title and starting directory

Set_Custom_Property('BLOCK.ITEM',1,'SET_FILECHOOSER_TITLE','title[,directory]');

e.g.:
Set_Custom_Property( 'BLZ.BEAN', 1, 'SET_FILECHOOSER_TITLE', 'Select a file,D:/' ) ; 

the directory argument is not mandatory



Set the JFileChooser Look and Feel


Set_Custom_Property('BLOCK.ITEM',1,'SET_FILECHOOSER_LAF','SYSTEM|other_value');


e.g.:
-- use the current O.S. L&F --
Set_Custom_Property( 'BLZ.BEAN', 1, 'SET_FILECHOOSER_LAF ', 'SYSTEM' ) ;
 

-- use the Metal L&F --
Set_Custom_Property( 'BLZ.BEAN', 1, 'SET_FILECHOOSER_LAF ', 'JAVA' ) ;
 


Set the log mode to output the Bean messages

Set_Custom_Property( 'BL
.BEAN', 1, 'SETLOG' , 'true|false' ) ;



In the sample dialog provided, here is the code used in the When-New-Form-Instance trigger:

PROCEDURE InitForm IS
BEGIN
  -- switch the log to true --
  Set_Custom_Property( 'BLZ.BEAN', 1, 'SETLOG', 'true' ) ;
  -- set the baen image bckground color --
  Set_Custom_Property( 'BLZ.BEAN', 1, 'SETBG', '255,255,255' ) ;
  -- Set the JFileChooser title --
  Set_Custom_Property( 'BLZ.BEAN', 1, 'SET_FILECHOOSER_TITLE',  'Select an image file' ) ;
  -- Set the JFileChooser L&F --
  Set_Custom_Property( 'BLZ.BEAN', 1, 'SET_FILECHOOSER_LAF', 'SYSTEM' ) ;
  -- scalling properties --

  Set_Custom_Property('BLZ.BEAN',1,'SCALE_IMAGE','Width=FIT,Height=FIT' ) ;
  -- display scrollbars policy --
  Set_Custom_Property( 'BLZ.BEAN', 1, 'SETSCROLL',  'false' ) ;
 
END;

Here is the description of the database table used:

CREATE TABLE PHOTOS
   (   
      "IDENTIFIANT" NUMBER(5,0) NOT NULL ENABLE,
      "NOM" VARCHAR2(50 BYTE),
      "PHOTO" BLOB,
      "PHOTO_JAVA" BLOB,
      CONSTRAINT "PHOTO_PK" PRIMARY KEY ("IDENTIFIANT") ENABLE
   )
/



The properties you can get from the JavaBean


Get the image size

Varchar2 :=
Get_Custom_Property( 'BL.BEAN', 1, 'GETSIZE'
) ;

The format returned (width,height) is like the following : 50,120



Get the
selected filename (JFileChooser)

Varchar2 :=
Get_Custom_Property( 'BL.BEAN', 1, 'GET_FILE_NAME' ) ;

this method both displays the JFileChooser and returns the selected file.



Get the current image chunks

Varchar2 :=
Get_Custom_Property( 'BL.BEAN', 1, 'GETIMAGE' ) ;

This method returns the last image read by the READIMGFILE() method..
It returns null when the image is completly read.

 


The events raised to Forms


Two events are raised by the Java Bean to Forms:

 

MOUSE_CLICKED and MOUSE_DOUBLECLICKED that you can trap through the When-Custom-Item-Event trigger:

 

DECLARE
    eventName varchar2(30) := :system.custom_item_event;
    eventValues ParamList;
    eventValueType number;
BEGIN
   IF (eventName='MOUSE_DOUBLECLICKED') THEN
      Message('Mouse double-click',no_acknowledge);
   ElsIF (eventName='MOUSE_CLICKED') THEN
      Message('Mouse click',no_acknowledge);
   END IF;
END;


 

The sample dialog


     . Download the handleimage3.zip file
     . Unzip the file
     . run the create_table.sql script under the Oracle user you want to test (It creates the sample image table).
     . run the PKG_READ_BLOB_IMAGE.sql script under the Oracle user you want to test (It creates the database package).
     . copy the handleimage3.jar file in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file to add the handleimage3.jar .
     . Open the HANDLEIMAGE3.fmb module (Oracle Forms 9.0.2)
     . Compile all and run the module



Note : If you rebuild the jar file, it has to be signed. (the handleimage3.jar file provided in this article is already signed).
Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
6 novembre 2007 2 06 /11 /novembre /2007 13:11

This Java Bean allows to process massive updates to the Forms source files (.FMB) through an XML input file.


Purpose

 


The goal is to hide the complexity of the Java/JDAPI stuff for those people that do not have time/skill to implement this Java API.

 
All the work expected to be done on the FMB files is described in a XML file.

JDAPI Utility

Three main sections are implemented to achieve the following:

  • section 1: define the global settings
  • section 2: do the job on all the modules given
  • section 3: do the job on each named module given

This Bean has been constructed as an enhanced Java Bean (using the FBean package), so it can be executed outside the Forms environment, from JDeveloper or from the command line.

I have tested it successfully under Forms 9i and the Sun Java plug in 1.5, but I have also encountered many problems while trying running it with Forms 10g and Sun Java plug in 1.6 or under the JInitiator.

This is the reason why I have added the possibility to run the stuff from the JAR file via the java.exe program called through the Host() Forms built-in.

 At this very moment (version 1.0) it can achieve the following:

 

  • Change the PL/SQL attached libraries name case to lower or upper case.
  • Attach a PL/SQL library
  • Remove a PL/SQL library
  • Add a Forms trigger
  • Remove a Forms trigger
  • Add a program unit
  • Remove a program unit
  • Delete PL/SQL code part from a trigger/program unit
  • Replace PL/SQL code part from a trigger/program unit
  • Add OLB sublassed object
  • do all available property setting on:
    • Alerts
    • Windows
    • Canvas
    • Blocks
    • Items
    • Editors
    • LOVs
    • Record Groups
    • Visual Attributes

 

To know what properties can be set to this last objects, study the JDAPI documentation and particularly the following classes:

 

  • oracle.forms.jdapi.Alert
  • oracle.forms.jdapi.Block
  • oracle.forms.jdapi.Canvas
  • oracle.forms.jdapi.Item
  • oracle.forms.jdapi.Window

 

for instance, here are the properties you can set to an alert:

 // String properties
setAlertMessage(String)
setBackColor(String)
setButton1Label(String)
setButton2Label(String
setButton3Label(String)
setComment(String)
setFillPattern(String)
setFontName(String
setForegroundColor(String)
setName(String
setTitle(String
setVisualAttributeName(String

// boolean properties
setSubclassObjectGroup(boolean)

// integer properties
setAlertStyle(int)
setDefaultAlertButton(int)
setFontSize(int)
setFontSpacing(int)
setFontStyle(int)
setFontWeight(int)
setLanguageDirection(int)


The implementation class of the Bean


     oracle.forms.fd.jdapiutil.JDAPIUtil


Register the bean:

FBean.Register_Bean('BL.BEAN', 1, 'oracle.forms.fd.jdapiutil.JDAPIUtil');


The methods you can call



Switch the logging mode:

FBean.Set_Property('BL.BEAN', 1, 'Log', true);



Set the log filename:

FBean.Set_Property('BL.BEAN', 1, 'LogFilename', 'c:/jdapiutil.log');



Process the XML file:

FBean.Invoke('BL.BEAN', 1, 'doProcess','XML_filename');


If you do not want to use this internal command (bug with some JREs) do as the following:


If internal Then
  FBean.Invoke('BL.BEAN', 1, 'doProcess',:BL.XMLFILE);
Else 
  Declare
    LC$Cmd Varchar2(512) ;
  Begin 
    LC$Cmd := 'cmd /c "' || :BL.JAVA || 'java.exe -classpath ' 
    || :BL.JAR_DIR || 'JDAPIUtil.jar;'
    || :BL.JAR_DIR || '
f90jdapi.jar; oracle.forms.fd.jdapiutil.JDAPIUtil '
    || :BL.XMLFILE || '"' ;
    host(LC$Cmd);
  End;

End if ; 
-- get the log file content --
:BL.LOG := FBean.Get_Property('BL.BEAN', 1, 'LogContent');
Go_Item('BL.LOG');
Edit_Textitem(10,10,500,400) ; 

In this code snippet, I used the Forms 9i version. If you use the Forms 10g version, replace f90jdapi.jar by frmjdapi.jar.

The :BL.JAVA field contains the directory name that contains the java.exe program (generally <devsuite_home>/jre/bin).
The :BL.JAR_DIR field contains the name of the directory where the JAR files are stored (generally <devsuite_home>/forms/java).

 

Run the program from the command line:

Assume the following:

The java.exe program is located in the C:
/Oracle/jdk/bin directory
The JAR files are located in the C:/Oracle/forms/java directory
The XML file full name is : C:/my_XML_file.xml

Open a DOS dialog box and e
nter the following command:

C:
/Oracle/jdk/bin/java.exe -classpath C:/Oracle/forms/java/JDAPIUtil.jar;C:/Oracle/forms/java/frmjdapi.jar; oracle.forms.fd.jdapiutil.JDAPIUtil C:/my_XML_file.xml



Get the log file content:

FBean.Set_Property('BL.BEAN', 1, 'LogFilename', 'c:/jdapiutil.log');

varchar :=
FBean.Get_Property('BL.BEAN', 1, 'LogContent');


The sample dialog


     . Download the jdapiutil.zip file
     . Unzip the file
     . copy the JDAPIUtil.jar file in the <ORACLE_HOME>/forms/java directory

     . Edit your /forms/server/formsweb.cfg file to add  JDAPIUtil.jar and f90jdapi.jar or frmjdapi.jar.
     . Open, compile and run the JDAPIUTIL.fmb module (Oracle Forms 9.0.2)

 

Documentation

 

See the XML syntax documentation

Download an XML file sample

Download the JDAPI documentation

Download the list of JDAPI integer constants

Download the complete JDeveloper project (that contains the Java source files)

You have to add the f90jdapi.jar (forms9i) or frmjdapi.jar (forms10g) to the project libraries.
You also have to indicate the oracle.forms.fd.jdapiutil.JDAPIUtil in the main class of the JAR deployment dialog.  

To implement this Bean in your Forms application, add the JDAPIUtil.jar and the f90jdapi.jar (Forms 9i) or the frmjdapi.jar (Forms 10g) to the archive and archive_jini tags of the /forms/server/forsweb.cfg file.


The JDAPIUtil.jar file read files from the client machine, so it needs to be signed.

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
19 septembre 2007 3 19 /09 /septembre /2007 10:00

Purpose

Here is a Java Bean to handle CLOB/NCLOB database columns in a Forms application.

It needs a database package to read the LOB data from the database, split into chunks in order to send them to Forms and finally to the JavaBean, and also to send back the modified text from the JavaBean to the database LOB column.

This package (PKG_CLOB), provided in the zip file, have functions and procedures to handle both CLOB and NCLOB columns.
It uses the EXECUTE IMMEDIATE function to Read and Write via full SQL orders passed as argument, so it is generic.

It has been successfully tested with Forms 10.1.2 and XE database.


Big Text Area




The Java code

     bigtextarea.java



The implementation class of the Bean Item

     oracle.forms.fd.TextArea


The methods you can call


Add text to the text item

Set_Custom_Property('BLOCK.ITEM',1,'ADD_TEXT','text');

e.g. :

LC$Text := 'Text to send to the bean' ;
Set_Custom_Property( 'BL.BEAN', 1, 'ADD_TEXT', LC$Text ) ; 
  

Use this method to read the database CLOB/NCLOB content then send it to the bean.

Here is a sample code you could write in a Post-Query trigger for instance:

Declare
  LN$Length  pls_integer ;
  LC$Chunk   Varchar2(32767) ;
  LN$Cpt     pls_integer := 0 ;
  LC$Req     Varchar2(1024);
Begin    
 
  ----------------------------------
  --  Build the Select SQL order  --
  ----------------------------------

  LC$Req := 'Select NTEXT From TEST_CLOB Where ID=1' ;
 
  ---------------------------------------
  --  select the database CLOB column  --
  ---------------------------------------

  If pkg_clob.select_nclob(LC$Req) then
    Loop
      -------------------------
      --  get the chunks...  --
      -------------------------

      LC$Chunk := pkg_clob.get_nchunk ;
      Exit when LC$Chunk is null ;
      LN$Cpt := LN$Cpt + 1 ;
      --------------------------------------
      --  ... then send them to the Bean  --
      --------------------------------------

      Set_Custom_Property('BLOCK3.BEAN',1, 'ADD_TEXT',LC$Chunk);
    End loop ;
    ---------------------------------
    --  display the complete text  --
    ---------------------------------

    Set_Custom_Property('BLOCK3.BEAN',1, 'SHOW','');
    ---------------------------
    --  get the text length  --
    ---------------------------

    LN$Length := Get_Custom_Property('BLOCK3.BEAN',1,'GET_LENGTH') ;
    message('length=' || LN$Length);    
  Else
    message('problem reading CLOB');      
  End if ;
 
end;


In this sample, we are selecting  the content of the NTEXT NCLOB column from the TEST_CLOB table.


Display the complete text

Set_Custom_Property('BL.BEAN',1,'SHOW','');

Use this method when all teh text chunks have been sent to the bean.



Clear the text

Set_Custom_Property('BL.BEAN',1,'CLEAR','');




The properties you can get from the JavaBean


Get the current text length

Varchar2 :=
Get_Custom_Property( 'BL.BEAN', 1, 'GET_LENGTH'
) ;


Get the current text chunks

Varchar2 :=
Get_Custom_Property( 'BL.BEAN', 1, 'GET_TEXT'
) ;

Use this method in a loop to get every chunk, then store them in the corresponding CLOB/NCLOB database column.

Here is a sample  code you can use in a Post-Insert or Post-Update trigger:

Declare
    LC$Chunk  Varchar2(32767) ;
    LC$Req    Varchar2(1024) ;
    LC$Msg    Varchar2(4000);
Begin  
    --------------------------------
    --  set the UPDATE SQL order  --
    --------------------------------

    LC$Req := 'Update TEST_CLOB Set NTEXT = :1 Where ID=1' ;
    -------------------------------------
    --  Init the transfer for a NCLOB  --
    -------------------------------------

    PKG_CLOB.Init_Transfer ( 'NCLOB' );
    Loop
      LC$Chunk := Get_Custom_Property('BLOCK3.BEAN',1,'GET_TEXT') ;
      Exit When  LC$Chunk Is Null ;
      ---------------------------------------
      --  Send the chunks to the database  --
      ---------------------------------------

      PKG_CLOB.Set_NChunk ( LC$Chunk ) ;
    End loop;
    ---------------------------------------------
    --  Update the CLOB/NCLOB database column  --
    ---------------------------------------------

    LC$Msg :=  PKG_CLOB.Transfer( LC$Req, 'NCLOB' ) ;
    If LC$Msg = 'OK' Then
     Forms_ddl('Commit') ;
    Else
         Message(LC$Msg);
    End if ;
End;

The writting process is done through three steps:

  • init the transfer by cleaning the target CLOB/NCLOB package's variable with Init_Transfer()
  • send the chunks to the database package to populate the package CLOB/NCLOB variable with Set_Chunk()
  • update the database row with the current CLOB/NCLOB variable with Transfer()





The sample dialog


     . Download the bigtextarea.zip file
     . Unzip the file
     . copy the bigtextarea.jar file in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file to add  bigtextarea.jar .
     . If needed, create the database sample table (create_table_test_clob.sql)
     . create the database package (pkg_clob.sql)
     . Open, compile and run the BIGTEXT.fmb module (Oracle Forms 9.0.2)

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
15 septembre 2007 6 15 /09 /septembre /2007 09:51

Purpose

Here is a Java Bean to read the Window Forms menu option.

You have access to every window opened in the Forms application to minimize or restore them.


windowmenu1

windowmenu2

windowmenu3




The Java code

     WindowMenu.java



The implementation class of the Bean Item

     oracle.forms.fd.WindowMenu


The methods you can call


Scan the application to find every opened window

Set_Custom_Property('BLOCK.ITEM',1,'FIND_WINDOWS','');

e.g. :
Set_Custom_Property( 'BL.BEAN', 1, 'FIND
_WINDOWS', '' ) ;   



Minimize all windows

Set_Custom_Property('BLOCK.ITEM',1,'MINIMIZE_ALL','');

 

Minimize a single window

Set_Custom_Property('BLOCK.ITEM',1,'MINIMIZE_WINDOW','window_title');


Restore all windows

Set_Custom_Property('BLOCK.ITEM',1,'RESTORE_ALL','');



Restore a single window

Set_Custom_Property('BLOCK.ITEM',1,'RESTORE_WINDOW','window_title');



Set the window(s) bounds

Set_Custom_Property('BLOCK.ITEM',1,'SET_BOUNDS','param');

Where param is: WINDOW_NAME|ALL,x|-[,y|-[,width|-[,height|-]]]


Use the ALL keyword to move all the windows.
Use a - instead a value to skip its definition:

-- set all windows new X position to 30 pixels
Set_Custom_Property( 'BL.BEAN', 1, 'SET_BOUNDS', 'ALL,30,-'
) ;


-- set all windows X position to 10 and width to 100
Set_Custom_Property( 'BL.BEAN', 1, 'SET_BOUNDS', 'ALL,10,-,100,-'
) ;





The properties you can get from the JavaBean


Get the list of opened windows

Varchar2 :=
Get_Custom_Property( 'BL.BEAN', 1, 'GET_WINDOWS'
) ;

Returns a comma separated list like the following : Window 1,Window 2[,...]




The sample dialog


     . Download the windowmenu.zip file
     . Unzip the file
     . copy the windowmenu.jar file in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file to add  windowmenu.jar .
     . Open and compile both the windowmenu.fmb and windowmenu2.fmb modules (Oracle Forms 9.0.2)
     . Compile all and run the windowmenu module

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
11 septembre 2007 2 11 /09 /septembre /2007 21:10

Purpose

Here is a Java Bean that allows reading, displaying with scaling and writing images.

(See the last  evolution of this solution here)

 

This Bean allows scaling images to fit the target item size, and includes a FileChooser with image preview dialog.


handleimage2

This JavaBean connects to the database through the JDBC driver to read and write the images, and does not need the Webutil library to pick up the image files from the JAR file, the client machine files or the Internet.


The Java code

     HandleImage.java     LectureBlob.java        GetImageFileName.java



The implementation class of the Bean Item

     oracle.forms.fd.HandleImage


The methods you can call


Set the connection string


Set_Custom_Property('BLOCK.ITEM',1,'SETCONN','the_connection_string');
e.g. :
Set_Custom_Property( 'BL.BEAN', 1, '
SETCONN', 'jdbc:oracle:thin:@my-machine:1521:XE' ) ;   
(Provide the complete jdbc:oracle:thin:... syntax)


Set the username


Set_Custom_Property('BLOCK.ITEM',1,'SETUSER','username');


Set the password

Set_Custom_Property('BLOCK.ITEM',1,'SETPWD','password');


Set the
database image table information

Set_Custom_Property('BLOCK.ITEM',1,'SETTABLEINFO','p1,p2');

p1 is the table name that holds the image Blob column
p2 is the Blob column name that holds the image

e.g.:
Set_Custom_Property( 'BLZ.BEAN', 1, 'SETTABLEINFO', 'PHOTOS,IMAGE' ) ;  

The instruction above indicates that the PHOTOS table handle images in the IMAGE Blob column..


Read an image from a file

Set_Custom_Property('BLOCK.ITEM',1,'READIMGFILE','the_complete_filename');

e.g.:
Set_Custom_Property( 'BLZ.BEAN', 1, 'READIMGFILE', 'D:/image.jpg' ) ; 


Read an image from the database table

Set_Custom_Property('BLOCK.ITEM',1,'READIMGBASE,'where_clause');

e.g.:
Set_Custom_Property( 'BLZ.BEAN', 1, 'READIMGBASE', 'IDENTIFIANT=20' ) ;  

where_clause is the SQL clause to identify a unique row to update in the table. The above instruction will be interpreted as :

   Select IMAGE From PHOTOS Where IDENTIFIANT=20


Put this method into the When-New-Record-Instance block-level trigger


Write an image to the database table

Set_Custom_Property('BLOCK.ITEM',1,'WRITEIMGFILE','where_clause');

e.g.:
Set_Custom_Property( 'BLZ.BEAN', 1, 'WRITEIMGBASE', 'IDENTIFIANT=20' ) ;  

where_clause is the SQL clause to identify a unique row to update in the table.
The above instruction will be interpreted as :

   Update PHOTOS Set IMAGE = ? Where IDENTIFIANT=20


Put this method into the Post-Insert and Post-Update block-level triggers



Clear the image

Set_Custom_Property( 'BL.BEAN', 1, '
CLEAR' , '' ) ;

This function has to be called in a When-New-Record-Instance trigger if the record does not exist:

When-New-Record-Instance trigger:
If :PHOTOS.IDENTIFIANT is not null Then
   Set_Custom_Property( 'BLZ.BEAN', 1, 'READIMGBASE', 'IDENTIFIANT=12' ) ;
Else
   Set_Custom_Property( 'BLZ.BEAN', 1, 'CLEAR', '' ) ;
End if ;
:BLZ.IMG_SIZE := Get_Custom_Property( 'BLZ.BEAN', 1, 'GETSIZE' ) ;


Set the display image scalling

This function concerns only the image displayed. The image stored with the WRITEIMGBASE method will be the initial image.

Set_Custom_Property( 'BL.BEAN', 1, '
SCALE_IMAGE
' , 'Width=x,Height=y' ) ;

Both Width and Height parameters must be transmitted

x and y can take the following values:


Any value greater than 0 that express an absolute size in pixels
the special value: FIT that extend to fit the exact size of the image panel' size
-1 that to keep the corresponding aspect ratio
0 that indicates no scale at all



Examples:


-- Scale the image to fit horizontally and vertically the image item --

Set_Custom_Property( 'BLZ.BEAN', 1, 'SCALE_IMAGE', 'Width=FIT,Height=FIT' ) ;

-- Scale the image to 200x100 pixels --
Set_Custom_Property( 'BLZ.BEAN', 1, 'SCALE_IMAGE', 'Width=200,Height=100' ) ;

-- Scale the image to 200 horizontal pixels and keep vertical aspect ratio --
Set_Custom_Property( 'BLZ.BEAN', 1, 'SCALE_IMAGE', 'Width=200,Height=-1' ) ;





Display/hide the image panel' scrollbars

Set_Custom_Property('BLOCK.ITEM',1,'SETSCROLL','true|false');


e.g.:
Set_Custom_Property( 'BLZ.BEAN', 1, 'SETSCROLL', 'true' ) ; 



Set the JFileChooser title and starting directory

Set_Custom_Property('BLOCK.ITEM',1,'SET_FILECHOOSER_TITLE','title[,directory]');

e.g.:
Set_Custom_Property( 'BLZ.BEAN', 1, 'SET_FILECHOOSER_TITLE', 'Select a file,D:/' ) ; 


Set the JFileChooser Look and Feel


Set_Custom_Property('BLOCK.ITEM',1,'SET_FILECHOOSER_LAF','SYSTEM|other_value');


e.g.:
-- use the current O.S. L&F --
Set_Custom_Property( 'BLZ.BEAN', 1, 'SET_FILECHOOSER_LAF', 'SYSTEM' ) ;
 

-- use the Metal L&F --
Set_Custom_Property( 'BLZ.BEAN', 1, 'SET_FILECHOOSER_LAF', 'JAVA' ) ;
 



Set the log mode to output the Bean messages

Set_Custom_Property( 'BLZ
.BEAN', 1, 'SETLOG' , 'true|false' ) ;



In the sample dialog provided, here is the code used in the When-New-Form-Instance trigger:

PROCEDURE InitForm IS
BEGIN
  -- switch the log to true --
  Set_Custom_Property( 'BLZ.BEAN', 1, 'SETLOG', 'true' ) ;
  -- set the baen image bckground color --
  Set_Custom_Property( 'BLZ.BEAN', 1, 'SETBG', '255,255,255' ) ;
  -- set the JDBC connection information --
  Set_Custom_Property( 'BLZ.BEAN', 1, 'SETCONN', 'jdbc:oracle:thin:@my-machine:1521:XE' ) ;
  Set_Custom_Property( 'BLZ.BEAN', 1, 'SETUSER', 'tutoforms' ) ;
  Set_Custom_Property( 'BLZ.BEAN', 1, 'SETPWD',  'tutoforms' ) ;
  -- set the image table and column name --
  Set_Custom_Property( 'BLZ.BEAN', 1, 'SETTABLEINFO',  'PHOTOS,PHOTO_JAVA,IDENTIFIANT' ) ;
  -- Set the JFileChooser title --
  Set_Custom_Property( 'BLZ.BEAN', 1, 'SET_FILECHOOSER_TITLE',  'Select an image file' ) ;
  -- Set the JFileChooser L&F --
  Set_Custom_Property( 'BLZ.BEAN', 1, 'SET_FILECHOOSER_LAF', 'SYSTEM' ) ;
  -- scalling properties --
  Set_Custom_Property( 'BLZ.BEAN', 1, 'SCALE_IMAGE' , 'Width=FIT,Height=FIT' ) ;
  -- display scrollbars policy --
  Set_Custom_Property( 'BLZ.BEAN', 1, 'SETSCROLL',  'false' ) ;
 
END;

Here is the description of the database table used:

CREATE TABLE PHOTOS
   (   
      "IDENTIFIANT" NUMBER(5,0) NOT NULL ENABLE,
      "NOM" VARCHAR2(50 BYTE),
      "PHOTO" BLOB,
      "PHOTO_JAVA" BLOB,
      CONSTRAINT "PHOTO_PK" PRIMARY KEY ("IDENTIFIANT") ENABLE
   )
/



The properties you can get from the JavaBean


Get the image size

Varchar2 :=
Get_Custom_Property( 'BL.BEAN', 1, 'GETSIZE'
) ;

The format returned (width,height) is like the following : 50,120



Get the
selected filename (JFileChooser)

Varchar2 :=
Get_Custom_Property( 'BL.BEAN', 1, 'GET_FILE_NAME'
) ;


This method, both open the JFileChooser dialog box, then returns the selected file.





Accessing to a remote database

Because the JavaBean is executed within an applet, it is not possible to connect to a remote database without a little adaptation:

   - first, the jar file must be signed.
   - second : you have to update the java.policy file stored in the Jinitiator directory

For example, to access to the database located on the machine-name server on the port 1524, add the following lines to the java.policy file:

C:/Program Files/Oracle/JInitiator 1.3.1.xx/lib/security/java.policy file

 

 permission java.net.SocketPermission "machine-name:1524-", "accept,connect,listen,resolve"; 

permission java.security.AllPermission;



The sample dialog


     . Download the handleimage2.zip file
     . Unzip the file
     . run the create_table.sql under the Oracle user you want to test (It creates the sample image table).
     . copy the handleimage2.jar file in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file to add both handleimage2.jar and classes12.jar (the classes12.jar is located in the <DEV_HOME>/jdbc/lib directory. add a copy of this file in the <DEV_HOME>/forms/java directory).
     . Open the HANDLEIMAGE2.fmb module (Oracle Forms 10.1.2)
     . Compile all and run the module



Note : If you rebuild the jar file, it has to be signed. (the handleimage2.jar file provided in this article is already signed).
Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
30 mai 2007 3 30 /05 /mai /2007 14:50

Purpose

Here is a Java Bean that allows handling frames at runtime.
Almost everything about frames can by handled.

With this single bean, you can create and handle as many frames as needed.

This Bean needs at least the Sun Java plugin 1.4

 

Dynamic Frames

Dynamic Frames

What you can do with these frames:

  • Create, move, modify, show, hide and remove
  • Set the border width, color, shadow color and rounded corners.
  • Set the title font, color and alignment. It can be on top, on left, on right or on bottom border line.
  • Set the frame inside color or gradient

 

The Implementation Class property

   oracle.forms.fd.frame


 

The Java code

    frame.java


 

The properties you can set

 

Each property takes a frame name as its first argument.
It is, so, easy to reuse this name to set the properties for the desired frame.

 


SET_FRAME
create the frame (must be used first)

Set_Custom_Property('BL.BEAN',1,'SET_FRAME','properties') ;

properties:
   name, border_width, title, font, font_size, font_weight [,title_pos, alignment]

title_pos can be:

  • top
  • bottom
  • left
  • right

alignment can be:

  • left
  • center
  • right

Set_Custom_Property('BL.BEAN',1,'SET_FRAME','F1,3,Frame Title,Arial,16,B,top,center') ;


SET_FRAME_TEXT
Set the frame title and eventually the position.

Set_Custom_Property('BL.BEAN',1,'SET_FRAME_TEXT','properties') ;

properties:
   name, title [,title_pos, alignment]

title_pos can be:

  • top
  • bottom
  • left
  • right

alignment can be:

  • left
  • center
  • right

Set_Custom_Property('BL.BEAN',1,'SET_FRAME'_TEXT,'F1,Frame Title,top,center') ;


SET_FRAME_TEXT_ALIGNMENT
Set the frame title position.


Set_Custom_Property('BL.BEAN',1,'SET_FRAME_TEXT_ALIGNMENT','properties') ;

properties:
   name, title_pos, alignment

title_pos can be:

  • top
  • bottom
  • left
  • right

alignment can be:

  • left
  • center
  • right

Set_Custom_Property('BL.BEAN',1,'SET_FRAME_TEXT_ALIGNMENT','F1,top,center') ;


SET_FRAME_TEXT_OPAQUE
Indicate if the title background is opaque or not

Set_Custom_Property('BL.BEAN',1,'SET_FRAME_TEXT_OPAQUE','frame_name, true|false') ;

Set_Custom_Property('BL.BEAN',1,'SET_FRAME_TEXT_OPAQUE','F1,false') ;

 


SET_FRAME_FONT
Set the title font

Set_Custom_Property('BL.BEAN',1,'SET_FRAME_FONT','properties') ;

properties:
   name, font_name [,font_size [,font_weight ] ]

font_weight can be:

  • N (Normal)
  • B (Bold)
  • I (Italic)
  • BI (Bold+Italic)

Set_Custom_Property('BL.BEAN',1,'SET_FRAME_FONT','Arial,14,B') ;


SET_FRAME_BACKGROUND
Set the inside frame background


Set_Custom_Property('BL.BEAN',1,'SET_FRAME_BACKGROUND','properties') ;

properties:
   name, color1 [,color2 [, transparency_level]]

colors are exprimed as RxxxGxxxBxxx syntax.
If the first color is given, it represents the plain background color
If  you specify the two colors, it represents a gradient from color1 to color 2
Transparency_level must be a flot between 0.0 (full tra,sparency) and 1.0 (opaque)
If you provide a transparency_level but no second color, put - in place of color2

-- plain red background --
Set_Custom_Property('BL.BEAN',1,'SET_FRAME_BACKGROUND','F1,r255g0b0') ;
-- gradient background from white to red --
Set_Custom_Property('BL.BEAN',1,'SET_FRAME_BACKGROUND','F1,r255g255b255,r255g0b0') ;
-- plain red background with .3 transparency level --
Set_Custom_Property('BL.BEAN',1,'SET_FRAME_BACKGROUND',' F1,r255g0b0,-,.3') ;


SET_FRAME_COLORS
Set the border frame colors


Set_Custom_Property('BL.BEAN',1,'SET_FRAME_FONT','properties') ;

properties:
   name, color1 [,color2]

colors are exprimed as RxxxGxxxBxxx syntax.
color1 is the frame color
color2 is the frame shadow color

-- set frame color without shadow --
Set_Custom_Property('BL.BEAN',1,'SET_FRAME_COLORS','F1,r200g200b200') ;
-- set frame color with shadow --
Set_Custom_Property('BL.BEAN',1,'SET_FRAME_COLORS','F1,r255g255b255,r120g120b120') ;


SET_FRAME_GRADIENT_ORIENTATION
Set the frame inside gradient orientation

Set_Custom_Property('BL.BEAN',1,'SET_FRAME_BACKGROUND','F1,orientation') ;

orientation can be:

  • LeftToRight
  • RightToLeft
  • UpToDown
  • DownToUp


Set_Custom_Property('BL.BEAN',1,'SET_FRAME_BACKGROUND','F1,LeftToRight') ;


SET_FRAME_ROUND_BORDER
Tell if the frame border is rounded or not

By default, the frame is created with no rounded border.

Set_Custom_Property('BL.BEAN',1,'SET_FRAME_ROUND_BORDER','F1, true|false') ;

Set_Custom_Property('BL.BEAN',1,'SET_FRAME_ROUND_BORDER','F1,true') ;


SET_FRAME_BOUNDS
Set the frame bounds

This method have to be used just after the SET_FRAME method

Set_Custom_Property('BL.BEAN',1,'SET_FRAME_BOUNDS','name,properties');

Properties:
   x_position, y_position, width, height

Set_Custom_Property('BL.BEAN',1,'SET_FRAME_BOUNDS','F1,10,10,300,200');


SET_FRAME_HCYCLE
Set the horizontal cycle factor for a gradient frame color


Set_Custom_Property('BL.BEAN',1,'SET_FRAME_HCYCLE','properties');

properties:
   name, cycle_value

cycle_value can be expressed in number of pixel or divisor_factor

-- Horizontal cycle that repeat twice in the frame --
Set_Custom_Property('BL.BEAN',1,'SET_FRAME_HCYCLE','F1,/2');


SET_FRAME_VCYCLE
Set the vertical cycle factor for a gradient frame color


Set_Custom_Property('BL.BEAN',1,'SET_FRAME_VCYCLE','properties');

properties:
   name, cycle_value

cycle_value can be expressed in number of pixel or divisor_factor

-- Vertical cycle that repeat each 50 pixels --
Set_Custom_Property('BL.BEAN',1,'SET_FRAME_VCYCLE','F1,50');

 

SET_FRAME_TITLE_COLOR
Set the frame title color


Set_Custom_Property('BL.BEAN',1,'SET_FRAME_TITLE_COLOR','properties');

properties:
   name, foreground_color [,background_color]

-- set a blue foreground title color
Set_Custom_Property('BL.BEAN',1,'SET_FRAME_TITLE_COLOR','F1,r0g0b255');


SHOW_FRAME
Show the given frame


Set_Custom_Property('BL.BEAN',1,'SHOW_FRAME','name, true|false');


HIDE_FRAME
Hide the given frame

Set_Custom_Property('BL.BEAN',1,'HIDE_FRAME','name, true|false');

 


REMOVE_FRAME
Remove the given frame

Set_Custom_Property('BL.BEAN',1,'REMOVE_FRAME','name');

 


REMOVE_ALL_FRAMES
Remove all frames


Set_Custom_Property('BL.BEAN',1,'REMOVE_ALL_FRAMES','');


Full example:

  -- create the frame --
  Set_Custom_Property('BL.BEAN',1,'SET_FRAME','F1,3, Frame Title ,Arial,16,B,top,center') ;
  -- set the bounds --
  Set_Custom_Property('BL.BEAN',1,'SET_FRAME_BOUNDS','F1,10,10,320,180') ;
  -- set the title color --
  Set_Custom_Property('BL.BEAN',1,'SET_FRAME_TITLE_COLOR','F1,r204g0b0') ;
  -- set the inset frame colors --
  Set_Custom_Property('BL.BEAN',1,'SET_FRAME_BACKGROUND','F1,r255g255b255,r204g0b0') ;
  -- set the vertical gradient cycle --
  Set_Custom_Property('BL.BEAN',1,'SET_FRAME_VCYCLE','F1,/2') ;
  -- set a rounded border --
  Set_Custom_Property('BL.BEAN',1,'SET_FRAME_ROUND_BORDER','F1,true') ;
  -- set the frame border colors --
  Set_Custom_Property('BL.BEAN',1,'SET_FRAME_COLORS','F1,r204g0b0,r180g180b180') ;


 

The sample dialog

     . Download the frames.zip file
     . Unzip the file
     . copy the frame.jar files in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file
     . Open the frame.fmb module (Oracle Forms 9.0.2)
     . Compile all and run the module

 

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article