Components panel API functions

 < Day Day Up > 

This section describes the API functions for populating the Components panel.

getComponentChildren()

Availability

Dreamweaver MX.

Description

This function returns a list of child ComponentRec objects for the active parent ComponentRec object. To load the root-level tree items, this function needs to read its metadata from its persistent store.

Arguments

 {parentComponentRec} 

  • The parentComponentRec argument is the componentRec object of the parent. If it is omitted, Dreamweaver expects a list of ComponentRec objects for the root node.

Returns

An array of ComponentRec objects.

Example

See function getComponentChildren(componentRec) in the WebServices.js file in the Configuration/Components/Common/WebServices folder.

getContextMenuId()

Availability

Dreamweaver MX.

Description

Returns the Context Menu ID for the component type. Every component type can have a context menu associated with it. The Context Menu pop-up menus are defined in the ComponentNameMenus.xml file, and they work the same way as the menu.xml file. The menu string can be static or dynamic. Shortcut keys (accelerator keys) are supported.

Arguments

None.

Returns

A string defining the Context Menu ID.

Example

The following example sets the menu options for the Components panel for web services associated with the ASP.NET/C# server model and defines the shortcut keys for that menu:

 function getContextMenuId() {   return "DWWebServicesContext"; } 

Where DWWebServicesContext is defined in the file in the Configuration/Components/ASP.NET_CSharp/WebServices/WebServicesMenus.xml as follows:

<shortcutlist > <shortcut key="Del" domRequired="false" enabled="(dw.serverComponentsPalette .getSelectedNode() != null && (dw.serverComponentsPalette.getSelectedNode() .objectType=='Root'))" command="clickedDelete();" /> </shortcutlist> <menubar name="" > <menu name="Server Component Popup" > <menuitem name="Edit Web Service" domRequired="false" enabled="dw .serverComponentsPalette.getSelectedNode() != null && (dw.serverComponentsPalette .getSelectedNode().objectType=='Root') && dw.serverComponentsPalette.getSelectedNode() .wsRec != null && dw.serverComponentsPalette.getSelectedNode().wsRec.ProxyGeneratorName != null" command="editWebService()" /> ... </menubar>

getCodeViewDropCode()

Availability

Dreamweaver MX.

Description

This function gets the code that is dragged and dropped in Code view from the Components panel or the code that is cut, copied, or pasted from the Components panel.

Arguments

 componentRec 

  • The componentRec argument is an object.

Returns

The string that contains the code for the component.

Example

The following example identifies the code for a common web service:

 function getCodeViewDropCode(componentRec) {   var codeToDrop="";   if (componentRec)   {     if (componentRec.objectType=="Class")     {       codeToDrop = dw.getExtDataValue("webservices_constructor","insertText");       codeToDrop = codeToDrop.replace(RegExp("@@Id@@","g"),componentRec.name);       codeToDrop = codeToDrop.replace(RegExp("@@Class@@","g"),componentRec.name);     }     else if (componentRec.objectType=="Method")     {       codeToDrop = componentRec.dropCode;     }     if(componentRec.dropCode)     {       codeToDrop = componentRec.dropCode;     }     else     {       codeToDrop = componentRec.name;     }   }   return codeToDrop; } 

getSetupSteps()

Availability

Dreamweaver MX.

Description

Dreamweaver calls this function if the setupStepsCompleted() function returns zero or a positive integer. This function controls the server-side setup instructions, which can be implemented using extensions that use a modal dialog box and extensions that use server components.

This function returns an array of the strings for Dreamweaver to display in either the Setup Steps dialog box or the Components panel, depending on the extension type.

Arguments

None.

Returns

An array of n+1 strings, where n is the number of steps, as described in the following list:

  • The title that appears above the list of setup steps

  • For each step, the text instructions, which can include any HTML markup that is legal inside a li tag

You can include hypertext links (a tags) in the list of steps by using the following form:

 <a href="#" onMouseDown="handler">Blue Underlined Text</a> 

The "handler" value can be replaced by any of the following strings or any JavaScript expression, such as "dw.browseDocument('http://www.macromedia.com')":

  • An "Event:SetCurSite" handler opens a dialog box to set the current site.

  • An "Event:CreateSite" handler opens a dialog box to create a new site.

  • An "Event:SetDocType" handler opens a dialog box to change the document type of the user's document.

  • An "Event:CreateConnection" handler opens a dialog box to create a new database connection.

  • An "Event:SetRDSPassword" handler opens a dialog box to set the Remote Development Service (RDS) user name and password (ColdFusion only).

  • An "Event:CreateCFDataSource" handler opens the ColdFusion administrator in a browser.

Example

The following example sets four steps for ColdFusion components, and provides a hypertext link in the fourth step so the user can enter the RDS user name and password:

 function getSetupSteps() {   var doSDK = false;   dom = dw.getDocumentDOM();   if (dom && dom.serverModel)   {     var aServerModelName = dom.serverModel.getDisplayName();   }   else   {     var aServerModelName = site.getServerDisplayNameForSite();   }   if (aServerModelName.length)   {     if(aServerModelName != "ColdFusion")     {       if(needsSDKInstalled != null)       {         doSDK = needsSDKInstalled();       }     }   }   var someSteps = new Array();   someSteps.push(MM.MSG_WebService_InstructionsTitle);   someSteps.push(MM.MSG_Dynamic_InstructionsStep1);   someSteps.push(MM.MSG_Dynamic_InstructionsStep2);   if(doSDK == true)   {     someSteps.push(MM.MSG_WebService_InstructionsStep3);   }   someSteps.push(MM.MSG_WebService_InstructionsStep4);   return someSteps; } 

setupStepsCompleted()

Availability

Dreamweaver MX.

Description

Dreamweaver calls this function before the Components tab appears. Dreamweaver then calls the getSetupSteps() function if the setupStepsCompleted() function returns zero or a positive integer.

Arguments

None.

Returns

An integer that represents the number of setup steps the user has completed, as described in the following list:

  • A value of either zero or a positive integer indicates the number of completed steps.

  • A value of -1 indicates that all the necessary steps are complete, so the instruction list does not appear.

handleDesignViewDrop()

Availability

Dreamweaver MX.

Description

Handles the drop operation when the user drags a table or view from the Database panel or a component from the Components panel to the Design view.

Arguments

 componentRec 

  • The componentRec argument is an object that contains the following properties:

    • The name property is the name of the tree node item.

    • The image property is an optional icon for the tree node item. If omitted, Dreamweaver MX uses a default icon.

    • The hasChildren property is a Boolean value that indicates whether the tree node item is expandable: if TRue, Dreamweaver MX displays the Plus (+) and Minus (-) buttons for the tree node item; if false, the item is not expandable.

    • The toolTipText property is optional tool tip text for the tree node item.

    • The isCodeViewDraggable property is a Boolean value that indicates whether the tree node item can be dragged and dropped into the Code view.

    • The isDesignViewDraggable property is a Boolean value that indicates whether the tree node item can be dragged and dropped into the Design view.

Returns

A Boolean value that indicates whether the drop operation was successful: true if successful; false otherwise.

Example

The following example determines if the component is a table or view, and then returns the appropriate bHandled value:

 function handleDesignViewDrop(componentRec) {   var bHandled = false;   if (componentRec)   {     if ((componentRec.objectType == "Table")||         (componentRec.objectType == "View"))     {       alert("popup Recordset Server Behavior");       bHandled = true;     }   }   return bHandled; } 

handleDoubleClick()

Availability

Dreamweaver MX.

Description

When the user double-clicks the node in the tree, the event handler is called to allow editing. This function is optional. The function can return a false value, which indicates that the event handler is not defined. In this case, double-clicking causes the default behavior, which expands or collapses the tree nodes.

Arguments

 componentRec 

  • The componentRec argument is an object that contains the following properties:

    • The name property is the name of the tree node item.

    • The image property is an optional icon for the tree node item. If this icon is omitted, Dreamweaver uses a default icon.

    • The hasChildren property is a Boolean value that indicates whether the tree node item is expandable: if true, Dreamweaver displays the Plus (+) and Minus (-) buttons for the tree node item; if false, the item is not expandable.

    • The toolTipText property is an optional tooltip text for the tree node item.

    • The isCodeViewDraggable property is a Boolean value that indicates whether the tree node item can be dragged and dropped into Code view.

    • The isDesignViewDraggable property is a Boolean value that indicates whether the tree node item can be dragged and dropped into Design view.

Returns

Nothing.

Example

In the following example, the extension has a chance to handle a double-click on the tree node item; if it returns the value false, the default behavior is to expand/collapse the nodes.

 function handleDoubleClick(componentRec) {   var selectedObj = dw.serverComponentsPalette.getSelectedNode();   if(dwscripts.IS_WIN)   {     if (selectedObj && selectedObj.wsRec && selectedObj.wsRec[ProxyGeneratorNamePropName])     {       if (selectedObj.objectType == "Root")       {         editWebService();          return true;       }       else if (selectedObj.objectType == "MissingProxyGen")       {         displayMissingProxyGenMessage(componentRec);         editWebService();         return true;       }     }   }   return false; } 

toolbarControls()

Availability

Dreamweaver MX.

Description

Every component type returns a list of toolBarButtonRec objects, which represents the toolbar icons, in left-to-right order. Each toolBarButtonRec object contains the following properties:

