Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions Toolset/libraries/revidedeveloperextensionlibrary.livecodescript
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,15 @@ private function __revIDEDeveloperExtensionFetchFolderDetails pFolder, pFile
if tDetailsA["defaultscript"] is not empty then
put pFolder & "/support/defaultscript.livecodescript" into tDetailsA["defaultscript_file"]
end if

# Custom PI editors
local tEditorsFolder, tEditors
put pFolder & slash & "editors" into tEditorsFolder
if there is a folder tEditorsFolder then
put __revIDEDeveloperExtensionListResourcesRecursive(tEditorsFolder, "") into tEditors
put tEditors into tDetailsA["editors"]
end if

return tDetailsA
end __revIDEDeveloperExtensionFetchFolderDetails

Expand Down Expand Up @@ -882,8 +891,18 @@ private on __revIDEDeveloperExtensionBuildPackage pFolder, pTargetFolder, @rBuil
put empty into tDefaultScript
end if

local tEditors
put (pFolder & slash & "editors") into tEditors
if there is not a folder tEditors then
put empty into tEditors
end if

if tError is empty then
put __revIDEDeveloperExtensionAddSpecifiedFilesToPackage(tFullPath, pFolder, tArchive, pFolder & slash & "module.lcm", tIcon, tRetinaIcon, tGuide, tDocs, tResources, tCode, tInterfaceFile, tDefaultScript) into tError
put __revIDEDeveloperExtensionAddSpecifiedFilesToPackage(\
tFullPath, pFolder, tArchive, pFolder & slash & "module.lcm", \
tIcon, tRetinaIcon, tGuide, tDocs, tResources, tCode, \
tInterfaceFile, tDefaultScript, tEditors) \
into tError
end if

revZipCloseArchive tArchive
Expand All @@ -903,7 +922,10 @@ private on __revIDEDeveloperExtensionBuildPackage pFolder, pTargetFolder, @rBuil
return empty
end __revIDEDeveloperExtensionBuildPackage

private function __revIDEDeveloperExtensionAddSpecifiedFilesToPackage pSource, pFolder, pArchive, pModule, pIcon, pRetinaIcon, pGuide, pDocs, pResourcesFolder, pCodeFolder, pInterfaceFile, pDefaultScript
private function __revIDEDeveloperExtensionAddSpecifiedFilesToPackage \
pSource, pFolder, pArchive, pModule, pIcon, pRetinaIcon, pGuide, \
pDocs, pResourcesFolder, pCodeFolder, pInterfaceFile, \
pDefaultScript, pEditors
local tError

set the itemdelimiter to slash
Expand Down Expand Up @@ -1016,6 +1038,19 @@ private function __revIDEDeveloperExtensionAddSpecifiedFilesToPackage pSource, p
end if
end if

# Add editors
if tError is empty and pEditors is not empty then
local tEditors
put __revIDEDeveloperExtensionListResourcesRecursive(pEditors, "") into tEditors
repeat for each line tLine in tEditors
revZipAddItemWithFile pArchive, "editors/" & tLine, pEditors & slash & tLine

if the result begins with "ziperr" then
__revIDEDeveloperExtensionSendWarning "couldn't add editors" && pEditors & slash & tLine
end if
end repeat
end if

return tError
end __revIDEDeveloperExtensionAddSpecifiedFilesToPackage

Expand Down
225 changes: 125 additions & 100 deletions Toolset/libraries/revideextensionlibrary.livecodescript
Original file line number Diff line number Diff line change
Expand Up @@ -111,28 +111,33 @@ function revIDEExtensionProperties pTypeID
return sExtensionProperties[pTypeID]
end revIDEExtensionProperties

# organise the property info into the structure that the inspectors
# expect, namely [<section>]["grouplist"][<group>]["proplist"][<prop>]
private function __OrganiseInspectorMetadata pDataA
local tExtensionPropsInfoA
repeat for each key tProp in pDataA
local tSection, tGroup, tOrder, tPropInfoA
put pDataA[tProp] into tPropInfoA
put pDataA[tProp]["order"] into tOrder
put pDataA[tProp]["label"] into tGroup
put pDataA[tProp]["section"] into tSection
put tPropInfoA into tExtensionPropsInfoA[tSection]["grouplist"][tGroup]["proplist"][tProp]

