Skip to content

Commit

Permalink
Making sure that the project is preserved.
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrence Ryan committed Nov 7, 2009
0 parents commit d71543d
Show file tree
Hide file tree
Showing 9 changed files with 293 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
12 changes: 12 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>BuilderTestCreator</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
<nature>com.adobe.ide.coldfusion.projectNature</nature>
</natures>
</projectDescription>
3 changes: 3 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Tue Sep 15 10:46:52 EDT 2009
eclipse.preferences.version=1
encoding/<project>=UTF-8
1 change: 1 addition & 0 deletions handlers/application.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<cfsetting showdebugoutput="false" enablecfoutputonly="FALSE" />
139 changes: 139 additions & 0 deletions handlers/createTestFile.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<cfset ideResults = manipulateIDEXML(form.ideeventInfo) />
<cffile action="write" file="#ideResults.fileLocation#" output="#ideResults.humanreadable#" />

<cfheader name="Content-Type" value="text/xml">
<response status="success" showresponse="true">
<ide >
<dialog width="600" height="400" />
<body>
<![CDATA[
<p>The following content was written to <cfoutput>#ideResults.fileLocation#</cfoutput><p>
<cfdump var="#ideResults.xmlObj#">
]]>
</body>
</ide>
</response>


<cffunction name="manipulateIDEXML" output="FALSE" access="public" returntype="struct" hint="" >
<cfargument name="XML" type="string" required="TRUE" hint="The formXML to manipulate" />

<cfset var results = StructNew() />
<cfset var xmldoc = XMLParse(arguments.XML) />
<cfset var folderPath = XMLSearch(xmldoc, "/event/user/input[@name='cfbtc_path']")[1].XMLAttributes.value />
<cfset var fileName = XMLSearch(xmldoc, "/event/user/input[@name='cfbtc_file']")[1].XMLAttributes.value />
<cfset var userAdditions = XMLSearch(xmldoc, "/event/user/input[@name='cfbtc_formsim']")[1].XMLAttributes.value />

<cfif listLen(userAdditions) gt 0>
<cfloop list="#userAdditions#" index="keyPair">
<cfset name = Trim(getToken(keypair,1,"=")) />
<cfset value = getToken(keypair,2,"=") />
<cfset node = XmlElemNew(xmldoc, "input") />
<cfset StructInsert(node.XmlAttributes, "name", name) />
<cfset StructInsert(node.XmlAttributes, "value", value) />

<cfset ArrayAppend(xmldoc.event.user.xmlChildren, node) />
</cfloop>
</cfif>

<cfset XmlDeleteNodesJava(xmldoc,XMLSearch(xmldoc, "/event/user/input[@name='cfbtc_path']") ) />
<cfset XmlDeleteNodesJava(xmldoc,XMLSearch(xmldoc, "/event/user/input[@name='cfbtc_file']") ) />
<cfset XmlDeleteNodesJava(xmldoc,XMLSearch(xmldoc, "/event/user/input[@name='cfbtc_formsim']") ) />

<cfset results.fileLocation = "#folderPath#/#fileName#" />
<cfset results.humanreadable = xmlHumanReadable(xmldoc) />
<cfset results.xmlObj = xmldoc />

<cfreturn results />
</cffunction>



