ActiveState Community

Can I add a tab to the right pane?

Posted by Dave_DLGreene on 2008-10-01 03:19
OS: All / Any

I was playing around with the Komodo extension template and fouled it up at one point and I got the dialog as a panel in the output window... I screwed up so I'm not overly sure how to reproduce MY error (nothing wrong with Komodo).

For my extension I really need to add a tab to the left panel and have a "outline control" that the end user can select stuff.

My question is not really about how to use xul to do it, although it would be nice to know if xul is the "toolset" to use. My question is... Is there ANY "toolset" that can be used to get to the right panel and add stuff to it? I'm guessing that I may need to write in Python and that's OK... I just need to know if there is ANY way to get to that panel and add a tab to it?

It would be really cool if I could also make my own "document" window that opens up in the regular edit window. This is a secondary question and is not as important but, it would be cool if I could.

I really need to get to the left panel... I want to build an "upside down" Cheetah. Cheetah builds the template and "fills" in the placeholders... I want to do the same thing but the variables and the data to be inserted will be known before getting to the template. So I want to insert the placeholders but I will know the values of the placeholders at "publish/run time".

Anyone that has ever used Companion knows exactly what I want. It's a dead application and it works very differantly than any other "template" application that I have ever run accross. All of the aspx, xhtml, xml, xsl, xsd, and CLIENT javascript at my site is generated with Companion.
http://www.dlgreene.com
Companion's downfall wasn't it's "publishing power" it was because the editing and editor capabilities were horrible at best. I actually have to spend quite a bit of time in other editors to actually write for my "output language" and copy and paste back into Companion to "program" the output. I'm sure that this makes absolutly no sense to anyone... Like I said Companion works very differantly than anything else most people have ever used.

jeffg | Wed, 2008-10-01 11:15

It is possible to add a tab to the right pane, in fact several extensions do this for the left pane including the Code tree extensions* and the Remote Drive Tree Extension**.

* http://community.activestate.com/node/1958
** http://community.activestate.com/node/1637

For the right pane, the overlay would look like this:

<?xml version="1.0"?>
<!DOCTYPE overlay PUBLIC "-//MOZILLA//DTD XUL V1.0//EN" "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>

<overlay id="rightpanelOverlay"
         xmlns:html="http://www.w3.org/1999/xhtml"
         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<tabs id="right_toolbox_tabs">
  <tab type="file-tab" id="my_right_tab" label="Test Right Toolbox"
                             oncommand=""
                             onfocus="ko.toolboxes.user.viewMgr.focus();"/>

</tabs>

<tabpanels id="right_toolbox_tabpanels">
  <tabpanel id="my_right_panel">
    <label value="hello world!"/>
  </tabpanel>
</tabpanels>

</overlay>

<?xml version="1.0"?>
<!DOCTYPE overlay PUBLIC "-//MOZILLA//DTD XUL V1.0//EN" "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>

<overlay id="rightpanelOverlay"
         xmlns:html="http://www.w3.org/1999/xhtml"
         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<tabs id="right_toolbox_tabs">
  <tab type="file-tab" id="my_right_tab" label="Test Right Toolbox"
                             oncommand=""
                             onfocus="ko.toolboxes.user.viewMgr.focus();"/>
</tabs>

<tabpanels id="right_toolbox_tabpanels">
  <tabpanel id="my_right_panel">
    <label value="hello world!"/>
  </tabpanel>
</tabpanels>

</overlay>

You would then use JavaScript to add in functionality. There is some basic extension development information specific to Komodo on our wiki here:

http://wiki.openkomodo.com/index.php/Extension_Development

If you have questions about any of this, just post back to this forum.

--
JeffG
http://www.openkomodo.com/blogs/jeffg

toddw | Wed, 2008-10-01 11:19

Hi Dave,

To add a new Komodo tab, you'll really need to understand XUL and XUL overlays.

To add a new right tab, you'll need to create an overlay that adds a new "tab" element to the project_toolbox tabs group. Something like this:

