CMXtraneous

Right on the edge of useful

Undocumented Dreamweaver: Getting Dreamweaver's Menu as a Collection of TreeNodes

Posted Sunday, September 12, 2004 8:37:05 AM by Paul R. Boon

Paul R. Boon

Dreamweaver ships with a custom control called the treeControl, this control allows data to be displayed in a tree, similar to the tree of the File & Snippets panel.

To use this control within your extension interface you use a MM:treeControl tags and the elements of the tree are displayed using MM:treenode tags.

If you are working with Dreamweaver's menu system and want to display the contents of the menus.xml file within a treeControl. You could either walk the xml nodes of the menus.xml files DOM, dynamically produce the html required to represent the menus.xml DOM as a collection of treenode elements, then insert this into your treecontrol using the innerHTML property of the treeControl.

Alternativly you could use the undocumented call getMenuTree() that returns an Object that contains Dreamweaver's menu system as a collection of treenodes.

This call was originally developed to allow shortcut keys to be easily mapped to menu items when using the Edit > Keyboard Shortcuts... option.
Due to the amount of time it would take using Javascript to walk the menus.xml file to gather all the information required, DW Engineers wrote the getMenuTree() API in C++. However this does not stop us using the call to get the parts of the menus.xml file in other extensions.

The object returned by the call contains a child collection of nodes as an Array of Nodes, a names Object and a keys Object.

accessable by using returnedObject.nodes, returnedObject.names and returnedObject.keys

In the Example below which is a htm file that you can save in the Configuration/Commands folder, you see first the doc type tag telling Dreamweaver to render this htm file using the CSS for a DWExtension dialog.
Inside the head tag we have the script tag that contains the function that we want called as the document loads, in this case doOnLoad() function.

You will see that the getMenuTree() function requires a number of parameters with the first parameter being the path to the menus.xml file and to do this we are using the undocumented call dw.getMenuFile() I mentioned in a previous blog.

Also required is the tag name we are interested in, the menus.xml file contains the references to shortcut keys defined using shortcut tags and menus defined using menubar tags. As we are interested in Dreamweaver's menus we are using 'MENUBAR' as the second parameter.

For the third parameter we are passing in the unique ID of the particular MENUBAR tag we are interested in and this is the menubar that represent Dreamweaver's main menu, this being 'DWMainWindow'.

The last parameter tells the API call to ignore child menuitems id attributes, and in this example we are passing in false.

The body tag in the example has the onload Attribute set to call the doOnLoad() function, and contains as a child tag Dreamweaver's custom UI Treecontrol tag, this tag is used to render the captured menu structure as a clickable tree.

AS the doOnload function is called the variable menuTree is assigned the returned object that contains the collection of nodes for the part of Dreamweaver's menu we are interested in. Then the treecontrols innerHTML is assigned the nodes array using the line of code document.myTreeControl.innerHTML=menuTree.nodes

Example of use:

<!DOCTYPE HTML SYSTEM "-//Macromedia//DWExtension layout-engine 5.0//dialog">
<html>
<head>

<script>

function doOnLoad(){
var menuTree = dw.getMenuTree(dw.getMenuFile(),'MENUBAR','DWMainWindow',false);
document.myTreeControl.innerHTML=menuTree.nodes;
}

</script>

<title>dw.getMenuTree() Demo</title>
</head>

<body onLoad="doOnLoad()">

<form name="theForm">

<mm:treecontrol name= "myTreeControl" id="myTreeControl" style="width:380px; " size="12" noheaders>
</mm:treecontrol>

</form>

</body>
</html>

To see what the command does simply copy the above code into a .htm file and save it as getMenuTreeDemo.htm in the configuration/commands folder and then restart Dreamweaver. Once restarted you will see a getMenuTreeDemo option in Dreamweavers main Commands menu.

 

Category tags: Dreamweaver, Extensibility

Undocumented Dreamweaver: Getting Snippets as a Collection of TreeNodes

Posted Sunday, September 12, 2004 8:29:14 AM by Paul R. Boon

Paul R. Boon

Dreamweaver ships with a custom control called the treeControl, this control allows data to be displayed in a tree, similar to the tree of the File & Snippets panel.

To use this control within your extension interface you use a MM:treeControl tags and the elements of the tree are displayed using MM:treenode tags.

If you are working with snippets and want to display the snippets folder and its contents within a treeControl.

