Jeudi 2 février 2006
Purpose

This bean allows to display a Jslider component in your Forms application.


JSlider bean

The java code


 package oracle.forms.fd;

import java.awt.*;
import java.awt.event.*;
import java.util.StringTokenizer;
import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import oracle.forms.ui.CustomEvent;
import oracle.forms.ui.VBean;
import oracle.forms.handler.IHandler;
import oracle.forms.properties.ID;

/**
 * A javabean to display Sliders in Forms
 *
 * @author Francois Degrelle
 * @version 1.0
 */


public class Slider  extends VBean implements ChangeListener
{
  public final static ID SetBG         = ID.registerProperty("SETBGCOLOR");    
  public final static ID SetFG         = ID.registerProperty("SETFGCOLOR");      
  public final static ID ValueChanged  = ID.registerProperty("VALUECHANGED");    
  public final static ID SetBounds     = ID.registerProperty("SETBOUNDS");      
  public final static ID SetValue      = ID.registerProperty("SETVALUE");          
  public final static ID GetValue      = ID.registerProperty("GETVALUE");        
  private IHandler  m_handler;  

  static int iValue = 0 ;             // current value variable
  protected JSlider slide  ;          // Slider pointer
  protected Color BGcolor, FGcolor  ; // Slider colors

  public Slider()
  {
    super();
    // create a new JSlider
    slide = new JSlider();

    slide.addChangeListener(this);
    slide.setPaintTrack(true);
    slide.setPaintTicks(true);
    slide.setPaintLabels(true);

    add(slide);
  }
 
  // Fires when the JSlider is modified
  public void stateChanged(ChangeEvent e) {
      JSlider source = (JSlider)e.getSource();
      if (!source.getValueIsAdjusting()) {
          iValue = (int)source.getValue();
          // Dispatch event
          CustomEvent ce = new CustomEvent(m_handler, ValueChanged);
          dispatchCustomEvent(ce);
      }
  }

  public void init(IHandler handler)
  {
    m_handler = handler;
    super.init(handler);
  }      

  public boolean setProperty(ID property, Object value)
  {

    if (property == SetBG) // Set the background color
    {
      String color = value.toString().trim();
      System.out.println("BG="+color) ;
      int c=0, i=0, r=0, g=0, b=0 ;
      StringTokenizer st = new StringTokenizer(color,",");
      while (st.hasMoreTokens()) {
               c = new Integer((String)st.nextToken()).intValue()  ;
               if( i == 0)  r = c;  
               if( i == 1 ) g = c ;
               if( i == 2 ) b = c ;
               i++;
             }      
      BGcolor = new Color(r,g,b);
      slide.setBackground(BGcolor);
      return true;
    }
    else if (property == SetFG) // Set the foreground color
    {
      String color = value.toString().trim();
      System.out.println("FG="+color) ;
      int c=0, i=0, r=0, g=0, b=0 ;
      StringTokenizer st = new StringTokenizer(color,",");
      while (st.hasMoreTokens()) {
               c = new Integer((String)st.nextToken()).intValue()  ;
               if( i == 0)  r = c;  
               if( i == 1 ) g = c ;
               if( i == 2 ) b = c ;
               i++ ;
             }      
      FGcolor = new Color(r,g,b);
      slide.setForeground(FGcolor);
      return true;
    }    
    else if (property == SetBounds) // Set the properties
    {
      String sBounds = value.toString().trim();
      int c=0, i=1 ;
      StringTokenizer st = new StringTokenizer(sBounds,",");
      while (st.hasMoreTokens()) {
            if( i == 1)
            {
               if ( st.nextToken().equals("H"))
                 slide.setOrientation(JSlider.HORIZONTAL);
               else
                 slide.setOrientation(JSlider.VERTICAL);
            }
            else
            {
               c = new Integer((String)st.nextToken()).intValue()  ;
               if( i == 2)  slide.setMinimum(c);  
               if( i == 3 ) slide.setMaximum(c);
               if( i == 4 ) slide.setMajorTickSpacing(c);
               if( i == 5 ) slide.setMinorTickSpacing(c);               
            }
             i++;
      }
      return true;
    }
    else if (property == SetValue) // Set the current value
    {
      slide.setValue(new Integer((String)value).intValue() );
      return true;
    }
    else
    {
     return super.setProperty(property, value);
    }
  }

  /**
   * Get the current value
   **/


  public Object getProperty(ID pId)
  {
    if (pId == GetValue)
    {
      return "" + iValue ;
    }
    else
    {
      return super.getProperty(pId);
    }
  }
 

}

