|
From: Benoit X. (JIRA) <no...@sp...> - 2008-04-07 16:41:05
|
[ http://jira.springframework.org/browse/RCP-553?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Benoit Xhenseval updated RCP-553:
---------------------------------
Attachment: BigDecimalTextField.java.patch
I do not know why the patch appears to be so different from the code, this is not the case. I think it is due to SVN thinking that many items have been inserted?
2 set of changes:
in insertString:
} else if (str.length() == 1 && SHORTCUTS.containsKey(str.toLowerCase())) { //+ BX Shortcut start
Integer shortcut = (Integer) SHORTCUTS.get(str.toLowerCase());
if (offset == 0) {
str = "1";
} else {
str = "";
}
for (int count = 0; count < shortcut.intValue(); count++) {
str += "0";
}
//+ BX Shortcut end
and a set of new methods at the beginning:
private static final Map SHORTCUTS = new HashMap();
private static boolean shortcutInitialised = false;
private static void initialiseShortcut() {
if (!shortcutInitialised) {
final Object o = ApplicationServicesLocator.services().getService(MessageSourceAccessor.class);
if (o instanceof MessageSourceAccessor) {
MessageSourceAccessor messageSourceAccessor = (MessageSourceAccessor) o;
addShortcut(messageSourceAccessor, "BigDecimalTextField.shortcut.hundred", new Integer(2));
addShortcut(messageSourceAccessor, "BigDecimalTextField.shortcut.thousand", new Integer(3));
addShortcut(messageSourceAccessor, "BigDecimalTextField.shortcut.million", new Integer(6));
addShortcut(messageSourceAccessor, "BigDecimalTextField.shortcut.billion", new Integer(9));
addShortcut(messageSourceAccessor, "BigDecimalTextField.shortcut.squillion", new Integer(0));
shortcutInitialised = true;
}
}
}
private static void addShortcut(final MessageSourceAccessor messageSourceAccessor, final String msgKey, final Integer offset) {
try {
SHORTCUTS.put(messageSourceAccessor.getMessage(msgKey), offset);
}catch(final NoSuchMessageException e) {
// do nothing
}
}
and finally a call to initialiseShortcut() in the main constructor.
I hope it is ok
Kind regards
Benoit.
> Adding shortcuts to BigDecimalTextField
> ---------------------------------------
>
> Key: RCP-553
> URL: http://jira.springframework.org/browse/RCP-553
> Project: Spring Framework Rich Client Project
> Issue Type: Improvement
> Components: Helper Classes
> Affects Versions: 1.0.0
> Reporter: Benoit Xhenseval
> Attachments: BigDecimalTextField.java.patch
>
>
> We would like to be able to add shortcuts, like "3m" meaning 3 millions, 2k = 2,000. Typically a shortcut for hundred, thousand, millions, billions (for SocGen J ).
> Unfortunately, BigDecimalTextField is explicitly instantiated in several places, making it impossible to extend.
> We have a patch that works fine for us and it should work internationally as the shortcut may vary from one language to the other.
> One needs to add the shortcut characters in a messages.properties file:
> BigDecimalTextField.shortcut.hundred=h
> BigDecimalTextField.shortcut.thousand=k
> BigDecimalTextField.shortcut.million=m
> BigDecimalTextField.shortcut.billion=b
> ...
> So if you type 3k in the field, it will immediately be replaced by 3000.
> If you do not have those entries in the messages.properties, it won't use shortcuts so it is transparent if you do not want it.
> I hope that the patch will be accepted so that we can use SpringRC straight out of the box...
> Many thanks
> Benoit
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.springframework.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|