Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » FormattedText not allowing 0 to be entered
FormattedText not allowing 0 to be entered [message #538646] Tue, 08 June 2010 10:12 Go to next message
Geejay is currently offline GeejayFriend
Messages: 160
Registered: February 2010
Senior Member
Is there any way to allow a 0 to be entered in an empty FormattedText (with
a NumericFormatter) ?

Thanks

Greg
Re: FormattedText not allowing 0 to be entered [message #538647 is a reply to message #538646] Tue, 08 June 2010 10:16 Go to previous messageGo to next message
Geejay is currently offline GeejayFriend
Messages: 160
Registered: February 2010
Senior Member
Sorry for the spam.

I figured out this was to do with the mask.

Changing from this: "-########.####" to this: "-########0.####" solved my
problem. It is actually better showing 0's by default anyway.

Greg

"geejay" <gjmcknight@schlagundrahm.ch> wrote in message
news:hul526$ljb$1@build.eclipse.org...
> Is there any way to allow a 0 to be entered in an empty FormattedText
> (with a NumericFormatter) ?
>
> Thanks
>
> Greg
Re: FormattedText not allowing 0 to be entered [message #599734 is a reply to message #538646] Tue, 08 June 2010 10:16 Go to previous messageGo to next message
Geejay is currently offline GeejayFriend
Messages: 160
Registered: February 2010
Senior Member
Sorry for the spam.

I figured out this was to do with the mask.

Changing from this: "-########.####" to this: "-########0.####" solved my
problem. It is actually better showing 0's by default anyway.

Greg

"geejay" <gjmcknight@schlagundrahm.ch> wrote in message
news:hul526$ljb$1@build.eclipse.org...
> Is there any way to allow a 0 to be entered in an empty FormattedText
> (with a NumericFormatter) ?
>
> Thanks
>
> Greg
Re: FormattedText not allowing 0 to be entered [message #1699371 is a reply to message #538646] Tue, 23 June 2015 18:41 Go to previous messageGo to next message
Scott Klein is currently offline Scott KleinFriend
Messages: 2
Registered: June 2015
Junior Member
I am looking for a solution to this issue as well.

## does NOT allow the user to enter a zero
#0 forces a zero into that digit

I am looking for an *optional* user entered zero value to be entered. It seems to me that the "##" format would allow this, but pressing the "0" key does nothing.

I have checked out the code but, good lord, it is complicated.
Re: FormattedText not allowing 0 to be entered [message #1699377 is a reply to message #599734] Tue, 23 June 2015 20:39 Go to previous messageGo to next message
Scott Klein is currently offline Scott KleinFriend
Messages: 2
Registered: June 2015
Junior Member
I have made the following change to the NumberFormat.format(int) method:

        if ( !allowUserEnteredZero ) { // wrap this to see if we allow zeroes
            while ( this.intCount > this.zeroIntLen ) {
                if ( this.editValue.charAt( i ) == '0' ) {
                    this.intCount--;
                } else if ( this.editValue.charAt( i ) !=    this.symbols.getGroupingSeparator() ) {
                    break;
                }
                this.editValue.deleteCharAt( i );
                if ( cursorPos > i ) {
                    cursorPos--;
                }
            }
        }

I have added a field and a setter for private boolean allowUserEnteredZero = false; so that it can be overridden

* This allows users to *optionally* type in a zero character for a "#"-style format
* It also allows entries of things like "0001" - that may be acceptable, or not and could be a further functional change

The code for these formatters is relatively complex, so this is a rather quick & dirty solution that would need someone who really understands the intricacy of it before it should be used.

scott
Re: FormattedText not allowing 0 to be entered [message #1701042 is a reply to message #1699377] Wed, 08 July 2015 20:56 Go to previous message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 330
Registered: July 2009
Senior Member

Hi Scott,

Does this not sound like a new formatter? We are happy to work with you on this.

Please file a bug [1] and post the buglink here.

[1] https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Nebula&component=FormattedText

Cheers,

Wim

http://wiki.eclipse.org/Nebula/New_Contributions
Previous Topic:Nebula grid GridItem.setForeground(color) not working
Next Topic:CDateTime -> do not show the "clear" button in toolbar
Goto Forum:
  


Current Time: Sat Sep 05 01:22:34 GMT 2015

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

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