Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Custom cell editors (Read 4091 times)
divis_dev
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 2
Joined: Oct 29th, 2021
Custom cell editors
Oct 29th, 2021 at 11:51am
Print Post  
Hi,
I tried to use a JComboBox as a custom cell editor and experienced some problems. The combo box works until the default text editor is used for the first time. After the first text edit, the text editor starts throwing IllegalComponentStateExceptions.
The problem seems to be that the GridView never resets the currentTextEditor reference to null. So even when processing an edit event for the ComboBox, there is a currentTextEditor reference set from another/previous cell edit.
In endEdit currentEditor is set to null, but currentTextEditor is not...
Another problem in endEdit might be
Code (Java)
Select All
if (newValue instanceof String)
  lastIO.setEditedText(newText);
 


because newValue != newText.

The attached file contains a small example.
  

MainWindow.java ( 4 KB | 160 Downloads )
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Online


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Custom cell editors
Reply #1 - Oct 29th, 2021 at 12:36pm
Print Post  
Hi,

Thanks for letting us know. Our developer will investigate.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Online


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Custom cell editors
Reply #2 - Nov 2nd, 2021 at 7:43am
Print Post  
Hi,

New jar here should fix that -
https://mindfusion.eu/_temp/JPack_editor.zip

If you build from source code, our fix is replacing this line in beginEdit -

Code
Select All
if (currentEditor instanceof JTextComponent)
    currentTextEditor = (JTextComponent)currentEditor; 



with this one -
Code
Select All
currentTextEditor = Helper.as(currentEditor, JTextComponent.class); 



(that accounts for incorrectly translated currentTextEditor = currentEditor as TextBoxBase assignment from our original C# code, which also nulls currentTextEditor when using a custom editor).

Regards,
Slavcho
  
Back to top
 
IP Logged
 
divis_dev
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 2
Joined: Oct 29th, 2021
Re: Custom cell editors
Reply #3 - Nov 2nd, 2021 at 1:47pm
Print Post  
Hi Slavcho,
thank you for your quick response.

The new beginEdit works fine, but there is one more thing in endEdit that seems to be a bug.

Code (Java)
Select All
if (newValue instanceof String)
  lastIO.setEditedText(newText);
 


should be replaced with
Code (Java)
Select All
if (newValue instanceof String)
  lastIO.setEditedText((String)newValue);
 


because newText is allways empty if currentTextEditor is null.
Which it is, when we use custom editors.

What do you think?

Best regards,
Stefan
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Online


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Custom cell editors
Reply #4 - Nov 3rd, 2021 at 8:18am
Print Post  
Hi,

Value from your custom editor is set correctly on next line (cell.setData...newValue). The newText assignment seems would be incorrect if custom editors return strings, which should be fixed here -

https://mindfusion.eu/_temp/JPack_editor.zip

If you build the jar from source code, our fix is in attached diff, setting newText before validations code so it's used there too. The diff contains one other fix we've found in our C# EndEdit, for comparing values from custom editors.

Regards,
Slavcho
  

diff.txt ( 1 KB | 159 Downloads )
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint