Overblog Suivre ce blog
Administration Créer mon blog
11 octobre 2006 3 11 /10 /octobre /2006 21:27

Purpose

Here is a Java Bean that allows to use regular expressions with the Sun Java Plug-in.

Regular expressions have been introduced in the Oracle database with the version 10g.
For those who still use a previous version, this Java Bean allows to use regular expressions to achieve complex validations in the Forms text items.
Because the java.util.regex package is available since the 1.4 version of the JDK, we cannot use it with JInitiator that use the 1.3 instruction set. This is the reason why this Bean works only with the Sun Java Plug-in.


regular expression with the Java Plugin


The Java code

     RegularExp.java  



The implementation class of the Bean Item

     oracle.forms.fd.RegularExp


The methods you can call

Set the pattern

Set_Custom_Property('BLOCK.ITEM', 1, 'SET_PATTERN', 'pattern');

e.g. :
Set_Custom_Property( 'BL.BEAN', 1, '
SET_PATTERN', '
[A-Z][a-z][a-z][a-z]' );   


Set the string to check


Set_Custom_Property('BLOCK.ITEM', 1, 'SET_STRING', 'string');




The properties you can get from the JavaBean


Get the boolean result

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

returns either true or false


Get the corresponding group sub-string

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



Get the start and end position of the substring

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

returns a value like : start_position,end_position




The sample dialog


     . Download the regularexp.zip file
     . Unzip the file
     . copy the regularexp.jar file in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file
     . Open the REGULAREXP.fmb module (Oracle Forms 10.1.2 and Java Plug-in 1.5.0_06)
     . Compile all and run the module

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
1 octobre 2006 7 01 /10 /octobre /2006 11:15

Purpose

Here is a Java Bean that allows to read, display and write images.

(See the last evolution of this solution here


When you load an image within Forms with the Read_Image_File() built-in, you can notice a certain lack of quality, both in the Forms Image item display quality and in the real information stored in the blob column.
The image seems to be compressed before it is stored in the database. This compression rate is between 25 and 50% !
This Java Bean allows to load images from a file, then store them in the database.

The Forms sample dialog provided with the article uses two image rooms:

 - The first one is a standard Forms Image item that is populated with the Client_Image.Read_Image_File() Webutil function that populates the PHOTO blob column.


 - The second one is the Java Bean itself that populates the PHOTO_JAVA blob column.


As you see as follows, the Read_Image_File() function can drastically compress the initial image:

1 select
2 identifiant,
3 length(photo),
4 length(photo_java),
5 round((length(photo)/length(photo_java)*100),1) || '%' "photo reduction"
6 from photos
7* where photo is not null
SQL> /

IDENTIFIANT LENGTH(PHOTO) LENGTH(PHOTO_JAVA) photo reduction
----------- ------------- ------------------ ---------------
2           23536         100952             23.3%
1            6763          13548             49.9%
 

This JavaBean connect to the database through the JDBC driver to read and write the images.
Of course, some of you can complain that this solution needs a second connection, the loading of the classes12.jar file on the client machine, so it is "deconnected" from the Forms transaction.
For this very moment, my answer is : everything has its price, and if you need to keep and display the real quality of the images in your Forms application, this bean is the one you need.

Let's see the screenshot to decide !

handleimage small format

Click here to get the full format image


The Java code

     HandleImage.java     LectureBlob.java    myPanel.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,p3');

p1 is the table name that hold the image blob column
p2 is the column name that hold the image
p3 is the column name that identifies the unique row in the table (for the UPDATE statment)

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

The instruction above indicates that the PHOTOS table handle images in the PHOTO_JAVA blob column, and the key column that identifies the unique row is IDENTIFIANT.


Read an image from a local 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,'unique_ID');

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

unique_ID is the value to identify a unique row to update in the table. The above instruction will be interpreted as :

   Select PHOTO_JAVA From PHOTOS Where IDENTIFIANT = 1


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','unique_ID');

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

unique_ID is the value to identify a unique row to update in the table.
The above instruction will be interpreted as :

   Update PHOTOS Set PHOTO_JAVA = ? Where IDENTIFIANT = 1


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', :PHOTOS.IDENTIFIANT ) ;
Else
   Set_Custom_Property( 'BLZ.BEAN', 1, 'CLEAR', '' ) ;
End if ;
:BLZ.IMG_SIZE := Get_Custom_Property( 'BLZ.BEAN', 1, 'GETSIZE' ) ;


Set the log mode to output the Bean messages

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



Set mode to allow the display of the scrollbars if needed

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


In the sample dialog, 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',  'tuto' ) ;
  -- set the image table and column name --
  Set_Custom_Property( 'BLZ.BEAN', 1, 'SETTABLEINFO',  'PHOTOS,PHOTO_JAVA,IDENTIFIANT' ) ;
  -- allow the bean to display scrollbars --
  Set_Custom_Property( 'BLZ.BEAN', 1, 'SETSCROLL',  'true' ) ; 
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


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 handleimage.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 handleimages.jar file in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file to add both handleimages.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 HANDLEIMAGE.fmb module (Oracle Forms 10.1.2)
     . Compile all and run the module

     . Enter a valid file name in the Image File name item then press the Read image file button


Note : If you rebuild the jar file, it has to be signed. (the handleimages.jar file provided in this article is already signed).
Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
28 août 2006 1 28 /08 /août /2006 22:19

Purpose

Here is a Java Bean that allows to start asynchronous jobs from an Oracle Forms application.

When you execute a stored procedure or function within a Forms application, the end user cannot get the hand until the procedure/function is completly finished, so the application seems to be "frozen".
By using a class that implements the Runnable interface, it is possible to run a job in its own thread, so the end user can continue to work while the execution of the stored function.

The JavaBean can connect to the database through the JDBC driver, execute the stored procedure/function, then call back Forms to indicate the end of the job.


The Java code

     asyncjob.java


The implementation class of the Bean Item

     oracle.forms.fd.AsyncJob


The methods you can call

Set the connection string

Set_Custom_Property('BLOCK.ITEM',1,'INITCONN','the_connection_string');


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


Set the username


Set_Custom_Property('BLOCK.ITEM',1,'INITUSER','user_name');


Set the password


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


Set the call of a function


Set_Custom_Property('BLOCK.ITEM',1,'INITFUNC','the_function_call');

e.g.:
Set_Custom_Property( 'BL.BEAN', 1, 'INITFUNC', 'begin ? := F1(5); end;' ) ; 


Set the call of a procedure


Set_Custom_Property('BLOCK.ITEM',1,'INITPROC','the_procedure_call');

e.g.:
Set_Custom_Property( 'BL.BEAN', 1, 'INITPROC', 'begin P1(5); end;' ) ; 



Set the log mode to output the Bean messages

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


In the sample dialog provided with the article, I use 2 buttons:

- One to execute a stored function:

  If :BL.CONN_STRING is not Null
      And :BL.USERNAME is not Null
      And :BL.PASSWORD is not Null Then
    Set_Custom_Property( 'BL.BEAN', 1, 'SETLOG' , 'true' ) ;
    Set_Custom_Property( 'BL.BEAN', 1, 'INITCONN', :BL.CONN_STRING ) ;   
    Set_Custom_Property( 'BL.BEAN', 1, 'INITUSER', :BL.USERNAME ) ;
    Set_Custom_Property( 'BL.BEAN', 1, 'INITPWD' , :BL.PASSWORD ) ;   
    Set_Custom_Property( 'BL.BEAN', 1, 'INITFUNC', 'begin ? := ' || :BL.SQL_ORDER || ' end;' ) ; 
    Message('Command sent'); synchronize;
  End if ;
   

- Another to execute a stored procedure:

  If :BL.CONN_STRING is not Null
      And :BL.USERNAME is not Null
      And :BL.PASSWORD is not Null Then
    Set_Custom_Property( 'BL.BEAN', 1, 'SETLOG' , 'true' ) ;
    Set_Custom_Property( 'BL.BEAN', 1, 'INITCONN', :BL.CONN_STRING ) ;
    Set_Custom_Property( 'BL.BEAN', 1, 'INITUSER', :BL.USERNAME ) ;
    Set_Custom_Property( 'BL.BEAN', 1, 'INITPWD' , :BL.PASSWORD ) ;   
    Set_Custom_Property( 'BL.BEAN', 1, 'INITPROC', 'begin ' || :BL.SQL_ORDER || ' end;' ) ;
    Message('Command sent'); synchronize;
  End if ;
   

The event that can be raised from the JavaBean

   EVENT

It indicates to Forms that the procedure/function is finished.
You can catch this event in the WHEN-CUSTOM-ITEM-EVENT trigger of the Bean item:

Declare
    LC$Error   Varchar2(4000) ;
    LC$Result  Varchar2(32000) ;
Begin   
  clear_message ;
  LC$Error  := Get_Custom_Property('BL.BEAN',1, 'GETERROR') ;
  LC$Result := Get_Custom_Property('BL.BEAN',1, 'GETRESULT') ;
  If LC$Error is not null Then
       Message( 'Error : ' || LC$Error ) ;
  Else
     Message( LC$Result, no_acknowledge);
  End if ;
End ; 

As you can see, the 2 properties you can get from the JavaBean are the return value (GETRESULT) and the error message (GETERROR) provided by the execution.

For this case I have created one stored function and one stored procedure like the following:

CREATE OR REPLACE
PROCEDURE P1 ( PN$Param IN NUMBER )
IS
BEGIN
  DBMS_LOCK.Sleep( PN$Param ) ;
END;
/

CREATE OR REPLACE
FUNCTION F1 ( PN$Param IN NUMBER )
RETURN VARCHAR2
IS
BEGIN
  DBMS_LOCK.Sleep( PN$Param ) ;
  RETURN ('Function ended at ' || To_Char(SYSDATE,'HH24:MI:SS') );
END;
/

As you can see, they do nothing else than waiste some time.
You can get the creation source in the asyncjob.sql provided with the sample.

To compile this code, the user must have the execute privilege on the SYS.DBMS_LOCK package granted.


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

asynchronous job


     . Download the asyncjob.zip file
     . Unzip the file
     . run the asyncjob.sql under the Oracle user you want to test (It creates the 2 small stored function/procedure).
     . copy the asyncjob.jar file in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file to add both asyncjob.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 ASYNCJOB.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 asyncjob.jar file provided in this article is already signed).
Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
8 juillet 2006 6 08 /07 /juillet /2006 16:27