<cfscript>
/**
* Formats an XML document for readability.
* update by Fabio Serra to CR code
*
* @param XmlDoc XML document. (Required)
* @return Returns a string.
* @author Steve Bryant (steve@bryantwebconsulting.com)
* @version 2, March 20, 2006
*/
function xmlHumanReadable(XmlDoc) {
var elem = "";
var result = "";
var tab = " ";
var att = "";
var i = 0;
var temp = "";
var cr = createObject("java","java.lang.System").getProperty("line.separator");
if ( isXmlDoc(XmlDoc) ) {
elem = XmlDoc.XmlRoot;//If this is an XML Document, use the root element
} else if ( IsXmlElem(XmlDoc) ) {
elem = XmlDoc;//If this is an XML Document, use it as-as
} else if ( NOT isXmlDoc(XmlDoc) ) {
XmlDoc = XmlParse(XmlDoc);//Otherwise, try to parse it as an XML string
elem = XmlDoc.XmlRoot;//Then use the root of the resulting document
}
//Now we are just working with an XML element
result = "<#elem.XmlName#";//start with the element name
if ( StructKeyExists(elem,"XmlAttributes") ) {//Add any attributes
for ( att in elem.XmlAttributes ) {
result = '#result# #att#="#XmlFormat(elem.XmlAttributes[att])#"';
}
}
if ( Len(elem.XmlText) OR (StructKeyExists(elem,"XmlChildren") AND ArrayLen(elem.XmlChildren)) ) {
result = "#result#>#cr#";//Add a carriage return for text/nested elements
if ( Len(Trim(elem.XmlText)) ) {//Add any text in this element
result = "#result##tab##XmlFormat(Trim(elem.XmlText))##cr#";
}
if ( StructKeyExists(elem,"XmlChildren") AND ArrayLen(elem.XmlChildren) ) {
for ( i=1; i lte ArrayLen(elem.XmlChildren); i=i+1 ) {
temp = Trim(XmlHumanReadable(elem.XmlChildren[i]));
temp = "#tab##ReplaceNoCase(trim(temp), cr, "#cr##tab#", "ALL")#";//indent
result = "#result##temp##cr#";
}//Add each nested-element (indented) by using recursive call
}
result = "#result#</#elem.XmlName#>";//Close element
} else {
result = "#result# />";//self-close if the element doesn't contain anything
}
return result;
}
</cfscript>


<!--- Code taken from Ben Nadel http://www.bennadel.com/blog/1236-Deleting-XML-Node-Arrays-From-A-ColdFusion-XML-Document.htm --->
<cffunction name="XmlDeleteNodesJava" access="public" returntype="void" output="false" hint="I remove a node or an array of nodes from the given XML document.">
<cfargument name="XmlDocument" type="any" required="true" hint="I am a ColdFusion XML document object." />
<cfargument name="Nodes" type="any" required="false" hint="I am the node or an array of nodes being removed from the given document." />

<cfset var LOCAL = StructNew() />

<cfif NOT IsArray( ARGUMENTS.Nodes )>
<cfset LOCAL.Node = ARGUMENTS.Nodes />
<cfset ARGUMENTS.Nodes = [ LOCAL.Node ] />
</cfif>


<!--- Loop over the nodes. --->
<cfloop index="LOCAL.Node" array="#ARGUMENTS.Nodes#">

<!--- Get the parent node. --->
<cfset LOCAL.ParentNode = LOCAL.Node.GetParentNode() />

<cfif StructKeyExists( LOCAL, "ParentNode" )>
<cfset LOCAL.PrevNode = LOCAL.Node.GetPreviousSibling() />

<cfif StructKeyExists( LOCAL, "PrevNode" )>
<cfset LOCAL.ParentNode.RemoveChild(LOCAL.PrevNode.GetNextSibling() ) />
<cfelse>
<cfset LOCAL.ParentNode.RemoveChild(LOCAL.ParentNode.GetFirstChild()) />
</cfif>
</cfif>

</cfloop>

</cffunction>
29 changes: 29 additions & 0 deletions handlers/pastecode.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<cfsavecontent variable="codeToPaste">

&lt;cfif not structKeyExists(form, "ideeventInfo")&gt;
&lt;cffile action="read" file="#ExpandPath('./sample.xml')#" variable="ideeventInfo" /&gt;
&lt;/cfif&gt;

</cfsavecontent>
<cfset codeToPaste = replaceList(codeToPaste, "&gt;,&lt;", ">,<") />

<cfheader name="Content-Type" value="text/xml">
<response showresponse="yes">
<ide >
<commands>
<command type="inserttext">
<params>
<param key="text">
<![CDATA[
<cfoutput>
#codeTopaste#
</cfoutput>
]]>
</param>
</params>

</command>

</commands>
</ide>
</response>
79 changes: 79 additions & 0 deletions ide_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<application>
<name>ColdFusion Builder Test Creator</name>
<author>Terry Ryan</author>
<version>1.0</version>
<email>terry.ryan@adobe.com</email>
<description>Creates a static file for the purposes of testing your ColdFusion Builder Extension</description>
<license>Copyright 2009 Terrence Ryan
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
</license>

<menucontributions >