put true into tExtensionPropsInfoA[tSection]["grouplist"][tGroup]["widget_prop"]
put tOrder into tExtensionPropsInfoA[tSection]["grouplist"][tGroup]["order"]
end repeat
return tExtensionPropsInfoA
end __OrganiseInspectorMetadata

function revIDEExtensionPropertiesInfo pTypeId, pOrganise
local tPropsA, tExtensionPropsInfoA
put revIDEExtensionProperties(pTypeId) into tPropsA

if pOrganise then
# If pOrganise is true, organise the property info into the structure that the property
# inspector expects, namely [<section>]["grouplist"][<group>]["proplist"][<prop>]
repeat for each key tProp in tPropsA
local tSection, tGroup, tOrder, tPropInfoA
put tPropsA[tProp] into tPropInfoA
put tPropsA[tProp]["order"] into tOrder
put tPropsA[tProp]["label"] into tGroup
put tPropsA[tProp]["section"] into tSection
put tPropInfoA into tExtensionPropsInfoA[tSection]["grouplist"][tGroup]["proplist"][tProp]

put true into tExtensionPropsInfoA[tSection]["grouplist"][tGroup]["widget_prop"]
put tOrder into tExtensionPropsInfoA[tSection]["grouplist"][tGroup]["order"]
end repeat
return __OrganiseInspectorMetadata(tPropsA)
else
put tPropsA into tExtensionPropsInfoA
return tPropsA
end if
return tExtensionPropsInfoA
end revIDEExtensionPropertiesInfo

function revIDEExtensionProperty pKind, pProperty
Expand All @@ -146,6 +151,25 @@ function revIDEExtensionProperty pKind, pProperty
return __extensionPropertyGet(tExtensionID, pProperty)
end revIDEExtensionProperty

function revIDEExtensionStandaloneSettings pID
# Get the internal cache index
local tCacheIndex
put __extensionCacheID("name", pID) into tCacheIndex

return __extensionPropertyGet(tCacheIndex, "standaloneSettings")
end revIDEExtensionStandaloneSettings

function revIDEExtensionStandaloneSettingsInfo pTypeId, pOrganise
local tPropsA, tExtensionPropsInfoA
put revIDEExtensionStandaloneSettings(pTypeId) into tPropsA

if pOrganise then
return __OrganiseInspectorMetadata(tPropsA)
else
return tPropsA
end if
end revIDEExtensionStandaloneSettingsInfo

##############################
# PRIVATE INSTALLATION PROCESS
##############################
Expand Down Expand Up @@ -477,112 +501,105 @@ end __extensionUninstallComplete
##############################
# PRIVATE SHARED
##############################
private command __ProcessInspectorMetadata @xMetadataA
repeat for each key tKey in xMetadataA
local tLabel, tSection
if xMetadataA[tKey]["section"] is empty then
put "Basic" into xMetadataA[tKey]["section"]
end if

if xMetadataA[tKey]["label"] is empty then
put tKey into xMetadataA[tKey]["label"]
end if

# Process value options, default and delimiter
replace comma with return in xMetadataA[tKey]["options"]
replace "\n" with return in xMetadataA[tKey]["delimiter"]
if xMetadataA[tKey]["default"] is not empty then
replace "\n" with return in xMetadataA[tKey]["default"]
end if

if xMetadataA[tKey]["user_visible"] is empty then
put true into xMetadataA[tKey]["user_visible"]
end if

if xMetadataA[tKey]["properties"] is not empty then
-- If there is a 'properties' value, delete the key
-- and replace it with that value
local tInfo, tNewKey
put xMetadataA[tKey] into tInfo
put tInfo["properties"] into tNewKey
delete variable xMetadataA[tKey]
delete variable tInfo["properties"]
put tInfo into xMetadataA[tNewKey]
end if
end repeat
end __ProcessInspectorMetadata