<?xml version="1.0"?>
<!DOCTYPE overlay PUBLIC "-//MOZILLA//DTD XUL V1.0//EN" "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<?xml-stylesheet href="chrome://komodo/skin/global/global.css" type="text/css"?>

<overlay id="my_overlay"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

    <tabs id="project_toolbox_tabs">
        <tab id="my_new_tab" label="New Tab"/>
    </tabs>
    <tabpanels id="project_toolbox_tabpanels">
        <tabpanel flex="1" id="my_new_tabpanel">
        </tabpanel>
    </tabpanels>

</overlay>

<?xml version="1.0"?>
<!DOCTYPE overlay PUBLIC "-//MOZILLA//DTD XUL V1.0//EN" "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<?xml-stylesheet href="chrome://komodo/skin/global/global.css" type="text/css"?>

<overlay id="my_overlay"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

    <tabs id="project_toolbox_tabs">
        <tab id="my_new_tab" label="New Tab"/>
    </tabs>
    <tabpanels id="project_toolbox_tabpanels">
        <tabpanel flex="1" id="my_new_tabpanel">
        </tabpanel>
    </tabpanels>

</overlay>

Note: You can also use JavaScript to manipulate the Komodo DOM, adding/removing XUL elements, but the overlay method is a lot easier and is a better design. Mozilla provides a lot of documentation on use of XUL and JavaScript.

You may wish to take a look at some of the Komodo addons that add side-panel tabs, like the "Drive Tree" extension.

For the second question, opening up your own editor page in Komodo, that one is a lot trickier, requiring a new Komodo "view", see:
http://svn.openkomodo.com/openkomodo/browse/openkomodo/trunk/src/chrome/...

Cheers,
Todd

Dave_DLGreene | Thu, 2008-10-02 08:00

I did see those extensions but, I have yet to find the source for any of it. I've looked pretty hard here and at the Open Komodo stuff and can't find any doc or example of doing it.

Thanks for at least a glimpse of the xul...

jeffg | Thu, 2008-10-02 09:54

The source for the extension is *in* the extension file. Xpi files ( like Java .jar files ) are just zip archives containing the source for the extension. For example, if I download and unzip the remotedrivetree extension, I these files extracted from the xpi file:

jeffg@opus drivetree> unzip remotedrivetree-1.2.0-ko.xpi 
Archive:  remotedrivetree-1.2.0-ko.xpi
  inflating: chrome.manifest         
  inflating: install.rdf             
  inflating: remotedrivetree.jar     
jeffg@opus drivetree> ls -1
chrome.manifest
install.rdf
remotedrivetree.jar

You'll notice that one file is a jar file. This file is also really just a zip file and contains all the Xul and JavaScript sources for the extension:

jeffg@opus drivetree> unzip remotedrivetree.jar 
Archive:  remotedrivetree.jar
   creating: content/
  inflating: content/Conscript       
  inflating: content/overlay.xul     
  inflating: content/remotedrivetree.js  
   creating: skin/
  inflating: skin/Conscript          
  inflating: skin/remotedrivetree.css  
   creating: skin/images/
  inflating: skin/images/Conscript   
 extracting: skin/images/serverAccountRefresh.png

The Xul examples Todd and I posted are the overlay, eg 'overlay.xul', which is a fragment of Xul the gets injected into Komodo's Xul when Komodo starts up.

For more on the basics of Mozilla extensions, you should check out the Mozilla extension development wiki:

http://developer.mozilla.org/en/Extensions

--
JeffG
http://www.openkomodo.com/blogs/jeffg

Dave_DLGreene | Fri, 2008-10-03 06:57

Thank you, Thank you...

I've got pkzip so now that I know that they are "re-extensioned" zips I now can understand much better what to do.

I have to say I don't know where the doc is that says that they are zips. I knew about jars but I kept trying to figure out how this stuff was doing what it was doing and could never figure it out!

It may well be documented somewhere that they are zips and it may also be that I'm the only one that is baffeled by this but, believe me if you don't know that one simple thing the whole this is very frustrating as everyone is talking about whats in it but I had no idea how to read it!