Forms configuration
  • Copy the Slider.jar file in the /forms/java directory
  • Sign the Slider.jar file with your own certificate
  • Edit the /forms/server/formsweb.cfg file to add the jar file to the archive_jinit variable
archive_jini=f90all_jinit.jar,……,Slider.jar

Implementation Class property

    oracle.forms.fd.Slider



Properties that can be set

The background color of the slider

Set_Custom_Property( BEAN_NAME, BEAN_NUMBER, 'SETBGCOLOR', 'rgb_color' ) ;

e.g.

Set_Custom_Property('BLK.ITEM_BEAN', 1, 'SETBGCOLOR', '255,0,255' ) ;


Information about the background property

If the background color of the bean is not setted, we use the canvas background color property.
If the canvas background color property is not setted, we have to know what colorscheme is currently in use

There is a package in the SLIDER.FMB module that store the RGB values for each colorscheme

-- Colorscheme RGB values --
GC$Teal Varchar2(15) := '115,142,140' ;
GC$Titanium Varchar2(15) := '99,101,99' ;
GC$Red Varchar2(15) := '156,130,123' ; 
GC$Khaki Varchar2(15) := '140,142,123' ; 
GC$Blue Varchar2(15) := '90,117,148' ;
GC$Olive Varchar2(15) := '107,113,99' ; 
GC$Purple Varchar2(15) := '123,113,140' ; 
GC$Blaf Varchar2(15) := '247,247,231' ;

-- Current colorscheme --
GC$CurScheme Varchar2(15) := '' ;


In the case of the use of a colorscheme, you have to indicate it as soon as possible (in a When-New-Form-Instance trigger)

-- ColorScheme used ? --
PKG_SLIDER.GC$CurScheme := PKG_SLIDER.GC$Blaf ;

In this example, i used the blaf colorscheme

The foreground color of the slider

Set_Custom_Property( BEAN_NAME, BEAN_NUMBER, 'SETFGCOLOR', 'rgb_color' ) ;

e.g.

Set_Custom_Property('BLK.ITEM_BEAN', 1, 'SETFGCOLOR', '0,0,0' ) ;

The properties of the slider

Set_Custom_Property( BEAN_NAME, BEAN_NUMBER, 'SETBOUNDS', PROPERTIES ) ;

Where properties are:

  • Orientation : could be H for a horizontal slider or V for a vertical slider
  • Max Value : the maximum value for the slider
  • Min Value : the minimum value for the slider
  • MajorTick : distance betwwen each principal graduations
  • MinorTick : distance betwwen each secondary graduations


e.g.

Set_Custom_Property('BLK.ITEM_BEAN', 1, 'SETBOUNDS', ' H,0,10,2,1 ' ) ;

The current value of the slider

Set_Custom_Property( BEAN_NAME, BEAN_NUMBER, 'SETVALUE', 'value' ) ;

e.g.

Set_Custom_Property('BLK.ITEM_BEAN', 1, 'SETVALUE', '5' ) ;


Properties that can be read


The current value of the slider

CHAR := Get_Custom_Property( BEAN_NAME, BEAN_NUMBER, 'GETVALUE' ) ;

e.g.

Value := Get_Custom_Property('BLK.ITEM_BEAN', 1, 'GETVALUE' ) ;



The sample dialog

  • Download the jslider.zip file
  • Unzip the jslider.zip file
  • Copy the Slider.jar file in your /forms/java/ directory
  • Edit your /forms/server/formsweb.cfg file
  • Open the SLIDER.fmb module (Oracle Forms 10.1.2)
  • Open the JSLIDER.fmb module (Oracle Forms 9.0.2)
  • Open the COLOR_SLIDER.fmb module (Oracle Forms 9.0.2)
This dialog allows to choose a color from Red, Green and Blue Jsliders
  • Compile all and run the module

The settings of the slider properties are grouped in the PKG_SLIDER package

PACKAGE PKG_SLIDER IS

  -- Colorscheme RGB values --
  GC$Teal      Varchar2(15) := '115,142,140' ;
  GC$Titanium  Varchar2(15) := '99,101,99' ;
  GC$Red       Varchar2(15) := '156,130,123' ; 
  GC$Khaki     Varchar2(15) := '140,142,123' ;       
  GC$Blue      Varchar2(15) := '90,117,148' ;
  GC$Olive     Varchar2(15) := '107,113,99' ; 
  GC$Purple    Varchar2(15) := '123,113,140' ;       
  GC$Blaf      Varchar2(15) := '247,247,231' ;

  -- Current colorscheme --
  GC$CurScheme Varchar2(15) := '' ;

  PROCEDURE    Init_Slider
  (
     PC$Name       IN VARCHAR2,
     PN$Num        IN PLS_INTEGER,
     PC$Bounds     IN VARCHAR2
  ) ;

  PROCEDURE Set_Value
  (
     PC$Name       IN VARCHAR2,
     PN$Num        IN PLS_INTEGER,
     PN$Value      IN NUMBER
  ) ; 

