Class: ValueElement
Instance Attribute Summary collapse
Attributes inherited from Element
#current, #eventHandlerAttributes, #instancePropertyAttributes, #lineNumber, #loadListener, #parent, #parentLoader, #staticPropertyAttributes, #staticPropertyElements, #value, #valueAdapter, #xmlStreamReader
Instance Method Summary
collapse
Methods inherited from Element
#add, #addEventHandler, #applyProperty, #callz, #getProperties, #getValueAdapter, #initialize, #isBidirectionalBindingExpression, #isBindingExpression, #isCollection, #isTyped, #populateArrayFromString, #populateListFromString, #processEventHandlerAttributes, #processInstancePropertyAttributes, #processPropertyAttribute, #processValue3, #resolvePrefixedValue, #set, #staticLoad, #updateValue, #warnDeprecatedEscapeSequence
Constructor Details
This class inherits a constructor from Element
Instance Attribute Details
#fx_id ⇒ Object
Returns the value of attribute fx_id.
59
60
61
|
# File 'lib/fxmlloader/value_elts.rb', line 59
def fx_id
@fx_id
end
|
Instance Method Details
#getListValue(parent, listPropertyName, value) ⇒ Object
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
# File 'lib/fxmlloader/value_elts.rb', line 117
def getListValue( parent, listPropertyName, value)
if (parent.isTyped())
listType = parent.getValueAdapter().getGenericType(listPropertyName);
if (listType != nil)
itemType = RubyWrapperBeanAdapter.getGenericListItemType(listType);
if (itemType.is_a? ParameterizedType)
itemType = (itemType).getRawType();
end
value = RubyWrapperBeanAdapter.coerce(value,itemType);
end
end
return value;
end
|
#processAttribute(prefix, localName, value) ⇒ Object
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
# File 'lib/fxmlloader/value_elts.rb', line 210
def processAttribute( prefix, localName, value)
if (prefix != nil && prefix == (FXL::FX_NAMESPACE_PREFIX))
if (localName == (FXL::FX_ID_ATTRIBUTE))
if (value == (FXL::NULL_KEYWORD))
raise LoadException.new("Invalid identifier.");
end
dputs callz + "Found FXID is #{value}"
@fx_id = value;
elsif (localName == (FXL::FX_CONTROLLER_ATTRIBUTE))
if (parentLoader.current.parent != nil)
raise LoadException.new(FXL::FX_NAMESPACE_PREFIX + ":" + FXL::FX_CONTROLLER_ATTRIBUTE + " can only be applied to root element.");
end
dputs callz + "Found controller attrib is #{value} (#{parentLoader.controller}, #{staticLoad})"
if (parentLoader.controller != nil)
raise LoadException.new("Controller value already specified.");
end
if (!staticLoad)
type = nil
begin
type = parentLoader.constantize(value)
rescue ClassNotFoundException => exception
raise LoadException.new(exception);
end
begin
if (parentLoader.controllerFactory == nil)
parentLoader.controller = type.new
else
parentLoder.controller = (parentLoader.controllerFactory.call(type));
end
rescue InstantiationException => exception
raise LoadException.new(exception);
rescue IllegalAccessException => exception
raise LoadException.new(exception);
end
end
else
raise LoadException.new("Invalid attribute.");
end
else
dputs callz + "Super Again!"
super(prefix, localName, value);
end
end
|
#processCharacters ⇒ Object
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
# File 'lib/fxmlloader/value_elts.rb', line 185
def processCharacters()
type = value.java_class
defaultProperty = type.getAnnotation(DefaultProperty.java_class);
if (defaultProperty != nil)
text = xmlStreamReader.getText();
text = .matcher(text).replaceAll(" ");
defaultPropertyName = defaultProperty.value();
valueAdapter = getValueAdapter();
if (valueAdapter.read_only?(defaultPropertyName) && List.class.isAssignableFrom(valueAdapter.getType(defaultPropertyName)))
list = valueAdapter.get(defaultPropertyName);
list.add(getListValue(self, defaultPropertyName, text));
else
valueAdapter.put(defaultPropertyName, text.strip);
end
else
throw LoadException.new(type.getName() + " does not have a default property.");
end
end
|
#processEndElement ⇒ Object
73
74
75
76
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
|
# File 'lib/fxmlloader/value_elts.rb', line 73
def processEndElement()
dputs callz + "process end super?"
super
dputs callz + "process end superd!"
dp value
if (value.is_a? Builder)
dputs "build it"
updateValue(value.build());
dputs "process it"
processValue();
else
processInstancePropertyAttributes();
end
dputs "donet"
processEventHandlerAttributes();
dputs "ahndersAtrrs"
if (staticPropertyAttributes.length > 0)
for attribute in staticPropertyAttributes
dputs "process prodp attr-----------"
dp attribute
processPropertyAttribute(attribute);
end
end
dputs "staticpro"
if (staticPropertyElements.length > 0)
for element in staticPropertyElements
RubyWrapperBeanAdapter.put(value, element.sourceType, element.name, element.value);
end
end
dputs "parentS>AS"
if (parent != nil)
if (parent.isCollection())
parent.add(value);
else
dputs callz + " ANd setting #{value} on #{parent}"
parent.set value
end
end
end
|
#processStartElement ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/fxmlloader/value_elts.rb', line 61
def processStartElement
super
updateValue(constructValue());
if (value.is_a? Builder)
processInstancePropertyAttributes();
else
processValue();
end
end
|
#processValue ⇒ Object
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
# File 'lib/fxmlloader/value_elts.rb', line 136
def processValue()
if (parent == nil)
root = value;
fxNSURI = xmlStreamReader.getNamespaceContext().getNamespaceURI("fx");
if (fxNSURI != nil)
fxVersion = fxNSURI[(fxNSURI.rindex("/") + 1)..-1];
if (parentLoader.compareJFXVersions(FxmlLoader::FX_NAMESPACE_VERSION, fxVersion) < 0)
raise LoadException.new("Loading FXML document of version " + fxVersion + " by JavaFX runtime supporting version " + FxmlLoader::FX_NAMESPACE_VERSION);
end
end
defaultNSURI = xmlStreamReader.getNamespaceContext().getNamespaceURI("");
if (defaultNSURI != nil)
nsVersion = defaultNSURI[(defaultNSURI.lastIndexOf("/") + 1)..-1]
if (parentLoader.compareJFXVersions(FXL::JAVAFX_VERSION, nsVersion) < 0)
Logging.getJavaFXLogger().warning("Loading FXML document with JavaFX API of version " + nsVersion + " by JavaFX runtime of version " + FXL::JAVAFX_VERSION);
end
end
end
if (@fx_id != nil)
parentLoader.namespace[@fx_id] = value
idProperty = value.java_class.annotation(IDProperty.java_class);
if (idProperty != nil)
properties = getProperties();
if (properties[idProperty.value] == nil)
dputs callz + "saving ID property #{idProperty.value}"
properties[idProperty.value()]= @fx_id;
end
end
dputs callz+ "About to set instance variable #{@fx_id}"
if (parentLoader.controller != nil)
field = parentLoader.controller.instance_variable_set("@" + @fx_id, value)
end
dputs callz + "Set.."
end
end
|