The only thing I can think of is trying
to see which widget (most likely the custom widget) is saving the
null value and where it is happening. There might still be some
additional logic required in the refreshValueFromMap. If you look
at the initialize(rmMap, lcMap) method that gets called by the
parent AbstractUpdateModel, it expects "mapValue" to be non null.
I don't see mapValue inside your update model's method so maybe it
sees the null and then calls restoreDefault() /
refreshValueFromMap. That might be why you are getting two refresh
map calls.
Chris
On 03/05/2013 02:19 PM, Dave Wootton wrote:
Chris
You are correct. I have a text
widget
and then a custom widget which is rendered in the run
configuration dialog
as a push button. The first way I can use this is to type the
name of the
job queue in the text box and not touch the push button at all.
In this
case the code should pick up the value entered in the text box
and the
custom widget should do nothing.
The second way to use this is to
click
the button. This results in running a query command on the
remote system
and populating a pop-up dialog with a table widget with the
response from
the query. If the user clicks the OK button in that dialog then
I save
the value the user picked and that is the value that is supposed
to be
returned.
I made the changes you suggested
and
am still having problems with restoring the attribute value in
the case
where I don't click the push button and where I should just
picking up
the intermediate value saved in the model.
I put some print statements in my
getValueFromControl()
and refreshValueFromMap() methids to try to see what is going
on.
I started by creating a new run
configuration
and then selecting my target system configuration and
connection. The run
configuration dialog resources tab populated with blank values
as I expected.
I typed the word 'night' into the text box and clicked run. I
did not click
my list push button.
The trace of the two methods to
this
point was as follows, where I just care about the LSF_QUEUE
attribute.
LSF_APP_PROFILE and LSF_RESERVATION should work similarly but
I'm not typing
anything in those fields:
In refreshValueFromMap for
LSF_QUEUE
for control QueueQueryControl {}
Value of LSF_QUEUE in
refreshValueFromMap
is null
Control QueueQueryControl {} is
not
selected
In refreshValueFromMap for
LSF_QUEUE
for control QueueQueryControl {}
Value of LSF_QUEUE in
refreshValueFromMap
is null
Control QueueQueryControl {} is
not
selected
In refreshValueFromMap for
LSF_APP_PROFILE
for control ApplicationQueryControl {}
Value of LSF_APP_PROFILE in
refreshValueFromMap
is null
Control ApplicationQueryControl
{}
is not selected
In refreshValueFromMap for
LSF_APP_PROFILE
for control ApplicationQueryControl {}
Value of LSF_APP_PROFILE in
refreshValueFromMap
is null
Control ApplicationQueryControl
{}
is not selected
In refreshValueFromMap for
LSF_RESERVATION_ID
for control ReservationQueryControl {}
Value of LSF_RESERVATION_ID in
refreshValueFromMap
is null
Control ReservationQueryControl
{}
is not selected
In refreshValueFromMap for
LSF_RESERVATION_ID
for control ReservationQueryControl {}
Value of LSF_RESERVATION_ID in
refreshValueFromMap
is null
Control ReservationQueryControl
{}
is not selected
In refreshValueFromMap for
LSF_RESERVATION_ID
for control ReservationQueryControl {}
Value of LSF_RESERVATION_ID in
refreshValueFromMap
is null
Control ReservationQueryControl
{}
is not selected
In refreshValueFromMap for
LSF_QUEUE
for control QueueQueryControl {}
Value of LSF_QUEUE in
refreshValueFromMap
is null
Control QueueQueryControl {} is
not
selected
In refreshValueFromMap for
LSF_APP_PROFILE
for control ApplicationQueryControl {}
Value of LSF_APP_PROFILE in
refreshValueFromMap
is null
Control ApplicationQueryControl
{}
is not selected
In getValueFromControl for
QueueQueryControl
{}
Default value for widget
QueueQueryControl
{} is ''
In getValueFromControl for
ApplicationQueryControl
{}
Default value for widget
ApplicationQueryControl
{} is ''
In getValueFromControl for
QueueQueryControl
{}
Default value for widget
QueueQueryControl
{} is ''
In getValueFromControl for
ApplicationQueryControl
{}
Default value for widget
ApplicationQueryControl
{} is ''
In getValueFromControl for
ReservationQueryControl
{}
Default value for widget
ReservationQueryControl
{} is ''
In getValueFromControl for
QueueQueryControl
{}
Default value for widget
QueueQueryControl
{} is ''
In getValueFromControl for
ApplicationQueryControl
{}
Default value for widget
ApplicationQueryControl
{} is ''
In getValueFromControl for
QueueQueryControl
{}
Default value for widget
QueueQueryControl
{} is ''
In getValueFromControl for
ApplicationQueryControl
{}
Default value for widget
ApplicationQueryControl
{} is ''
In getValueFromControl for
QueueQueryControl
{}
Default value for widget
QueueQueryControl
{} is ''
In getValueFromControl for
ApplicationQueryControl
{}
Default value for widget
ApplicationQueryControl
{} is ''
In refreshValueFromMap for
LSF_RESERVATION_ID
for control ReservationQueryControl {}
Value of LSF_RESERVATION_ID in
refreshValueFromMap
is ''
Control ReservationQueryControl
{}
is not selected
In refreshValueFromMap for
LSF_QUEUE
for control QueueQueryControl {}
Value of LSF_QUEUE in
refreshValueFromMap
is 'n'
Control QueueQueryControl {} is
not
selected
In refreshValueFromMap for
LSF_APP_PROFILE
for control ApplicationQueryControl {}
Value of LSF_APP_PROFILE in
refreshValueFromMap
is ''
Control ApplicationQueryControl
{}
is not selected
In getValueFromControl for
QueueQueryControl
{}
Default value for widget
QueueQueryControl
{} is 'n'
In getValueFromControl for
ApplicationQueryControl
{}
Default value for widget
ApplicationQueryControl
{} is ''
In refreshValueFromMap for
LSF_RESERVATION_ID
for control ReservationQueryControl {}
Value of LSF_RESERVATION_ID in
refreshValueFromMap
is ''
Control ReservationQueryControl
{}
is not selected
In refreshValueFromMap for
LSF_QUEUE
for control QueueQueryControl {}
Value of LSF_QUEUE in
refreshValueFromMap
is 'ni'
Control QueueQueryControl {} is
not
selected
In refreshValueFromMap for
LSF_APP_PROFILE
for control ApplicationQueryControl {}
Value of LSF_APP_PROFILE in
refreshValueFromMap
is ''
Control ApplicationQueryControl
{}
is not selected
In getValueFromControl for
QueueQueryControl
{}
Default value for widget
QueueQueryControl
{} is 'ni'
In getValueFromControl for
ApplicationQueryControl
{}
Default value for widget
ApplicationQueryControl
{} is ''
In refreshValueFromMap for
LSF_RESERVATION_ID
for control ReservationQueryControl {}
Value of LSF_RESERVATION_ID in
refreshValueFromMap
is ''
Control ReservationQueryControl
{}
is not selected
In refreshValueFromMap for
LSF_QUEUE
for control QueueQueryControl {}
Value of LSF_QUEUE in
refreshValueFromMap
is 'nigh'
Control QueueQueryControl {} is
not
selected
In refreshValueFromMap for
LSF_APP_PROFILE
for control ApplicationQueryControl {}
Value of LSF_APP_PROFILE in
refreshValueFromMap
is ''
Control ApplicationQueryControl
{}
is not selected
In getValueFromControl for
QueueQueryControl
{}
Default value for widget
QueueQueryControl
{} is 'nigh'
In getValueFromControl for
ApplicationQueryControl
{}
Default value for widget
ApplicationQueryControl
{} is ''
In refreshValueFromMap for
LSF_RESERVATION_ID
for control ReservationQueryControl {}
Value of LSF_RESERVATION_ID in
refreshValueFromMap
is ''
Control ReservationQueryControl
{}
is not selected
In refreshValueFromMap for
LSF_QUEUE
for control QueueQueryControl {}
Value of LSF_QUEUE in
refreshValueFromMap
is 'night'
Control QueueQueryControl {} is
not
selected
In refreshValueFromMap for
LSF_APP_PROFILE
for control ApplicationQueryControl {}
Value of LSF_APP_PROFILE in
refreshValueFromMap
is ''
Control ApplicationQueryControl
{}
is not selected
In getValueFromControl for
QueueQueryControl
{}
Default value for widget
QueueQueryControl
{} is 'night'
In getValueFromControl for
ApplicationQueryControl
{}
Default value for widget
ApplicationQueryControl
{} is ''
In getValueFromControl for
QueueQueryControl
{}
Default value for widget
QueueQueryControl
{} is 'night'
In getValueFromControl for
ApplicationQueryControl
{}
Default value for widget
ApplicationQueryControl
{} is ''
Then I open the same run
configuration
a second time with the following trace. The first thing that
happens for
each attribute is that refreshValueFromMap() is called twice for
each attribute.
For LSF_QUEUE I see that the first time 'night' is retrieved
from the map.
Then refreshValueFromMap() is called again and this time the
value retrieved
from the map is null. It seems like something is rewriting the
map. This
is where I'm wondering if there's some sort of problem with the
handling
of the text widget and my custom widget which both reference and
set the
LSF_QUEUE attribute.
In refreshValueFromMap for
LSF_APP_PROFILE
for control ApplicationQueryControl {}
Value of LSF_APP_PROFILE in
refreshValueFromMap
is ''
Control ApplicationQueryControl
{}
is not selected
In refreshValueFromMap for
LSF_APP_PROFILE
for control ApplicationQueryControl {}
Value of LSF_APP_PROFILE in
refreshValueFromMap
is null
Control ApplicationQueryControl
{}
is not selected
In refreshValueFromMap for
LSF_QUEUE
for control QueueQueryControl {}
Value of LSF_QUEUE in
refreshValueFromMap
is 'night'
Control QueueQueryControl {} is
not
selected
In refreshValueFromMap for
LSF_QUEUE
for control QueueQueryControl {}
Value of LSF_QUEUE in
refreshValueFromMap
is null
Control QueueQueryControl {} is
not
selected
In refreshValueFromMap for
LSF_RESERVATION_ID
for control ReservationQueryControl {}
Value of LSF_RESERVATION_ID in
refreshValueFromMap
is ''
Control ReservationQueryControl
{}
is not selected
In refreshValueFromMap for
LSF_RESERVATION_ID
for control ReservationQueryControl {}
Value of LSF_RESERVATION_ID in
refreshValueFromMap
is null
Control ReservationQueryControl
{}
is not selected
In refreshValueFromMap for
LSF_APP_PROFILE
for control ApplicationQueryControl {}
Value of LSF_APP_PROFILE in
refreshValueFromMap
is null
Control ApplicationQueryControl
{}
is not selected
In refreshValueFromMap for
LSF_QUEUE
for control QueueQueryControl {}
Value of LSF_QUEUE in
refreshValueFromMap
is null
Control QueueQueryControl {} is
not
selected
In refreshValueFromMap for
LSF_RESERVATION_ID
for control ReservationQueryControl {}
Value of LSF_RESERVATION_ID in
refreshValueFromMap
is null
Control ReservationQueryControl
{}
is not selected
In getValueFromControl for
ApplicationQueryControl
{}
Default value for widget
ApplicationQueryControl
{} is ''
In getValueFromControl for
QueueQueryControl
{}
Default value for widget
QueueQueryControl
{} is ''
In getValueFromControl for
ApplicationQueryControl
{}
Default value for widget
ApplicationQueryControl
{} is ''
In getValueFromControl for
QueueQueryControl
{}
Default value for widget
QueueQueryControl
{} is ''
In getValueFromControl for
ApplicationQueryControl
{}
Default value for widget
ApplicationQueryControl
{} is ''
In getValueFromControl for
QueueQueryControl
{}
Default value for widget
QueueQueryControl
{} is ''
The two methods in question are:
public void
refreshValueFromMap()
{
Object
value;
System.out.printf("In
refreshValueFromMap
for %s for control %s\n", name, control);
value
= lcMap.getValue(name);
if
(value == null) {
System.out.printf("Value of %s
in refreshValueFromMap is null\n", name);
value = "";
}
else
{
System.out.printf("Value of %s
in refreshValueFromMap is '%s'\n", name, value);
}
defaultValue
= value;
if
(control.widgetSelected()) {
System.out.printf("Control %s
is selected, setting value '%s'\n", control, value);
control.setSelectedValue((String) value);
}
else
{
System.out.printf("Control %s
is not selected\n", control);
}
}
public Object
getValueFromControl()
{
Object
value;
System.out.printf("In
getValueFromControl
for %s\n", control);
if
(control.widgetSelected()) {
value = control.getSelectedValue();
System.out.printf("Value for widget
%s is '%s'\n", control, value);
}
else
{
value = defaultValue;
System.out.printf("Default value
for widget %s is '%s'\n", control, value);
}
return
value;
}
Dave
From:
Christopher Navarro
<cmnavarr@xxxxxxxxxxxx>
To:
<ptp-dev@xxxxxxxxxxx>
Date:
03/01/2013 10:41 AM
Subject:
Re: [ptp-dev]
Problem saving attribute values with JAXB
custom widgets
Sent by:
ptp-dev-bounces@xxxxxxxxxxx
Just to clarify, I meant store an intermediate
value in
the custom widget's model class that gets returned instead of
the control's
value if the control has no values.
Chris
On 03/01/2013 09:35 AM, Christopher Navarro wrote:
Dave,
If I understand your two widgets correctly, the custom widget is
empty
unless the user selects it and has it dynamically query the
queues to populate
a list; otherwise, a user can forego this step and simply enter
the name
of the queue they want, is that right?
If that's the case, I think I know what could be going wrong.
Inside your
custom model, I think you have to be careful about how you
implement getValueFromControl.
When your re-open the run dialog, that control has no values
because it
hasn't been ran yet so getValueFromControl is going to be null
or empty.
I believe refreshValueFromMap gets called first so you might
need to store
an intermediate value in your control that gets returned in the
case that
your custom widget hasn't been populated. Otherwise, what is
probably happening
is getValueFromControl is getting called and returning null
(which gets
stored for LSF_QUEUE) before the Text widget gets created.
Here is what I think those two methods should probably look
like:
public void refreshValueFromMap() {
Object value;
value = lcMap.getValue(name);
if (value == null) {
value = "";
}
intermediateValue = value;
// Here you need to check if the widget was
even populated. If it's not, this selection should not happen
control.setSelectedValue((String) value);
public Object getValueFromControl() {
Object value;
if(((List)control).getItems.length == 0))
{
value = intermediateValue;
} else {
value = control.getSelectedValue();
}
return value;
}
Chris
On 02/28/2013 12:55 PM, Dave Wootton wrote:
Chris
I modified my methods as follows and still not getting correct
results.
My text box is still blank when I open the run configuration
dialog
public void refreshValueFromMap() {
Object value;
value = lcMap.getValue(name);
if (value == null) {
value = "";
}
control.setSelectedValue((String) value);
public Object getValueFromControl() {
Object value;
value = control.getSelectedValue();
return value;
}
With this change, refreshValueFromMap is setting an initial
value for my
queryWidget and getValueFromControl gets that value back. If I
don't click
the list button, meaning I don't get my popup dialog and I don't
update
the widget value, I should get the same value back when I call
getValueFromControl().
I tried debugging this a bit, where I set breakpoints on these
two methods.
When I open the run configuration dialog I stop twice at
refreshValueFromMap
for attribute LSF_QUEUE. The first time, lcMap.getValue()
returns 'night'
which is the saved value and I have the first traceback pasted
below. I
continue and get a second stop at refreshValueFromMap where this
time the
returned value is null and I have the second traceback pasted
below. Since
I get null, I set the value of my widget to "".
One other thing hat occurred to me. My text box is coded before
my custom
widget in the XML. Is it possible that there's some kind of
timing/ordering
problem where the text box is being handled second and somehow
causing
this?
Also, the tracebacks are with PTP Kepler code updated to latest
source
as of yesterday.


Dave
From: Christopher
Navarro <cmnavarr@xxxxxxxxxxxx>
To: <ptp-dev@xxxxxxxxxxx>
Date: 02/27/2013
05:20 PM
Subject: Re:
[ptp-dev] Problem saving attribute values with JAXB
custom widgets
Sent by: ptp-dev-bounces@xxxxxxxxxxx
Hi Dave,
I don't see where you are setting the value for your custom
widget inside
refreshValueFromMap(), which might be why you don't see it
update the UI
properly when you open the run configuration (after a successful
run with
the correct queue). For example, if your custom widget was a
Combo box,
you should have something like:
public void refreshValueFromMap() {
defaultAttributeValue = lcMap.getValue(name);
if (defaultAttributeValue == null) {
defaultAttributeValue
= "";
} else {
// found a value, set it as the selection
for (int i = 0; i < items.length;
i++) {
if (items[i].equals(defaultAttributeValue))
{
combo.select(i);
break;
}
}
}
Chris
On 02/27/2013 03:58 PM, Dave Wootton wrote:
Chris
I've implemented a class LSFQueryModel which implements the
AbstractUpdateModel
interface.
I think the two methods of interest are getMethodFromControl()
and updateValueFromMap()
which I've implemented as follows
public Object getValueFromControl() {
Object value;
value = control.getSelectedValue();
if (value == null) {
if (defaultAttributeValue
== null) {
return "";
}
return defaultAttributeValue;
}
return value;
}
public void refreshValueFromMap() {
defaultAttributeValue = lcMap.getValue(name);
if (defaultAttributeValue == null)
{
defaultAttributeValue
= "";
}
}
The idea is that when the run configuration opens,
refreshValueFromMap()
will run and pick up whatever value is in the attribute set,
which I'm
expecting to be either the value saved from the previous run or
the value
typed in the text box if I type a value there.
Then when I click run, getValueFromControl(), that mathod will
either get
the value from the model if I clicked the list button and picked
a value
from the list, or get defaultAttributeValue if I did not click
the
list button.
The other thing I'm doing, which I think is ok is that since I
have three
custom widgets which behave essentially the same, except for
running a
different LSF command, I have three <widget>
specifications registered
to the org.eclipse.ptp.rm.jaxb.control.ui.widget extension
point. Each
widget has a unique widgetClass but has the same
updateModelClass. I thik
this is ok because when I run in debug mode with a breakpoint
set on getValueFromControl(),
the 'this' variable has a unique id in the debug cariables view
(id=nnn)
and I'm seeing different data such as the 'name' field matching
the attribute
name.
I created a new run configuration where all attributes/fields
are initially
not filled in/blank. If I enter the name of the LSF queue in the
text field
or pick the queue name from my popup dialog then when I hit run
the job
is submitted with the right queue name.
I think the value is being stored correctly in the attribute set
at that
time since if I rerun the job with the same attributes (by
clicking the
Run icon and picking my application from the list, avoiding the
run configuration
dialog), that job is submitted with the correct queue name.
If I then open the run configuration dialog to the same run
configuration,
the fields where I use my widget including queue name are blank
and if
I don't change anything my job gets submitted to a default
queue, not the
queue I picked in the previous run configuration dialog
instance.
So it looks like there's something going wrong when the new run
configuration
dialog instance is getting populated from the attribute set, but
I don't
know what.
Dave
From: Christopher
Navarro <cmnavarr@xxxxxxxxxxxx>
To: <ptp-dev@xxxxxxxxxxx>
Date: 02/27/2013
11:32 AM
Subject: Re:
[ptp-dev] Problem saving attribute values with JAXB custom
widgets
Sent by: ptp-dev-bounces@xxxxxxxxxxx
Your custom widget should have an update model associated with
it and in
there you should implement the method getValueFromControl()
which specifies
the object returned from your custom widget. This will get
called by the
AbstractUpdateModel when it attempts to store the value for your
custom
widget.
Chris
On 02/27/2013 09:57 AM, Dave Wootton wrote:
I've implemented a custom widget for my resource manager so the
user can
dynamically query LSF queues in the run configuration dialog,
but have
run into a problem where the attribute value for any attribute
used by
this custom widget is not saved across invocations of the run
configuration
dialog. Other attributes are saved.
I've implemented this by coding a text box widget and a custom
widget which
refer to the same attribute
<widget style="SWT.BORDER" attribute="LSF_QUEUE"
type="text"
>
<layout-data>
<grid-data widthHint="300" horizontalSpan="1"/>
</layout-data>
<tooltip>${ptp_rm:LSF_QUEUE#tooltip}</tooltip>
</widget>
<widget type="custom" typeId="queueQuery"
style="SWT.LEFT" attribute="LSF_QUEUE">
<layout-data>
<grid-data widthHint="100" horizontalAlign="SWT.BEGINNING"
/>
</layout-data>
<fixed-text>List</fixed-text>
</widget>
The way I intended for this to work was that the user can either
just fill
in the queue name in the text box or he can click the list
button which
is part of my custome widget, select a queue name from the table
in a popup
dialog and click ok.
I'm not doing anything in my custom widget to save the attribute
value.
Am I supposed to be doing anything to save the value? If so, how
do I get
access to the attribute? I see a 'lcMap' variable that's
available to the
refreshValueFromMap method in the model for the widget but I
don't know
how to get access to it for saving a value or where I would do
that.
Is what I'm trying to do supposed to work?
Dave
|