END;
 

PACKAGE BODY PKG_SLIDER IS

PROCEDURE    Init_Slider
  (
     PC$Name       IN VARCHAR2,
     PN$Num        IN PLS_INTEGER,
     PC$Bounds     IN VARCHAR2
  )
Is
      LC$CVBColor   Varchar2(20) := Get_Canvas_Property( Get_Item_Property( PC$Name, ITEM_CANVAS ), BACKGROUND_COLOR ) ;
      LC$CVFColor   Varchar2(20) := Get_Canvas_Property( Get_Item_Property( PC$Name, ITEM_CANVAS ), FOREGROUND_COLOR ) ;  
      LC$BGColor    Varchar2(20) := Get_Item_Property(PC$Name, BACKGROUND_COLOR) ;
      LC$FGColor    Varchar2(20) := Get_Item_Property(PC$Name, FOREGROUND_COLOR) ;     
      LC$Color      Varchar2(15) ;
Begin

-- BackGround color --
If LC$BGColor is not null Then
  LC$Color := Translate( LC$BGColor, '0123456789gbr','0123456789,,' ) ;
  Set_Custom_Property( PC$Name, PN$Num, 'SETBGCOLOR', LC$Color ) ;    
Elsif LC$CVBColor is not null Then
  LC$Color := Translate( LC$CVBColor, '0123456789gbr','0123456789,,' ) ;   
  Set_Custom_Property( PC$Name, PN$Num, 'SETBGCOLOR', LC$Color ) ;
Else
      LC$Color := PKG_SLIDER.GC$CurScheme ;
      Set_Custom_Property( PC$Name, PN$Num, 'SETBGCOLOR', LC$Color ) ;
End if ;

-- ForeGround color --
If LC$FGColor is not null Then
  LC$Color := Translate( LC$FGColor, '0123456789gbr','0123456789,,' ) ;
  Set_Custom_Property( PC$Name, PN$Num, 'SETFGCOLOR', LC$Color ) ;
Elsif LC$CVFColor is not null Then
  LC$Color := Translate( LC$CVFColor, '0123456789gbr','0123456789,,' ) ;   
  Set_Custom_Property( PC$Name, PN$Num, 'SETBGCOLOR', LC$Color ) ; 
End if ;

-- Bounds --
Set_Custom_Property( PC$Name, PN$Num, 'SETBOUNDS', PC$Bounds ) ;

End ;
 

-------------------------------------------
--  Set the current value of the Slider  --
-------------------------------------------
PROCEDURE Set_Value
  (
     PC$Name       IN VARCHAR2,
     PN$Num        IN PLS_INTEGER,
     PN$Value      IN NUMBER
  )
IS
BEGIN

  -- Initial value --
  Set_Custom_Property( PC$Name, PN$Num, 'SETVALUE', To_Char(PN$Value) ) ;

End Set_Value;

END;

So, in the When-New-Form-Instance trigger, you can set the slider settings:

-- ColorScheme used ? --
PKG_SLIDER.GC$CurScheme := PKG_SLIDER.GC$Blaf ;

-- Init the slider properties --
PKG_SLIDER.Init_Slider ( 'BL1.BEAN_SLIDER', 1, 'H,0,10,2,1' ) ;

-- Set current the value --
PKG_SLIDER.Set_Value   ( 'BL1.BEAN_SLIDER', 1, 5 ) ;


And get the current value with the When-Custom-Item-Event trigger created on the bean item:

-- Get new value --
:BL1.VAL := Get_Custom_Property( 'BL1.BEAN_SLIDER', 1, 'GETVALUE') ;
par Oracle Forms community publié dans : Bean - Button
ajouter un commentaire commentaires (0)    recommander
Jeudi 2 février 2006
Purpose

This is a Javabean component that allow to enter a value from an input dialog box


imput dialog bean

The java code


package oracle.forms.fd;

import oracle.forms.handler.IHandler;
import oracle.forms.properties.ID;
import oracle.forms.ui.VBean;
import javax.swing.JOptionPane;

/**
 * A javabean input dialog box for Oracle Forms
 *
 * @author Francois Degrelle
 * @version 1.0
 */


public class InputDialog extends VBean {