jeffg | Fri, 2008-10-03 09:33

You're not a bone-head! I too found this stuff a bit mystifying at the start, in particular in how different extension development is to web development.

You should read through the Mozilla docs on this, in particular this 'getting started' page:

http://developer.mozilla.org/en/Building_an_Extension

It explains how Mozilla extensions work better than I could. Komodo extensions work in exactly the same way, except there are some extra features you can take advantage of if you want to do more complex functionality, or write your code in Python.

Another thing you should try is starting a Komodo extension using Komodo's built-in project template. To try this out:

1. go to File / New / "Project from Template..."
2. select the Komodo category, and then the Komodo Extension template
3. choose a file name for the project file and a base directory for the new project, and hit 'Open'
4. Komodo will then create a new project and pop up a configuration dialog for your new template. Just as a test, accept all the defaults and click on 'Save'.

The new project contains the basic skeleton files of a Komodo extension, including a simple overlay and all of the required meta-data files like chrome.manifest and install.rdf. You can 'build' / package the extension up by running the 'Build' macro in the 'Project' folder. You can then install the extension into Komodo just by dragging the xpi file that is created onto the Komodo application window.

--
JeffG
http://www.openkomodo.com/blogs/jeffg

Dave_DLGreene | Fri, 2008-10-03 10:10

I have done the "Project from Template" thing... Unfortunatly there is too much in it and worse yet it fails in some of what it does. It does function but some key features don't work like loading a description looses the description somehow.

We don't really need to have much of a discussion about the matter but, all the if OS="win"(or whatever) puts a level of programming into the mix that makes the whole thing even more confusing. I realize that jars are just zips but in the sample app, for a beginner, I'm thinking "How can I do this stuff?" and in trying to decipher the sample it looks as though I have to do all sorts of "if OS=" stuff. Worse, even though I am aware that jars are just zips, in the sample there is the "if OS=" and there appears to be Java stuff so my immediate though is that I can't really do any of this without learning Java. I don't think that's true but, the sample app gives that appearance.

Further there is too much in the sample that is "a level above". Meaning that it would appear that some of the design is for actually installing the sample into the menu. When first trying to decipher what's happening that level is just too confusing.

Trying to desipher what needs to be in Python and what needs to be in Javascript is really baffeling at first. I'm beginning to figure out the difference but, it's not real clear from most of the samples.

As a separate note:
If you have any influence over the KomodoJavaScript...
IT'S A BONE HEAD MISTAKE THAT KOMODOJAVASCIPT CAN'T READ AND WRITE XML NATIVELY!!!!!

Not only read and write it but effectivly and easily use xslt AND XSD!! I know that schema is the one that is always either frowned upon or feared, but a "good" xml setup has THREE LEGS, xml, xslt, AND XSD.

jeffg | Fri, 2008-10-03 10:45

A few of comments that will hopefully clarify some of your confusion:

a) You don't need to write any Java, the only language necessary to get going is JavaScript, for which there is a substantial API under ko.*. Just to be clear again, there is *no* Java anywhere in Komodo.

b) You should not have to do a lot of OS-specific code when creating an extension, unless you are integrating Komodo directly with OS-specific services. I'm not sure what example you were looking at? Most of my code that has to deal with example file paths and deleting files uses the koIOs interface which is actually just a Mozilla wrapper around the Python os module:

var os = Components.classes['@activestate.com/koOs;1'].
  getService(Components.interfaces.koIOs);

if (os.path.exists('filename.txt')) {
// etc.
}

var os = Components.classes['@activestate.com/koOs;1'].
  getService(Components.interfaces.koIOs);

if (os.path.exists('filename.txt')) {
// etc.
}

c) In Komodo we overwhelmingly run screaming to the Python Elementtree module for dealing with Xml instead of other methods, but this is all on the Python side. On the JavaScript side you have the DOM. The JavaScript interpreter in Komodo is the same as Firefox, for better or for worse.

--
JeffG
http://www.openkomodo.com/blogs/jeffg