<contribution target="projectview">
<menu name="ColdFusion Builder Test Creator">
<action name="Create Test File" handlerid="createTestFile" showResponse="true">
<input name="cfbtc_path" label="Path" tooltip="The dir location for the file this will create." type="dir" default="{$projectlocation}"/>
<input name="cfbtc_file" label="File" tooltip="The file name for the file this will create." type="string" default="sample.xml"/>
<input name="cfbtc_formsim" label="Form Details" type="string" default=""
helpmessage="Any simulated form details you would like to add in CFML. ex file=sample.xml, path=/wwwroot"
tooltip="Any simulated form details you would like to add in CFML. ex file=sample.xml, path=/wwwroot" />
</action>
</menu>
</contribution>
<contribution target="rdsview">
<menu name="ColdFusion Builder Test Creator">
<action name="Create Test File" handlerid="createTestFile" showResponse="true">
<input name="cfbtc_path" label="Path" tooltip="The dir location for the file this will create." type="dir" default="{$projectlocation}"/>
<input name="cfbtc_file" label="File" tooltip="The file name for the file this will create." type="string" default="sample.xml"/>
<input name="cfbtc_formsim" label="Form Details" type="string" default=""
helpmessage="Any simulated form details you would like to add in CFML. ex file=sample.xml, path=/wwwroot"
tooltip="Any simulated form details you would like to add in CFML. ex file=sample.xml, path=/wwwroot" />
</action>
</menu>
</contribution>
<contribution target="outlineview">
<menu name="ColdFusion Builder Test Creator">
<action name="Create Test File" handlerid="createTestFile" showResponse="true">
<input name="cfbtc_path" label="Path" tooltip="The dir location for the file this will create." type="dir" default="{$projectlocation}"/>
<input name="cfbtc_file" label="File" tooltip="The file name for the file this will create." type="string" default="sample.xml"/>
<input name="cfbtc_formsim" label="Form Details" type="string" default=""
helpmessage="Any simulated form details you would like to add in CFML. ex file=sample.xml, path=/wwwroot"
tooltip="Any simulated form details you would like to add in CFML. ex file=sample.xml, path=/wwwroot" />
</action>
</menu>
</contribution>
<contribution target="editor">
<menu name="ColdFusion Builder Test Creator">
<action name="Create Test File" handlerid="createTestFile" showResponse="true">
<input name="cfbtc_path" label="Path" tooltip="The dir location for the file this will create." type="dir" default="{$projectlocation}"/>
<input name="cfbtc_file" label="File" tooltip="The file name for the file this will create." type="string" default="sample.xml"/>
<input name="cfbtc_formsim" label="Form Details" type="string" default=""
helpmessage="Any simulated form details you would like to add in CFML. ex file=sample.xml, path=/wwwroot"
tooltip="Any simulated form details you would like to add in CFML. ex file=sample.xml, path=/wwwroot" />
</action>
<action name="Paste Code" handlerid="pasteCode" showResponse="true">
</action>
</menu>
</contribution>


</menucontributions>

<handlers>
<handler id="createTestFile" type="CFM" filename="createTestFile.cfm" />
<handler id="pasteCode" type="CFM" filename="pastecode.cfm" />
</handlers>


</application>
20 changes: 20 additions & 0 deletions sample.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<event>
<ide>
<editor>
<file location="/Users/terryr/Sites/centaur.dev/CFCIntrospector/test.cfc" name="test.cfc" project="CFCIntrospector" projectlocation="/Users/terryr/Sites/centaur.dev/CFCIntrospector" projectrelativelocation="test.cfc" />
<selection endcolumn="15" endline="10" startcolumn="2" startline="3">
<text>
&lt;cffunction name=&quot;list&quot; output=&quot;FALSE&quot; access=&quot;public&quot; returntype=&quot;query&quot; hint=&quot;&quot; &gt;
&lt;cfquery name=&quot;result&quot; datasource=&quot;cfartgallery&quot;&gt;
SELECT *
FROM artist

&lt;/cfquery&gt;
&lt;cfreturn result /&gt;
&lt;/cffunction&gt;
</text>
</selection>
</editor>
</ide>
<user />
</event>
10 changes: 10 additions & 0 deletions settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ResourceDetails>
<ServerName>centaur.dev</ServerName>
<LauncherName></LauncherName>
<ExternalBrowser></ExternalBrowser>
<Mappings>
</Mappings>
<VariableMappings>
</VariableMappings>
</ResourceDetails>

0 comments on commit d71543d

Please sign in to comment.