    static String title = "" ;
    static String text  = "" ;
    static String result = "" ;
    static int    icon  = JOptionPane.QUESTION_MESSAGE ;
    private IHandler mHandler;
    private static final ID pSetTitle   = ID.registerProperty("SETTITLE");
    private static final ID pSetText    = ID.registerProperty("SETTEXT");
    private static final ID pGetString  = ID.registerProperty("GETSTRING");    

    public InputDialog() {
      super();
      try
      {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        SwingUtilities.updateComponentTreeUI(this);
      }
      catch (Exception ex)
      {
        ex.printStackTrace();
      }    
    }

    public void init(IHandler handler) {
        super.init(handler);
        mHandler = handler;
    }
 

    /**
     * Set the properties from Forms
     **/

    public boolean setProperty(ID id, Object value) {
        if (id == pSetTitle) { /** Set the title **/
            title = (String)value ;
            return true;
        }
        else if (id == pSetText) { /** Set the message and display the dialog box **/
            text = (String)value ;
            result = ShowDialog();
            return true;
        }
        else {
            return true;
        }
    }

  /**
   * Get the result string from Forms
   **/

  public Object getProperty(ID pId)
  {
    if (pId == pGetString)
    {
      return "" + result ;
    }
    else
    {
      return super.getProperty(pId);
    }
  } // getProperty()


    /**
     * Display the dialog box
     */

    public static String ShowDialog() {
 
        String sReturn = "" ;
        sReturn =  JOptionPane.showInputDialog(null, text, title, icon);
        if( sReturn == null ) return "" ;
        else return sReturn ;

    }

}

Forms configuration
  • Copy the inputdialog.jar file in the /forms/java directory
  • Sign the inputdialog.jar file with your own certificate
  • Edit the /forms/server/formsweb.cfg file to add the jar file to the archive_jinit variable
archive_jini=f90all_jinit.jar,……,inputdialog.jar

Implementation Class property

    oracle.forms.fd.InputDialog



Properties that can be set

Set the title of the message box

Set_Custom_Property( ‘BLOCK.BEAN_ITEM’, ‘SETTITLE’, ‘the_title’ ) ;


Set the text of the message box

Set_Custom_Property( ‘BLOCK.BEAN_ITEM’, ‘SETTEXT’, ‘the_text’ ) ;


Properties that can be read

The returned string

:BLK.ITEM := Get_Custom_Property( ' BLOCK.BEAN_ITEM', 1, 'GETSTRING' ) ;



The sample dialog

  • Download the inputdialog.zip file
  • Unzip the inputdialog.zip file
  • Copy the inputdialog.jar file in your /forms/java/ directory
  • Edit your /forms/server/formsweb.cfg file
  • Open the inputdialog.fmb module (Oracle Forms 9.0.2)
  • Compile all and run the module

 

par Oracle Forms community publié dans : Bean - JoptionPane
ajouter un commentaire commentaires (0)    recommander
Jeudi 2 février 2006
Purpose

The Show_Alert() Forms built-in allows to display any message in a popup modal window.
This built-in is limited to a maximum of 255 characters displayed.
This limitation cannot allow to display huge messages like trace/log message.

This is a Javabean component that allow to display messages with thousands of characters





The java code


package oracle.forms.fd;

import oracle.forms.handler.IHandler;
import oracle.forms.properties.ID;
import oracle.forms.ui.CustomEvent;
import oracle.forms.ui.VBean;
import javax.swing.JOptionPane;

/**
 * A dialog box for Forms that allow to output 1 up to 32767 characters
 *
 * @author Francois Degrelle
 * @version 1.0
 */


public class ShowMessage extends VBean {

    static String title = "" ;
    static String text  = "" ;
    static String icone = "" ;   
    static int    max   = 150 ;
    static int    icon  = JOptionPane.INFORMATION_MESSAGE ;
    private IHandler mHandler;
    private static final ID pSetTitle = ID.registerProperty("SETTITLE");
    private static final ID pSetText  = ID.registerProperty("SETTEXT");
    private static final ID pSetIcon  = ID.registerProperty("SETICON");
    private static final ID pSetSize  = ID.registerProperty("SETLINESIZE");
    private static final ID pShow     = ID.registerProperty("SHOW");   
    private static final ID pClear    = ID.registerProperty("CLEAR");       
 
    public ShowMessage() {
        super();
    }

    public void init(IHandler handler) {
        super.init(handler);
        mHandler = handler;
    }

    /**
     * Set the properties from Forms
     **/