Purpose

Here is a Java Bean that allows to write/read files on the client machine without installing Webutil.

The Java code

     clientfile.java


Register the Bean

The bean must be registered before you can call its methods.
Because the Bean cannot be registered at the very start of the form (When-New-Form-Instance for example), we need to place this instruction in a When-Timer-Expired trigger:

When-New-Form-Instance trigger:

DECLARE
    timer_id Timer;
BEGIN
    timer_id := CREATE_TIMER('bean_timer', 200, NO_REPEAT);
END;



When-Timer-Expired trigger:

FBean.Register_Bean('BL.BEAN_ITEM',1,'oracle.forms.fd.ClientFile');


In my sample dialog, I have a bean area called BEAN_ITEM in the BL block.

The bean is registred, now, so we can invoke its methods:


The methods you can call

Set the filename

FBean.Invoke('BLOCK.ITEM',1,'setFileName','the_file_name');


Write the text to this file

FBean.Invoke('BLOCK.ITEM',1,'writeToFile','the_text');


Append the text to this file

FBean.Invoke('BLOCK.ITEM',1,'writeAppendToFile','the_text');


Read the text from this file

varchar2 := FBean.Invoke_Char('BLOCK.BEAN',1,'readFromFile','');


Set the log mode to output the Bean messages

FBean.Invoke('BLOCK.ITEM',1,'SetLog','');