You could either walk the file structure of the snippets folder, dynamically produce the html required to represent the Snippets file system as a collection of treenode elements, then insert this into your treecontrol using the innerHTML property of the treeControl.

Alternativly you could use the undocumented call getSnippetsTree() that returns an Object that contains the snippets folder as a collection of treenodes.

This call was originally developed to allow shortcut keys to be easily mapped to snippets folder when using the Edit > Keyboard Shortcuts... option.
Due to the amount of time it would take using Javascript to walk the snippets folder and menus.xml file to gather all the information required, DW Engineers wrote the getSnippetsTree() API in C++. However this does not stop us using the call to get the Snippets folder structure in other extensions.

The object returned by the call contains a child collection of nodes as an Array of Nodes, a names Object and a keys Object.

accessable by using returnedObject.nodes, returnedObject.names and returnedObject.keys

In the Example below which is a htm file that you can save in the Configuration/Commands folder you see first the doc type tag telling Dreamweaver to render this htm file using the CSS for a DWExtension dialog.
Inside the head tag we have the script tag that contains the function that we want called as the document loads, in this case doOnLoad() function.

You will see that the getSnippetsTree() function requires a path to the menus.xml file and to do this we are using the undocumented call dw.getMenuFile() I mentioned in a previous blog. This is because as mentioned above, this call was originally developed for the edit shortcut keys command that ships with Dreamweaver and the menus.xml holds all Dreamweaver's keyboard shortcuts.

Although we pass in the parameter we are not interested in shortcut keys assigned to snippets, we are just interested in getting the snippets folder structure.

The body tag in the example has the onload Attribute set to call the doOnLoad() function, and contains as a child tag Dreamweaver's custom UI Treecontrol tag, this tag is used to render the captured snippets structure as a clickable tree.

AS the doOnload function is called the variable snippetTree is assigned the returned object that contains the collection of nodes. Then the treecontrols innerHTML is assigned the nodes array using the line of code document.myTreeControl.innerHTML=snippetTree.nodes

Example of use:

<!DOCTYPE HTML SYSTEM "-//Macromedia//DWExtension layout-engine 5.0//dialog">
<html>
<head>

<script>
function doOnLoad(){
var snippetTree = dw.getSnippetsTree(dw.getMenuFile());
document.myTreeControl.innerHTML=snippetTree.nodes;
}
</script>

<title>dw.getSnippetsTree() Demo</title>
</head>

<body onLoad="doOnLoad()">

<form name="theForm">

<mm:treecontrol name= "myTreeControl" id="myTreeControl" style="width:380px; " size="10" noheaders>
</mm:treecontrol>

</form>

</body>
</html>

To see what the command does simply copy the above code into a .htm file and save it as getSnippetsTreeDemo.htm in the configuration/commands folder and then restart Dreamweaver. Once restarted you will see a getSnippetsTreeDemo option in Dreamweavers main Commands menu.

 

Category tags: Dreamweaver, Extensibility

Undocumented Dreamweaver: A Completely Pointless API Call

Posted Sunday, September 12, 2004 6:55:36 AM by Paul R. Boon

Paul R. Boon

This is a bit of a did you know blog.

Did you know that, at some time during Dreamweaver's development, snippets were going to be defined in an xml file called index.xml, this file would probably have held the shortcut key definitions that can be assigned to snippets using the Edit > Keyboard Shorcuts.. command. This xml file was going to be stored in the root of the configuration/snippets folder. How do we know this was the case? The answer is simply that an undocumented API call dreamweaver.getSnippetsFile() returns a file url that points to this index.xml file.

Example of use:

var nonExistantSnippetsFile=dw.getSnippetsFile();

Note: Using this call is pointless as the snippets file does not exist

Category tags: Dreamweaver, Extensibility

Undocumented Dreamweaver: Getting the Path of the Menus.xml file

Posted Sunday, September 12, 2004 6:26:52 AM by Paul R. Boon

Paul R. Boon

Dreamweaver's menu system is defined using xml stored in the menus.xml file, this file can be located within the menus folder of Dreamweaver's Configuration folder.

An easy way to get the path to Dreamweaver's menus.xml file is to use the undocumented API call getMenuFile().

Example of use:

var menuXMLPath = dw.getMenuFile();

 

Category tags: Dreamweaver, Extensibility