Home » Developer & Programmer » Forms » Where do I get navigator.pll
Where do I get navigator.pll [message #83954] Thu, 08 January 2004 23:23 Go to next message
Kaushik Basu
Messages: 2
Registered: January 2004
Junior Member
I am trying to create a tree structure (in D2K)where i will be able to drag and drop the tree nodes.
For this I need navigator.pll.
Please advice me where do i get it .
If there is any other solution , plese suggest
Re: Where do I get navigator.pll [message #83955 is a reply to message #83954] Fri, 09 January 2004 01:20 Go to previous messageGo to next message
Deepak
Messages: 111
Registered: December 1999
Senior Member
Dear Basu,

for this you have to install the froms demo,
After this you can find in orant/forms45/plsllib dir

or i m send the package of naviagator.pll you just cust and paste into new pll

PACKAGE BODY navigator IS

/***
Private variables
***/

--Most recently clicked row (needed for shift-click)
last_click number default 0;

/***
Deal with a mouse click
***/

PROCEDURE Set_Tree_Selection(tree varchar2, list_index number, keystate varchar2) IS
selected number;
range_max number;
range_min number;

BEGIN
--If no keys down, clear everything else, set this one
if keystate IS NULL then
reset_group_selection(tree);
set_group_selection(tree, list_index);
--Save the click for next time in case the next one is Shift+
last_click := list_index;

--If just control key down, toggle this one
elsif keystate = 'Ctrl+' then
--Find out if this one is already selected
selected := 0;
for i in 1..nvl(get_group_selection_count(tree),0) loop
if get_group_selection(tree, i) = list_index then
selected := 1;
exit;
end if;
end loop;

if selected = 1 then
unset_group_selection(tree, list_index);
else
set_group_selection(tree, list_index);
end if;
--Save the click for next time
last_click := list_index;

--If just Shift key down, select a range
elsif keystate = 'Shift+' and last_click <> 0 then
range_min := least(last_click, list_index);
range_max := greatest(last_click, list_index);
for i in range_min..range_max loop
set_group_selection(tree, i);
end loop;
end if;
end;

/***
Analogues of get_group_selection_count and get_group_selection.
Provided to hide implementation.
***/

FUNCTION Get_Tree_Selection_Count(tree varchar2) RETURN number IS
BEGIN
return NVL(Get_Group_Selection_Count(tree), 0);
END;

FUNCTION Get_Tree_Selection(tree varchar2, selection_number number) RETURN number IS
BEGIN
return Get_Group_Selection(tree, selection_number);
END;

/***
Convert a block record number (typically :SYSTEM.CURSOR_RECORD)
to a tree index without navigating in the block.
Uses the current tree_name.

Arguments:
Number block record number to convert

Return:
Number index into the tree structure of the corresponding tree Element
***/

FUNCTION To_Index(line_num number) RETURN number is
curr_depth number default -1; -- depth of current row
hide_depth number default -1; -- -1 means don't hide
curr_record number default 0;

BEGIN
--Loop through the tree structure counting displayed rows
--until we reach the requested one. Look for collapsed
--nodes in the tree to determine which rows are shown and
--which are hidden

for i in 1..get_group_row_count(get_tree_name) loop
curr_depth := get_group_number_cell(get_tree_name||'.depth', i);

--Each line is displayed if its parent is expanded. We
--start hiding when we find a collapsed node (set hide_depth).
--When depth is <= the depth of the last collapsed node,
--we have left the scope of the last collapsed node so we
--stop hiding.

if hide_depth = -1 or curr_depth <= hide_depth then

--If this line itself is displayed, check whether it is collapsed
--State=1 indicates an expanded node
if get_group_number_cell(get_tree_name||'.state', i) = 1 then
hide_depth := -1; -- don't hide below this depth
else
hide_depth := curr_depth; -- hidden below this depth
end if;

curr_record := curr_record + 1; -- increment count of displayed rows
if curr_record = line_num then -- this is the one
return i;
end if;
end if;
end loop;

--Only reach here if line_num is greater than the number of displayed rows
--Should never happen!
return NULL; -- not found
END;

/***
Return the name of the tree currently displayed in the
navigator block. This function is provided
to hide the implementation of the tree structure.

Arguments:
None

Return:
Varchar2 name of the currently displayed tree
***/

FUNCTION Get_Tree_Name return varchar2 IS
BEGIN
return name_in('navigator_control.nav_tree_name');
END;

/***
Private procedure to save away the tree name
***/

Procedure Set_Tree_Name(treen varchar2) IS
BEGIN
copy(UPPER(treen), 'navigator_control.nav_tree_name');
END;

/***
Return the size of a tree. This function is provided
to hide the implementation of the tree structure.

Arguments:
Varchar2 name of a tree

Return:
Number number of elements in the tree
***/

FUNCTION Get_Tree_Element_Count(tree varchar2) RETURN number IS
BEGIN
return nvl(get_group_row_count(tree), 0);
END;

/***
Get_Tree_Element_XXX functions to return state, depth, label, value.

Arguments:
Varchar2 name of a tree
Number index into the tree structure

Return:
Number State values: -1 = collapsed; 0 = leaf; +1 = expanded
OR Number Depth of nesting
OR Varchar2 Label
OR Varchar2 Value
***/

FUNCTION Get_Tree_Element_State(tree varchar2, list_index number) RETURN number IS
this_depth number;
next_depth number;

BEGIN
--The last Element must be a leaf since there is nothing below it!
if list_index >= get_group_row_count(tree) then
return 0;
end if;

--Now it must be OK to refer to list_index+1
this_depth := get_group_number_cell(tree||'.depth', list_index);
next_depth := get_group_number_cell(tree||'.depth', list_index+1);

--If next Element is at same or lower depth then this is a leaf Element
if next_depth >= this_depth then
return 0;
else
--Return the actual state setting
return get_group_number_cell(tree||'.state', list_index);
end if;
END;

FUNCTION Get_Tree_Element_Depth(tree varchar2, list_index number) RETURN number IS
BEGIN
return get_group_number_cell(tree||'.depth', list_index);
END;

FUNCTION Get_Tree_Element_Label(tree varchar2, list_index number) RETURN varchar2 IS
BEGIN
return get_group_char_cell(tree||'.label', list_index);
END;

FUNCTION Get_Tree_Element_Value(tree varchar2, list_index number) RETURN varchar2 IS
BEGIN
return get_group_char_cell(tree||'.value', list_index);
END;

FUNCTION Get_Tree_Element_Parent(tree varchar2, list_index number) RETURN number IS
this_depth number;
i number default list_index-1;

BEGIN
this_depth := get_group_number_cell(tree||'.depth', list_index);
for i in reverse 1..list_index loop
if get_group_number_cell(tree||'.depth', i) < this_depth then
return i;
end if;
end loop;

return 0; -- parent not found, this is a top level node
END;

/***
Set_Tree_element_XXX functions to set label, value.
To change state, use the expand/collapse functions.
Cannot change the depth of an existing element.

Arguments:
Varchar2 name of a tree
Number index into the tree structure

Varchar2 Label
OR Varchar2 Value
***/

PROCEDURE Set_Tree_Element_Label(tree varchar2, list_index number, label varchar2) IS
BEGIN
set_group_char_cell(tree||'.label', list_index, label);
END;

PROCEDURE Set_Tree_Element_Value(tree varchar2, list_index number, value varchar2) IS
BEGIN
set_group_char_cell(tree||'.value', list_index, value);
END;

/***
Create an empty tree structure.

Arguments:
Varchar2 name of a tree
***/

PROCEDURE Create_Tree(tree varchar2) IS
group_id RecordGroup;
col_id GroupColumn;

BEGIN
group_id := create_group(tree);
col_id := Add_Group_Column(group_id,'State',NUMBER_COLUMN);
col_id := Add_Group_Column(group_id,'Depth',NUMBER_COLUMN);
col_id := Add_Group_Column(group_id,'Label',CHAR_COLUMN,255);
col_id := Add_Group_Column(group_id,'Value',CHAR_COLUMN,255);
END;

/***
Delete a tree structure.

Arguments:
Varchar2 name of a tree
***/

PROCEDURE Delete_Tree(tree varchar2) IS
BEGIN
if not id_null(find_group(tree)) then
Delete_Group(tree);
end if;
END;

/***
Resize the navigator pane (canvas) to fill the window.
Normally called from the WHEN-WINDOW-RESIZED trigger.

Arguments:
None
***/

PROCEDURE Resize_Navigator IS
BEGIN
set_view_property('NAVIGATOR_TREE', HEIGHT,
get_window_property('NAVIGATOR', HEIGHT));
set_view_property('NAVIGATOR_TREE', WIDTH,
get_window_property('NAVIGATOR', WIDTH));
END;

/***
Display a tree in the Navigator window. Many trees can be prepared
in memory using Create_Tree allowing the view to be switched
rapidly, and avoiding the need to re-query to show different views.

If this procedure is called with no argument, the current tree is
redisplayed and the cursor position is retained at the current record
number. In normal use (expanding or collapsing the tree, adding elements
below the current record) this should be the correct position.
However, if you have programmatically changed the tree structure for
example by adding records above the current record, you may need to
manually adjust the cursor position by using the NEXT_RECORD built-in,
checking the return of the Navigate.To_Index function until you
are at the place you want.

NOTE: this procedure and Clear_Tree are the ONLY routines that change
the displayed state of the block. They are also the only routines that
cause navigation. All other routines change only the internal state of a
tree. This allows the developer to make many changes to a tree
without constant redrawing, then to call this procedure when the
final state of the tree is ready for display.

Arguments:
Varchar2 name of a tree

***/

PROCEDURE Display_Tree(tree varchar2 default null, markers varchar2 default NULL) IS
curr_depth number default -1;
hide_depth number default -1; -- -1 means not hiding
curr_record number;
treen varchar2(30) default tree;
list_count number;

do_multiselect number;
next_select number default 0; --index of next row to highlight
select_total number default 0; --total number of highlighted rows
select_count number default 1; --counter for next highlighted row


BEGIN
go_block('NAVIGATOR');

--Figure out which tree we are using
if treen is not null then
curr_record := 1; -- will go to first record after display
else -- use the current tree
treen := get_tree_name;
go_block('NAVIGATOR');
curr_record := to_number(name_in('system.cursor_record')); -- will return to cursor position
end if;

--Flag to prevent WHEN-NEW-RECORD-INSTANCE from doing useless work...
set_tree_name(NULL);

--Initialize multiselection counters
do_multiselect := to_number(name_in('navigator_control.nav_multiselect'));

if do_multiselect = 1 then
select_total := nvl(get_group_selection_count(treen),0);
end if;

--Tree markers
if length(markers) >= 3 then
copy(' ' || substr(markers, 1, 1) || ' ', 'navigator_control.nav_expanded');
copy(' ' || substr(markers, 2, 1) || ' ', 'navigator_control.nav_collapsed');
copy(' ' || substr(markers, 3, 1) || ' ', 'navigator_control.nav_leaf');
end if;

clear_block(no_commit);

--No tree to display, so blank navigator
--Should only happen if the developer calls Display_Tree
--without an argument and there is no current tree.

if treen IS NULL then
go_block('NAVIGATOR_CONTROL');
hide_view('NAVIGATOR_TREE');
return;
end if;

list_count := nvl(get_group_row_count(treen),0);

for i in 1..list_count loop
curr_depth := get_group_number_cell(treen||'.depth', i);

--Each line is displayed if its parent is expanded. We
--start hiding when we find a collapsed node (set hide_depth).
--When depth is <= the depth of the last collapsed node,
--we have left the scope of the last collapsed node so we
--stop hiding.

if hide_depth = -1 or curr_depth <= hide_depth then -- display this line

--element is a leaf if it is last, or if the next Element is at the same or lower depth.
--NOTE: Don't use an OR here as we can't guarantee the order of evaluation, and if
--we are looking at the last element, i+1 is not a valid Element.

if i = list_count then
copy(name_in('navigator_control.nav_leaf'), 'navigator.nav_display');
elsif get_group_number_cell(treen||'.depth', i+1) <= curr_depth then
copy(name_in('navigator_control.nav_leaf'), 'navigator.nav_display');
elsif get_group_number_cell(treen||'.state', i) = 1 then -- expanded
hide_depth := -1; -- stop hiding
copy(name_in('navigator_control.nav_expanded'), 'navigator.nav_display');
else
hide_depth := curr_depth; -- hide below this depth
copy(name_in('navigator_control.nav_collapsed'), 'navigator.nav_display');
end if;

--Create the displayed string by blank padding to create indentation
copy(lpad(name_in('navigator.nav_display'), (curr_depth-1)*4+3)
|| ' ' || get_group_char_cell(treen||'.label', i),
'navigator.nav_display');

--Set the VA according to whether the element is selected
--(only if multiselect is enabled)
if do_multiselect = 1 then

--Discard any selections that are not displayed due to tree being collapsed
while select_count <= select_total and next_select < i loop
next_select := get_group_selection(treen, select_count);
select_count := select_count+1;
end loop;

--Display this one
if i = next_select then
Display_item('NAVIGATOR.nav_DISPLAY', 'NAV_TREE_ELEMENT_SELECTED');
else
Display_item('NAVIGATOR.nav_DISPLAY', 'NAV_TREE_ELEMENT');
end if;
end if;

go_block('NAVIGATOR');
next_record;
end if;
end loop;

--Set the height of the canvas to match the number of records
--so that the size of the view scrollbar
--reflects the number of records displayed in the tree

go_block('NAVIGATOR');
last_record;
set_canvas_property('NAVIGATOR_TREE', HEIGHT,
to_number(name_in('system.cursor_record')) *
to_number(get_item_property('NAVIGATOR.nav_DISPLAY', HEIGHT)));

resize_navigator;

--Restore the cursor position
go_block('NAVIGATOR');
go_record(curr_record);

if name_in('system.block_status') = 'NEW' then
--only 1 NEW record in block so the tree was empty
go_block('NAVIGATOR_CONTROL');
hide_view('NAVIGATOR_TREE');
else
show_view('NAVIGATOR_TREE');
go_block('NAVIGATOR');
if name_in('system.record_status') = 'NEW' then --Just in case!
previous_record;
end if;
end if;

--Save this tree for next time
set_tree_name(treen);
END;

/***
Clear the navigator window. Set the current tree to NULL.

Arguments:
None
***/

PROCEDURE Clear_Tree IS
BEGIN
go_block('NAVIGATOR');
clear_block(no_commit);
go_block('NAVIGATOR_CONTROL');
hide_view('NAVIGATOR_TREE');

set_tree_name(NULL);
END;

/***
Change state of nodes of the tree.
Although you can change the nominal state of a
leaf element, it does not affect the display. However,
this is useful if you are adding elements below what is
currently a leaf: the setting will determine the initial
state, expanded or collapsed, when the element is no
longer a leaf.

NOTE: none of these routines changes the displayed state
of the navigator. You must call Display_Tree when you are
ready to update the display.

Arguments:
Varchar2 name of a tree
Number index into the tree structure
***/

PROCEDURE Invert_State(tree varchar2, list_index number) IS
BEGIN
if get_group_number_cell(tree||'.state', list_index) = -1 then --currently collapsed
set_group_number_cell(tree||'.state', list_index, 1); --make it expanded
else
set_group_number_cell(tree||'.state', list_index, -1); --make it collapsed
end if;
END;

PROCEDURE Expand(tree varchar2, list_index number) IS
BEGIN
set_group_number_cell(tree||'.state', list_index, 1); --expanded
END;

PROCEDURE Expand_All(tree varchar2, list_index number) IS
stop_depth number;

BEGIN
--expand the first one and get its depth

set_group_number_cell(tree||'.state', list_index, 1);
stop_depth := get_group_number_cell(tree||'.depth', list_index);

--expand everything until the end of the list
--or until finding an element at the same or lower depth as this one

for i in list_index+1..nvl(get_group_row_count(tree),0) loop
exit when get_group_number_cell(tree||'.depth', i) <= stop_depth;
set_group_number_cell(tree||'.state', i, 1); --expanded
end loop;
END;

PROCEDURE Collapse(tree varchar2, list_index number) IS
BEGIN
set_group_number_cell(tree||'.state', list_index, -1); --collapsed
END;

PROCEDURE Collapse_All(tree varchar2, list_index number) IS
stop_depth number;

BEGIN
--collapse the first one and get its depth

set_group_number_cell(tree||'.state', list_index, -1);
stop_depth := get_group_number_cell(tree||'.depth', list_index);

--collapse everything until the end of the list
--or until finding an element at the same or lower depth as this one

for i in list_index+1..nvl(get_group_row_count(tree),0) loop
exit when get_group_number_cell(tree||'.depth', i) <= stop_depth;
set_group_number_cell(tree||'.state', i, -1); --collapsed
end loop;
END;

/***
Add an element to the tree at a specific index. All
elements below the new element are renumbered to make room.

Arguments:
Varchar2 name of a tree
Number index into the tree
Number initial state: -1 for collapsed, 1 for expanded
Number nesting depth of this Element
Varchar2 label that will appear in displayed tree
Varchar2 value represented by this node, not displayed

***/

PROCEDURE Add_Tree_Element(tree varchar2, list_index number,
tree_state number, tree_depth number, element varchar2, value varchar2) IS
BEGIN
add_group_row(tree, list_index);
set_group_number_cell(tree||'.state', list_index, tree_state);
set_group_number_cell(tree||'.depth', list_index, tree_depth);
set_group_char_cell(tree||'.label', list_index, element);
set_group_char_cell(tree||'.value', list_index, value);
END;

/***
Delete an element from the tree at a specific index. All
elements below the new element are renumbered.

NOTE: deleting an element also removes all its children!

Arguments:
Varchar2 name of a tree
Number index into the tree

***/

PROCEDURE Delete_Tree_Element(tree varchar2, list_index number) IS
del_depth number;

BEGIN
--Get the depth of the current one, then remove it

del_depth := get_group_number_cell(tree||'.depth', list_index);
delete_group_row(tree, list_index);

--Remove everything until the end of the list
--or the end of the children.
--NOTE: deleting each element automatically renumbers the others,
--which is why we use list_index not i within the loop!

for i in list_index..nvl(get_group_row_count(tree),0) loop
exit when get_group_number_cell(tree||'.depth', list_index) <= del_depth;
delete_group_row(tree, list_index);
end loop;
END;

/***
Populate a tree with the contents of a query. The query will normally
(though not necessarily) be a tree walk).
The query must return the following four columns:
Number initial state, 1 for expanded, -1 for collapsed
Number nesting depth
Varchar2 label displayed in tree, up to 255 characters
Varchar2 value associated with label, up to 255 characters

Arguments:
Varchar2 Name of the tree to populate
Varchar2 Select statement to execute
***/

FUNCTION Populate_Tree_With_Query(tree varchar2, query varchar2) RETURN number IS
BEGIN
RETURN populate_group_with_query(tree, query);
END;

/***
That's all, folks!
***/
END;
Re: Where do I get navigator.pll [message #246123 is a reply to message #83954] Wed, 20 June 2007 01:05 Go to previous message
lakshmi surya ram
Messages: 188
Registered: June 2006
Location: HYDERABAD
Senior Member

Hi Deepak,
Can you send me the form you have designed so that it could be easy for me to understand.
regards
surya
Previous Topic: TABLE UPDATE DATE AND TIME
Next Topic: master-detail block depepndency
Goto Forum:
  


Current Time: Sat Dec 03 01:11:11 CST 2016

Total time taken to generate the page: 0.14941 seconds