function __extensionFetchPropertyMetadata pXMLTree, pProperty, pElement
local tNode
put revXMLMatchingNode(pXMLTree, "package", "metadata", "key", pProperty &"." & pElement, 1) into tNode
if tNode is not empty then
return revXMLNodeContents(pXMLTree, tNode)
end if

return empty
end __extensionFetchPropertyMetadata

function __extensionPropertyInfoFromManifest pManifestPath
private function __extensionPropertyInfoFromManifest pId, pManifestPath
if not there is a file pManifestPath then return empty
# Create the XML tree
local tXMLTree, tProperties, tExtensionData
local tXMLTree, tProperties, tExtensionData, tPropertyNodes
put revXMLCreateTreeFromFile(pManifestPath,true,true,false) into tXMLTree

# Process the general property metadata into an array
local tMetadataNodes, tMetadataA, tKeys, tValue
put revXMLChildNames(tXMLTree, "package",return,"metadata",true) into tMetadataNodes
set the itemdelimiter to "."
repeat for each line tMetadata in tMetadataNodes
put revXMLAttribute(tXMLTree,"package" & "/" & tMetadata,"key") into tKeys
put revXMLNodeContents(tXMLTree,"package" & "/" & tMetadata) into tValue
repeat with x = the number of items in tKeys down to 1
get tValue
put empty into tValue
put it into tValue[item x of tKeys]
end repeat
union tMetadataA with tValue recursively
end repeat
put revXMLChildNames(tXMLTree,"package",return,"property",true) into tPropertyNodes

put revXMLChildNames(tXMLTree,"package",return,"property",true) into tProperties
local tOrder, tPropertyDataA
local tCacheID
put __extensionCacheID("name", pID) into tCacheId

local tMetadataKeys
put the keys of tMetadataA into tMetadataKeys
sort tMetadataKeys
sort tMetadataKeys by tMetadataA[each]["order"]
repeat for each line tKey in tMetadataKeys
local tPropertyInfo
put revIDEPropertyInfo(tKey) into tPropertyInfo
if tPropertyInfo is empty then
next repeat
end if
add 1 to tOrder
union tMetadataA[tKey] with tPropertyInfo
put tMetadataA[tKey] into tPropertyDataA[tKey]
put tOrder into tPropertyDataA[tKey]["order"]
local tPropertyNames, tPropertyXMLData
repeat for each line tPropertyNode in tPropertyNodes
local tName
put revXMLAttribute(tXMLTree,"package" & "/" & tPropertyNode,"name") into tName
put __extensionPropertyGet(tCacheId, tName) into tPropertyXMLData[tName]["data"]
put revXMLAttribute(tXMLTree,"package" & "/" & tPropertyNode,"set") into \
tPropertyXMLData[tName]["set"]
put revXMLAttribute(tXMLTree,"package" & "/" & tPropertyNode,"get") into \
tPropertyXMLData[tName]["get"]
end repeat
put the keys of tPropertyXMLData into tPropertyNames
sort tPropertyNames by tPropertyXMLData[each]["data"]["order"]

repeat for each line tProperty in tProperties
add 1 to tOrder
local tName
put revXMLAttribute(tXMLTree,"package" & "/" & tProperty,"name") into tName

put tMetadataA[tName] into tPropertyDataA[tName]
local tOrder, tPropertyDataA
repeat for each line tProperty in tPropertyNames
local tIDEPropertyInfo, tPropertyInfoA
put tPropertyXMLData[tProperty]["data"] into tPropertyInfoA
put revIDEPropertyInfo(tProperty) into tIDEPropertyInfo
if tIDEPropertyInfo is not empty then
add 1 to tOrder
union tPropertyInfoA with tIDEPropertyInfo
put tPropertyInfoA into tPropertyDataA[tProperty]
put tOrder into tPropertyDataA[tProperty]["order"]
else
put tPropertyInfoA into tPropertyDataA[tProperty]
end if

local tReadOnly
get revXMLAttribute(tXMLTree,"package" & "/" & tProperty,"set")
if it is empty or it begins with "xmlerr" then
local tReadOnly, tSetter
put tPropertyXMLData[tProperty]["set"] into tSetter
if tSetter is empty or tSetter begins with "xmlerr" then
put true into tReadOnly
else
put false into tReadOnly
end if
put tReadOnly into tPropertyDataA[tName]["read_only"]
put tReadOnly into tPropertyDataA[tProperty]["read_only"]

