Monday, April 09, 2007

Extending the Navigator with children

I started to answer this question with a reply to the comment but thought I'd just put a post together since this is should make it easier to find.

Question #3: Do you have the xsd file ?
There is an XSD for the navigator in sqldev 1.1 and it's located here. In the xsd you'll notice there's quite a bit that I didn't mention before.

Question #2: How to add multi-level folder like "Storage" > "Datafiles" > "Files" ?
The full xml from the first post is here. The part that will add the children is the <node/> tag which quite empty in the example. All that has to be done to add children is change the <node /> tag to something like this with PARENT_NAME being the bind for the immediate parent in the tree.
<node>
<childType id="COLUMN"">
<icon RSKEY="/path/to/my/icon.png"/>
<queries >
<query>
<sql>
<![CDATA[SELECT COLUMN_NAME
FROM SYS.ALL_TAB_COLUMNS
WHERE OWNER = :SCHEMA
AND TABLE_NAME = :PARENT_NAME
ORDER BY COLUMN_ID]]>
</sql>
</query>
</queries>
</childType>
</node>


Question #1: How to link navigator "id" with editor "node" in the case I want to add say "SQL*Profiles" ?

The posts I did a while back explain how to get tabs added with Forgotten tabs however this has changed quite a lot in 1.1. The simpliest way now to add a tab to the broswing is to goto into the reports section and define your report exactly how you'd like to see it. Be sure to use :OBJECT_NAME , :OBJECT_TYPE , :OBJECT_OWNER as the bind variables. Then once everything is setup just right click on the report and choose Export. Export this file to some location and open it in your favorite xml editor. You'll get something that looks like this. Now in the <display tag add objectType="TABLE" Oracle will be the default for any tabs added to change to something else add connType="TimesTen".

The resulting display tag will look something like this:

<display id="" style="Table" enable="true" connType="Oracle" objectType="TABLE">

Now to add this file, it just like adding a file for the navigator. Go into the preferences and click add row , choose EDITOR.


6 comments:

ArKZoYD said...

Kris,

I've successfully developed what you've explained as you can see : http://arkzoyd.free.fr/sqldev/sqldev-addin01.jpg

I've one more question ! I'd like to register the <display> xml file as you've done with the navigator xml file with this method : XMLBasedObjectAction.registerContextMenus

It does not seem to work in this case!

S'il te plaƮt ? -Gregory

Kris Rice said...

That call is only for context menus. To add the tabs there's 2 choices:

1) Add a single file:
ViewerAddin.registerEditors("/path/to/file.xml");
This is the call under the preferences pane.



or 2) Add all xml in a package
ViewerAddin.registerPackage("mypackage.mydisplays");

This call will process *.xml from that package in the jar. This make s it easy to keep the displays in seperate files for maintance. This is how sqldev does it.

-kris

ArKZoYD said...

Kris,

Thank you very much; I made the first solution work... So everything is fine ! I'll be able to shift to my next topic !

I would have prefered the second solution. I put my explain.xml file in the same directory as my add-in... So it is deployed in my JAR file. I get the following message : "Could not load:arkzoyd.sqldeveloper.addins"

Anyway... Thank you very much!

Gregory

Ghassan said...

Kris,
This blog is very welcomed. I'm no java man, but used the xml description to add a node for 'Dimensions' in the navigator + required tabs. There's no way to publish these (+ other tabs I added for partitions/subpartitions, statistics on these, ...). Why not modify the extensions pages to allow user to add these?

rgds

Kris Rice said...

Do you mean the extension preferences or the exchange? In the preferences, instead of pointing to a file you can point to a URL where you could store the xml files like:
http://myhost/mytabs.xml

If you mean the exchange, I'm working on it. It'll come but takes a little time.

-kris

Ghassan said...

Thanks Kris,
I was talking about the exchange.

I'll upload my extensions when it'll be possible.
rgds

Disqus for Kris' Blog