In the sample dialog provided with the article, I use 2 buttons:

- One to write the text:

If :BL.filename is not null Then
   -- set the log on --
   FBean.Invoke('BL.BEAN_ITEM',1,'SetLog','');
   -- set the file name --
   FBean.Invoke('BL.BEAN_ITEM',1,'setFileName',:BL.filename);
   -- write the text --
   FBean.Invoke('BL.BEAN_ITEM',1,'writeToFile','"' || :BL.write || '"');
End if ;   

- Another to read the text:

If :BL.filename is not null Then
   -- set the log on --
   FBean.Invoke('BL.BEAN_ITEM',1,'SetLog','');
   -- set the file name --
   FBean.Invoke('BL.BEAN_ITEM',1,'setFileName',:BL.filename);
   -- read the text from the file --
   :BL.READ := FBean.Invoke_Char('BL.BEAN_ITEM',1,'readFromFile','');
End if ;   


The sample dialog

clientfile


     . Download the clientfile.zip file
     . Unzip the file
     . copy the clientfile.jar file in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file
     . Open the CLIENTFILE.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 clientfile.jar file provided in this article is already signed).
Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
14 avril 2006 5 14 /04 /avril /2006 16:55

Purpose

This is the part II of the utilities Java Bean.

utilities (2)

A second tab allows to manipulate some Text field properties.

  . You can set dynamically the maximum of  charaters the user can enter.
  . You can also set the cursor blink rate and the cursor style.


