Overblog
Editer l'article Suivre ce blog Administration + Créer mon blog
19 mai 2007 6 19 /05 /mai /2007 15:15

Purpose

Here is a Java bean to dynamically handle menu options at runtime.

Dynamic Menu


Dynamic Menu

You can dynamically add, remove, enable, disable, show and hide menus and menu options.


The Java code

     DynamicMenu.java



The implementation class of the Bean Item

     oracle.forms.fd.DynamicMenu


The methods you can set



Set the menu and menu option graphical properties

Set_Custom_Property('BL.BEAN', 1, 'SET_PROPERTIES', 'props' ) ;

props is : menu_type, font_name, weight,size[,foreground_color[,background_color]]

menu_type can be MenuBar or MenuOption


e.g. :
Set_Custom_Property('BL.BEAN', 1, 'SET_PROPERTIES', 'MenuBar,Tahoma,B,14,r255g255b255,r255g0b0' ) ;
   


Read the current menu

It is used to get the starting Forms current menu to set the given graphical properties.

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

 

Add a popup menu

Set_Custom_Property('BL.BEAN', 1, 'ADD_MENU', 'menu_name,menu_label' ) ;

Adds a new popup menu at the end of the menu bar


e.g. :
Set_Custom_Property('BL.BEAN', 1, 'ADD_MENU', 'Main.Menu1,Menu1' ) ;
   

 

Add a menu option to an existing popup menu

Set_Custom_Property('BL.BEAN', 1, 'ADD_MENU_OPTION', 'props' ) ;

 

props is : internal_menu_name, label, command [, tooltip [,image] ]


internal_menu_name is the name given to the menu option -> e.g: Menu1.Option1


- If you want to provide image name, but no tooltip, put '-' instead of tooltip text


note: Image size for menu option is generally 16x16 pixels.


If the given parent's popup menu does not exists, the method does nothing.

e.g. :

-- Tooltip and no icon --
Set_Custom_Property('BL.BEAN', 1, 'ADD_MENU_OPTION', 'Menu1.Opt1,Option 1,Exit-Form','Option to exit the current form' ) ;

-- no tooltip but icon --
Set_Custom_Property('BL.BEAN', 1, 'ADD_MENU_OPTION', 'Menu2.Opt3,Option 3,instruction3,-,C:/dev/gif/icon-16.gif' ) ;

 

  

 

Add an option menu's separator

Set_Custom_Property('BL.BEAN', 1, 'ADD_MENU_OPTION', 'internal_option_name,SEPARATOR' ) ;

internal_option_name is the name given to the menu option -> e.g: Menu1.Sep1

e.g. :

Set_Custom_Property('BL.BEAN', 1, 'ADD_MENU_OPTION', 'Menu1.sep1,SEPARATOR' )


 

 

 

Show/Hide a popup menu

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

 

Enable/Disable a popup menu

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

 

Remove a menu option

Set_Custom_Property('BL.BEAN', 1, 'REMOVE_MENU_OPTION', 'Menu1.Opt10' ) ;

 

Show/Hide a menu option

Set_Custom_Property('BL.BEAN', 1, 'VISIBLE_MENU_OPTION', 'Menu1.Opt4, true|false' ) ;

 

Enabled/Disable a menu option

Set_Custom_Property('BL.BEAN', 1, 'STATUS_MENU_OPTION', 'Menu1.Opt4, true|false' ) ;

 

Move the "Window" system menu at end of the menu bar

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

Use this method when you have added all your popup menu to move the Window system popup menu at the end of the menu bar.

 

Here is an exemple of what could be a When-New-Form-Instance trigger:

-- Set menu properties --
Set_Custom_Property('BL.BEAN', 1, 'SET_PROPERTIES', 'MenuBar,Tahoma,B,14,r255g255b255,r255g0b0' ) ;
Set_Custom_Property('BL.BEAN', 1, 'SET_PROPERTIES', 'MenuOption,Tahoma,B,14,r128g128b255,r255g255b255' ) ;
-- Get the current menu --
Set_Custom_Property('BL.BEAN', 1, 'GET_MENU', '' ) ;
-- Add a few menu options --
Set_Custom_Property('BL.BEAN', 1, 'ADD_MENU', 'Menu1' ) ;
Set_Custom_Property('BL.BEAN', 1, 'ADD_MENU_OPTION', 'Menu1.Opt1,Option 1,instruction1' ) ;
Set_Custom_Property('BL.BEAN', 1, 'ADD_MENU_OPTION', 'Menu1.Opt2,Option 2,instruction2' ) ;
Set_Custom_Property('BL.BEAN', 1, 'ADD_MENU_OPTION', 'Menu1.sep1,SEPARATOR' ) ;
Set_Custom_Property('BL.BEAN', 1, 'ADD_MENU_OPTION', 'Menu1.Exit,Exit,Exit-Form' ) ;
Set_Custom_Property('BL.BEAN', 1, 'ADD_MENU', 'Menu1.SubMenu1,SubMenu1' ) ;
Set_Custom_Property('BL.BEAN', 1, 'ADD_MENU_OPTION', 'Menu1.SubMenu1.Exit,Exit,Exit-Form' ) ;
Set_Custom_Property('BL.BEAN', 1, 'ADD_MENU', 'Menu1.SubMenu1.SubSubMenu1,SubSubMenu1' ) ;  
Set_Custom_Property('BL.BEAN', 1, 'ADD_MENU_OPTION', 'Menu1.SubMenu1.SubSubMenu1.Exit,Exit,Exit-Form' ) ;
-- Move Window system menu at end --
Set_Custom_Property('BL.BEAN', 1, 'MOVE_WIN_MENU_OPTION', '' ) ;


 

 


The event received from the Bean

MENU_MSG


This event tells Forms that a menu option has been clicked.

The command associated to the menu option is read from the MENU_OPTION parameter.

You can get it in a WHEN-CUSTOM-ITEM-EVENT event:

DECLARE
    eventName      Varchar2(30) := :system.custom_item_event;
    eventValues    ParamList;
    eventValueType Number;
    LC$Option      varchar2(100);   
BEGIN
   
   IF (eventName='MENU_MSG') THEN
      -- get the menu message --
      eventValues := get_parameter_list(:system.custom_item_event_parameters);
      get_parameter_attr(eventValues,'MENU_OPTION',eventValueType, LC$Option);
      clear_message;
      Message(LC$Option, no_acknowledge) ;
      Synchronize ;
      ---------------------------------
      --  Handle the raised options  --
      ---------------------------------
      If LC$Option = 'Exit-Form' Then
           Exit_Form ;
      End if ;           
   END IF;
   
END;

 


The sample dialog

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


Partager cet article
Repost0

commentaires

K
How to use it in Oracle 11g Forms
Répondre
A
Dears <br /> wishing my mail find you well<br /> I need jar to change Oracle Form Tab Canvas (header) , the tab itself , need to change the colour to be dynamic
Répondre