Class: WirisPlugin::ConfigurationImpl
- Inherits:
-
Object
- Object
- WirisPlugin::ConfigurationImpl
- Extended by:
- ConfigurationInterface
- Includes:
- Wiris
- Defined in:
- lib/com/wiris/plugin/impl/ConfigurationImpl.rb
Instance Attribute Summary collapse
-
#initialized ⇒ Object
Returns the value of attribute initialized.
-
#initObject ⇒ Object
Returns the value of attribute initObject.
-
#plugin ⇒ Object
Returns the value of attribute plugin.
-
#props ⇒ Object
Returns the value of attribute props.
Instance Method Summary collapse
- #appendElement2JavascriptArray(array, value) ⇒ Object
- #appendVarJs(sb, varName, value, comment) ⇒ Object
- #getFullConfiguration ⇒ Object
- #getJavaScriptConfigurationJson ⇒ Object
- #getJavaScriptHash ⇒ Object
- #getJsonConfiguration(configurationKeys) ⇒ Object
- #getProperty(key, dflt) ⇒ Object
-
#initialize ⇒ ConfigurationImpl
constructor
A new instance of ConfigurationImpl.
- #initialize0 ⇒ Object
- #initialize_(cu) ⇒ Object
- #setConfigurations(configurationKeys, configurationValues) ⇒ Object
- #setInitObject(context) ⇒ Object
- #setPluginBuilderImpl(plugin) ⇒ Object
- #setProperty(key, value) ⇒ Object
Methods included from ConfigurationInterface
Constructor Details
#initialize ⇒ ConfigurationImpl
Returns a new instance of ConfigurationImpl.
18 19 20 21 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 18 def initialize() super() @props = PropertiesTools::newProperties() end |
Instance Attribute Details
#initialized ⇒ Object
Returns the value of attribute initialized.
17 18 19 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 17 def initialized @initialized end |
#initObject ⇒ Object
Returns the value of attribute initObject.
15 16 17 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 15 def initObject @initObject end |
#plugin ⇒ Object
Returns the value of attribute plugin.
14 15 16 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 14 def plugin @plugin end |
#props ⇒ Object
Returns the value of attribute props.
16 17 18 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 16 def props @props end |
Instance Method Details
#appendElement2JavascriptArray(array, value) ⇒ Object
69 70 71 72 73 74 75 76 |
# 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) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# 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 ⇒ Object
22 23 24 25 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 22 def getFullConfiguration() initialize0() return @props end |
#getJavaScriptConfigurationJson ⇒ Object
134 135 136 137 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 134 def getJavaScriptConfigurationJson() javaScriptHash = getJavaScriptHash() return JSon::encode(javaScriptHash) end |
#getJavaScriptHash ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# 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) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# 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) ⇒ Object
26 27 28 29 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 26 def getProperty(key, dflt) initialize0() return PropertiesTools::getProperty(@props,key,dflt) end |
#initialize0 ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# 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) ⇒ Object
51 52 53 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 51 def initialize_(cu) cu::init(@initObject) end |
#setConfigurations(configurationKeys, configurationValues) ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 |
# 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) ⇒ Object
33 34 35 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 33 def setInitObject(context) @initObject = context end |
#setPluginBuilderImpl(plugin) ⇒ Object
54 55 56 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 54 def setPluginBuilderImpl(plugin) self.plugin = plugin end |
#setProperty(key, value) ⇒ Object
30 31 32 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 30 def setProperty(key, value) PropertiesTools::setProperty(@props,key,value) end |