The Java code

      FJTextField.java


The Implementation Class property

      forms.fd.utilities.FJTextField


The properties you can set

The maximum characters the user can enter

Set_Custom_Property( 'BL.BEAN', 1, 'SETMAX', 'max_length' ) ;

The cursor blink rate

Set_Custom_Property( 'BL.BEAN', 1, 'SETBLINKRATE', 'value' ) ;

100 is very fast and 800 is very slow

The cursor style

Set_Custom_Property( 'BL.BEAN', 1, 'SETCURSOR', 'style' ) ;

Where style can be one of the following:

   . DEFAULT
   . HAND
   . CROSS
   . MOVE
   . TEXT
   . WAIT


The sample dialog

     . Download the utilities.zip file
     . Unzip the file
     . copy the fjutilities.jar file in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file
     . Open the UTILITIES.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
8 avril 2006 6 08 /04 /avril /2006 17:57

Purpose

This Java Bean is the first step to build a utilities' bean that will group several functionalities.
In this introduction, the Java Bean starts with a "Font" chapter that allows to get the bounding box for any string of any font, and also to get the list of available fonts.


utilities (1)


The Java code

      fjfont.java


The Implementation Class property

      forms.fd.utilities.FJFont


The properties you can set

The target font

Set_Custom_Property( 'BL.BEAN', 1, 'SET_FONT', 'font_name,font_type,font_size' ) ;

font_type could be:
   . N (normal)
   . B (bold)
   .
I (Italic)
   . BI (bold+italic)


Set_Custom_Property( 'BL.BEAN', 1, 'SET_FONT', 'Tahoma,N,8' ) ;

The string that we want calculate the bounding box

Set_Custom_Property( 'BL.BEAN', 1, 'SET_STRING', 'string' ) ;

Set_Custom_Property( 'BL.BEAN', 1, 'SET_STRING', 'Hello World' ) ;

Draw the selected font

Set_Custom_Property( 'BL.BEAN', 1, 'DRAW_FONT', NUM_FONT ) ;


The properties you can get

Get the width of the string

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

Get the height of the string

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

Get both width and height

Varchar2 := Get_Custom_Property( 'BL.BEAN', 1, 'GET_SIZE' ) ;
(return format will be : width,height)

Get the font list

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

Get the first font in the list

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

Get the next font in the list

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


The sample dialog

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

In this dialog, the "input" item is resized on the When-Validate-Item trigger:

-- compute the new size
Declare
 LN$Width   pls_integer := 0 ;
 LN$Height  pls_integer := 0 ;
Begin 
  If :BL.INPUT is not null Then
    Set_Custom_Property( 'BL.BEANSTRING', 1, 'SET_STRING', :BL.INPUT ) ;
    :BL.WIDTH  := 6 + Get_Custom_Property( 'BL.BEANSTRING', 1, 'GET_WIDTH' ) ;
    :BL.HEIGHT := Get_Custom_Property( 'BL.BEANSTRING', 1, 'GET_HEIGHT' ) ; 
    Set_Item_Property( 'BL.INPUT', WIDTH, :BL.WIDTH ) ;
  End if ;
End;


Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
4 avril 2006 2 04 /04 /avril /2006 14:48

Purpose

This is a JavaBean that allows to handle a "HTML Map" in a Forms application.

Map


The Java code

      MapComponent.java      zone.java


The Implementation Class property

      oracle.forms.fd.MapComponent


The properties you can set

Set a polygonal area

Set_Custom_Property('BL.BEAN',1, 'SETPOLYGON','name,url,coordinates_pairs');

e.g.
Set_Custom_Property('BL.BEAN',1, 'SETPOLYGON','Region1,url1,284,128,272,353,178,361,166,342,133');

Set a rectangular area

Set_Custom_Property('BL.BEAN',1, 'SETRECT','name,url,x,y,width,height');

name is the name that identify each area. this name is get from the GetProperty(NAME)
url is the area url (must be specified but not used in this version)

Set the background image

Set_Custom_Property('BL.BEAN',1, 'SETIMAGE','image_name' );

Image from JAR file:
Set_Custom_Property('BL.BEAN',1, 'SETIMAGE','/france.jpg' );

Image from client machine:
Set_Custom_Property('BL.BEAN',1, 'SETIMAGE','file:///d:/france.jpg' );

