Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Showing "special" values in number fields/smart fields
Showing "special" values in number fields/smart fields [message #1400610] Mon, 14 July 2014 12:58 Go to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 402
Registered: October 2012
Location: Bern, Switzerland
Senior Member
In our application we have forms that are used to display the values of single objects. For this, we have added IntegerFields, StringFields, LongFields, SmartFields and Checkboxes to the form.

However, the user also has the possibility to select multiple entries from a table and then display the same form for a consolidation of the values of all those entries. If a certain field has the same value for all entities, the corresponding field will display this value. If a field has differing values across those entries, an asterisk needs to be displayed in this field.

Obviously the case where an identical value needs to be shown is trivial (same as displaying values for a single entity). Covering the asterisk (*) case for a StringField is also trivial.

For the checkbox we wrote our own TriState checkbox control.

However, I don't quite see what the best way would be to display the asterisk for Integer/LongFields and for SmartFields.

For SmartFields I guess I could define a marker value that I could use with setValue() and then cover as a special case in the LookupCalls.getDataByKey() method.

How would this best be done for NumberFields? I could replace them with a StringField but as we also want to be able to enter data (overwriting the * to force a certain value on all instances of the field) this would mean I would need to add a lot of the validation functionality to this field that a NumberField already offers.

Is there a way to call IntegerField.setText() similar to the way execDecorateCell() works on table columns?
Re: Showing "special" values in number fields/smart fields [message #1400654 is a reply to message #1400610] Mon, 14 July 2014 14:18 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 402
Registered: October 2012
Location: Bern, Switzerland
Senior Member
I've found the answer to part of my question.

I've extended AbstractIntegerField as follows:
public abstract class AbstractAsteriskIntegerField extends AbstractCisIntegerField {
  public static final Integer ASTERISK = new Integer(-4321); // value is never used

  @Override
  protected String execFormatValue(Integer validValue) {
    if (ASTERISK == validValue) {
      return "*";
    }
    return super.execFormatValue(validValue);
  }
}


I can now fill the field using the following logic:
      if (valueIsDifferent) {
        getVmaxField().setValue(AbstractAsteriskIntegerField.ASTERISK);
      } else {
        getVmaxField().setValue(commonValue);
      }


I'll have to see how this handles editing (currently the fields are read-only) when the user clicks in the field... that might then revert to the magic marker number, which would be undesired. But that is for another day Smile I'll now go play with SmartFields to verify an idea I have for them.

[Updated on: Mon, 14 July 2014 14:24]

Report message to a moderator

Re: Showing "special" values in number fields/smart fields [message #1401238 is a reply to message #1400654] Tue, 15 July 2014 10:28 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 990
Registered: October 2011
Senior Member
Thanks for your feedback.

You could also investigage AbstractValueField.setDisplayText(String).
Obviously this is one special case, where the display text should not match with the value set in the scout model.

I think that you are already looking into this direction, because the return value of execFormatValue() is set as display text.
Re: Showing "special" values in number fields/smart fields [message #1401817 is a reply to message #1401238] Wed, 16 July 2014 05:50 Go to previous message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 402
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Thank you Jérémie, in the mean time I've redesigned our solution a little. It no longer uses a "marker value" but adds a private member "asterisk" to AbstractAsteriskIntegerField which can then be set/cleared using the setter method. It also supports setValue(Integer value, boolean asterisk) so this can be achieved at the same time. We are then using a combination of execFormatValue() and setDisplayText().
Previous Topic:Enabling/Disabling Menus at Runtime
Next Topic:Page closing issue
Goto Forum:
  


Current Time: Thu Sep 03 09:12:47 GMT 2015

Powered by FUDForum. Page generated in 0.07191 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software