class WirisPlugin::ConfigurationImpl

Attributes

initObject[RW]
initialized[RW]
plugin[RW]
props[RW]

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/com/wiris/plugin/impl/ConfigurationImpl.rb, line 18
def initialize()
    super()
    @props = PropertiesTools::newProperties()
end

Public Instance Methods

appendElement2JavascriptArray(array, value) click to toggle source
# File lib/com/wiris/plugin/impl/ConfigurationImpl.rb, line 69
def appendElement2JavascriptArray(array, value)
    arrayOpen = array::indexOf("[")
    arrayClose = array::indexOf("]")
    if (arrayOpen == -1) || (arrayClose == -1)
        raise Exception,"Array not valid"
    end
    return ((("[" + "\'") + value) + "\'") + (array::length() == 2 ? "]" : "," + Std::substr(array,arrayOpen + 1,arrayClose - arrayOpen).to_s)
end
appendVarJs(sb, varName, value, comment) click to toggle source
# File lib/com/wiris/plugin/impl/ConfigurationImpl.rb, line 57
def appendVarJs(sb, varName, value, comment)
    sb::add("var ")
    sb::add(varName)
    sb::add(" = ")
    sb::add(value)
    sb::add(";")
    if (comment != nil) && (comment::length() > 0)
        sb::add("// ")
        sb::add(comment)
    end
    sb::add("\r\n")
end
getFullConfiguration() click to toggle source
# File lib/com/wiris/plugin/impl/ConfigurationImpl.rb, line 22
def getFullConfiguration()
    initialize0()
    return @props
end
getJavaScriptConfigurationJson() click to toggle source
# File lib/com/wiris/plugin/impl/ConfigurationImpl.rb, line 134
def getJavaScriptConfigurationJson()
    javaScriptHash = getJavaScriptHash()
    return JSon::encode(javaScriptHash)
end
getJavaScriptHash() click to toggle source
# File lib/com/wiris/plugin/impl/ConfigurationImpl.rb, line 77
def getJavaScriptHash()
    javaScriptHash = Hash.new()
    javaScriptHash::set("editorEnabled",Boolean::valueOf((getProperty("wiriseditorenabled",nil) == "true")))
    javaScriptHash::set("imageMathmlAttribute",getProperty("wiriseditormathmlattribute",nil))
    javaScriptHash::set("saveMode",getProperty("wiriseditorsavemode",nil))
    javaScriptHash::set("base64savemode",getProperty("wiriseditorbase64savemode",nil))
    javaScriptHash::set("saveHandTraces",Boolean::valueOf((getProperty(ConfigurationKeys::SAVE_MATHML_SEMANTICS,nil) == "true")))
    parseLatexElements = Array.new()
    if (getProperty("wiriseditorparselatex",nil) == "true")
        parseLatexElements::push("latex")
    end
    if (getProperty("wiriseditorparsexml",nil) == "true")
        parseLatexElements::push("xml")
    end
    javaScriptHash::set("parseModes",parseLatexElements)
    javaScriptHash::set("editorAttributes",getProperty("wiriseditorwindowattributes",nil))
    javaScriptHash::set("editorUrl",@plugin::getImageServiceURL("editor",false))
    javaScriptHash::set("modalWindow",Boolean::valueOf((getProperty("wiriseditormodalwindow",nil) == "true")))
    javaScriptHash::set("modalWindowFullScreen",Boolean::valueOf((getProperty("wiriseditormodalwindowfullscreen",nil) == "true")))
    javaScriptHash::set("CASEnabled",Boolean::valueOf((getProperty("wiriscasenabled",nil) == "true")))
    javaScriptHash::set("CASMathmlAttribute",getProperty("wiriscasmathmlattribute",nil))
    javaScriptHash::set("CASAttributes",getProperty("wiriscaswindowattributes",nil))
    javaScriptHash::set("hostPlatform",getProperty("wirishostplatform",nil))
    javaScriptHash::set("versionPlatform",getProperty("wirisversionplatform","unknown"))
    javaScriptHash::set("enableAccessibility",Boolean::valueOf((getProperty("wirisaccessibilityenabled",nil) == "true")))
    javaScriptHash::set("editorToolbar",getProperty(ConfigurationKeys::EDITOR_TOOLBAR,nil))
    javaScriptHash::set("chemEnabled",Boolean::valueOf((getProperty("wirischemeditorenabled",nil) == "true")))
    javaScriptHash::set("imageFormat",getProperty("wirisimageformat","png"))
    if getProperty(ConfigurationKeys::EDITOR_PARAMS,nil) != nil
        javaScriptHash::set("editorParameters",JSon::decode(getProperty(ConfigurationKeys::EDITOR_PARAMS,nil)))
    else 
        h = ConfigurationKeys::imageConfigPropertiesInv
        attributes = Hash.new()
        confVal = ""
        i = 0
        it = h::keys()
        while it::hasNext()
            value = it::next()
            if getProperty(value,nil) != nil
                confVal = getProperty(value,nil)
                StringTools::replace(confVal,"-","_")
                StringTools::replace(confVal,"-","_")
                attributes::set(confVal,value)
            end
        end
        javaScriptHash::set("editorParameters",attributes)
    end
    javaScriptHash::set("wirisPluginPerformance",Boolean::valueOf((getProperty("wirispluginperformance",nil) == "true")))
    begin
    version = Storage::newResourceStorage("VERSION")::read()
    if version == nil
        version = "Missing version"
    end
    end
    javaScriptHash::set("version",version)
    return javaScriptHash
