• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
J slider
 

J slider

on

  • 253 views

 

Statistics

Views

Total Views
253
Views on SlideShare
253
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    J slider J slider Document Transcript

    • Jslider - Francois Degrelle Oracle Forms – Javabean A Jslider in your application Home page1. Purpose This bean allows to display a Jslider component in your Forms application.2. The Javabean 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 * f.degrelle@free.fr - http://fdegrelle.over-blog.com/
    • Jslider - Francois Degrelle* @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; } f.degrelle@free.fr - http://fdegrelle.over-blog.com/
    • Jslider - Francois Degrelle 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); } }} f.degrelle@free.fr - http://fdegrelle.over-blog.com/
    • Jslider - Francois Degrelle3. Forms configuration Copy the Slider.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,……, Slider.jar4. How to implement this bean in your own form Open your form Add a Javabean component to any block Set its Implementation class property to oracle.forms.fd.Slider Eventually, set the Backgroud and/or the foreground color5. The properties that can be sent to the bean 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) f.degrelle@free.fr - http://fdegrelle.over-blog.com/
    • Jslider - Francois Degrelle -- 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 ) ;6. The properties that can be read from the bean 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 ) ; f.degrelle@free.fr - http://fdegrelle.over-blog.com/
    • Jslider - Francois Degrelle7. 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) 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,, ) ; f.degrelle@free.fr - http://fdegrelle.over-blog.com/
    • Jslider - Francois Degrelle 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 ) ;ElseLC$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 )ISBEGIN -- 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) ; f.degrelle@free.fr - http://fdegrelle.over-blog.com/