Closed claudio-rosati closed 6 years ago
I'll have to look at it next week.
Meanwhile, in the code that generates scripts from rules, you could locate the part that creates the else setPropertyValue(prop, the_default_value)
and modify it so that string default values are corrected, each return must be formatted as '\n'.
That is part of the problem I think, because, as you can see from CSSTUDIO-630-3.bob
, there is no such value in the XML:
<?xml version="1.0" encoding="UTF-8"?>
<display version="2.0.0">
<name>CSSTUDIO-630-3</name>
<widget type="bool_button" version="2.0.0">
<name>Boolean Button_1</name>
<pv_name>loc://A-BOOLEAN(0)</pv_name>
<x>20</x>
<y>20</y>
</widget>
<widget type="label" version="2.0.0">
<name>Label_1</name>
<text>-</text>
<x>20</x>
<y>70</y>
<rules>
<rule name="New Rule" prop_id="text" out_exp="false">
<exp bool_exp="pvInt0 == 0">
<value>NO TOOLTIP</value>
</exp>
<exp bool_exp="pvInt0 > 0">
<value>TOOLTIP</value>
</exp>
<pv_name>loc://A-BOOLEAN</pv_name>
</rule>
</rules>
<tooltip>$(text)</tooltip>
</widget>
<widget type="textupdate" version="2.0.0">
<name>Text Update_1</name>
<pv_name>loc://A-BOOLEAN(0)</pv_name>
<x>140</x>
<y>70</y>
<rules>
<rule name="New Rule" prop_id="tooltip" out_exp="false">
<exp bool_exp="pvInt0 == 0">
<value>NO TOOLTIP</value>
</exp>
<exp bool_exp="pvInt0 > 0">
<value>TOOLTIP</value>
</exp>
<pv_name>loc://A-BOOLEAN</pv_name>
</rule>
</rules>
</widget>
</display>
It seems like
else:
widget.setPropertyValue('tooltip', "$(pv_name)
$(pv_value)")
is coming from the original default value of the Tooltip property.
The else
part of the rule sets the property to the current value of the property.
In your case, the current value seems to be the default value, which is "$(pv_name)\n$(pv_value)"
for a tooltip property.
So the rule-to-script code definitely needs an update to handle string values, where newlines need to be properly escaped. Not sure if that completely solves the issue, there may be more to do.
It seems reasonable.
Try again with the latest from master
.
The string literals generated for Jython now escape the newline, and the NPE is also gone.
@kasemir I've tried and everything is working. Only the following problem still exists (is it really a problem?):
CSSTUDIO-630-1.bob
, select the Label and add a new expression to the existing rule, e.g. pvInt0 < 0
-> SOME TEXT
. As soon you press RETURN on the Value the following message still appear in console:2018-03-20 08:51:49.869 WARNING [Thread 1] org.csstudio.display.builder.model.WidgetProperty (getPath) - Cannot determine path to text for Widget 'Label_1' (label)
If that is not a problem, please feel free to close the issue.
Try now, the warning should be gone
Works fine. Thank you.
Hello Kay,
a colleague has found a problem with tooltip and rules, and I then I've found more trying to reproduce it. Please refers to the attached OPIs:
CSSTUDIO-630.zip
CSSTUDIO-630-1.bob
has:If you open with the editor and then run it everything works fine.
In
CSSTUDIO-630-1.bob
I have set the Tooltip to "-" and created a rule identical to the one updating the Label's Text. Here already I have a problem, because when I set a rule's value I got the following message:Now If you open the
CSSTUDIO-630-2.bob
file in the editor you should have the following error:The funny thing is that inside the file "$(pv_name)$(pv_value)" doesn't exist.
If you open the file in runtime, you should have the same error, but everything works as expected.
In the last OPI,
CSSTUDIO-630-3.bob
, the Text Update is left with its default Tooltip value, but with the usual rule to change it depending on the localPV value.In that case, when you open the file in the editor you'll have the same error as before. If you open it in runtime, the following appears instead:
and the tooltip doesn't behave as expected.