Wednesday, December 20, 2006

Extending the Navigator


Now that Sql Dev 1.1 is out, we can start showing some of the new way to extend it. The new thing I'll talk about is the new navigator. It's been re-written from scratch. This new one is mostly based all in XML much like lots of areas in Sql Dev. The schema will be published later but here's a quick peek at what can be done.


This example will add a node to the connection under Oracle connections only name "Custom Table." I've updated the skeleton extension mentioned before to include this example. There's 1 changed file and 1 new file.


First we'll create the file which has the sql and tree information to be added. This is located here. When you look at this file there's somethings which will look quite familiar like the <query> tag. This is the same tag used by the reports. The parts that add this to the tree for Oracle connections is


<objectType connType="Oracle" id="TABLE" weight="0.0">


It's pretty simple but let's break this down

connType="Oracle" - If you connected to one of the other databases supported this element of the tree would not show.

id="TABLE" - This will key all the editors for table to be used when clicked on. Also things like Edit/Create dialogs and context menus weight="0.0" - This is the sorting order. To make my new node show first , I made it 0.0.


The next 2 tags are fairly obvious

<icon RSKEY="/oracle/dbtools/raptor/images/table_folder.png"/> - This is where to get the icon to show for the folder in the tree.

<label RSKEY="Custom Tables"/> - This is the name which will show in the tree.


Second the file to be edited is the extension.xml. The change should be pretty easy to pick out from the diff. What this is doing is registering the new table.xml file so that Sql Dev will load it. In this case it's inside the package sample.


<sqldev-navigator-hook xmlns="http://xmlns.oracle.com/sqldeveloper/sqldev-navigator">

<descriptor>/sample/table.xml</descriptor>

</sqldev-navigator-hook>


Here's the results:




and expanded:





This should allow anyone to make an extension would could have custom queries for the same base objects we have exposed in Sql Dev. This along with the other posts on this blog now show

1) how to add to the tree

2) how to add editors to what is clicked in the tree

3) how to add context menus to the nodes in the tree


There's a lot more that can be done in the navigator and we'll go into it in more detail later like how to add children , filter , ....