Image from internet url:
Set_Custom_Property('BL.BEAN',1, 'SETIMAGE','http://fdtool.free.fr/tmp/france.jpg' );


Set the selected area color


Set_Custom_Property('BL.BEAN',1, 'SETFONTCOLOR','r,g,b' );

Set_Custom_Property('BL.BEAN',1, 'SETFONTCOLOR','255,0,100' );


The properties you can get

The area selected (clicked)

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


The events you can raise

An area has been clicked

      ZONECLICKED



The sample dialog


     . Download the map.zip file
     . Unzip the file
     . copy the fjmap.jar file in the <ORACLE_HOME>/forms/java directory
            the jar file must be signed
     . Edit your /forms/server/formsweb.cfg file
     . Open the MAP.fmb module (Oracle Forms 9.0.2)
     . Compile all and run the module


Different display of the selected area


You can "tune" the display()
  function to change the display of the selected area:

Map


 /*************************************
  *  Show/Hide the selected map part  *
  ************************************/

 void display(int iNum, boolean b) {
  float fArea = 0.1f, fText = 0.9f;
  g2 = (Graphics2D) this.getGraphics();
  String sName="" ;
  if(g2 != null && iNum >= 0)
  {
    g2.setColor(Color.white);
    g2.clearRect((int)jp.getX(),(int)jp.getY(),(int)jp.getWidth(),(int)jp.getHeight());
    image.paintIcon(null,g2,0,0);
    if(b)
    {
      // draw the selected area
      g2.setComposite(AlphaComposite.SrcOver);
      AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, fArea);
      g2.setComposite(ac);

      g2.setColor(cFontColor);
      g2.fillPolygon(tz[iNum].p);
      ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, fText);
      g2.setComposite(ac);

      g2.setColor(Color.black);
      sName = tz[iNum].name ;
     
      Font font = new Font("Arial",Font.BOLD,14);
      FontRenderContext frc = g2.getFontRenderContext();
      TextLayout layout = new TextLayout(tz[iNum].name, font, frc);
      Rectangle2D bounds = layout.getBounds();
      // draw the text bouding box
      g2.drawRect((int)((tz[iNum].r.getX()+(tz[iNum].r.getWidth()/2))-2),
                  (int)((tz[iNum].r.getY()+(tz[iNum].r.getHeight()/2))-(int)bounds.getHeight()),
                  (int)(bounds.getWidth()+4),
                  (int)(bounds.getHeight()+4));
      g2.setColor(Color.white);
      g2.fillRect((int)((tz[iNum].r.getX()+(tz[iNum].r.getWidth()/2))-2),
                  (int)((tz[iNum].r.getY()+(tz[iNum].r.getHeight()/2))-(int)bounds.getHeight()),
                  (int)(bounds.getWidth()+4),
                  (int)(bounds.getHeight()+4));
      g2.setColor(cFontColor);     
      g2.setFont(font);
      g2.drawString(tz[iNum].name,
      (int)(tz[iNum].r.getX()+(tz[iNum].r.getWidth()/2)),
      (int)(tz[iNum].r.getY()+(tz[iNum].r.getHeight()/2)));
    }
  }
 }

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
28 mars 2006 2 28 /03 /mars /2006 10:00

Purpose

Let's have a little bit fun and break the wall with this Oracle Forms JavaBean.

The purpose of this research&development unit is only to show that the VBean class allows to do anything in an Oracle Forms application.
You are able to build a complete interface with different frames, panels, menus and actions like reading/writing files.


WallBrick Player

WallBrick Builder

This wallbrick is as simple as I am not a game expert and is probably the worst example of this kind of game you could find anywhere.
But this one allows you to create/modify your own levels.
So, the JAR file contains 2 main classes, one for building the wall (FJBuild.java) and one to play (FJBrick.java).



The java code

      get here the complete Java source code


The Implementation class properties

for the builder:
      oracle.forms.fd.FJBuild

for the player:
      oracle.forms.fd.FJBrick


The properties you can set

Set the log ON/OFF

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

Start a new game/builder

Set_Custom_Property('BL.BEAN', 1, 'START', '[configuration file's directory]' ) ;

configuration file's directory is not required. It can be used to indicate in which directory the configuration file will be created/stored.
If no indication, the configuration file is read/stored in the default user directory.

If you want to store the configuration file in the C:TEMP directory, use the following:

Set_Custom_Property('BL.BEAN', 1, 'START', 'C:TEMP' ) ;