if tPropertyDataA[tName]["editor"] is empty then
if tPropertyDataA[tProperty]["editor"] is empty then
local tType
put revXMLAttribute(tXMLTree,"package" & "/" & tProperty,"get") into tType
put tPropertyXMLData[tProperty]["get"] into tType
if tType is "Integer" or tType is "Real" then
put "com.livecode.pi.number" into tPropertyDataA[tName]["editor"]
put "com.livecode.pi.number" into tPropertyDataA[tProperty]["editor"]
else
put "com.livecode.pi." & tolower(tType) into tPropertyDataA[tName]["editor"]
put "com.livecode.pi." & tolower(tType) into tPropertyDataA[tProperty]["editor"]
end if
end if
put tOrder into tPropertyDataA[tName]["order"]
end repeat

repeat for each key tName in tPropertyDataA
local tLabel, tSection

if tPropertyDataA[tName]["section"] is empty then
put "Basic" into tPropertyDataA[tName]["section"]
end if

if tPropertyDataA[tName]["label"] is empty then
put tName into tPropertyDataA[tName]["label"]
end if

# Process value options, default and delimiter
replace comma with return in tPropertyDataA[tName]["options"]
replace "\n" with return in tPropertyDataA[tName]["delimiter"]
if tPropertyDataA[tName]["default"] is not empty then
replace "\n" with return in tPropertyDataA[tName]["default"]
end if

put tOrder into tPropertyDataA[tProperty]["order"]
# Tag the property as a widget property, so we can order them
# correctly after the built-in props for the given section
put true into tPropertyDataA[tName]["widget_prop"]

if tPropertyDataA[tName]["user_visible"] is empty then
put true into tPropertyDataA[tName]["user_visible"]
end if
put true into tPropertyDataA[tProperty]["widget_prop"]
end repeat

__ProcessInspectorMetadata tPropertyDataA

revXMLDeleteTree tXMLTree
return tPropertyDataA
end __extensionPropertyInfoFromManifest
Expand Down Expand Up @@ -628,9 +645,9 @@ private command __extensionSetExtensionInfoFromManifest pCacheIndex, pManifestPa
end repeat
end __extensionSetExtensionInfoFromManifest

command __extensionSetPropertyInfoFromManifest pID, pManifest
private command __extensionSetPropertyInfoFromManifest pID, pManifest
local tPropertyInfo
put __extensionPropertyInfoFromManifest(pManifest) into tPropertyInfo
put __extensionPropertyInfoFromManifest(pId, pManifest) into tPropertyInfo
put tPropertyInfo into sExtensionProperties[pID]
end __extensionSetPropertyInfoFromManifest

Expand Down Expand Up @@ -1340,6 +1357,11 @@ command revIDEExtensionMetadata pFolder, pFile, pType, @rDataA
return tResult
end revIDEExtensionMetadata

private command __SetMetadata pKey, pValue, @xArray
split pKey by "."
put pValue into xArray[pKey]
end __SetMetadata

private command revIDEExtensionFetchMetadata pManifestPath, @rDataA
local tDataA

Expand Down Expand Up @@ -1399,7 +1421,7 @@ private command revIDEExtensionFetchMetadata pManifestPath, @rDataA
if tMetadataValue is empty or tMetadataValue begins with "xmlerr" then
put empty into tMetadataValue
end if
put tMetadataValue into tDataA[tMetadataKey]
__SetMetadata tMetadataKey, tMetadataValue, tDataA
end repeat

# Fetch extension dependencies
Expand Down Expand Up @@ -1439,6 +1461,9 @@ private command revIDEExtensionFetchMetadata pManifestPath, @rDataA
put true into tDataA["uservisible"]
end if

# Make sure 'inspector' style metadata is processed
__ProcessInspectorMetadata tDataA["standaloneSettings"]

put tDataA into rDataA
return empty
end revIDEExtensionFetchMetadata
Expand Down
Loading