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
|