    public boolean setProperty(ID id, Object value) {
        if (id == pSetTitle) { /** Set the title **/
            title = (String)value ;
            return true;
        }
        else if (id == pSetText) { /** Set the message **/
            text += (String)value ;
            return true;
        }
        else if (id == pClear) { /** Clear the text **/
            text = "" ;
            return true;
        }       
        else if (id == pSetSize) { /** Set max line size **/       
            max = new Integer((String)value).intValue() ;
            return true;
        }
        else if (id == pSetIcon) { /** Set the dialog box icon **/
            icone = (String)value ;
            if( icone.equals("I") )      icon = JOptionPane.INFORMATION_MESSAGE ;
            else if( icone.equals("E") ) icon = JOptionPane.ERROR_MESSAGE ;
            else if( icone.equals("P") ) icon = JOptionPane.PLAIN_MESSAGE ;
            else if( icone.equals("W") ) icon = JOptionPane.WARNING_MESSAGE ;
            return true;
        }       
        else if (id == pShow) { /** Display the dialog box **/
            text = Wrap_Text( text ) ;
            ShowDialog();
            return true;
        }               
        else {
            return true;
        }
    }


    /**
     * Display the dialog box
     */

    public static void ShowDialog() {

        JOptionPane.showMessageDialog(null, text, title, icon);

    }


     /**
     * Wrap the text if lines are too long
     */

    private String Wrap_Text( String sText )
    {
      String sWraped = "" ;
      String s1 = sText ;
      String s2 = "" ;
      int    l, x = 0 ;

      l = s1.length() ;
      if( l <= max ) sWraped = s1 ;
      else
      {
        while( l > 0 )
        {
          x = s1.indexOf("n") ;
          if( (x > 0) && (x <= max))
          {
            sWraped += s1.substring(0,x) ;
            s1 = s1.substring(x) ;
          }
          else
          {
            s2 = s1.substring(0, max-1) ;
            sWraped += s2 + "n" ;
            s1 = s1.substring(max-1) ;
          }

          l = s1.length() ;

          if( l <= max )
          {
            sWraped += s1 ;
            l = 0 ;
          }
        }
      }

      return sWraped ;     

    }    

}

Forms configuration
  • Copy the showmessage.jar file in the /forms/java directory
  • Sign the showmessage.jar file with your own certificate
  • Edit the /forms/server/formsweb.cfg file to add the jar file to the archive_jinit variable
archive_jini=f90all_jinit.jar,……,showmessage.jar

Implementation Class property

    oracle.forms.fd.ShowMessage


Properties that can be set

Clear the text

Set_Custom_Property( ‘BLOCK.BEAN_ITEM’, ‘CLEAR’, ‘’ ) ;

Set the title of the message box

Set_Custom_Property( ‘BLOCK.BEAN_ITEM’, ‘SETTITLE’, ‘the_title’ ) ;

Set the icon style

Set_Custom_Property( ‘BLOCK.BEAN_ITEM’, ‘SETICON’, ‘icon_type’ ) ;

Where icon_type could be:
  • I   Information
  • E   Error
  • P   Plain (no icon)
  • W   Warning
     

Set the maximum length of a line

Set_Custom_Property( ‘BLOCK.BEAN_ITEM’, ‘SETLINESIZE’, ‘max_size’ ) ;

Set the text of the message box

Set_Custom_Property( ‘BLOCK.BEAN_ITEM’, ‘SETTEXT’, ‘the_text’ ) ;

Display the message box

Set_Custom_Property( ‘BLOCK.BEAN_ITEM’, ‘SHOW’, ‘’ ) ;



The sample dialog

  • Download the showmessage.zip file
  • Unzip the showmessage.zip file
  • Copy the showmessage.jar file in your /forms/java/ directory
  • Edit your /forms/server/formsweb.cfg file
  • Open the showmessage.fmb module (Oracle Forms 9.0.2)
  • Compile all and run the module

 

par Oracle Forms community publié dans : Bean - JoptionPane
ajouter un commentaire commentaires (0)    recommander
Mercredi 1 février 2006
You have written some PJC/Bean of your own and would like to share it.

Write a document that contains the followings points:

  • . Some information about yourself
  • . A title that identify the component
  • . A purpose that describes in a few sentences the functionalities
  • . Eventually a screen shot of the result
  • . The java code of the component
  • . The Oracle Forms Implementation Class name
  • . The list of the properties that you can set
  • . The list of the properties that you can read
  • . The list of the events that can be raised by the bean
  • . Indication if the jar file have to be signed
  • . Eventually, a link to any material to download (.jar file, Forms modules, ...)

Send the doc to the following mail adress: forms.pjc.bean@free.fr
par Oracle Forms community publié dans : General
ajouter un commentaire commentaires (0)    recommander
Créer un blog sur over-blog.com - Contact - C.G.U. - Rémunération en droits d'auteur avec TF1 Network - Signaler un abus