Overblog Suivre ce blog
Administration Créer mon blog
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
23 mars 2006 4 23 /03 /mars /2006 18:40

After reading the article about the input dialog box, someone asked me if it was possible to have a multi-lines input box.

So, this is the version 1.1 of the input dialog box

Input Dialog 2


Here is the Java code      and the JAR file


To use the single line input box use the following:

Set_Custom_Property( 'BL.BEAN', 1, 'SETTEXT',  'question text' ) ;

To use the multi lines input box use the following:

Set_Custom_Property( 'BL.BEAN', 1, 'SETTEXTMULTI',  'question text' ) ;

Repost 0
Published by Oracle Forms community - dans Bean - JoptionPane
commenter cet article
20 mars 2006 1 20 /03 /mars /2006 22:47
Repost 0
Published by Oracle Forms community - dans PJC - Text items
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
3 mars 2006 5 03 /03 /mars /2006 18:31

Purpose

Sometimes I find questions on forums on how to handle frames at runtime.
Of course, at this moment (10gR2), there is no built-in available.
This is a workaround that allows to create and handle frames at runtime.

Frame


The Java code

Get the full source code here

Implementation Class property

     oracle.forms.fd.frame

Note : The frame is not displayed inside the Forms JavaBean component, so you can set its Mouse and Keyboard navigation properties to NO.

The properties you can set

(properties with bold font are required.)

Create a new frame


Set_Custom_Property( 'BLK.BEAN', 1, 'INIT_FRAME', 'v1,...,vn' ) ;

type : line or lowered
line width : width of the line in pixels
title
font name
font size
weight :
     . N ormal
     . I talic
     . B old
     . BI bold + italic
Alignment:
     . left
     . center
     . right

The font of the title frame

Set_Custom_Property( 'BLK.BEAN', 1, 'SET_FONT', 'name[,size[,weight[,alignment]]]' ) ;

font name
font size
weight :
     . N ormal
     . I talic
     . B old
     . BI bold + italic
Alignment:
     . left
     . center
     . right


The frame title color

Set_Custom_Property( 'BLK.BEAN', 1, 'SET_FRAME_TITLE_COLOR', 'r,g,b' ) ;

The frame background color

Set_Custom_Property( 'BLK.BEAN', 1, 'SET_BACKGROUND', 'r,g,b' ) ;

The frame bounds

Set_Custom_Property( 'BLK.BEAN', 1, 'SET_BOUNDS', 'x,y,w,h' ) ;

x : x position in pixel on the canvas
y : y position in pixel on the canvas
w : width in pixel
h : height in pixel

Set the title

Set_Custom_Property( 'BLK.BEAN', 1, 'SET_TEXT', 'title[,alignment]' ) ;

title
alignment :
     . left
     . center
     . right


Hide the frame

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


Show the frame

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



The sample dialog

     . Download the frame.zip file
     . Unzip the file
     . copy the frame.jar file 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
26 février 2006 7 26 /02 /février /2006 21:42

Purpose

This is the second part of the chapter on "how to create component at runtime".
In this chapter, let's see how to create some titled-framed text items


AddItem part II
Click here to get the full format image

On the Forms module displayed on this screenshot, all the components of the left panel are created at runtime.
The right panel allows to change the properties of each selected component.


The Java code

Get the full source code here


Implementation Class property

      oracle.forms.fd.AddItem2


Forms configuration

. Copy the additem2.jar file in the /forms/java directory
. Edit the /forms/server/formsweb.cfg file to add the jar file to the archive_jini variable

         archive_jini=f90all_jinit.jar,……,additem2.jar


The properties

Get the properties list here


The sample dialog

     . Download the additem2.zip file
     . Unzip the file
     . Edit your /forms/server/formsweb.cfg file
     . Open the FRAMEDTEXT.fmb module (Oracle Forms 9.0.2 and 10.1.2)
     . Compile all and run the module

Repost 0
Published by Oracle Forms community - dans Bean - general
commenter cet article
22 février 2006 3 22 /02 /février /2006 20:26

Purpose

This PJC extends default button functionality to show both icon and label.

By
Oleg Tishchenko




The Java code

Get the source code here


Forms configuration

. Copy the lablediconbutton.jar file in the /forms/java directory
. Edit the/forms/server/formsweb.cfg file to add the jar file to thearchive_jini variable

         archive_jini=f90all_jinit.jar,……,lablediconbutton.jar

  Note : Notice that icon files used in this demo are stored in the root of the jar file


Implementation Class property

     oracle.forms.enhancedItems.LabledIconButton


The properties you can set

On image

Set_Custom_Property( 'BLOC.BEAN_ITEM',1, 'IMAGE_NAME_ON', 'icon_name' );

Off image

Set_Custom_Property( 'BLOC.BEAN_ITEM',1, 'IMAGE_NAME_OFF', 'icon_name' );

Trun debug on/off

Set_Custom_Property( 'BLOC.BEAN_ITEM',1, 'DEBUGMESSAGES', 'true' );

Trun debug all instance of this PJC on/off

Set_Custom_Property( 'BLOC.BEAN_ITEM',1, ' DEBUGMESSAGES_ALL', 'false' );


The properties you can read

On image

Get_Custom_Property( 'BLOC.BEAN_ITEM',1, 'IMAGE_NAME_ON' );

Off image

Get_Custom_Property( 'BLOC.BEAN_ITEM',1, 'IMAGE_NAME_OFF' );


The sample dialog

     . Download the lablediconbutton.zip file
     . Unzip the file
     . Edit your /forms/server/formsweb.cfg file
     . Open the lablediconbutton.fmb module (Oracle Forms 10.1.2)
     . Compile all and run the module

Repost 0
Published by Oracle Forms community - dans PJC - Buttons
commenter cet article