Property Name

Description

image

Path to image file

disabledImage

Optional; path to disabled image searches for the toolbar button

pressedImage

Optional; path to pressed image searches for the toolbar button

toolTipText

Tooltip for the toolbar button

toolStyle

Left /right

enabled

JavaScript code that returns a Boolean value (TRue or false). The enablers are called when the following conditions exist:

  • When the dreamweaver.serverComponents.refresh() function is called

  • When the selection in the tree changes

  • When server model changes

command

The JavaScript code to execute. The command handler can force a refresh using the dreamweaver.serverComponents.refresh() function.

menuId

The unique menu ID for the pop-up menu button when the button is clicked. When this ID is present, it overrides the command handler. In other words, the button can be either a button associated with a command, or a button that has a pop-up menu associated with it, but not both at the same time.


Arguments

None.

Returns

An array of toolbar buttons in left-to-right order.

Example

The following example assigns properties to the toolbar buttons:

function toolbarControls() { var toolBarBtnArray = new Array(); dom = dw.getDocumentDOM(); var plusButton = new ToolbarControlRec(); var aServerModelName = null; if (dom && dom.serverModel) { aServerModelName = dom.serverModel.getDisplayName(); } else { //look in the site for potential server model aServerModelName = site.getServerDisplayNameForSite(); } if (aServerModelName.length) { if(aServerModelName == "ColdFusion") { plusButton.image= PLUS_BUTTON_UP; plusButton.pressedImage= PLUS_BUTTON_DOWN; plusButton.disabledImage= PLUS_BUTTON_UP; plusButton.toolStyle= "left"; plusButton.toolTipText= MM.MSG_WebServicesAddToolTipText; plusButton.enabled= "dwscripts.IS_WIN"; plusButton.command= "invokeWebService()"; } else { plusButton.image= PLUSDROPBUTTONUP; plusButton.pressedImage= PLUSDROPBUTTONDOWN; plusButton.disabledImage= PLUSDROPBUTTONUP; plusButton.toolStyle= "left"; plusButton.toolTipText= MM.MSG_WebServicesAddToolTipText; plusButton.enabled= "dwscripts.IS_WIN"; plusButton.menuId = "DWWebServicesChoosersContext"; } toolBarBtnArray.push(plusButton); var minusButton = new ToolbarControlRec(); minusButton.image= MINUSBUTTONUP; minusButton.pressedImage= MINUSBUTTONDOWN; minusButton.disabledImage= MINUSBUTTONDISABLED; minusButton.toolStyle= "left"; minusButton.toolTipText= MM.MSG_WebServicesDeleteToolTipText; minusButton.command = "clickedDelete()"; minusButton.enabled = "(dw.serverComponentsPalette.getSelectedNode() != null && dw .serverComponentsPalette.getSelectedNode() && ((dw.serverComponentsPalette.getSelectedNode ().objectType=='Root') || (dw.serverComponentsPalette.getSelectedNode().objectType == 'Error') || (dw.serverComponentsPalette.getSelectedNode().objectType == 'MissingProxyGen')))"; toolBarBtnArray.push(minusButton); if(aServerModelName != null && aServerModelName.indexOf(".NET") >= 0) { var deployWServiceButton = new ToolbarControlRec(); deployWServiceButton.image= DEPLOYSUPPORTBUTTONUP; deployWServiceButton.pressedImage= DEPLOYSUPPORTBUTTONDOWN; deployWServiceButton.disabledImage= DEPLOYSUPPORTBUTTONUP; deployWServiceButton.toolStyle= "right"; deployWServiceButton.toolTipText= MM.MSG_WebServicesDeployToolTipText; deployWServiceButton.command = "site.showTestingServerBinDeployDialog()"; deployWServiceButton.enabled = true; toolBarBtnArray.push(deployWServiceButton); } //add the rebuild proxy button for windows only. //bug 45552: if(navigator.platform.charAt(0) !="M") { var proxyButton = new ToolbarControlRec(); proxyButton.image= PROXYBUTTONUP; proxyButton.pressedImage= PROXYBUTTONDOWN; proxyButton.disabledImage= PROXYBUTTONDISABLED; proxyButton.toolStyle= "right"; proxyButton.toolTipText= MM.MSG_WebServicesRegenToolTipText; proxyButton.command = "reGenerateProxy()"; proxyButton.enabled = "enableRegenerateProxyButton()"; toolBarBtnArray.push(proxyButton); } } return toolBarBtnArray; }

     < Day Day Up > 


    Developing Extensions for Macromedia Dreamweaver 8
    Developing Extensions for Macromedia Dreamweaver 8
    ISBN: 0321395409
    EAN: 2147483647
    Year: 2005
    Pages: 282

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net