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
_______________________________________________
ptp-dev mailing list
ptp-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ptp-dev
_______________________________________________
ptp-dev mailing list
ptp-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ptp-dev
_______________________________________________
ptp-dev mailing list
ptp-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ptp-dev
_______________________________________________
ptp-dev mailing list
ptp-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ptp-dev
_______________________________________________
ptp-dev mailing list
ptp-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ptp-dev
|