end
getJsonConfiguration(configurationKeys) click to toggle source
# File lib/com/wiris/plugin/impl/ConfigurationImpl.rb, line 138
def getJsonConfiguration(configurationKeys)
    configurationKeysArray = Std::split(configurationKeys,",")
    iterator = configurationKeysArray::iterator()
    jsonOutput = Hash.new()
    jsonVariables = Hash.new()
    thereIsNullValue = false
    while iterator::hasNext()
        key = iterator::next()
        value = self.getProperty(key,"null")
        if (value == "null")
            thereIsNullValue = true
        end
        jsonVariables::set(key,value)
    end
    if !thereIsNullValue
        jsonOutput::set("status","ok")
    else 
        jsonOutput::set("status","warning")
    end
    jsonOutput::set("result",jsonVariables)
    return JSon::encode(jsonOutput)
end
getProperty(key, dflt) click to toggle source
# File lib/com/wiris/plugin/impl/ConfigurationImpl.rb, line 26
def getProperty(key, dflt)
    initialize0()
    return PropertiesTools::getProperty(@props,key,dflt)
end
initialize0() click to toggle source
# File lib/com/wiris/plugin/impl/ConfigurationImpl.rb, line 36
def initialize0()
    if @initialized
        return 
    end
    @initialized = true
    @plugin::addConfigurationUpdater(FileConfigurationUpdater.new())
    @plugin::addConfigurationUpdater(CustomConfigurationUpdater.new(self))
    a = @plugin::getConfigurationUpdaterChain()
    iter = a::iterator()
    while iter::hasNext()
        cu = iter::next()
        initialize_(cu)
        cu::updateConfiguration(@props)
    end
end
initialize_(cu) click to toggle source
# File lib/com/wiris/plugin/impl/ConfigurationImpl.rb, line 51
def initialize_(cu)
    cu::init(@initObject)
end
setConfigurations(configurationKeys, configurationValues) click to toggle source
# File lib/com/wiris/plugin/impl/ConfigurationImpl.rb, line 160
def setConfigurations(configurationKeys, configurationValues)
    configurationKeysArray = Std::split(configurationKeys,",")
    configurationValuesArray = Std::split(configurationValues,",")
    keysIterator = configurationKeysArray::iterator()
    valuesIterator = configurationValuesArray::iterator()
    while keysIterator::hasNext() && valuesIterator::hasNext()
        key = keysIterator::next()
        value = valuesIterator::next()
        if self.getProperty(key,nil) != nil
            self.setProperty(key,value)
        end
    end
end
setInitObject(context) click to toggle source
# File lib/com/wiris/plugin/impl/ConfigurationImpl.rb, line 33
def setInitObject(context)
    @initObject = context
end
setPluginBuilderImpl(plugin) click to toggle source
# File lib/com/wiris/plugin/impl/ConfigurationImpl.rb, line 54
def setPluginBuilderImpl(plugin)
    self.plugin = plugin
end
setProperty(key, value) click to toggle source
# File lib/com/wiris/plugin/impl/ConfigurationImpl.rb, line 30
def setProperty(key, value)
    PropertiesTools::setProperty(@props,key,value)
end