left alignment in Property Pane for numeric data

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

left alignment in Property Pane for numeric data

Postby staiger » Mon Mar 17, 2014 7:08 am

Hi Jide friends,

I want to change the alignment of my numeric data in a propertypane generally to left align.

Is this possible?

I have the following code (copied from JIDE Demo)

SimpleProperty prop = new SimpleProperty("Double", "The row is intended to show how to create a cell to input a double.", Double.class);
pane.getPropertyList().add(prop);

CellEditorManager.registerEditor(Double.class, new CellEditorFactory()

@Override
public CellEditor create()
{
DoubleCellEditor editor = new DoubleCellEditor();

DecimalFormat format = new DecimalFormat();

format.setMinimumFractionDigits(2);
format.setMaximumFractionDigits(10);
DoubleConverter editorConverter = new DoubleConverter(format);
editor.setConverter(editorConverter);
return editor;
}
});

Thanks
Norbert
staiger
 
Posts: 13
Joined: Wed Mar 03, 2010 3:17 am

Re: left alignment in Property Pane for numeric data

Postby JIDE Support » Mon Mar 17, 2014 9:03 am

A quick way to do is to use CellEditorManager.addCellEditorCustomizer.

Code: Select all
      CellEditorManager.addCellEditorCustomizer(new CellEditorManager.CellEditorCustomizer() {
          public void customize(CellEditor cellEditor) {
              if(cellEditor instanceof NumberCellEditor) {
                  ((NumberCellEditor) cellEditor).getTextField().setHorizontalAlignment(SwingConstants.LEADING);
              }
          }
      });
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 36468
Joined: Sun Sep 14, 2003 10:49 am

Re: left alignment in Property Pane for numeric data

Postby staiger » Tue Mar 18, 2014 12:50 am

sorry, but this does not work in my Application.

the alignment is still right.

I use the following code:

prop = new SimpleProperty("Double", "The row is intended to show how to create a cell to input a double.", Double.class);
pane.getPropertyList().add(prop);

public void register4Double()
{
DecimalFormat format = new DecimalFormat();
format.setMinimumFractionDigits(2);
format.setMaximumFractionDigits(2);
DoubleConverter converter = new DoubleConverter(format);
ObjectConverterManager.registerConverter(Double.class, converter);

CellEditorManager.registerEditor(Double.class, new CellEditorFactory()
{

@Override
public CellEditor create()
{
DoubleCellEditor editor = new DoubleCellEditor();

DecimalFormat format = new DecimalFormat();
format.setMinimumFractionDigits(2);
format.setMaximumFractionDigits(10);
DoubleConverter editorConverter = new DoubleConverter(format);
editor.setConverter(editorConverter);

return editor;
}
});
}


private void registerLeftAlign()
{
CellEditorManager.addCellEditorCustomizer(new CellEditorManager.CellEditorCustomizer() {
@Override
public void customize(CellEditor cellEditor) {
if(cellEditor instanceof NumberCellEditor) {
((NumberCellEditor) cellEditor).getTextField().setHorizontalAlignment(SwingConstants.LEFT);
}
}
});
}
staiger
 
Posts: 13
Joined: Wed Mar 03, 2010 3:17 am

Re: left alignment in Property Pane for numeric data

Postby JIDE Support » Tue Mar 18, 2014 7:47 am

It should work. Can you debug and see if the CellEditorCustomizer is called at all?
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 36468
Joined: Sun Sep 14, 2003 10:49 am

Re: left alignment in Property Pane for numeric data

Postby staiger » Tue Mar 18, 2014 8:07 am

the setHorizontalAlignment method is called when clicking to the long field.

But the field remains right aligned.

Thank you
Norbert
staiger
 
Posts: 13
Joined: Wed Mar 03, 2010 3:17 am

Re: left alignment in Property Pane for numeric data

Postby JIDE Support » Tue Mar 18, 2014 8:25 am

My fault. The horizontalAlignment flag was later reset in the NumberCellEditor.java to TRAILING. Whatever you set to horizontalAlignment in CellEditorCustomizer got lost, since it was called before the same call in NumberCellEditor. On one hand, I will modify NumberCellEditor to call setHorizontalAlignment earlier so that CellEditorCustomizer will have effect. I will let you know when we have a new release for it. On the other hand, you can use CellStyle feature to control the cell alignment as well. Just define a CellStyle constant with CellStyle#setHorizontalAlignment(SwingConstants.LEADING) then return it for the cell you want to align left in the getCellStyleAt method.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 36468
Joined: Sun Sep 14, 2003 10:49 am

Re: left alignment in Property Pane for numeric data

Postby staiger » Tue Mar 18, 2014 9:12 am

Thank you very much.

Norbert
staiger
 
Posts: 13
Joined: Wed Mar 03, 2010 3:17 am

Re: left alignment in Property Pane for numeric data

Postby JIDE Support » Fri Apr 04, 2014 10:36 am

Just so you know, JIDE 3.5.15 is released which fixed this bug.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 36468
Joined: Sun Sep 14, 2003 10:49 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 5 guests

cron