25 posts
Showing 20
| Next
(page 1 of 2)
Undocumented Dreamweaver: Getting Dreamweaver's Menu as a Collection of TreeNodes
Posted Sunday, September 12, 2004 8:37:05 AM by 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
Posted by Paul R. Boon
Add comment |
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: Getting Snippets as a Collection of TreeNodes
Posted Sunday, September 12, 2004 8:29:14 AM by 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
Posted by Paul R. Boon
Add comment |
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: A Completely Pointless API Call
Posted Sunday, September 12, 2004 6:55:36 AM by 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
Posted by Paul R. Boon
Add comment |
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: Getting the Path of the Menus.xml file
Posted Sunday, September 12, 2004 6:26:52 AM by 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
Posted by Paul R. Boon
Add comment |
View comments (2) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: Changing the Cursor During Time Consuming Code
Posted Saturday, September 11, 2004 6:21:40 PM by Paul R. Boon
During development it may be necessary to write a function or piece of code that takes awhile to execute. It is our responsibility as the developer to let the user know that the code is doing something.
An easy way to do this is to change the cursor (mouse pointer) from its default to the egg timer. This gives the user a visual indication that the code is doing something. When the piece of code has finished executing, you then change the cursor back to the default pointer.
We can do this in an extension using the undocumented API calls MM.setBusyCursor() and MM.clearBusyCursor().
Example of use:
function timeConsumingCode(){
MM.setBusyCursor();
// time consuming code working out result goes here;
MM.clearBusyCursor();
return result;
}
In the above function as the function timeConsumingCode() is executed first the cursor is changed to the egg timer using MM.setBusyCursor() then the time consuming code (what ever that may be) is executed then just before the function returns its result the cursor is set back using MM.clearBusyCursor().
Category tags: Dreamweaver, Extensibility
Posted by Paul R. Boon
Add comment |
View comments (3) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: Determining the Location of the All User Configuration Folder
Posted Saturday, September 11, 2004 3:33:46 PM by Paul R. Boon
I get asked a lot how to determine the path to Dreamweaver's All user configuration folder. So i have decided to pass on this information, well at least to developers developing extensions for the MS Windows platform.
To do this we need to use an undocumented API call for working with the Windows Registry.
This call is MM.getRegValue(), and is a child method of the global scope MM Object, this call is exposed via the MM.dll located within the Configuration/jsExtensions folder. Infact this call is part of a 2 call set and has a sister call MM.setRegValue(). These calls are used to read (get) and write (set) values to Registry Keys.
The trick to using these calls is knowing what hive, keys and data/value pairs you need to access to get to the information you might need.
So as this blog is about finding out what the path to Dreamweaver's all user configration folder we need to access the hive, key and value/data pair holding this information.
First we use dw.regGetValue() to get the value of the Common Application Data path, then we simple add the remaining fixed path that would point us to Dreamweaver's All User configuration folder.
Below is a function getAllUserConfiguration that returns the path or URL of the All User configuration folder on a Windows machine.
function getAllUserConfiguration(path){
path=(path)?path:false;
var theHive= 'HKEY_LOCAL_MACHINE';
var theKey = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders';
var theValueData='Common AppData';
var appDataPath=MM.regGetValue(theHive,theKey,theValueData);
var aUC= appDataPath+'\\Macromedia\\Dreamweaver MX 2004\\Configuration';
if(path){
return aUC;
}else{
return MMNotes.filePathToLocalURL(aUC);
}
}
Example of use:
To return the File URL of the 'All User' configuration we would simple use the following.
var allUserConfigURL = getAllUserConfiguration();
to return the File Path we would pass in the optional true parameter.
var allUserConfigPath = getAllUserConfiguration(true);
Category tags: Dreamweaver, Extensibility
Posted by Paul R. Boon
Add comment |
View comments (2) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: Closing Documents
Posted Saturday, September 11, 2004 7:35:11 AM by Paul R. Boon
I was looking through the Extending Dreamweaver PDF file and the DW API PDF file and I could not believe that dw.closeAll() dw.closeOtherFiles() are not listed. In fact, I had to double check, then triple check. Why these calls are not listed, I have no idea.
Still, for those of you who do not know what they do, here is a very brief explanation.
dw.closeAll()
Closes all open files/documents.
Example of use:
dw.closeAll()
dw.closeOtherFiles()
When more than one file is open in Dreamweaver, this call can be used to close all files except the currently selected or active document.
Example of use:
dw.closeOtherFiles()
Category tags: Dreamweaver, Extensibility
Posted by Paul R. Boon
Add comment |
View comments (1) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: Discovering the Server Language, Name or Model
Posted Tuesday, September 07, 2004 1:47:49 PM by Paul R. Boon
When writing Server Behaviors, Components, or Server Model related extensions, you might need to find out what server language or model Dreamweaver thinks the current active document is related to or which Server Model-related folder Dreamweaver needs to use.
This may be especially necessary if your behavior uses a central JS lib or class file that is linked into any extensions' core files from within Dreamweaver's Shared Folder.
Thankfully, there are three handy undocumented calls that can help the developer out.
getServerLanguageFromDoc()
getServerLanguageFromDoc returns the Server Language associated with a document type.
Example of use:
var dom=dw.getDocumentDOM();
var sLang=dom.getServerLanguageFromDoc();
In the above example, the sLang variable will contain 'CFML' for .cfm documents.
getServerNameFromDoc()
getServerNameFromDoc() returns the English or label name for the server language associated with a document type.
var dom=dw.getDocumentDOM();
var sName=dom.getServerNameFromDoc();
In the above example, the sName variable would contain 'Cold Fusion' for .cfm documents.
getServerModelFolderNameFromDoc()
getServerModelFolderNameFromDoc() returns the name of the child folder that the Server Model's extensions are contained within. This is a child folder of the Configuration/Server Model folder.
var dom=dw.getDocumentDOM();
var sModel=dom.getServerModelFolderNameFromDoc();
The variable sModel would contain the value 'ColdFusion' for .cfm documents.
Category tags: Dreamweaver, Extensibility
Posted by Paul R. Boon
Add comment |
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: Working With External Applications and Processes
Posted Tuesday, September 07, 2004 7:43:05 AM by Paul R. Boon
One of the questions i get asked and which also appears in the newsgroups, is how a developer can write an extension that calls an external application, batch file or process.
dw.openWithApp()
Dreamweaver has a documented way of working with external applications with the API call dw.openWithApp(fileURL, appURL). Whilst this call is handy when passing a file to another application, for example passing the current active document to notepad.exe. it falls short in allowing a developer to call an external application that requires passed in attributes and handling the output or location handling of the external application (similar to windows desktop shortcuts).
Example of passing in the current active document to notepad.exe:
dw.openWithApp(dw.getDocumentDOM().URL,'notepad.exe')
To simply run an external application, without passing it a file to work with, you can in most cases use dw.openWithApp() by passing in a blank or empty string as the fileURL
Example of simply opening notepad.exe:
dw.openWithApp("",'notepad.exe')
When more complex situations arise, dw.openWithApp() just does not cut it. Luckily Dreamweaver's has a number of undocumented calls that allow more complex operations to take place.
DWfile.runCommandLine() & MM.runCommandLine()
First we will deal with the simply way of calling an external batch file or executable.
DWfile.runCommandLine() & MM.runCommandLine() accept a single parameter that is the path to the external process to run, in most cases this is a batch file or executable.
Example of use:
DWfile.runCommandLine('c:\myFolder\MyBatchFile.bat');
or
MM.runCommandLine('c:\myFolder\MyBatchFile.bat');
However whilst this works fine it does open up a Command prompt window (small dos window) whilst the executable is running.
MM.shellExecute()
MM.shellExecute() is a slightly more complex way of calling an executable and it allows arguments to be passed to the external application.
Example of use:
MM.shellExecute(appPath, arguments, runDir)
| appPath: | The path (not URL) to the executable. |
| arguments: Optional |
The arguments passed to executable. |
| runDirectory: Optional |
The folder that contains the original item or some related files. Sometimes, programs need to use files from other locations. You might need to specify the folder where these files are located so that the program can find them. |
MM.createProcess()
MM.createProcess() is probably the most useful and also the most powerful way of dealing with the need to have greater control over the external application or process you need to call. Personally i use this method when dealing with external applications, batch files and processes.
Example of use:
MM.createProcess(executable, arguments, timeout, createNoWindow, runDir, outputFile)
| executable: | String, The path (not URL) to the executable. |
| arguments: Optional |
String, The arguments passed to executable. |
| timeout: optional |
-1 Does not timeout, Dreamweaver/extension code waits for application/process to finish before completing the operation. 1 Dreamweaver carries on regardless. |
| createNoWindow: optional |
Boolean, true Dreamweaver does not show the application window during it's execution, false application window is shown during it's execution. |
| runDirectory: Optional |
The folder that contains the original item or some related files. Sometimes, programs need to use files from other locations. You might need to specify the folder where these files are located so that the program can find them. |
| outputFile Path: optional |
The directory used to write out the output from the executable, if the process would write out a result to the command prompt/screen normally this output would be written back to the path specified. |
Note: All paths used are actual file paths and not file URL's for all the above undocumented calls where a path is used.
so use 'c:\folder\executable.exe' and not 'file:///c|/folder/executable.exe'.
Category tags: Dreamweaver, Extensibility
Posted by Paul R. Boon
Add comment |
View comments (6) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: Finding Out what Document Type you are dealing with.
Posted Tuesday, September 07, 2004 5:19:12 AM by Paul R. Boon
The majority of extensions deal with manipulating a document in someway. Knowing what the type of document the user is currently editing becomes a small but important part of writing these type of extensions.
Now whilst this might seem an easy thing to work out, after all you simply look at the files extension and you can tell if its a CSS document, an html document or a PHP document etc.
Well this may be true, but what if the document has not been saved?
What document type does Dreamweaver think it is, and how do we find this out? Ah, i hear people saying, the simple answer is to get the user to save the document first, then we can check the file extension after the save has happened.
Yes, this is a solution, but it is not how i like to do things. Personally i only want the user to get involved when there is a real need for the user to make a decision. If the code can be written to handle a situation without the need for user input, then that's preferable.
So how can we determine the document type without checking the file extension, we simply use an undocumented static property of the Document Object called documentType.
Example of use:
var dom = dw.getDocumentDOM();
var thisDocType = dom.documentType;
So in the above example the thisDocType variable holds the value of the static property, and the values of the property match the id attribute of the matching document type defined in Dreamweaver's MMDocumentTypes.xml file, located in the Configuration/DocumentTypes folder.
Note: This also works on unsaved documents.
Example of the types of values stored for the corresponding document type.
| Documents of Type | documentType Property Value |
| HTML | HTML |
| JavaScript | JavaScript |
| ASP JavaScript | ASP-JS |
| ASP VBScript | ASP-VB |
| ColdFusion | ColdFusion |
| ColdFusion CFC | CFC |
| JSP | JSP |
| ASP.NET VB | ASP.NET_VB |
| ASP.NET C# | ASP.NET_CSharp |
| PHP MySQL | PHP_MySQL |
| CSS | CSS |
| XML | XML |
| ActionScript | Actionscript |
Note: for a full list see the MMDocumentTypes.xml file located in DW Install Path configuration/DocumentTypes folder.
Category tags: Dreamweaver, Extensibility
Posted by Paul R. Boon
Add comment |
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: Saving a Copy of a DOM
Posted Monday, September 06, 2004 7:24:26 PM by Paul R. Boon
For extension developers it can be a hassle when working with some DW API calls because they popup a dialog by default, a good example of this is dw.saveDocumentAs().
For example you might write an extension to insert code or manipulate the documents dom. You want to save a copy of the document before applying the changes. Now using dw.saveDocumentAs() is out of the question because you don't want the user to choose the location/filename of the file, as you want the extension to work silently in the background when making the backup.
Normally the solution would be to grab the contents of the dom and write this out to a file using DWfile.write() and whilst this is only a couple of lines of code, there is an easier way of handling this situation.
Example using DWfile.write():
var dom = dw.getDocumentDOM();
var path='dw.getConfigurationPath()+'/backup.htm';
var docContents = dom.documentElement.outerHTML;
DWfile.write(path,docContents);
The easier way comes thanks to the undocumented call saveCopyAs(path), this is a child method of the Document Object, so once again we need a reference to the documents DOM.
Example of Use:
var dom=dw.getDocumentDOM();
var path='dw.getConfigurationPath()+'/backup.htm';
dom.saveCopyAs(path)
Category tags: Dreamweaver, Extensibility
Posted by Paul R. Boon
Add comment |
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: Programmatically Calling a Toolbar Item
Posted Monday, September 06, 2004 3:23:38 PM by Paul R. Boon
Following on from my blog entry titled Programmatically calling a Menu item, i thought i would pass on another little gem for calling other DW extension types programmatically.
This time as i am sure you can guess we are dealing with toolbar items.
First if you have not already read the blog about calling Menu Items programmatically, i would advise reading it then coming back and reading this blog, mainly so i don't have to re-type the intro about dw.runCommand() :-).
Ok, Ok, i admit it, i am lazy, but name me a programmer who does not reuse code.
Anyway the method to call a Toolbar Item programmatically is a child method of the Document Object, so as normal first we get a reference to a DOM, then we use the undocumented call activateToolbarItem('toolbarID','ToolbarITemID').
Example of use:
var dom=dw.getDocumentDOM();
dom.activateToolbarItem("DW_Toolbar_Main","DW_CodeView");
The example above simulates the user clicking on the 'Code' toolbar item of the main Document Toolbar (the button that puts Dreamweaver into code view). As with calling a menu item, for this method to work you must first make sure that the toolbars items enabler would return true, that is the toolbar item could be clicked by the user during normal operation.
Category tags: Dreamweaver, Extensibility
Posted by Paul R. Boon
Add comment |
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: Finding Out the File Extensions DW Supports
Posted Monday, September 06, 2004 6:49:46 AM by Paul R. Boon
You may have seen the message 'Can't find a valid editor for this file extension' whilst using Dreamweaver. All files Dreamweaver can edit are listed in one of three places.
These being.
Extension.txt file: Located in the root of Dreamweaver's configuration folder.
This file contains a list of file extensions recognized by Dreamweaver.
Grouped into types, these groupings are used within Dreamweaver's file dialogs.
Document Types: Defined in the MMDocumentTypes.xml located in the Configuration/DocumentTypes folder. This contains a list of defined document types that Dreamweaver can create and is linked to a default document for each type held within the Configuration/DocumentTypes/NewDocuments Folder.
Editor Preferences: Accessible from the 'Edit' > 'Preferences' > 'File Types/ Editor' option. This is used to set external editors to a file extension, informing Dreamweaver of the editor (external application) that a file type should be open or passed to for editing.
I have sometimes needed to know what file extensions Dreamweaver can edit when writing an extension. This is particularly helpful when developing an extension that checks file extensions during a function that manipulates large collections of files.
Luckily an undocumented API call comes in handy for getting a list of file types that Dreamweaver understands, this is dw.getExtensionsList()
Example of use:
var fileExtensions=dw.getExtensionsList();
This call returns an array of file extensions Dreamweaver currently supports.
Example of the alerted return is below:
HTM,SHTM,SHTML,HTA,HTC,XHTML,STM,SSI,JS,AS,ASC,ASR,XML,
XSL,XSD,DTD,XSLT,RSS,RDF,LBI,DWT,ASP,ASA,ASPX,ASCX,ASMX, CONFIG,CS,CSS,CFM,CFML,CFC,TLD,TXT,PHP,PHP3,PHP4,PHP5,
TPL,LASSO,JSP,JSF,VB,VBS,VTM,VTML,INC,JAVA,EDML,WML,HTM,
HTA,HTC,XHTML,SHTM,SHTML,STM,SSI,INC,JS,XML,DTD,XSD,XSL,
XSLT,RSS,RDF,LBI,DWT,CSS,ASP,ASA,ASPX,ASCX,ASMX,CS,VB,
CONFIG,CFM,CFML,CFC,AS,ASC,ASR,TXT,PHP,PHP3,PHP4,PHP5,
TPL,LASSO,JSP,JST,JSF,TLD,JAVA,WML,EDML,VBS,VTM,VTML,MXI
The list of supported file extension will change between different installs, so this is the list my installation of Dreamweaver understands as i have extended my copy of Dreamweaver to understand some new file extensions and document types.
Category tags: Dreamweaver, Extensibility
Posted by Paul R. Boon
Add comment |
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: Programmatically calling a Menu item
Posted Wednesday, September 01, 2004 1:24:22 PM by Paul R. Boon
Most extensions developers sooner or later come to realize that one of the most usefully API calls available to them is the call dw.runCommand(), this handy call allows a developer to call or launch an other extension (of type command). This is especially handy when your primary extension needs to utilize a second dialog for handling settings or for utilizing functionality found or already developed in another extension.
Example of using dw.runCommand()
dw.runCommand('AlertDS.htm')
the single parameter used in the above example is the name of the Command extension we want to run/call that is located in Dreamweaver's Configuration/Command folder, in the case the AlertDS.htm file.
The method can also handle having other parameters passed in, and these parameters are then passed to the called Command extension as its received arguments.
Example of use:
dw.runCommand('myCommand.htm','Please press the cancel button',true);
In the above example the Command the myCommand.htm file is called/run and the string 'please press the cancel button' and the boolean true are then passed into the command as arguments, these can then be accessed/processed in the command receiveArguments() method.
Note: before dw.runCommand() was introduced another call could be used that did the same thing, this is the call dw.popupCommand() however this call was depreciated in DW3 and whilst it still exists in Dreamweaver's API in MX and MX2004 you should always use dw.runCommand() as technically dw.popupCommand() could be removed from future versions of the API.
So far i have only mentioned Documented API calls.
dw.runCommand() as mentioned is used to run/call another extension of type Command, Dreamweaver's API also has an undocumented API to programmatically run a command associated with an entry in Dreamweaver's menu System.
Dreamweaver's Menu system is created from an XML file called Menus.xml located in the Configuration/Menus folder. All menus in Dreamweaver are defined in this file, using a combination of menubar, menu, menuitem, and separator tags.
Example of menu.xml contents:
<menubar name="" id=myMenuBar">
<menu name="My Menu" id="myUniqueMenuID">
<menuitem name="My Menu Item "
enabled="true" command="executeThisCall()"
id="myCommandID" />
</menu>
</menubar>
As you can see in the example above the menu tag has a child menutag this menuitem tag has four attributes name, enabled,command and id. Whilst there are more attributes that can be used, for this discussion we are really only interested in the menuitem tags ID attribute. All menuitems, menus and menu tags should have a unique ID attribute, that is the value of the ID attribute should be different for every tag.
Because every menuitem has or should have a unique ID, it is possible using an Undocumented API call to programmatically cause Dreamweaver to execute that menu item. This basically means that from code we can simulate a user selecting the item with there mouse.
To do this we would use dw.doMenuCommand('menuItemsUniqueId'); so for the menu listed in the above example we would use the following:
dw.doMenuCommand('myCommandID');
Note: to successfully call a menu command you also need to make sure the proper conditions exists that would allow that menu command to also be selected by the user normally. What this means is that the menu commands enabled attribute's value/js must return true or the menu command will not run.
Category tags: Dreamweaver, Extensibility
Posted by Paul R. Boon
Add comment |
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: Every Millisecond Counts
Posted Tuesday, August 31, 2004 11:46:50 AM by Paul R. Boon
When developing an extension you may need to know how long the user's machine has been running and thanks to a handy undocumented API, you can.
dw.getMilliseconds() returns the number of milliseconds since the start of the current OS session.
Example of use.
var sessionMill=dw.getMilliseconds()
Category tags: Dreamweaver, Extensibility
Posted by Paul R. Boon
Add comment |
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: getSelectorsDefinedInStylesheet
Posted Monday, August 30, 2004 3:59:17 AM by Paul R. Boon
A handy undocumented API call is available to those developers wanting to write extensions that deal with stylesheets.
getSelectorsDefinedInStylesheet('selector'), this API call is a child method of the Document Object, so once again a reference to a DOM is required.
getSelectorsDefinedInStylesheet('selector') does exactly as its name implies, it returns a array of selectors that match the type passed in as an attribute. The passed in attribute can be either 'class' or 'id'.
To get an array of the 'class' selectors we would use the following:
var dom=dw.getDocumentDOM();
var classSelectors = dom.getSelectorsDefinedInStylesheet('class');
To get an array of 'id' selectors we would use the following:
var dom=dw.getDocumentDOM();
var classSelectors = dom.getSelectorsDefinedInStylesheet('id');
Category tags: Dreamweaver, Extensibility
Posted by Paul R. Boon
Add comment |
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: Locating the systems temp folder
Posted Saturday, August 28, 2004 7:16:36 AM by Paul R. Boon
The documented API call dreamweaver.getTempFolderPath() returns a File URL to a temporary folder within Dreamweaver's configuration folder where you can store temporary or transient files. These are usually files that you may need during a session of Dreamweaver but are not needed across sessions.
I commonly use this location when one of my extensions needs to write out temporary data collected from other locations or when performing complex file system operations, as it is safe known place to move files during the current DW session.
Note: When using this folder you should treat it like the shared folder, by first creating your own child folder.
However you may require access to the operating systems own temp folder and luckily there is yet again an undocumented API call the comes to the aid of us extension developers.
getSystemTempFolder() This undocumented call is exposed by the DWfile File I/O Object and so to reference it we use DWfile.getSystemTempFolder();
Example of use:
var systemTempFolder = DWfile.getSystemTempFolder();
Note: This call returns an operating system file path and not a file URL like other path related API calls.
Category tags: Dreamweaver, Extensibility
Posted by Paul R. Boon
Add comment |
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: Dynamic toolbar attributes
Posted Friday, August 27, 2004 6:12:47 PM by Paul R. Boon
From the time Macromedia launched Dreamweaver and introduced the ability for everyday users to extend the product by developing extensions, one extension type was missing, the Toolbar extension. With the release of Dreamweaver MX, extension developers finally got the chance to customize Dreamweaver's toolbars.
Toolbar based extensions are extremely useful, each button or item on a toolbar can be used to launch a single feature/function or by the use of popup menus can be used as the launch point for a group of features/functions. They take up a small amount of screen real estate and allow functions/ features that otherwise might be berried within the menu system to be no more than a mouse click away.
When developing a toolbar item you can choose from eight different base item types, those being Button, Checkbutton, Radiobutton, Menubutton, Dropdown, Combobox, Editcontrol and Colorpicker.
The toolbar items are defined in an xml file called toolbars.xml. Each toolbar is deinfed using a Toolbar tag and toolbar items are defined as child tags, using one of the eight item types i mentioned before.
<toolbar id="DW_Toolbar_Main" label="Document">
<button id="MyButton"
command="alert('hello mum') "
enabled="true"
image="Shared/images/alert_on.gif"
disabledimage="Shared/alert_off.gif"
tooltip="hello mum."
update="onEveryIdle" />
</toolbar>
Whilst toolbars and toolbar items are easy to define, one of the main issues developers find is the lack of ability to dynamically change a toolbar item tags attributes at run time, and for those changes to be effective within the current active session.
Developers often ask if its possible to change a toolbar items defined image at runtime or want to change the tooltip that appears when the users mouse passes over a toolbar item.
Changes made to a toolbar items definition only take effect the next time Dreamweaver is restarted or after a forced reload of Dreamweaver's extensions, using the Dreamweaver.reloadExtensions() API call.
It would be nice to be able to change a toolbar items defined attributes and for the change to take effect on the fly, without doing a restart or using the dw.reloadExtensions() API call. Thanks to an undocumented API call this is possible.
The undocumented call is a child method of the Core Document Object and is called setToolbarItemAttribute();
To use this method we first either need to get a reference to the DOM of a document or to reference the DOM directly when using the method like so:
Example of changing the tooltip for the toolbar item defined above.
var dom=dw.getDocumentDOM();
dom.setToolbarItemAttribute('DW_Toolbar_Main', 'MyButton', 'tooltip', 'Boo');
As you can see from the example above the first argument is the unique id of the parent toolbar, followed by the unique id of the toolbar item we want to change. Then comes the attribute you want to change, in our case this is the tooltip attribute. The final argument is the new value to use.
Category tags: Dreamweaver, Extensibility
Posted by Paul R. Boon
Add comment |
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: Obtaining the current selected sites local root URL
Posted Friday, August 27, 2004 12:18:57 PM by Paul R. Boon
Following on from Danilo's blog on Locating a root folder for a specific site. There is another undocumented API call dw.getSiteConfigurationPath(). This API call returns a URL of the current selected site within Dreamweavers site panel.
Example of use:
var selectedSiteRoot =dw.getSiteConfigurationPath();
Note: This API call only returns the URL for the site currently selected within the Sites panel. If you need the URL of a site thats not the current selected site, you should follow the instructions here: Locating a root folder for a specific site
Category tags: Dreamweaver, Extensibility
Posted by Paul R. Boon
Add comment |
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
Undocumented Dreamweaver: getElementsByAttributeName
Posted Friday, August 27, 2004 8:47:09 AM by Paul R. Boon
Dreamweaver's DOM (Documeny Object Model) is made up of a subset of objects, properties, and methods from the World Wide Web Consortium (W3C) DOM Level 1 and some properties of the Microsoft Internet Explorer 4.0 DOM.
The most usefull methods available to extension developers are the methods used to return a custom collection of elements contained within a Document Object, such as getElementsByTagName().
However there is a another undocumented method for returning a custom collection of elements that is not part of W3C DOM standards or from Microsofts IE DOM, this being getElementsByAttributeName('passedInAttributeName').
This handy API call works in a similiar way to the getElementsByTagName() API call but as its name implies it returns a collection of elements that have the attibute passed in defined within thier markup.
Example Element Markup with a style attribute defined:
<div id="myDivOne" style="width:100px;height:200px" ></div>
So if we were looking to get all elements within a document that contained a defined style attribute we would use the following:
var elementsWithAStyleAttribute = dw.getDocumentDOM().getElementsByAttributeName('style');
or
var dom=dw.getDocumentDOM();
var elementsWithAStyleAttribute = dom.getElementsByAttributeName('style');
As this method is also an undocumented child method of the core Element Object you can also use this method to return a collection of elements that are child elements of another element, for example a Form element or Div based element.
For Example, to return all elements contained within the second Div element that have a style attribute defined we could use the following:
var dom = dw.getDocuentDOM();
var divElements=dom.getElementsByTagName('div');
var Div2=divElements[1];
var childElements=Div2.getElementsByAttribute('style');
Category tags: Dreamweaver, Extensibility
Posted by Paul R. Boon
Add comment |
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
25 posts
Showing 20
| Next
(page 1 of 2)
See Community MX content by Paul R. Boon


Blog RSS feed