The sample dialog

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

        WALLBRICK.fmb

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
20 mars 2006 1 20 /03 /mars /2006 10:18

Purpose

This JavaBean allows to find and handle the form windows (current window and MDI window).
With this handle, you can set some particular properties like the following:

   . setMovable()*
   . setClosable()*
   . setMaximizable()*
   . setMinimizable()*
   . setModal()*
   . setResizable()
   . setVisible()
   . enable()*
   . disable()*
   . setToolTipValue()*
   . setIcon()
   . setExtendedState() (only with SE 4.0)
   . setAlwaysOnTop() (only with SE 5.0)

    * You cannot apply this function on the MDI frame.

FormsFrames

How to find the frames ?

You can recursively find the different layers with the getParent() function.

      Container container = this.getParent();
      while (container!=null)
      {
        // output the object hierarchy
        System.out.println("--> "+container.getName()+" ["+container.getClass()+"]") ;
        container = container.getParent() ;
      }

The FORMSFRAMES.fmb sample module shows, in the Java console, the list of all the layers.


The application Forms window class name is oracle.forms.ui.ExtendedFrame      
The application Forms MDI window class name is oracle.ewt.swing.JBufferedFrame

Notice that in future version, this class names may change.



The Java code

     formsframe.java

     The JAR file must be signed

The properties you can set

set the frame structure info
Set_Custom_Property('BL.BEAN',1, 'INFO','' ) ;

movable()
Set_Custom_Property( 'BL.BEAN', 1, 'SET', 'MOVE,true|false' ) ;

closable()
Set_Custom_Property( 'BL.BEAN', 1, 'SET', 'CLOSE,true|false' ) ;

maximizable()
Set_Custom_Property( 'BL.BEAN', 1, 'SET', 'MAX,true|false' ) ;

minimizable()
Set_Custom_Property( 'BL.BEAN', 1, 'SET', 'MIN,true|false' ) ;

resizable()
Set_Custom_Property( 'BL.BEAN', 1, 'SET', 'SIZE,true|false' ) ;

disable()
Set_Custom_Property( 'BL.BEAN', 1, 'SET','DISABLE' ) ;  

set icon for standar or MDI frame
Set_Custom_Property( 'BL.BEAN', 1, 'SETICON','target,icon_name' ) ;

    -- Set the MDI icon --
  Set_Custom_Property('BL.BEAN',1, 'SETICON','MDI,/indxicon.gif' ) ;
  
  -- Set the internal window icon --
  Set_Custom_Property('BL.BEAN',1, 'SETICON','WIN,/oracle.gif' ) ;



maximize the MDI frame (works only with the Sun Java Plug-in JRE 1.4)
Set_Custom_Property( 'BL.BEAN', 1, 'SETMAXSIZE','true|false' ) ;

Set the window always on top (works only with the Sun Java Plug-in JRE 1.5)
Set_Custom_Property( 'BL.BEAN', 1, 'SETONTOP','true|false' ) ;

(if you want to use this property, use the formsframes5.jar file instead of the formsframes.jar)


In this demo, 2 icon files are stored in the root of the jar file (indxicon.gif and oracle.gif)


The sample dialog

     . Download the formsframes.zip file
     . Unzip the file
     . copy the formsframes.jar file in the <ORACLE_HOME>/forms/java directory
       (or the formsframes5.jar if you use the 1.5 JRE)
         the jar file must be signed
     . Edit your /forms/server/formsweb.cfg file
     . Open the FORMSFRAMES.fmb module (Oracle Forms 9.0.2)
     . Compile all and run the module

     Open the Java console to see the whole frame structure of the Forms module

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
7 mars 2006 2 07 /03 /mars /2006 17:03

Purpose

This is a JavaBean that allows to play sound files from the file system.

Sound JavaBean


The Java code

sound.java    soundlist.java      soundloader.java

note : the jar file must be signed


Implementation Class property

      oracle.forms.fd.Sound


The properties you can set

Set the file name to read

Set_Custom_Property( 'BLK.BEAN', 1, 'SET_FILE', 'directory,filename' ) ;


Play the sound

Set_Custom_Property( 'BLK.BEAN', 1, 'PLAY', '' ) ;


The sample dialog

     . Download the sound.zip file
     . Unzip the file
     . copy the sound.jar file in the <ORACLE_HOME>/forms/java directory
     . Edit your /forms/server/formsweb.cfg file
     . Open the SOUND.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